chiark / gitweb /
Import effective orig tree for upstream version 2.4.2+dfsg
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Feb 2019 11:07:30 +0000 (11:07 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Feb 2019 11:07:30 +0000 (11:07 +0000)
This includes the contents of the .orig(s), minus any debian/ directory.

[git-debrebase convert-from-dgit-view upstream-import-convert: 2.4.2+dfsg]

248 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
TODO [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
api/Makefile.am [new file with mode: 0644]
api/Makefile.in [new file with mode: 0644]
api/deprecated.c [new file with mode: 0644]
api/f77api.c [new file with mode: 0644]
api/f77funcs.h [new file with mode: 0644]
api/f77funcs_.h [new file with mode: 0644]
api/general.c [new file with mode: 0644]
api/nlopt-in.hpp [new file with mode: 0644]
api/nlopt-internal.h [new file with mode: 0644]
api/nlopt.3 [new file with mode: 0644]
api/nlopt.f [new file with mode: 0644]
api/nlopt.h [new file with mode: 0644]
api/nlopt.hpp [new file with mode: 0644]
api/optimize.c [new file with mode: 0644]
api/options.c [new file with mode: 0644]
auglag/Makefile.am [new file with mode: 0644]
auglag/Makefile.in [new file with mode: 0644]
auglag/README [new file with mode: 0644]
auglag/auglag.c [new file with mode: 0644]
auglag/auglag.h [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
bobyqa/COPYRIGHT [new file with mode: 0644]
bobyqa/Makefile.am [new file with mode: 0644]
bobyqa/Makefile.in [new file with mode: 0644]
bobyqa/README [new file with mode: 0644]
bobyqa/README.orig [new file with mode: 0644]
bobyqa/bobyqa.c [new file with mode: 0644]
bobyqa/bobyqa.h [new file with mode: 0644]
cdirect/Makefile.am [new file with mode: 0644]
cdirect/Makefile.in [new file with mode: 0644]
cdirect/README [new file with mode: 0644]
cdirect/cdirect.c [new file with mode: 0644]
cdirect/cdirect.h [new file with mode: 0644]
cdirect/hybrid.c [new file with mode: 0644]
cobyla/COPYRIGHT [new file with mode: 0644]
cobyla/Makefile.am [new file with mode: 0644]
cobyla/Makefile.in [new file with mode: 0644]
cobyla/README [new file with mode: 0644]
cobyla/README.orig [new file with mode: 0644]
cobyla/cobyla.c [new file with mode: 0644]
cobyla/cobyla.h [new file with mode: 0644]
compile [new file with mode: 0755]
config.guess [new file with mode: 0755]
config.h.in [new file with mode: 0644]
config.sub [new file with mode: 0755]
configure [new file with mode: 0755]
configure.ac [new file with mode: 0644]
crs/Makefile.am [new file with mode: 0644]
crs/Makefile.in [new file with mode: 0644]
crs/README [new file with mode: 0644]
crs/crs.c [new file with mode: 0644]
crs/crs.h [new file with mode: 0644]
depcomp [new file with mode: 0755]
direct/AUTHORS [new file with mode: 0644]
direct/COPYING [new file with mode: 0644]
direct/DIRect.c [new file with mode: 0644]
direct/DIRparallel.c [new file with mode: 0644]
direct/DIRserial.c [new file with mode: 0644]
direct/DIRsubrout.c [new file with mode: 0644]
direct/Makefile.am [new file with mode: 0644]
direct/Makefile.in [new file with mode: 0644]
direct/README [new file with mode: 0644]
direct/direct-internal.h [new file with mode: 0644]
direct/direct.h [new file with mode: 0644]
direct/direct_wrap.c [new file with mode: 0644]
direct/tstc.c [new file with mode: 0644]
esch/COPYRIGHT [new file with mode: 0644]
esch/Makefile.am [new file with mode: 0644]
esch/Makefile.in [new file with mode: 0644]
esch/README [new file with mode: 0644]
esch/esch.c [new file with mode: 0644]
esch/esch.h [new file with mode: 0644]
install-sh [new file with mode: 0755]
isres/Makefile.am [new file with mode: 0644]
isres/Makefile.in [new file with mode: 0644]
isres/README [new file with mode: 0644]
isres/isres.c [new file with mode: 0644]
isres/isres.h [new file with mode: 0644]
ltmain.sh [new file with mode: 0644]
luksan/COPYRIGHT [new file with mode: 0644]
luksan/Makefile.am [new file with mode: 0644]
luksan/Makefile.in [new file with mode: 0644]
luksan/README [new file with mode: 0644]
luksan/luksan.h [new file with mode: 0644]
luksan/mssubs.c [new file with mode: 0644]
luksan/plip.c [new file with mode: 0644]
luksan/plis.c [new file with mode: 0644]
luksan/plis.txt [new file with mode: 0644]
luksan/pnet.c [new file with mode: 0644]
luksan/pssubs.c [new file with mode: 0644]
m4/ax_c_threadlocal.m4 [new file with mode: 0644]
m4/libtool.m4 [new file with mode: 0644]
m4/ltoptions.m4 [new file with mode: 0644]
m4/ltsugar.m4 [new file with mode: 0644]
m4/ltversion.m4 [new file with mode: 0644]
m4/lt~obsolete.m4 [new file with mode: 0644]
missing [new file with mode: 0755]
mlsl/Makefile.am [new file with mode: 0644]
mlsl/Makefile.in [new file with mode: 0644]
mlsl/README [new file with mode: 0644]
mlsl/mlsl.c [new file with mode: 0644]
mlsl/mlsl.h [new file with mode: 0644]
mma/Makefile.am [new file with mode: 0644]
mma/Makefile.in [new file with mode: 0644]
mma/README [new file with mode: 0644]
mma/ccsa_quadratic.c [new file with mode: 0644]
mma/mma.c [new file with mode: 0644]
mma/mma.h [new file with mode: 0644]
neldermead/Makefile.am [new file with mode: 0644]
neldermead/Makefile.in [new file with mode: 0644]
neldermead/README [new file with mode: 0644]
neldermead/neldermead.h [new file with mode: 0644]
neldermead/nldrmd.c [new file with mode: 0644]
neldermead/sbplx.c [new file with mode: 0644]
newuoa/COPYRIGHT [new file with mode: 0644]
newuoa/Makefile.am [new file with mode: 0644]
newuoa/Makefile.in [new file with mode: 0644]
newuoa/README [new file with mode: 0644]
newuoa/README.orig [new file with mode: 0644]
newuoa/newuoa.c [new file with mode: 0644]
newuoa/newuoa.h [new file with mode: 0644]
nlopt.pc.in [new file with mode: 0644]
octave/Makefile.am [new file with mode: 0644]
octave/Makefile.in [new file with mode: 0644]
octave/NLOPT_AUGLAG.m [new file with mode: 0644]
octave/NLOPT_AUGLAG_EQ.m [new file with mode: 0644]
octave/NLOPT_GD_MLSL.m [new file with mode: 0644]
octave/NLOPT_GD_MLSL_LDS.m [new file with mode: 0644]
octave/NLOPT_GD_STOGO.m [new file with mode: 0644]
octave/NLOPT_GD_STOGO_RAND.m [new file with mode: 0644]
octave/NLOPT_GN_CRS2_LM.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT_L.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT_L_NOSCAL.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT_L_RAND.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT_L_RAND_NOSCAL.m [new file with mode: 0644]
octave/NLOPT_GN_DIRECT_NOSCAL.m [new file with mode: 0644]
octave/NLOPT_GN_ESCH.m [new file with mode: 0644]
octave/NLOPT_GN_ISRES.m [new file with mode: 0644]
octave/NLOPT_GN_MLSL.m [new file with mode: 0644]
octave/NLOPT_GN_MLSL_LDS.m [new file with mode: 0644]
octave/NLOPT_GN_ORIG_DIRECT.m [new file with mode: 0644]
octave/NLOPT_GN_ORIG_DIRECT_L.m [new file with mode: 0644]
octave/NLOPT_G_MLSL.m [new file with mode: 0644]
octave/NLOPT_G_MLSL_LDS.m [new file with mode: 0644]
octave/NLOPT_LD_AUGLAG.m [new file with mode: 0644]
octave/NLOPT_LD_AUGLAG_EQ.m [new file with mode: 0644]
octave/NLOPT_LD_CCSAQ.m [new file with mode: 0644]
octave/NLOPT_LD_LBFGS.m [new file with mode: 0644]
octave/NLOPT_LD_LBFGS_NOCEDAL.m [new file with mode: 0644]
octave/NLOPT_LD_MMA.m [new file with mode: 0644]
octave/NLOPT_LD_SLSQP.m [new file with mode: 0644]
octave/NLOPT_LD_TNEWTON.m [new file with mode: 0644]
octave/NLOPT_LD_TNEWTON_PRECOND.m [new file with mode: 0644]
octave/NLOPT_LD_TNEWTON_PRECOND_RESTART.m [new file with mode: 0644]
octave/NLOPT_LD_TNEWTON_RESTART.m [new file with mode: 0644]
octave/NLOPT_LD_VAR1.m [new file with mode: 0644]
octave/NLOPT_LD_VAR2.m [new file with mode: 0644]
octave/NLOPT_LN_AUGLAG.m [new file with mode: 0644]
octave/NLOPT_LN_AUGLAG_EQ.m [new file with mode: 0644]
octave/NLOPT_LN_BOBYQA.m [new file with mode: 0644]
octave/NLOPT_LN_COBYLA.m [new file with mode: 0644]
octave/NLOPT_LN_NELDERMEAD.m [new file with mode: 0644]
octave/NLOPT_LN_NEWUOA.m [new file with mode: 0644]
octave/NLOPT_LN_NEWUOA_BOUND.m [new file with mode: 0644]
octave/NLOPT_LN_PRAXIS.m [new file with mode: 0644]
octave/NLOPT_LN_SBPLX.m [new file with mode: 0644]
octave/dummy.c [new file with mode: 0644]
octave/nlopt_minimize.m [new file with mode: 0644]
octave/nlopt_minimize_constrained.m [new file with mode: 0644]
octave/nlopt_optimize-mex.c [new file with mode: 0644]
octave/nlopt_optimize-oct.cc [new file with mode: 0644]
octave/nlopt_optimize.m [new file with mode: 0644]
octave/nlopt_optimize_usage.h [new file with mode: 0644]
praxis/Makefile.am [new file with mode: 0644]
praxis/Makefile.in [new file with mode: 0644]
praxis/README [new file with mode: 0644]
praxis/praxis.c [new file with mode: 0644]
praxis/praxis.h [new file with mode: 0644]
py-compile [new file with mode: 0755]
slsqp/COPYRIGHT [new file with mode: 0644]
slsqp/Makefile.am [new file with mode: 0644]
slsqp/Makefile.in [new file with mode: 0644]
slsqp/README [new file with mode: 0644]
slsqp/slsqp.c [new file with mode: 0644]
slsqp/slsqp.h [new file with mode: 0644]
stogo/COPYRIGHT [new file with mode: 0644]
stogo/Makefile.am [new file with mode: 0644]
stogo/Makefile.in [new file with mode: 0644]
stogo/README [new file with mode: 0644]
stogo/global.cc [new file with mode: 0644]
stogo/global.h [new file with mode: 0644]
stogo/linalg.cc [new file with mode: 0644]
stogo/linalg.h [new file with mode: 0644]
stogo/local.cc [new file with mode: 0644]
stogo/local.h [new file with mode: 0644]
stogo/prog.cc [new file with mode: 0644]
stogo/rosen.h [new file with mode: 0644]
stogo/stogo.cc [new file with mode: 0644]
stogo/stogo.h [new file with mode: 0644]
stogo/stogo_config.h [new file with mode: 0644]
stogo/testfun.h [new file with mode: 0644]
stogo/testros.cc [new file with mode: 0644]
stogo/tools.cc [new file with mode: 0644]
stogo/tools.h [new file with mode: 0644]
stogo/tst.cc [new file with mode: 0644]
stogo/tstc.c [new file with mode: 0644]
swig/Makefile.am [new file with mode: 0644]
swig/Makefile.in [new file with mode: 0644]
swig/nlopt-enum-renames.i [new file with mode: 0644]
swig/nlopt-exceptions.i [new file with mode: 0644]
swig/nlopt-guile.cpp [new file with mode: 0644]
swig/nlopt-guile.i [new file with mode: 0644]
swig/nlopt-python.cpp [new file with mode: 0644]
swig/nlopt-python.i [new file with mode: 0644]
swig/nlopt.i [new file with mode: 0644]
swig/nlopt.py [new file with mode: 0644]
swig/nlopt.scm.in [new file with mode: 0644]
swig/numpy.i [new file with mode: 0644]
test/Makefile.am [new file with mode: 0644]
test/Makefile.in [new file with mode: 0644]
test/test_std.py [new file with mode: 0644]
test/testfuncs.c [new file with mode: 0644]
test/testfuncs.h [new file with mode: 0644]
test/testopt.cpp [new file with mode: 0644]
util/Makefile.am [new file with mode: 0644]
util/Makefile.in [new file with mode: 0644]
util/mt19937ar.c [new file with mode: 0644]
util/nlopt-util.h [new file with mode: 0644]
util/qsort_r.c [new file with mode: 0644]
util/redblack.c [new file with mode: 0644]
util/redblack.h [new file with mode: 0644]
util/redblack_test.c [new file with mode: 0644]
util/rescale.c [new file with mode: 0644]
util/soboldata.h [new file with mode: 0644]
util/sobolseq.c [new file with mode: 0644]
util/stop.c [new file with mode: 0644]
util/timer.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..6e2be75
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
+NLopt was written/packaged by:
+
+Steven G. Johnson <stevenj@alum.mit.edu>
+
+See the subdirectories for the authors of the original nonlinear optimization
+libraries utilized by NLopt.
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..f3d4c84
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,40 @@
+NLopt combines several free/open-source nonlinear optimization
+libraries by various authors.  See the COPYING, COPYRIGHT, and README
+files in the subdirectories for the original copyright and licensing
+information of these packages.
+
+The compiled NLopt library, i.e. the combined work of all of the
+included optimization routines, is licensed under the conjunction of
+all of these licensing terms.  Currently, the most restrictive terms
+are for the code in the "luksan" directory, which is licensed under
+the GNU Lesser General Public License (GNU LGPL), version 2.1 or
+later (see luksan/COPYRIGHT).
+
+That means that the compiled NLopt library is governed by the terms of
+the LGPL.
+
+---------------------------------------------------------------------------
+
+Other portions of NLopt, including any modifications to the abovementioned
+packages, are licensed under the standard "MIT License:"
+
+Copyright (c) 2007-2011 Massachusetts Institute of Technology
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..5264766
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1 @@
+See https://github.com/stevengj/nlopt for a detailed version history.
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..007e939
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,370 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
+Inc.
+
+   Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.  Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below.  The lack of an optional feature in a given package is not
+necessarily a bug.  More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+   The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package, generally using the just-built uninstalled binaries.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.  When installing into a prefix owned by root, it is
+     recommended that the package be configured and built as a regular
+     user, and only the `make install' phase executed with root
+     privileges.
+
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
+     this time using the binaries in their final installed location.
+     This target does not install anything.  Running this target as a
+     regular user, particularly if the prior `make install' required
+     root privileges, verifies that the installation completed
+     correctly.
+
+  6. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  7. Often, you can also type `make uninstall' to remove the installed
+     files again.  In practice, not all packages have tested that
+     uninstallation works correctly, even though it is required by the
+     GNU Coding Standards.
+
+  8. Some packages, particularly those that use Automake, provide `make
+     distcheck', which can by used by developers to test that all other
+     targets like `make install' and `make uninstall' work correctly.
+     This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.  This
+is known as a "VPATH" build.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.  In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+   The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+   The first method involves providing an override variable for each
+affected directory.  For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'.  Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated.  The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the `DESTDIR' variable.  For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names.  The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters.  On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+   Some packages offer the ability to configure how verbose the
+execution of `make' will be.  For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved.  Use GNU `make'
+instead.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS
+     KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf limitation.  Until the limitation is lifted, you can use
+this workaround:
+
+     CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..ad699ee
--- /dev/null
@@ -0,0 +1,36 @@
+OPTIONS_AUTOMAKE=gnu
+lib_LTLIBRARIES = libnlopt@NLOPT_SUFFIX@.la
+
+ACLOCAL_AMFLAGS=-I m4
+
+if WITH_CXX
+CXX_DIRS = stogo
+CXX_LIBS = stogo/libstogo.la
+endif
+
+SUBDIRS = util direct cdirect $(CXX_DIRS) praxis luksan crs mlsl mma cobyla newuoa neldermead auglag bobyqa isres slsqp esch api . octave test swig
+EXTRA_DIST = autogen.sh nlopt.pc.in m4
+
+libnlopt@NLOPT_SUFFIX@_la_SOURCES = 
+libnlopt@NLOPT_SUFFIX@_la_LIBADD = direct/libdirect.la                 \
+cdirect/libcdirect.la $(CXX_LIBS) praxis/libpraxis.la \
+luksan/libluksan.la crs/libcrs.la mlsl/libmlsl.la mma/libmma.la                \
+cobyla/libcobyla.la newuoa/libnewuoa.la neldermead/libneldermead.la    \
+auglag/libauglag.la bobyqa/libbobyqa.la isres/libisres.la              \
+slsqp/libslsqp.la esch/libesch.la api/libapi.la util/libutil.la
+
+if WITH_CXX
+libnlopt@NLOPT_SUFFIX@_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
+else
+libnlopt@NLOPT_SUFFIX@_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@
+endif
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = nlopt.pc
+
+if MAINTAINER_MODE
+
+README: README.md
+       cp -f $(srcdir)/README.md $@
+
+endif
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..8205be2
--- /dev/null
@@ -0,0 +1,997 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = .
+DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
+       $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/configure $(am__configure_deps) \
+       $(srcdir)/config.h.in $(srcdir)/nlopt.pc.in COPYING TODO \
+       compile config.guess config.sub depcomp install-sh missing \
+       py-compile ltmain.sh
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = nlopt.pc
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libnlopt@NLOPT_SUFFIX@_la_DEPENDENCIES = direct/libdirect.la \
+       cdirect/libcdirect.la $(CXX_LIBS) praxis/libpraxis.la \
+       luksan/libluksan.la crs/libcrs.la mlsl/libmlsl.la \
+       mma/libmma.la cobyla/libcobyla.la newuoa/libnewuoa.la \
+       neldermead/libneldermead.la auglag/libauglag.la \
+       bobyqa/libbobyqa.la isres/libisres.la slsqp/libslsqp.la \
+       esch/libesch.la api/libapi.la util/libutil.la
+am_libnlopt@NLOPT_SUFFIX@_la_OBJECTS =
+libnlopt@NLOPT_SUFFIX@_la_OBJECTS =  \
+       $(am_libnlopt@NLOPT_SUFFIX@_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libnlopt@NLOPT_SUFFIX@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+       $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+       $(AM_CFLAGS) $(CFLAGS) $(libnlopt@NLOPT_SUFFIX@_la_LDFLAGS) \
+       $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libnlopt@NLOPT_SUFFIX@_la_SOURCES)
+DIST_SOURCES = $(libnlopt@NLOPT_SUFFIX@_la_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+       ctags-recursive dvi-recursive html-recursive info-recursive \
+       install-data-recursive install-dvi-recursive \
+       install-exec-recursive install-html-recursive \
+       install-info-recursive install-pdf-recursive \
+       install-ps-recursive install-recursive installcheck-recursive \
+       installdirs-recursive pdf-recursive ps-recursive \
+       tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+DATA = $(pkgconfig_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+       cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+       $(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = util direct cdirect stogo praxis luksan crs mlsl mma \
+       cobyla newuoa neldermead auglag bobyqa isres slsqp esch api . \
+       octave test swig
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+OPTIONS_AUTOMAKE = gnu
+lib_LTLIBRARIES = libnlopt@NLOPT_SUFFIX@.la
+ACLOCAL_AMFLAGS = -I m4
+@WITH_CXX_TRUE@CXX_DIRS = stogo
+@WITH_CXX_TRUE@CXX_LIBS = stogo/libstogo.la
+SUBDIRS = util direct cdirect $(CXX_DIRS) praxis luksan crs mlsl mma cobyla newuoa neldermead auglag bobyqa isres slsqp esch api . octave test swig
+EXTRA_DIST = autogen.sh nlopt.pc.in m4
+libnlopt@NLOPT_SUFFIX@_la_SOURCES = 
+libnlopt@NLOPT_SUFFIX@_la_LIBADD = direct/libdirect.la                 \
+cdirect/libcdirect.la $(CXX_LIBS) praxis/libpraxis.la \
+luksan/libluksan.la crs/libcrs.la mlsl/libmlsl.la mma/libmma.la                \
+cobyla/libcobyla.la newuoa/libnewuoa.la neldermead/libneldermead.la    \
+auglag/libauglag.la bobyqa/libbobyqa.la isres/libisres.la              \
+slsqp/libslsqp.la esch/libesch.la api/libapi.la util/libutil.la
+
+@WITH_CXX_FALSE@libnlopt@NLOPT_SUFFIX@_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@
+@WITH_CXX_TRUE@libnlopt@NLOPT_SUFFIX@_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = nlopt.pc
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+am--refresh: Makefile
+       @:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+       @test -f $@ || rm -f stamp-h1
+       @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+nlopt.pc: $(top_builddir)/config.status $(srcdir)/nlopt.pc.in
+       cd $(top_builddir) && $(SHELL) ./config.status $@
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+       }
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libnlopt@NLOPT_SUFFIX@.la: $(libnlopt@NLOPT_SUFFIX@_la_OBJECTS) $(libnlopt@NLOPT_SUFFIX@_la_DEPENDENCIES) $(EXTRA_libnlopt@NLOPT_SUFFIX@_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(libnlopt@NLOPT_SUFFIX@_la_LINK) -rpath $(libdir) $(libnlopt@NLOPT_SUFFIX@_la_OBJECTS) $(libnlopt@NLOPT_SUFFIX@_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+distclean-libtool:
+       -rm -f libtool config.lt
+install-pkgconfigDATA: $(pkgconfig_DATA)
+       @$(NORMAL_INSTALL)
+       @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+       done
+
+uninstall-pkgconfigDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+       @fail=; \
+       if $(am__make_keepgoing); then \
+         failcom='fail=yes'; \
+       else \
+         failcom='exit 1'; \
+       fi; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+       test ! -s cscope.files \
+         || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+       -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+       -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           $(am__make_dryrun) \
+             || test -d "$(distdir)/$$subdir" \
+             || $(MKDIR_P) "$(distdir)/$$subdir" \
+             || exit 1; \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -755 \
+               -exec chmod u+rwx,go+rx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+       $(am__post_remove_distdir)
+
+dist-lzip: distdir
+       tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+       $(am__post_remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+       $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+       @echo WARNING: "Support for shar distribution archives is" \
+                      "deprecated." >&2
+       @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__post_remove_distdir)
+
+dist-shar: distdir
+       @echo WARNING: "Support for distribution archives compressed with" \
+                      "legacy program 'compress' is deprecated." >&2
+       @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__post_remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__post_remove_distdir)
+
+dist dist-all:
+       $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+       $(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lz*) \
+         lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir)
+       chmod u+w $(distdir)
+       mkdir $(distdir)/_build $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__post_remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @test -n '$(distuninstallcheck_dir)' || { \
+         echo 'ERROR: trying to run $@ with an empty' \
+              '$$(distuninstallcheck_dir)' >&2; \
+         exit 1; \
+       }; \
+       $(am__cd) '$(distuninstallcheck_dir)' || { \
+         echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+         exit 1; \
+       }; \
+       test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(LTLIBRARIES) $(DATA) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+       mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-pkgconfigDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
+
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+       am--refresh check check-am clean clean-cscope clean-generic \
+       clean-libLTLIBRARIES clean-libtool cscope cscopelist-am ctags \
+       ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \
+       dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \
+       distclean-compile distclean-generic distclean-hdr \
+       distclean-libtool distclean-tags distcleancheck distdir \
+       distuninstallcheck dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am \
+       install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+       install-pkgconfigDATA install-ps install-ps-am install-strip \
+       installcheck installcheck-am installdirs installdirs-am \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+       pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
+       uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
+
+
+@MAINTAINER_MODE_TRUE@README: README.md
+@MAINTAINER_MODE_TRUE@ cp -f $(srcdir)/README.md $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..6a9dfc3
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,347 @@
+NLopt 2.4.2 (20 May 2014)
+
+* Fix CRS for empty dimensions (where lower == upper bound) (issue #13).
+
+* Improvements to CMake (thanks to @xantares) and Windows builds (issue #12).
+
+* Fix guile2 compatibility (issue #21).
+
+NLopt 2.4.1 (19 November 2013)
+
+* Use cdecl calling convention instead of stdcall on Win32, to
+  simplify shared-library usage and for consistency with Win64.
+
+NLopt 2.4 (2 November 2013)
+
+* New genetic algorithm ESCH, thanks to Carlos Henrique da Silva Santos.
+
+* Fix swig dir for VPATH builds, thanks to Sandro Vitenti for the bug report.
+
+* Use python-config program in the configure script to find the include
+  directories for Python, if possible (may be overridden by PYTHON_CONFIG
+  environment variable).
+
+* Bugfix in copy constructor for C++ and Python interfaces.
+
+* Bugfix in return value for setting min/max objective.
+
+* Handle negative rescalings in COBYLA and BOBYQA.
+
+* Plugin installation honors the configure --prefix, if any
+  (thanks to xantares@github).
+
+* Various compilation fixes for compatibility with recent software.
+
+NLopt 2.3.1 (16 September 2012)
+
+* Bug fix: COBLYA should return ROUNDOFF_LIMITED rather than XTOL_REACHED
+  if the trust-region radius underflows to zero; thanks to David Liu.
+
+* Bug fix: incorrect return value from set min/max objective.
+
+* Handle case of negative rescalings (from negative dx) in COBYLA and BOBYQA;
+  thanks to Alexander Law for the bug report
+
+NLopt 2.3 (20 July 2012)
+
+* In Matlab/Octave interface, make returning NaN from the objective
+  equivalent to nlopt_force_stop; thanks to Norman Violet for the suggestion.
+
+* Added CCSA-quadratic (NLOPT_LD_CCSAQ), similar to MMA.
+
+* Added interface for supplying a preconditioner (approximate Hessian);
+  currently only supported in CCSAQ.
+
+* When adding mconstraints, allow tol==NULL as synonym for zero tolerances.
+
+* Added missing NLOPT_LD_SLSQP constant in Matlab/Octave.
+
+* Lower tolerance for dual optimization in MMA/CCSAQ; thanks to
+  Christophe Leruste for the problem report
+
+* Fixed bug in timer, thanks to William Vaughn for the patch.
+
+* Bug fix to convergence test in sbplx; thanks to Douglas Bates.
+
+NLopt 2.2.4 (9 June 2011)
+
+* Fixed linking problem for C++ and Python shared libraries on MacOS X;
+  thanks to Volker Lorrmann for the bug report.
+
+NLopt 2.2.3 (8 June 2011)
+
+* Fixed additional re-entrancy problem in Luksan algorithms missed
+  in the previous version; thanks to Gert Wollny for the bug report.
+
+* Fixed set/get vector_storage in Fortran interface for Fortran
+  compilers with all-uppercase linkage.
+
+NLopt 2.2.2 (26 May 2011)
+
+* Added set_vector_storage API to modify the memory usage and the 
+  subspace dimension for low-storage quasi-Newton methods.
+
+* Fixed missing support for maxtime stopping criteria in Luksan and
+  ORIG_DIRECT algorithms; thanks to Jurgen Werner for the bug report.
+
+* Fixed algorithms to support the case where the lower and upper bounds
+  are equal for some variables (which effectively eliminates those
+  variables from optimization).
+
+* Added missing xtol check to SLSQP, which caused erroneous ROUNDOFF_LIMITED
+  error codes to be returned; thanks to Alexander Riess for the bug report.
+
+* Fixed slight overcounting of function evaluations for maxeval check
+  in SLSQP.
+
+* Fixed deprecated API to support xtol_abs == NULL for backward
+  compatibility (thanks to Francesco Biscani for the bug report).
+
+* Made Luksan algorithms (e.g. LBFGS and other quasi-Newton methods)
+  re-entrant; thanks to Gert Wollny for the bug report.  (Fixes
+  Gentoo bug #368685.)
+
+* Fixed bug in DIRECT (not ORIG_DIRECT), where a typo caused suboptimal
+  convergence in some cases; thanks to Sinisa Hristov for the bug report.
+
+NLopt 2.2.1 (6 September 2010)
+
+* If you compile nlopt.h with the NLOPT_DLL_EXPORT symbol #defined,
+  it now uses the dllexport directive (under Windows), useful for
+  compiling an NLopt DLL under Microsoft compilers; thanks to Benoit
+  Scherrer for the suggestion.
+
+* Handle case where copysign function is missing, e.g. on Windows;
+  thanks to Benoit Scherrer for the bug report.
+
+* Remove C99-style mixed declaration and code in a couple files, so
+  that code compiles in C89; thanks to Benoit Scherrer for the bug report.
+
+* Removed a few compiler warnings under Microsoft compilers; thanks
+  to Benoit Scherrer for the bug report.
+
+* Export nlopt_get_algorithm_name function on Windows; thanks to Ofek
+  Shilon for the bug report.
+
+* Don't use dllimport directive with lcc on Windows (which doesn't
+  support it); thanks to Laurent Vanbeylen for the bug report.
+
+* Update Nodedal README directory to indicate that Nocedal's LBFGS code
+  is now available under the GPL, and therefore may be distributed with
+  a future NLopt version (although Luksan's LBFGS code already works well).
+
+* Bug fix in set/get_xtol_abs; thanks to David Rivest-Henault for the report.
+
+NLopt 2.2 (15 July 2010)
+
+* Added SLSQP algorithm for gradient-based local optimization with
+  nonlinear constraints via sequential quadratic programming, based
+  on the implementation by Dieter Kraft that was adapted for SciPy.
+
+* Modified BOBYQA and COBYLA algorithms to support unequal initial
+  step sizes in different directions; thanks to Tom Fiddaman for pointing
+  out the need for this in the case where different directions have
+  very different scales.
+
+* Added Python module docstring; thanks to Sebastian Walter for the suggestion.
+
+* Added GUILE_INSTALL_DIR variable to allow the user to change the
+  Guile installation directory.
+
+* Added Fortran interface for vector-valued constraints.
+
+* Throw correct exceptions in Python for the add_*constraint functions;
+  thanks to Dmitrey Kroshko for the bug report.
+
+* Support forced stop and exceptions in ORIG_DIRECT algorithm.
+
+* Remove arbitrary 1e20 upper bound on function values from ORIG_DIRECT
+  code.
+
+* Bugfix in C++ interface (and some other language front-ends) when
+  deallocating the nlopt_opt object in cases like MLSL where
+  local_optimizer is used; thanks to Jurgen Werner for the bug report.
+
+NLopt 2.1.2 (8 July 2010)
+
+* The Python mconstraint (vector-valued constraint) functions
+  now pass a 2-dimensional array for the gradient argument, rather
+  than a flattened 1d array.
+
+* Improved handling of exceptions and forced stops for constrained
+  optimization, making sure that no constraints are evaluated after
+  the stop.
+
+* Return an NLOPT_INVALID_ARGS error if more than n equality constraints
+  are added in an n-dimensional problem.
+
+* Fix bug that could cause spurious NLOPT_INVALID_ARGS errors when
+  adding constraints under rare circumstances.
+
+* Eliminate a few small memory leaks that could occur under error conditions.
+
+NLopt 2.1.1 (7 July 2010)
+
+* More robust configure check for Python include directories, via
+  distutils.sysconfig.get_python_inc() and numpy.get_include().
+  Thanks to Nathaniel Smith for the tip.
+
+* Bug fix in Guile interface: added missing prefix to nlopt-version-major
+  etcetera.
+
+NLopt 2.1 (6 July 2010)
+
+* New vector-valued constraint feature; thanks to Dmitrey Kroshko of OpenOpt
+  for the suggestion.
+
+* COBYLA now accepts equality constraints.
+
+* Guard against multiple inclusion in nlopt.hpp; thanks to Saul
+  Thurrowgood for the suggestion.
+
+NLopt 2.0.2 (17 June 2010)
+
+* Fixed compilation failure in Microsoft Visual Studio, due to
+  incorrect usage of __stdcall keyword; thanks to Dave Katz for the
+  bug report.
+
+NLopt 2.0.1 (16 June 2010)
+
+* Bug fix in Fortran API (for nlo_get_ functions returning arrays).
+
+* Fixed buggy compilation with MinGW.
+
+NLopt 2.0 (15 June 2010)
+
+* New C API, that works by creating an nlopt_opt "object" and then calling
+  functions to set the optimization parameters -- much more extensible
+  than the old API (which is preserved for backwards compatibility).
+  (Updated Fortran, Matlab, and GNU Octave wrappers as well.)
+
+* C++ nlopt.hpp wrapper around C API, allowing namespaces, object
+  constructors/destructors, std::vector<double>, and exceptions
+  to be exploited.
+
+* New nlopt wrappers callable from Python and GNU Guile, generated
+  with the help of SWIG.
+
+* New 'man nlopt' manual page documenting new API.
+
+* New AUGLAG algorithm(s) implementing an augmented-Lagrangian method
+  proposed by Birgin and Martinez (2008), which supports nonlinear
+  equality and inequality constraints "wrapped around" other
+  local/global optimization methods.
+
+* Added API for nonlinear equality constraints (currently only
+  supported by AUGLAG and ISRES algorithms).
+
+* Support inequality constraints directly in ORIG_DIRECT algorithms
+  (no need to return NaN when constraint is violated).
+
+* Inequality/equality constraints now have optional tolerances that
+  are used as conditions in stopping criteria.
+
+* Pseudo-randomize simplex steps in COBYLA algorithm, improving robustness
+  by avoiding accidentally taking steps that don't improve conditioning
+  (which seems to happen sometimes with active bound constraints).  The
+  algorithm remains deterministic (a deterministic seed is used), however.
+
+* Allow COBYLA to increase the trust-region radius if the predicted improvement
+  was approximately right and the simplex is OK, following a suggestion
+  in the SAS manual for PROC NLP that seems to improve convergence speed.
+
+* Added nlopt_force_stop function to force a (graceful) halt to
+  the optimization, and corresponding NLOPT_FORCED_STOP return code.
+
+* Improved thread-safety in random-number generation: thread-local
+  storage is used for random-number state, on compilers that support
+  it (e.g. gcc, Intel, Microsoft), to make the generation thread-safe.
+  In this case, the random-number seed must be set per-thread.
+
+* Return an error in global-search algorithms if the domain is not finite.
+
+* Use stdcall convention on Windows; thanks to Alan Young for the suggestion.
+
+* Added missing absolute-tolerance criteria in Luksan algorithms; thanks
+  to Greg Nicholas for the bug report.
+
+* Fixed compilation under C++, and use C++ compiler for everything in
+  --with-cxx mode; thanks to Greg Nicholas for the bug report.
+
+* In MMA, only stop at minf_max/stopval if the point is feasible.
+
+* Fix Matlab mex file to not include unnecessary nlopt-util.h file,
+  simplifying Windows compilation.
+
+NLopt 1.2 (18 November 2009)
+
+* Added Powell's BOBYQA algorithm for box-constrained optimization
+  without derivatives, an improvement on NEWUOA.
+
+* Added ISRES genetic algorithm, supporting nonlinearly constrained
+  global optimization.
+
+* New functions nlopt_{set/get}_stochastic_population to provide
+  optional greater control over the random "population" sizes in
+  stochastic algorithms (although it still has a sensible default).
+
+* Bug fix: remove extraneous text accidentally included in nlopt.f Fortran
+  include file.
+
+* Bug fix: configure script now correctly handles Matlab installation
+  when MEX_INSTALL_DIR is specified manually by the user.
+
+NLopt 1.1 (12 November 2009)
+
+* configure script detects whether --enable-shared is required
+  in order to compile Matlab and Octave plugins (as is the case
+  on x86_64), and disables compilation of those plugins if
+  --enable-shared is not used.
+
+* Added --without-octave and --without-matlab configure options to
+  disable Octave and Matlab plugins, respectively.
+
+* Modified COBYLA algorithm to have better support for bound
+  constraints.
+
+* Added new NLOPT_ROUNDOFF_LIMITED failure code to indicate
+  cases in which optimization breaks down due to roundoff errors,
+  in which case it is possible that useful results were obtained.
+
+* Experimental support for nonlinear equality constraints via
+  augmented-Lagrangian method.
+
+* Support for compiling under Windows (ideally with MinGW) as a 
+  DLL, although you have to manually add #define NLOPT_DLL
+  to nlopt.h *after* installing (after compiling NLopt).
+
+* Added several checks for roundoff-related breakdown to NEWUOA code.
+
+* When only a relative error tolerance is specified, no longer
+  fails to halt when exact convergence to zero is obtained.
+
+* Workaround for incompatible qsort_r functions in BSD and GNU libc
+  by always using my own version; thanks to Wendy Vandoolaeghe
+  and Philippe Preux for the bug report and explanation.
+
+* Workaround for gcc 3.4.x conflict with HUGE_VAL definition in Solaris
+  (gcc bug 19933).
+
+* Better identification of Matlab-plugin installation directory.
+
+* Fixed identification of Octave-plugin installation directory for
+  recent Octave versions.
+
+NLopt 1.0.1 (13 Nov. 2008)
+
+* Allow user to override Matlab-plugin installation directory with
+  MEX_INSTALL_DIR.
+
+* Bug fix in my DIRECT code that prevented convergence (DIRECT-L unaffected).
+
+* MLSL needs a nonzero default ftol_rel and/or xtol_rel to ensure that
+  its local searches terminate; use roughly machine precision as defaults.
+
+NLopt 1.0 (11 Nov. 2008)
+
+* Initial public release.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..922be16
--- /dev/null
+++ b/README
@@ -0,0 +1,39 @@
+NLopt is a library for nonlinear local and global optimization, for
+functions with and without gradient information.  It is designed as
+as simple, unified interface and packaging of several free/open-source
+nonlinear optimization libraries.
+
+The latest release and a complete manual may be found at the NLopt
+home page: http://ab-initio.mit.edu/nlopt
+
+It is compiled and installed with the standard GNU autoconf/automake
+commands:
+
+    ./configure
+    make
+    make install
+
+See `./configure --help` or the `INSTALL` file for other options.  To
+build the latest development sources:
+
+    git clone git://github.com/stevengj/nlopt
+    cd nlopt
+    sh autogen.sh
+    make
+
+(To build from git, you will need GNU autoconf, automake, and libtool
+installed, along with SWIG and Unix tools such as m4, perl, and sed.)
+
+Once it is installed, `#include <nlopt.h>` in your C/C++ programs and
+link it with `-lnlopt -lm`.  You may need to use the C++ compiler to link
+in order to include the C++ libraries (which are used internally by NLopt,
+even though it has a C API).
+
+The minimization function, `nlopt_minimize`, is described in the [man
+page](http://en.wikipedia.org/wiki/Man_page) (`api/nlopt_minimize.3`,
+which is installed by `make install`.  See also the manual on our
+web page.
+
+There are also interfaces for Fortran, Python, Matlab, Octave, OCaml,
+GNU Guile, GNU R, Lua, and Julia.  Interfaces for other languages may
+be added in the future.
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..2153355
--- /dev/null
+++ b/TODO
@@ -0,0 +1,11 @@
+Add nonlinearly constrained multistart algorithm.
+
+Add option to control subspace size (mf) in LBFGS etcetera.
+
+STOGO has bitrotted - doesn't return proper NLopt codes, doesn't
+support forced stop, etcetera.  Needs to be fixed.
+
+If local_optimizer is set, STOGO should use it instead of its
+own BFGS.
+
+Wrappers for GNU R, Java, Perl, Ocaml, C#, ...
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..8cc8ae4
--- /dev/null
@@ -0,0 +1,1455 @@
+# generated automatically by aclocal 1.14 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.14'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.14], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.14])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Older Autoconf quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named 'Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running 'make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "$am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+             [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES([CC])],
+                 [m4_define([AC_PROG_CC],
+                            m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES([CXX])],
+                 [m4_define([AC_PROG_CXX],
+                            m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES([OBJC])],
+                 [m4_define([AC_PROG_OBJC],
+                            m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+                 [_AM_DEPENDENCIES([OBJCXX])],
+                 [m4_define([AC_PROG_OBJCXX],
+                            m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+  fi
+fi])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
+# From Jim Meyering
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAINTAINER_MODE([DEFAULT-MODE])
+# ----------------------------------
+# Control maintainer-specific portions of Makefiles.
+# Default is to disable them, unless 'enable' is passed literally.
+# For symmetry, 'disable' may be passed as well.  Anyway, the user
+# can override the default with the --enable/--disable switch.
+AC_DEFUN([AM_MAINTAINER_MODE],
+[m4_case(m4_default([$1], [disable]),
+       [enable], [m4_define([am_maintainer_other], [disable])],
+       [disable], [m4_define([am_maintainer_other], [enable])],
+       [m4_define([am_maintainer_other], [enable])
+        m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
+AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode's default is 'disable' unless 'enable' is passed
+  AC_ARG_ENABLE([maintainer-mode],
+    [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
+      am_maintainer_other[ make rules and dependencies not useful
+      (and sometimes confusing) to the casual installer])],
+    [USE_MAINTAINER_MODE=$enableval],
+    [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
+  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+  AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST([MAINT])dnl
+]
+)
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
+else
+  am_missing_run=
+  AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+#  -*- Autoconf -*-
+# Obsolete and "removed" macros, that must however still report explicit
+# error messages when used, to smooth transition.
+#
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([AM_CONFIG_HEADER],
+[AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
+AC_CONFIG_HEADERS($@)])
+
+AC_DEFUN([AM_PROG_CC_STDC],
+[AC_PROG_CC
+am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
+AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should simply use the 'AC][_PROG_CC' macro instead.
+Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
+but upon 'ac_cv_prog_cc_stdc'.])])
+
+AC_DEFUN([AM_C_PROTOTYPES],
+         [AC_FATAL([automatic de-ANSI-fication support has been removed])])
+AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+  [whether $CC understands -c and -o together],
+  [am_cv_prog_cc_c_o],
+  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------
+# Adds support for distributing Python modules and packages.  To
+# install modules, copy them to $(pythondir), using the python_PYTHON
+# automake variable.  To install a package with the same name as the
+# automake package, install to $(pkgpythondir), or use the
+# pkgpython_PYTHON automake variable.
+#
+# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
+# locations to install python extension modules (shared libraries).
+# Another macro is required to find the appropriate flags to compile
+# extension modules.
+#
+# If your package is configured with a different prefix to python,
+# users will have to add the install directory to the PYTHONPATH
+# environment variable, or create a .pth file (see the python
+# documentation for details).
+#
+# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
+# cause an error if the version of python installed on the system
+# doesn't meet the requirement.  MINIMUM-VERSION should consist of
+# numbers and dots only.
+AC_DEFUN([AM_PATH_PYTHON],
+ [
+  dnl Find a Python interpreter.  Python versions prior to 2.0 are not
+  dnl supported. (2.0 was released on October 16, 2000).
+  m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
+[python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
+ python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
+
+  AC_ARG_VAR([PYTHON], [the Python interpreter])
+
+  m4_if([$1],[],[
+    dnl No version check is needed.
+    # Find any Python interpreter.
+    if test -z "$PYTHON"; then
+      AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
+    fi
+    am_display_PYTHON=python
+  ], [
+    dnl A version check is needed.
+    if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      AC_MSG_CHECKING([whether $PYTHON version is >= $1])
+      AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
+                             [AC_MSG_RESULT([yes])],
+                             [AC_MSG_RESULT([no])
+                              AC_MSG_ERROR([Python interpreter is too old])])
+      am_display_PYTHON=$PYTHON
+    else
+      # Otherwise, try each interpreter until we find one that satisfies
+      # VERSION.
+      AC_CACHE_CHECK([for a Python interpreter with version >= $1],
+       [am_cv_pathless_PYTHON],[
+       for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
+         test "$am_cv_pathless_PYTHON" = none && break
+         AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
+       done])
+      # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
+      if test "$am_cv_pathless_PYTHON" = none; then
+       PYTHON=:
+      else
+        AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      fi
+      am_display_PYTHON=$am_cv_pathless_PYTHON
+    fi
+  ])
+
+  if test "$PYTHON" = :; then
+  dnl Run any user-specified action, or abort.
+    m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+  else
+
+  dnl Query Python for its version number.  Getting [:3] seems to be
+  dnl the best way to do this; it's what "site.py" does in the standard
+  dnl library.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
+    [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
+  AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
+
+  dnl Use the values of $prefix and $exec_prefix for the corresponding
+  dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
+  dnl distinct variables so they can be overridden if need be.  However,
+  dnl general consensus is that you shouldn't need this ability.
+
+  AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
+  AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
+
+  dnl At times (like when building shared libraries) you may want
+  dnl to know which OS platform Python thinks this is.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
+    [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
+  AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
+
+  # Just factor out some code duplication.
+  am_python_setup_sysconfig="\
+import sys
+# Prefer sysconfig over distutils.sysconfig, for better compatibility
+# with python 3.x.  See automake bug#10227.
+try:
+    import sysconfig
+except ImportError:
+    can_use_sysconfig = 0
+else:
+    can_use_sysconfig = 1
+# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    from platform import python_implementation
+    if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7':
+        can_use_sysconfig = 0
+except ImportError:
+    pass"
+
+  dnl Set up 4 directories:
+
+  dnl pythondir -- where to install python scripts.  This is the
+  dnl   site-packages directory, not the python standard library
+  dnl   directory like in previous automake betas.  This behavior
+  dnl   is more consistent with lispdir.m4 for example.
+  dnl Query distutils for this directory.
+  AC_CACHE_CHECK([for $am_display_PYTHON script directory],
+    [am_cv_python_pythondir],
+    [if test "x$prefix" = xNONE
+     then
+       am_py_prefix=$ac_default_prefix
+     else
+       am_py_prefix=$prefix
+     fi
+     am_cv_python_pythondir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+    sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+else:
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
+     case $am_cv_python_pythondir in
+     $am_py_prefix*)
+       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
+       ;;
+     *)
+       case $am_py_prefix in
+         /usr|/System*) ;;
+         *)
+         am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
+         ;;
+       esac
+       ;;
+     esac
+    ])
+  AC_SUBST([pythondir], [$am_cv_python_pythondir])
+
+  dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
+  dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
+  dnl   more consistent with the rest of automake.
+
+  AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
+
+  dnl pyexecdir -- directory for installing python extension modules
+  dnl   (shared libraries)
+  dnl Query distutils for this directory.
+  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
+    [am_cv_python_pyexecdir],
+    [if test "x$exec_prefix" = xNONE
+     then
+       am_py_exec_prefix=$am_py_prefix
+     else
+       am_py_exec_prefix=$exec_prefix
+     fi
+     am_cv_python_pyexecdir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+    sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
+else:
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
+     case $am_cv_python_pyexecdir in
+     $am_py_exec_prefix*)
+       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
+       ;;
+     *)
+       case $am_py_exec_prefix in
+         /usr|/System*) ;;
+         *)
+          am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
+          ;;
+       esac
+       ;;
+     esac
+    ])
+  AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
+
+  dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
+
+  AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+  dnl Run any user-specified action.
+  $2
+  fi
+
+])
+
+
+# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-FALSE otherwise.
+# This test uses sys.hexversion instead of the string equivalent (first
+# word of sys.version), in order to cope with versions such as 2.2c1.
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
+AC_DEFUN([AM_PYTHON_CHECK_VERSION],
+ [prog="import sys
+# split strings by '.' and convert to numeric.  Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
+sys.exit(sys.hexversion < minverhex)"
+  AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+       # -L didn't work.
+       set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+       && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+       # If neither matched, then we have a broken ls.  This can happen
+       # if, for instance, CONFIG_SHELL is bash and it inherits a
+       # broken ls alias from the environment.  This has actually
+       # happened.  Such a system could not be considered "sane".
+       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+       @$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+#
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
+
+  [pax],
+    [],
+
+  [m4_fatal([Unknown tar format])])
+
+  AC_MSG_CHECKING([how to create a $1 tar archive])
+
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
+
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
+
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
+  rm -rf conftest.dir
+
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/ax_c_threadlocal.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
diff --git a/api/Makefile.am b/api/Makefile.am
new file mode 100644 (file)
index 0000000..d4d08d2
--- /dev/null
@@ -0,0 +1,24 @@
+AM_CPPFLAGS = -I$(top_srcdir)/cdirect -I$(top_srcdir)/direct -I$(top_srcdir)/stogo -I$(top_srcdir)/praxis -I$(top_srcdir)/lbfgs -I$(top_srcdir)/luksan -I$(top_srcdir)/crs -I$(top_srcdir)/mlsl -I$(top_srcdir)/mma -I$(top_srcdir)/cobyla -I$(top_srcdir)/newuoa -I$(top_srcdir)/neldermead -I$(top_srcdir)/auglag -I$(top_srcdir)/bobyqa -I$(top_srcdir)/isres -I$(top_srcdir)/slsqp -I$(top_srcdir)/esch -I$(top_srcdir)/util
+
+include_HEADERS = nlopt.h nlopt.f nlopt.hpp
+noinst_LTLIBRARIES = libapi.la
+dist_man_MANS = nlopt.3
+
+libapi_la_SOURCES = general.c options.c optimize.c deprecated.c        \
+nlopt-internal.h nlopt.h f77api.c f77funcs.h f77funcs_.h
+
+BUILT_SOURCES = nlopt.f nlopt.hpp
+EXTRA_DIST = nlopt-in.hpp
+
+if MAINTAINER_MODE
+# convert constants to F77 parameter statements & C++
+
+nlopt.f: nlopt.h
+       rm -f $@
+       (i=0; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' $(srcdir)/nlopt.h | tr -d ' =0,' | while read n; do echo "      integer $$n"; echo "      parameter ($$n=$$i)"; i=`expr $$i + 1`; done; tail -n +`grep -n enum $(srcdir)/nlopt.h |cut -d: -f1 |tail -n 1` $(srcdir)/nlopt.h  | grep NLOPT | egrep -v 'EXTERN|DEPRECATED|MINF_MAX' | cut -d, -f1 | tr -d ' ' | perl -pe 's/([A-Za-z0-9_]+)=([-+0-9]+)/      integer \1\n      parameter (\1=\2)/') > $(srcdir)/$@
+
+nlopt.hpp: nlopt.h nlopt-in.hpp
+       rm -f $@
+       (n=`grep -n GEN_ENUMS_HERE $(srcdir)/nlopt-in.hpp | cut -d: -f1`; head -n $$n $(srcdir)/nlopt-in.hpp;  echo "  enum algorithm {"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(srcdir)/nlopt.h | sed 's/NLOPT_//g'; echo "  };"; echo "  enum result {"; egrep 'NLOPT_[A-Z_]* =' $(srcdir)/nlopt.h | egrep -v 'NLOPT_[LG][DN]' | sed 's/NLOPT_//g'; echo "  };"; tail -n +$$n $(srcdir)/nlopt-in.hpp) > $(srcdir)/$@
+
+endif
diff --git a/api/Makefile.in b/api/Makefile.in
new file mode 100644 (file)
index 0000000..b8d4dc1
--- /dev/null
@@ -0,0 +1,734 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = api
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp $(dist_man_MANS) $(include_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libapi_la_LIBADD =
+am_libapi_la_OBJECTS = general.lo options.lo optimize.lo deprecated.lo \
+       f77api.lo
+libapi_la_OBJECTS = $(am_libapi_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libapi_la_SOURCES)
+DIST_SOURCES = $(libapi_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+man3dir = $(mandir)/man3
+am__installdirs = "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(includedir)"
+NROFF = nroff
+MANS = $(dist_man_MANS)
+HEADERS = $(include_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/cdirect -I$(top_srcdir)/direct -I$(top_srcdir)/stogo -I$(top_srcdir)/praxis -I$(top_srcdir)/lbfgs -I$(top_srcdir)/luksan -I$(top_srcdir)/crs -I$(top_srcdir)/mlsl -I$(top_srcdir)/mma -I$(top_srcdir)/cobyla -I$(top_srcdir)/newuoa -I$(top_srcdir)/neldermead -I$(top_srcdir)/auglag -I$(top_srcdir)/bobyqa -I$(top_srcdir)/isres -I$(top_srcdir)/slsqp -I$(top_srcdir)/esch -I$(top_srcdir)/util
+include_HEADERS = nlopt.h nlopt.f nlopt.hpp
+noinst_LTLIBRARIES = libapi.la
+dist_man_MANS = nlopt.3
+libapi_la_SOURCES = general.c options.c optimize.c deprecated.c        \
+nlopt-internal.h nlopt.h f77api.c f77funcs.h f77funcs_.h
+
+BUILT_SOURCES = nlopt.f nlopt.hpp
+EXTRA_DIST = nlopt-in.hpp
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu api/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu api/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libapi.la: $(libapi_la_OBJECTS) $(libapi_la_DEPENDENCIES) $(EXTRA_libapi_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libapi_la_OBJECTS) $(libapi_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deprecated.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/f77api.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/general.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man3: $(dist_man_MANS)
+       @$(NORMAL_INSTALL)
+       @list1=''; \
+       list2='$(dist_man_MANS)'; \
+       test -n "$(man3dir)" \
+         && test -n "`echo $$list1$$list2`" \
+         || exit 0; \
+       echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
+       $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
+       { for i in $$list1; do echo "$$i"; done;  \
+       if test -n "$$list2"; then \
+         for i in $$list2; do echo "$$i"; done \
+           | sed -n '/\.3[a-z]*$$/p'; \
+       fi; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man3:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man3dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.3[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
+install-includeHEADERS: $(include_HEADERS)
+       @$(NORMAL_INSTALL)
+       @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+         $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+       done
+
+uninstall-includeHEADERS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS)
+installdirs:
+       for dir in "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(includedir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man3
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS uninstall-man
+
+uninstall-man: uninstall-man3
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am \
+       install-includeHEADERS install-info install-info-am \
+       install-man install-man3 install-pdf install-pdf-am install-ps \
+       install-ps-am install-strip installcheck installcheck-am \
+       installdirs maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+       uninstall-am uninstall-includeHEADERS uninstall-man \
+       uninstall-man3
+
+
+# convert constants to F77 parameter statements & C++
+
+@MAINTAINER_MODE_TRUE@nlopt.f: nlopt.h
+@MAINTAINER_MODE_TRUE@ rm -f $@
+@MAINTAINER_MODE_TRUE@ (i=0; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' $(srcdir)/nlopt.h | tr -d ' =0,' | while read n; do echo "      integer $$n"; echo "      parameter ($$n=$$i)"; i=`expr $$i + 1`; done; tail -n +`grep -n enum $(srcdir)/nlopt.h |cut -d: -f1 |tail -n 1` $(srcdir)/nlopt.h  | grep NLOPT | egrep -v 'EXTERN|DEPRECATED|MINF_MAX' | cut -d, -f1 | tr -d ' ' | perl -pe 's/([A-Za-z0-9_]+)=([-+0-9]+)/      integer \1\n      parameter (\1=\2)/') > $(srcdir)/$@
+
+@MAINTAINER_MODE_TRUE@nlopt.hpp: nlopt.h nlopt-in.hpp
+@MAINTAINER_MODE_TRUE@ rm -f $@
+@MAINTAINER_MODE_TRUE@ (n=`grep -n GEN_ENUMS_HERE $(srcdir)/nlopt-in.hpp | cut -d: -f1`; head -n $$n $(srcdir)/nlopt-in.hpp;  echo "  enum algorithm {"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(srcdir)/nlopt.h | sed 's/NLOPT_//g'; echo "  };"; echo "  enum result {"; egrep 'NLOPT_[A-Z_]* =' $(srcdir)/nlopt.h | egrep -v 'NLOPT_[LG][DN]' | sed 's/NLOPT_//g'; echo "  };"; tail -n +$$n $(srcdir)/nlopt-in.hpp) > $(srcdir)/$@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/api/deprecated.c b/api/deprecated.c
new file mode 100644 (file)
index 0000000..e6e4b40
--- /dev/null
@@ -0,0 +1,171 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include "nlopt.h"
+
+/*************************************************************************/
+
+nlopt_algorithm nlopt_local_search_alg_deriv = NLOPT_LD_MMA;
+nlopt_algorithm nlopt_local_search_alg_nonderiv = NLOPT_LN_COBYLA;
+int nlopt_local_search_maxeval = -1; /* no maximum by default */
+
+void
+NLOPT_STDCALL nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
+                                     nlopt_algorithm *nonderiv,
+                                     int *maxeval)
+{
+     *deriv = nlopt_local_search_alg_deriv;
+     *nonderiv = nlopt_local_search_alg_nonderiv;
+     *maxeval = nlopt_local_search_maxeval;
+}
+
+void
+NLOPT_STDCALL nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
+                                     nlopt_algorithm nonderiv,
+                                     int maxeval)
+{
+     nlopt_local_search_alg_deriv = deriv;
+     nlopt_local_search_alg_nonderiv = nonderiv;
+     nlopt_local_search_maxeval = maxeval;
+}
+
+/*************************************************************************/
+
+int nlopt_stochastic_population = 0;
+
+int
+NLOPT_STDCALL nlopt_get_stochastic_population(void) { 
+     return nlopt_stochastic_population; }
+void
+NLOPT_STDCALL nlopt_set_stochastic_population(int pop) { 
+     nlopt_stochastic_population = pop <= 0 ? 0 : (unsigned) pop; }
+
+/*************************************************************************/
+
+nlopt_result
+NLOPT_STDCALL nlopt_minimize_econstrained(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     int m, nlopt_func_old fc, void *fc_data_, ptrdiff_t fc_datum_size,
+     int p, nlopt_func_old h, void *h_data_, ptrdiff_t h_datum_size,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     double htol_rel, double htol_abs,
+     int maxeval, double maxtime)
+{
+     char *fc_data = (char *) fc_data_;
+     char *h_data = (char *) h_data_;
+     nlopt_opt opt;
+     nlopt_result ret;
+     int i;
+
+     if (n < 0 || m < 0 || p < 0) return NLOPT_INVALID_ARGS;
+
+     opt = nlopt_create(algorithm, (unsigned) n);
+     if (!opt) return NLOPT_INVALID_ARGS;
+
+     ret = nlopt_set_min_objective(opt, (nlopt_func) f, f_data);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     for (i = 0; i < m; ++i) {
+         ret = nlopt_add_inequality_constraint(opt, (nlopt_func) fc, 
+                                               fc_data + i*fc_datum_size,
+                                               0.0);
+         if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     }
+
+     (void) htol_rel; /* unused */
+     for (i = 0; i < p; ++i) {
+         ret = nlopt_add_equality_constraint(opt, (nlopt_func) h, 
+                                             h_data + i*h_datum_size,
+                                             htol_abs);
+         if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     }
+
+     ret = nlopt_set_lower_bounds(opt, lb);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     ret = nlopt_set_upper_bounds(opt, ub);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     ret = nlopt_set_stopval(opt, minf_max);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     ret = nlopt_set_ftol_rel(opt, ftol_rel);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     ret = nlopt_set_ftol_abs(opt, ftol_abs);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     ret = nlopt_set_xtol_rel(opt, xtol_rel);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     if (xtol_abs) ret = nlopt_set_xtol_abs(opt, xtol_abs);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+     
+     ret = nlopt_set_maxeval(opt, maxeval);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     ret = nlopt_set_maxtime(opt, maxtime);
+     if (ret != NLOPT_SUCCESS) { nlopt_destroy(opt); return ret; }
+
+     ret = nlopt_optimize(opt, x, minf);
+
+     nlopt_destroy(opt);
+     return ret;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_minimize_constrained(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     int m, nlopt_func_old fc, void *fc_data, ptrdiff_t fc_datum_size,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     int maxeval, double maxtime)
+{
+     return nlopt_minimize_econstrained(
+         algorithm, n, f, f_data, 
+         m, fc, fc_data, fc_datum_size, 0, NULL, NULL, 0,
+         lb, ub, x, minf, minf_max, ftol_rel, ftol_abs,
+         xtol_rel, xtol_abs, ftol_rel, ftol_abs, maxeval, maxtime);
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_minimize(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     int maxeval, double maxtime)
+{
+     return nlopt_minimize_constrained(
+         algorithm, n, f, f_data, 0, NULL, NULL, 0,
+         lb, ub, x, minf, minf_max, ftol_rel, ftol_abs,
+         xtol_rel, xtol_abs, maxeval, maxtime);
+}
diff --git a/api/f77api.c b/api/f77api.c
new file mode 100644 (file)
index 0000000..e753c86
--- /dev/null
@@ -0,0 +1,129 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "nlopt.h"
+
+/*-----------------------------------------------------------------------*/
+/* wrappers around f77 procedures */
+
+typedef void (*nlopt_f77_func)(double *val, const int *n, const double *x,
+                              double *gradient, const int *need_gradient,
+                              void *func_data);
+
+typedef void (*nlopt_f77_mfunc)(const int *m,
+                               double *val, const int *n, const double *x,
+                               double *gradient, const int *need_gradient,
+                               void *func_data);
+
+typedef struct {
+     nlopt_f77_func f;
+     nlopt_f77_mfunc mf;
+     void *f_data;
+} f77_func_data;
+
+static void *free_f77_func_data(void *p) { free(p); return NULL; }
+static void *dup_f77_func_data(void *p) { 
+     void *pnew = (void*) malloc(sizeof(f77_func_data));
+     if (pnew) memcpy(pnew, p, sizeof(f77_func_data));
+     return pnew;
+}
+
+static double f77_func_wrap_old(int n, const double *x, double *grad, void *data)
+{
+     f77_func_data *d = (f77_func_data *) data;
+     double val;
+     int need_gradient = grad != 0;
+     d->f(&val, &n, x, grad, &need_gradient, d->f_data);
+     return val;
+}
+
+static double f77_func_wrap(unsigned n, const double *x, double *grad, void *data)
+{
+     f77_func_data *d = (f77_func_data *) data;
+     int ni = (int) n;
+     double val;
+     int need_gradient = grad != 0;
+     d->f(&val, &ni, x, grad, &need_gradient, d->f_data);
+     return val;
+}
+
+static void f77_mfunc_wrap(unsigned m, double *result, unsigned n, const double *x, double *grad, void *data)
+{
+     f77_func_data *d = (f77_func_data *) data;
+     int mi = (int) m;
+     int ni = (int) n;
+     int need_gradient = grad != 0;
+     d->mf(&mi, result, &ni, x, grad, &need_gradient, d->f_data);
+}
+
+/*-----------------------------------------------------------------------*/
+
+#define F77_GET(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(T *val, nlopt_opt *opt) { *val = (T) nlopt_get_##name(*opt); }
+#define F77_SET(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, *val); }
+#define F77_GETSET(name,NAME,T) F77_GET(name,NAME,T) F77_SET(name,NAME,T)
+
+#define F77_GETA(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_get_##name(*opt, val); }
+#define F77_SETA(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, val); }
+#define F77_GETSETA(name,NAME,T) F77_GETA(name,NAME,T) F77_SETA(name,NAME,T) F77_SET(name##1,NAME##1,T)
+
+/*-----------------------------------------------------------------------*/
+/* rather than trying to detect the Fortran name-mangling scheme with
+   autoconf, we just include wrappers with all common name-mangling
+   schemes ... this avoids problems and also allows us to work with
+   multiple Fortran compilers on the same machine.  Since the Fortran
+   wrapper functions are so small, the library bloat of including them
+   multiple times is negligible and seems well worth the benefit. */
+
+#  define F77CALL(a, A) F77(a, A)
+
+/* name + underscore is by far the most common (gfortran, g77, Intel, ...) */
+#  define F77(a, A) a ## _
+#  include "f77funcs.h"
+
+/* also include g77 convention of name + double underscore for identifiers
+   containing underscores */
+#  define F77_(a, A) a ## __
+#  include "f77funcs_.h"
+#  undef F77_
+
+/* AIX and HPUX use just the lower-case name */
+#  undef F77
+#  define F77(a, A) a
+#  include "f77funcs.h"
+
+/* Old Cray Unicos, as well as several Windows Fortran compilers
+   (Digital/Compaq/HP Visual Fortran and Intel Fortran) use all-uppercase
+   name */
+
+/* Digital/Compaq/HP Visual Fortran, Intel Fortran.  stdcall attribute
+   is apparently required to adjust for calling conventions (callee
+   pops stack in stdcall).  See also:
+       http://msdn.microsoft.com/library/en-us/vccore98/html/_core_mixed.2d.language_programming.3a_.overview.asp
+*/
+#  undef F77
+#  undef F77CALL
+#  define F77(a, A) NLOPT_STDCALL A
+#  define F77CALL(a, A) A
+#  include "f77funcs.h"
diff --git a/api/f77funcs.h b/api/f77funcs.h
new file mode 100644 (file)
index 0000000..332b16b
--- /dev/null
@@ -0,0 +1,118 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* Fortran API wrappers, using the F77 macro defined in f77api.c.
+   This header file is #included one or more times from f77api.c
+   in order to define verions of the Fortran API for various compilers. 
+
+   In homage to Fortran 77, we stick with 6-character subroutine names.
+   The return value of the function is converted into the first argument
+   of the subroutine. */
+
+/* nlopt_minimize_constrained */
+void F77(nloptc,NLOPTC)(int *info, 
+                       const int *algorithm,
+                       const int *n, nlopt_f77_func f, void *f_data,
+                       const int *m, nlopt_f77_func fc, 
+                       char *fc_data, char *fc_second_datum,
+                       const double *lb, const double *ub,
+                       double *x, double *minf,
+                       const double *minf_max,
+                       const double *ftol_rel, const double *ftol_abs,
+                       const double *xtol_rel, const double *xtol_abs,
+                       const int *have_xtol_abs,
+                       const int *maxeval, const double *maxtime)
+{
+     f77_func_data d, *dc;
+     int i;
+
+     d.f = f; d.f_data = f_data;
+     if (*m < 0) { *info = NLOPT_INVALID_ARGS; return; }
+     dc = (f77_func_data *) malloc(sizeof(f77_func_data) * *m);
+     if (*m > 0 && !dc) { *info = NLOPT_OUT_OF_MEMORY; return; }
+     for (i = 0; i < *m; ++i) {
+         dc[i].f = fc;
+         dc[i].f_data = fc_data + i * (fc_second_datum - fc_data);
+     }
+
+     *info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm, 
+                                       *n, f77_func_wrap_old, &d,
+                                       *m, f77_func_wrap_old, 
+                                       dc, sizeof(f77_func_data),
+                                       lb, ub, x, minf,
+                                       *minf_max, *ftol_rel, *ftol_abs,
+                                       *xtol_rel,
+                                       *have_xtol_abs ? xtol_abs : 0,
+                                       *maxeval, *maxtime);
+
+     if (dc) free(dc);
+}
+
+/* nlopt_minimize */
+void F77(nloptm,NLOPTM)(int *info, 
+                       const int *algorithm,
+                       const int *n, nlopt_f77_func f, void *f_data,
+                       const double *lb, const double *ub,
+                       double *x, double *minf,
+                       const double *minf_max,
+                       const double *ftol_rel, const double *ftol_abs,
+                       const double *xtol_rel, const double *xtol_abs,
+                       const int *have_xtol_abs,
+                       const int *maxeval, const double *maxtime)
+{
+     int m = 0;
+     F77CALL(nloptc,NLOPTC)(info, algorithm, n, f, f_data, &m, 0, 0, 0,
+                       lb, ub, x, minf, minf_max, ftol_rel, ftol_abs,
+                       xtol_rel, xtol_abs, have_xtol_abs, maxeval, maxtime);
+}
+
+void F77(nlosr,NLOSR)(const int *seed) { nlopt_srand((unsigned long) *seed); }
+void F77(nlosrt,NLOSRT)(void) { nlopt_srand_time(); }
+void F77(nloptv,NLOPTV)(int *major, int *minor, int *bugfix) {
+     nlopt_version(major, minor, bugfix);
+}
+void F77(nlogls,NLOGLS)(int *ideriv, int *inonderiv, int *maxeval)
+{
+     nlopt_algorithm deriv, nonderiv;
+     nlopt_get_local_search_algorithm(&deriv, &nonderiv, maxeval);
+     *ideriv = deriv;
+     *inonderiv = nonderiv;
+}
+void F77(nlosls,NLOSLS)(int *ideriv, int *inonderiv, int *maxeval)
+{
+     nlopt_algorithm deriv = (nlopt_algorithm) *ideriv;
+     nlopt_algorithm nonderiv = (nlopt_algorithm) *inonderiv;
+     nlopt_set_local_search_algorithm(deriv, nonderiv, *maxeval);
+}
+
+void F77(nlogsp,NLOGSP)(int *pop)
+{
+     *pop = nlopt_get_stochastic_population();
+}
+void F77(nlossp,NLOSSP)(const int *pop)
+{
+     nlopt_set_stochastic_population(*pop);
+}
+
+#define F77_(name,NAME) F77(name,NAME)
+# include "f77funcs_.h"
+#undef F77_
diff --git a/api/f77funcs_.h b/api/f77funcs_.h
new file mode 100644 (file)
index 0000000..a8534fd
--- /dev/null
@@ -0,0 +1,168 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* Fortran API wrappers, using the F77 macro defined in f77api.c.
+   This header file is #included one or more times from f77api.c
+   in order to define verions of the Fortran API for various compilers. 
+
+   All of the functions in this file have underscores in their names,
+   which means that they are treated differently for name-mangling
+   (thank you, g77 and f2c) than names without underscores.
+   
+   The return value of a function is converted to the first argument
+   of a subroutine. */
+
+void F77_(nlo_create,NLO_CREATE)(nlopt_opt *opt, int *alg, int *n)
+{
+     if (*n < 0) *opt = NULL;
+     else {
+         *opt = nlopt_create((nlopt_algorithm) *alg, (unsigned) *n);
+         nlopt_set_munge(*opt, free_f77_func_data, dup_f77_func_data);
+     }
+}
+
+void F77_(nlo_copy,NLO_COPY)(nlopt_opt *nopt, nlopt_opt *opt)
+{
+     *nopt = nlopt_copy(*opt);
+}
+
+void F77_(nlo_destroy,NLO_DESTROY)(nlopt_opt *opt)
+{
+     nlopt_destroy(*opt);
+}
+
+void F77_(nlo_optimize,NLO_OPTIMIZE)(int *ret,
+                                    nlopt_opt *opt, double *x, double *optf)
+{
+     *ret = (int) nlopt_optimize(*opt, x, optf);
+}
+
+void F77_(nlo_set_min_objective,NLO_SET_MIN_OBJECTIVE)(
+     int *ret, nlopt_opt *opt, nlopt_f77_func f, void *f_data)
+{
+     f77_func_data *d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->f = f;
+     d->f_data = f_data;
+     *ret = (int) nlopt_set_min_objective(*opt, f77_func_wrap, d);
+}
+
+void F77_(nlo_set_max_objective,NLO_SET_MAX_OBJECTIVE)(
+     int *ret, nlopt_opt *opt, nlopt_f77_func f, void *f_data)
+{
+     f77_func_data *d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->f = f;
+     d->f_data = f_data;
+     *ret = (int) nlopt_set_max_objective(*opt, f77_func_wrap, d);
+}
+
+F77_GET(algorithm, ALGORITHM, int)
+F77_GET(dimension, DIMENSION, int)
+
+F77_GETSETA(lower_bounds, LOWER_BOUNDS, double)
+F77_GETSETA(upper_bounds, UPPER_BOUNDS, double)
+
+void F77_(nlo_remove_inequality_constraints,NLO_REMOVE_INEQUALITY_CONSTRAINTS)(
+     int *ret, nlopt_opt *opt) { 
+     *ret = (int) nlopt_remove_inequality_constraints(*opt);
+}
+
+void F77_(nlo_add_inequality_constraint,NLO_ADD_INEQUALITY_CONSTRAINT)(
+     int *ret, nlopt_opt *opt, nlopt_f77_func fc, void *fc_data, double *tol)
+{
+     f77_func_data *d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->f = fc;
+     d->f_data = fc_data;
+     *ret = (int) nlopt_add_inequality_constraint(*opt, f77_func_wrap,d, *tol);
+}
+
+void F77_(nlo_add_inequality_mconstraint,NLO_ADD_INEQUALITY_MCONSTRAINT)(
+     int *ret, nlopt_opt *opt, int *m,
+     nlopt_f77_mfunc mfc, void *mfc_data, double *tol)
+{
+     f77_func_data *d;
+     if (*m < 0) { *ret = (int) NLOPT_INVALID_ARGS; return; }
+     if (*m == 0) { *ret = (int) NLOPT_SUCCESS; return; }
+     d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->mf = mfc;
+     d->f_data = mfc_data;
+     *ret = (int) nlopt_add_inequality_mconstraint(*opt, (unsigned) *m, 
+                                                  f77_mfunc_wrap, d, tol);
+}
+
+void F77_(nlo_remove_equality_constraints,NLO_REMOVE_EQUALITY_CONSTRAINTS)(
+     int *ret, nlopt_opt *opt) { 
+     *ret = (int) nlopt_remove_equality_constraints(*opt);
+}
+
+void F77_(nlo_add_equality_constraint,NLO_ADD_EQUALITY_CONSTRAINT)(
+     int *ret, nlopt_opt *opt, nlopt_f77_func fc, void *fc_data, double *tol)
+{
+     f77_func_data *d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->f = fc;
+     d->f_data = fc_data;
+     *ret = (int) nlopt_add_equality_constraint(*opt, f77_func_wrap,d, *tol);
+}
+
+void F77_(nlo_add_equality_mconstraint,NLO_ADD_EQUALITY_MCONSTRAINT)(
+     int *ret, nlopt_opt *opt, int *m,
+     nlopt_f77_mfunc mfc, void *mfc_data, double *tol)
+{
+     f77_func_data *d;
+     if (*m < 0) { *ret = (int) NLOPT_INVALID_ARGS; return; }
+     if (*m == 0) { *ret = (int) NLOPT_SUCCESS; return; }
+     d = (f77_func_data*) malloc(sizeof(f77_func_data));
+     if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; return; }
+     d->mf = mfc;
+     d->f_data = mfc_data;
+     *ret = (int) nlopt_add_equality_mconstraint(*opt, (unsigned) *m, 
+                                                f77_mfunc_wrap, d, tol);
+}
+
+F77_GETSET(stopval, STOPVAL, double)
+F77_GETSET(ftol_rel, FTOL_REL, double)
+F77_GETSET(ftol_abs, FTOL_ABS, double)
+F77_GETSET(xtol_rel, XTOL_REL, double)
+F77_GETSETA(xtol_abs, XTOL_ABS, double)
+F77_GETSET(maxeval, MAXEVAL, int)
+F77_GETSET(maxtime, MAXTIME, double)
+
+F77_GETSET(force_stop, FORCE_STOP, int)
+void F77_(nlo_force_stop,NLO_FORCE_STOP)(int *ret, nlopt_opt *opt) {
+     *ret = (int) nlopt_force_stop(*opt);
+}
+
+F77_SET(local_optimizer, LOCAL_OPTIMIZER, nlopt_opt)
+F77_GETSET(population, POPULATION, unsigned)
+F77_GETSET(vector_storage, vector_storage, unsigned)
+
+F77_SETA(default_initial_step, DEFAULT_INITIAL_STEP, double)
+F77_SETA(initial_step, INITIAL_STEP, double)
+F77_SET(initial_step1, INITIAL_STEP1, double)
+void F77_(nlo_get_initial_step, NLO_GET_INITIAL_STEP)(
+     int *ret, nlopt_opt *opt, const double *x, double *dx) {
+     *ret = (int) nlopt_get_initial_step(*opt, x, dx);
+}
diff --git a/api/general.c b/api/general.c
new file mode 100644 (file)
index 0000000..d97fcb5
--- /dev/null
@@ -0,0 +1,141 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include <float.h>
+
+#include "nlopt-internal.h"
+
+/*************************************************************************/
+
+int nlopt_isinf(double x) {
+     return fabs(x) >= HUGE_VAL * 0.99
+#ifdef HAVE_ISINF
+         || isinf(x)
+#endif
+         ;
+}
+/*************************************************************************/
+
+void NLOPT_STDCALL nlopt_version(int *major, int *minor, int *bugfix)
+{
+     *major = MAJOR_VERSION;
+     *minor = MINOR_VERSION;
+     *bugfix = BUGFIX_VERSION;
+}
+
+/*************************************************************************/
+
+static const char nlopt_algorithm_names[NLOPT_NUM_ALGORITHMS][256] = {
+     "DIRECT (global, no-derivative)",
+     "DIRECT-L (global, no-derivative)",
+     "Randomized DIRECT-L (global, no-derivative)",
+     "Unscaled DIRECT (global, no-derivative)",
+     "Unscaled DIRECT-L (global, no-derivative)",
+     "Unscaled Randomized DIRECT-L (global, no-derivative)",
+     "Original DIRECT version (global, no-derivative)",
+     "Original DIRECT-L version (global, no-derivative)",
+#ifdef WITH_CXX
+     "StoGO (global, derivative-based)",
+     "StoGO with randomized search (global, derivative-based)",
+#else
+     "StoGO (NOT COMPILED)",
+     "StoGO randomized (NOT COMPILED)",
+#endif
+     "original L-BFGS code by Nocedal et al. (NOT COMPILED)",
+     "Limited-memory BFGS (L-BFGS) (local, derivative-based)",
+     "Principal-axis, praxis (local, no-derivative)",
+     "Limited-memory variable-metric, rank 1 (local, derivative-based)",
+     "Limited-memory variable-metric, rank 2 (local, derivative-based)",
+     "Truncated Newton (local, derivative-based)",
+     "Truncated Newton with restarting (local, derivative-based)",
+     "Preconditioned truncated Newton (local, derivative-based)",
+     "Preconditioned truncated Newton with restarting (local, derivative-based)",
+     "Controlled random search (CRS2) with local mutation (global, no-derivative)",
+     "Multi-level single-linkage (MLSL), random (global, no-derivative)",
+     "Multi-level single-linkage (MLSL), random (global, derivative)",
+     "Multi-level single-linkage (MLSL), quasi-random (global, no-derivative)",
+     "Multi-level single-linkage (MLSL), quasi-random (global, derivative)",
+     "Method of Moving Asymptotes (MMA) (local, derivative)",
+     "COBYLA (Constrained Optimization BY Linear Approximations) (local, no-derivative)",
+     "NEWUOA unconstrained optimization via quadratic models (local, no-derivative)",
+     "Bound-constrained optimization via NEWUOA-based quadratic models (local, no-derivative)",
+     "Nelder-Mead simplex algorithm (local, no-derivative)",
+     "Sbplx variant of Nelder-Mead (re-implementation of Rowan's Subplex) (local, no-derivative)",
+     "Augmented Lagrangian method (local, no-derivative)",
+     "Augmented Lagrangian method (local, derivative)",
+     "Augmented Lagrangian method for equality constraints (local, no-derivative)",
+     "Augmented Lagrangian method for equality constraints (local, derivative)",
+     "BOBYQA bound-constrained optimization via quadratic models (local, no-derivative)",
+     "ISRES evolutionary constrained optimization (global, no-derivative)",
+     "Augmented Lagrangian method (needs sub-algorithm)",
+     "Augmented Lagrangian method for equality constraints (needs sub-algorithm)",
+     "Multi-level single-linkage (MLSL), random (global, needs sub-algorithm)",
+     "Multi-level single-linkage (MLSL), quasi-random (global, needs sub-algorithm)",
+     "Sequential Quadratic Programming (SQP) (local, derivative)",
+     "CCSA (Conservative Convex Separable Approximations) with simple quadratic approximations (local, derivative)",
+     "ESCH evolutionary strategy"
+};
+
+const char * NLOPT_STDCALL nlopt_algorithm_name(nlopt_algorithm a)
+{
+     if (((int) a) < 0 || a >= NLOPT_NUM_ALGORITHMS) return "UNKNOWN";
+     return nlopt_algorithm_names[a];
+}
+
+/*************************************************************************/
+/* get thread id, if possible, for use in nlopt_srand_time to ensure that
+   different threads have a different default seed even if they are called
+   simultaneously */
+
+#if defined(_WIN32) || defined(__WIN32__)
+#  include <windows.h>
+#  define my_gettid GetCurrentThreadId
+#elif defined(HAVE_GETTID_SYSCALL)
+#  include <unistd.h>
+#  include <sys/syscall.h>
+#  define my_gettid() syscall(SYS_gettid)
+#elif defined(HAVE_GETPID)
+#  include <sys/types.h>
+#  include <unistd.h>
+#  define my_gettid getpid
+#else
+#  define my_gettid() (0)
+#endif
+
+/*************************************************************************/
+
+static THREADLOCAL int nlopt_srand_called = 0;
+void NLOPT_STDCALL nlopt_srand(unsigned long seed) {
+     nlopt_srand_called = 1;
+     nlopt_init_genrand(seed);
+}
+
+void NLOPT_STDCALL nlopt_srand_time(void) {
+     nlopt_srand(nlopt_time_seed() + my_gettid() * 314159);
+}
+
+void nlopt_srand_time_default(void) {
+     if (!nlopt_srand_called) nlopt_srand_time();
+}
+
+/*************************************************************************/
diff --git a/api/nlopt-in.hpp b/api/nlopt-in.hpp
new file mode 100644 (file)
index 0000000..d2ef93f
--- /dev/null
@@ -0,0 +1,536 @@
+/* Copyright (c) 2007-2011 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+// C++ style wrapper around NLopt API
+// nlopt.hpp is AUTOMATICALLY GENERATED from nlopt-in.hpp - edit the latter!
+
+#ifndef NLOPT_HPP
+#define NLOPT_HPP
+
+#include <nlopt.h>
+
+#include <vector>
+#include <stdexcept>
+#include <new>
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+
+// convenience overloading for below (not in nlopt:: since has nlopt_ prefix)
+inline nlopt_result nlopt_get_initial_step(const nlopt_opt opt, double *dx) {
+      return nlopt_get_initial_step(opt, (const double *) NULL, dx);
+}
+
+namespace nlopt {
+
+  //////////////////////////////////////////////////////////////////////
+  // nlopt::* namespace versions of the C enumerated types
+  //          AUTOMATICALLY GENERATED, DO NOT EDIT
+  // GEN_ENUMS_HERE
+  //////////////////////////////////////////////////////////////////////
+
+  typedef nlopt_func func; // nlopt::func synoynm
+  typedef nlopt_mfunc mfunc; // nlopt::mfunc synoynm
+
+  // alternative to nlopt_func that takes std::vector<double>
+  // ... unfortunately requires a data copy
+  typedef double (*vfunc)(const std::vector<double> &x,
+                         std::vector<double> &grad, void *data);
+
+  //////////////////////////////////////////////////////////////////////
+  
+  // NLopt-specific exceptions (corresponding to error codes):
+  class roundoff_limited : public std::runtime_error {
+  public:
+    roundoff_limited() : std::runtime_error("nlopt roundoff-limited") {}
+  };
+
+  class forced_stop : public std::runtime_error {
+  public:
+    forced_stop() : std::runtime_error("nlopt forced stop") {}
+  };
+
+  //////////////////////////////////////////////////////////////////////
+
+  class opt {
+  private:
+    nlopt_opt o;
+    
+    void mythrow(nlopt_result ret) const {
+      switch (ret) {
+      case NLOPT_FAILURE: throw std::runtime_error("nlopt failure");
+      case NLOPT_OUT_OF_MEMORY: throw std::bad_alloc();
+      case NLOPT_INVALID_ARGS: throw std::invalid_argument("nlopt invalid argument");
+      case NLOPT_ROUNDOFF_LIMITED: throw roundoff_limited();
+      case NLOPT_FORCED_STOP: throw forced_stop();
+      default: break;
+      }
+    }
+
+    typedef struct {
+      opt *o;
+      mfunc mf; func f; void *f_data;
+      vfunc vf;
+      nlopt_munge munge_destroy, munge_copy; // non-NULL for SWIG wrappers
+    } myfunc_data;
+
+    // free/destroy f_data in nlopt_destroy and nlopt_copy, respectively
+    static void *free_myfunc_data(void *p) { 
+      myfunc_data *d = (myfunc_data *) p;
+      if (d) {
+       if (d->f_data && d->munge_destroy) d->munge_destroy(d->f_data);
+       delete d;
+      }
+      return NULL;
+    }
+    static void *dup_myfunc_data(void *p) {
+      myfunc_data *d = (myfunc_data *) p;
+      if (d) {
+       void *f_data;
+       if (d->f_data && d->munge_copy) {
+         f_data = d->munge_copy(d->f_data);
+         if (!f_data) return NULL;
+       }
+       else
+         f_data = d->f_data;
+       myfunc_data *dnew = new myfunc_data;
+       if (dnew) {
+         *dnew = *d;
+         dnew->f_data = f_data;
+       }
+       return (void*) dnew;
+      }
+      else return NULL;
+    }
+
+    // nlopt_func wrapper that catches exceptions
+    static double myfunc(unsigned n, const double *x, double *grad, void *d_) {
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       return d->f(n, x, grad, d->f_data);
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      return HUGE_VAL;
+    }
+
+    // nlopt_mfunc wrapper that catches exceptions
+    static void mymfunc(unsigned m, double *result,
+                       unsigned n, const double *x, double *grad, void *d_) {
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       d->mf(m, result, n, x, grad, d->f_data);
+       return;
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      for (unsigned i = 0; i < m; ++i) result[i] = HUGE_VAL;
+    }
+
+    std::vector<double> xtmp, gradtmp, gradtmp0; // scratch for myvfunc
+
+    // nlopt_func wrapper, using std::vector<double>
+    static double myvfunc(unsigned n, const double *x, double *grad, void *d_){
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       std::vector<double> &xv = d->o->xtmp;
+       if (n) std::memcpy(&xv[0], x, n * sizeof(double));
+       double val=d->vf(xv, grad ? d->o->gradtmp : d->o->gradtmp0, d->f_data);
+       if (grad && n) {
+         std::vector<double> &gradv = d->o->gradtmp;
+         std::memcpy(grad, &gradv[0], n * sizeof(double));
+       }
+       return val;
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      return HUGE_VAL;
+    }
+
+    void alloc_tmp() {
+      if (xtmp.size() != nlopt_get_dimension(o)) {
+       xtmp = std::vector<double>(nlopt_get_dimension(o));
+       gradtmp = std::vector<double>(nlopt_get_dimension(o));
+      }
+    }
+
+    result last_result;
+    double last_optf;
+    nlopt_result forced_stop_reason;
+
+  public:
+    // Constructors etc.
+    opt() : o(NULL), xtmp(0), gradtmp(0), gradtmp0(0), 
+           last_result(nlopt::FAILURE), last_optf(HUGE_VAL),
+           forced_stop_reason(NLOPT_FORCED_STOP) {}
+    ~opt() { nlopt_destroy(o); }
+    opt(algorithm a, unsigned n) : 
+      o(nlopt_create(nlopt_algorithm(a), n)), 
+      xtmp(0), gradtmp(0), gradtmp0(0),
+      last_result(nlopt::FAILURE), last_optf(HUGE_VAL),
+      forced_stop_reason(NLOPT_FORCED_STOP) {
+      if (!o) throw std::bad_alloc();
+      nlopt_set_munge(o, free_myfunc_data, dup_myfunc_data);
+    }
+    opt(const opt& f) : o(nlopt_copy(f.o)), 
+                       xtmp(f.xtmp), gradtmp(f.gradtmp), gradtmp0(0),
+                       last_result(f.last_result), last_optf(f.last_optf),
+                       forced_stop_reason(f.forced_stop_reason) {
+      if (f.o && !o) throw std::bad_alloc();
+    }
+    opt& operator=(opt const& f) {
+      if (this == &f) return *this; // self-assignment
+      nlopt_destroy(o);
+      o = nlopt_copy(f.o);
+      if (f.o && !o) throw std::bad_alloc();
+      xtmp = f.xtmp; gradtmp = f.gradtmp;
+      last_result = f.last_result; last_optf = f.last_optf;
+      forced_stop_reason = f.forced_stop_reason;
+      return *this;
+    }
+
+    // Do the optimization:
+    result optimize(std::vector<double> &x, double &opt_f) {
+      if (o && nlopt_get_dimension(o) != x.size())
+        throw std::invalid_argument("dimension mismatch");
+      forced_stop_reason = NLOPT_FORCED_STOP;
+      nlopt_result ret = nlopt_optimize(o, x.empty() ? NULL : &x[0], &opt_f);
+      last_result = result(ret);
+      last_optf = opt_f;
+      if (ret == NLOPT_FORCED_STOP)
+       mythrow(forced_stop_reason);
+      mythrow(ret);
+      return last_result;
+    }
+
+    // variant mainly useful for SWIG wrappers:
+    std::vector<double> optimize(const std::vector<double> &x0) {
+      std::vector<double> x(x0);
+      last_result = optimize(x, last_optf);
+      return x;
+    }
+    result last_optimize_result() const { return last_result; }
+    double last_optimum_value() const { return last_optf; }
+
+    // accessors:
+    algorithm get_algorithm() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return algorithm(nlopt_get_algorithm(o));
+    }
+    const char *get_algorithm_name() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return nlopt_algorithm_name(nlopt_get_algorithm(o));
+    }
+    unsigned get_dimension() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return nlopt_get_dimension(o);
+    }
+
+    // Set the objective function
+    void set_min_objective(func f, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_min_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_min_objective(vfunc vf, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_min_objective(o, myvfunc, d)); // d freed via o
+      alloc_tmp();
+    }
+    void set_max_objective(func f, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_max_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_max_objective(vfunc vf, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_max_objective(o, myvfunc, d)); // d freed via o
+      alloc_tmp();
+    }
+
+    // for internal use in SWIG wrappers -- variant that
+    // takes ownership of f_data, with munging for destroy/copy
+    void set_min_objective(func f, void *f_data,
+                          nlopt_munge md, nlopt_munge mc) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_set_min_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_max_objective(func f, void *f_data,
+                          nlopt_munge md, nlopt_munge mc) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_set_max_objective(o, myfunc, d)); // d freed via o
+    }
+
+    // Nonlinear constraints:
+
+    void remove_inequality_constraints() {
+      nlopt_result ret = nlopt_remove_inequality_constraints(o);
+      mythrow(ret);
+    }
+    void add_inequality_constraint(func f, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_constraint(o, myfunc, d, tol));
+    }
+    void add_inequality_constraint(vfunc vf, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_constraint(o, myvfunc, d, tol));
+      alloc_tmp();
+    }
+    void add_inequality_mconstraint(mfunc mf, void *f_data, 
+                                   const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d, 
+                                              tol.empty() ? NULL : &tol[0]));
+    }
+
+    void remove_equality_constraints() {
+      nlopt_result ret = nlopt_remove_equality_constraints(o);
+      mythrow(ret);
+    }
+    void add_equality_constraint(func f, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_constraint(o, myfunc, d, tol));
+    }
+    void add_equality_constraint(vfunc vf, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_constraint(o, myvfunc, d, tol));
+      alloc_tmp();
+    }
+    void add_equality_mconstraint(mfunc mf, void *f_data, 
+                                 const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d, 
+                                            tol.empty() ? NULL : &tol[0]));
+    }
+
+    // For internal use in SWIG wrappers (see also above)
+    void add_inequality_constraint(func f, void *f_data, 
+                                  nlopt_munge md, nlopt_munge mc,
+                                  double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_inequality_constraint(o, myfunc, d, tol));
+    }
+    void add_equality_constraint(func f, void *f_data, 
+                                nlopt_munge md, nlopt_munge mc,
+                                double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_equality_constraint(o, myfunc, d, tol));
+    }
+    void add_inequality_mconstraint(mfunc mf, void *f_data, 
+                                   nlopt_munge md, nlopt_munge mc,
+                                   const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d, 
+                                              tol.empty() ? NULL : &tol[0]));
+    }
+    void add_equality_mconstraint(mfunc mf, void *f_data, 
+                                 nlopt_munge md, nlopt_munge mc,
+                                 const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d, 
+                                            tol.empty() ? NULL : &tol[0]));
+    }
+
+#define NLOPT_GETSET_VEC(name)                                         \
+    void set_##name(double val) {                                      \
+      mythrow(nlopt_set_##name##1(o, val));                            \
+    }                                                                  \
+    void get_##name(std::vector<double> &v) const {                    \
+      if (o && nlopt_get_dimension(o) != v.size())                     \
+        throw std::invalid_argument("dimension mismatch");             \
+      mythrow(nlopt_get_##name(o, v.empty() ? NULL : &v[0]));          \
+    }                                                                  \
+    std::vector<double> get_##name() const {                   \
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");    \
+      std::vector<double> v(nlopt_get_dimension(o));                   \
+      get_##name(v);                                                   \
+      return v;                                                                \
+    }                                                                  \
+    void set_##name(const std::vector<double> &v) {                    \
+      if (o && nlopt_get_dimension(o) != v.size())                     \
+        throw std::invalid_argument("dimension mismatch");             \
+      mythrow(nlopt_set_##name(o, v.empty() ? NULL : &v[0]));          \
+    }
+
+    NLOPT_GETSET_VEC(lower_bounds)
+    NLOPT_GETSET_VEC(upper_bounds)
+
+    // stopping criteria:
+
+#define NLOPT_GETSET(T, name)                                          \
+    T get_##name() const {                                             \
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");    \
+      return nlopt_get_##name(o);                                      \
+    }                                                                  \
+    void set_##name(T name) {                                          \
+      mythrow(nlopt_set_##name(o, name));                              \
+    }
+    NLOPT_GETSET(double, stopval)
+    NLOPT_GETSET(double, ftol_rel)
+    NLOPT_GETSET(double, ftol_abs)
+    NLOPT_GETSET(double, xtol_rel)
+    NLOPT_GETSET_VEC(xtol_abs)
+    NLOPT_GETSET(int, maxeval)
+    NLOPT_GETSET(double, maxtime)
+
+    NLOPT_GETSET(int, force_stop)
+    void force_stop() { set_force_stop(1); }
+
+    // algorithm-specific parameters:
+
+    void set_local_optimizer(const opt &lo) {
+      nlopt_result ret = nlopt_set_local_optimizer(o, lo.o);
+      mythrow(ret);
+    }
+
+    NLOPT_GETSET(unsigned, population)
+    NLOPT_GETSET(unsigned, vector_storage)
+    NLOPT_GETSET_VEC(initial_step)
+
+    void set_default_initial_step(const std::vector<double> &x) {
+      nlopt_result ret 
+       = nlopt_set_default_initial_step(o, x.empty() ? NULL : &x[0]);
+      mythrow(ret);
+    }
+    void get_initial_step(const std::vector<double> &x, std::vector<double> &dx) const {
+      if (o && (nlopt_get_dimension(o) != x.size()
+               || nlopt_get_dimension(o) != dx.size()))
+        throw std::invalid_argument("dimension mismatch");
+      nlopt_result ret = nlopt_get_initial_step(o, x.empty() ? NULL : &x[0],
+                                               dx.empty() ? NULL : &dx[0]);
+      mythrow(ret);
+    }
+    std::vector<double> get_initial_step_(const std::vector<double> &x) const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      std::vector<double> v(nlopt_get_dimension(o));
+      get_initial_step(x, v);
+      return v;
+    }
+  };
+
+#undef NLOPT_GETSET
+#undef NLOPT_GETSET_VEC
+
+  //////////////////////////////////////////////////////////////////////
+
+  inline void srand(unsigned long seed) { nlopt_srand(seed); }
+  inline void srand_time() { nlopt_srand_time(); }
+  inline void version(int &major, int &minor, int &bugfix) {
+    nlopt_version(&major, &minor, &bugfix);
+  }
+  inline int version_major() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return major;
+  }
+  inline int version_minor() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return minor;
+  }
+  inline int version_bugfix() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return bugfix;
+  }
+  inline const char *algorithm_name(algorithm a) {
+    return nlopt_algorithm_name(nlopt_algorithm(a));
+  }
+
+  //////////////////////////////////////////////////////////////////////
+
+} // namespace nlopt
+
+#endif /* NLOPT_HPP */
diff --git a/api/nlopt-internal.h b/api/nlopt-internal.h
new file mode 100644 (file)
index 0000000..bc67e44
--- /dev/null
@@ -0,0 +1,95 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef NLOPT_INTERNAL_H
+#define NLOPT_INTERNAL_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/*********************************************************************/
+
+struct nlopt_opt_s {
+     nlopt_algorithm algorithm; /* the optimization algorithm (immutable) */
+     unsigned n; /* the dimension of the problem (immutable) */
+
+     nlopt_func f; void *f_data; /* objective function to minimize */
+     nlopt_precond pre; /* optional preconditioner for f (NULL if none) */
+     int maximize; /* nonzero if we are maximizing, not minimizing */
+
+     double *lb, *ub; /* lower and upper bounds (length n) */
+
+     unsigned m; /* number of inequality constraints */
+     unsigned m_alloc; /* number of inequality constraints allocated */
+     nlopt_constraint *fc; /* inequality constraints, length m_alloc */
+
+     unsigned p; /* number of equality constraints */
+     unsigned p_alloc; /* number of inequality constraints allocated */
+     nlopt_constraint *h; /* equality constraints, length p_alloc */
+
+     nlopt_munge munge_on_destroy, munge_on_copy; /* hack for wrappers */
+
+     /* stopping criteria */
+     double stopval; /* stop when f reaches stopval or better */
+     double ftol_rel, ftol_abs; /* relative/absolute f tolerances */
+     double xtol_rel, *xtol_abs; /* rel/abs x tolerances */
+     int maxeval; /* max # evaluations */
+     double maxtime; /* max time (seconds) */
+
+     int force_stop; /* if nonzero, force a halt the next time we
+                       try to evaluate the objective during optimization */
+     /* when local optimization is used, we need a force_stop in the
+       parent object to force a stop in child optimizations */
+     struct nlopt_opt_s *force_stop_child;
+
+     /* algorithm-specific parameters */
+     nlopt_opt local_opt; /* local optimizer */
+     unsigned stochastic_population; /* population size for stochastic algs */
+     double *dx; /* initial step sizes (length n) for nonderivative algs */
+     unsigned vector_storage; /* max subspace dimension (0 for default) */
+
+     void *work; /* algorithm-specific workspace during optimization */
+};
+
+/*********************************************************************/
+extern void nlopt_srand_time_default(void); /* init the rand. seed only if unset */
+
+/*********************************************************************/
+/* global defaults set by deprecated API: */
+
+extern nlopt_algorithm nlopt_local_search_alg_deriv;
+extern nlopt_algorithm nlopt_local_search_alg_nonderiv;
+extern int nlopt_local_search_maxeval;
+extern unsigned nlopt_stochastic_population;
+
+/*********************************************************************/
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* NLOPT_INTERNAL_H */
diff --git a/api/nlopt.3 b/api/nlopt.3
new file mode 100644 (file)
index 0000000..3234093
--- /dev/null
@@ -0,0 +1,736 @@
+.\" 
+.\" Copyright (c) 2007 Massachusetts Institute of Technology
+.\" 
+.\" Copying and distribution of this file, with or without modification,
+.\" are permitted in any medium without royalty provided the copyright
+.\" notice and this notice are preserved.
+.\"
+.TH NLOPT 3  2007-08-23 "MIT" "NLopt programming manual"
+.SH NAME
+nlopt \- Nonlinear optimization library
+.SH SYNOPSIS
+.nf
+.B #include <nlopt.h>
+.sp
+.BI "nlopt_opt " "opt" " = nlopt_create(" "algorithm" , " n" );
+.BI "nlopt_set_min_objective(" "opt" , " f" , " f_data" );
+.BI "nlopt_set_ftol_rel(" "opt" , " tol");
+.BI "..."
+.BI "nlopt_optimize(" "opt" , " x " , " &opt_f" );
+.BI "nlopt_destroy(" "opt" );
+.sp
+The "..." indicates any number of calls to NLopt functions, below, to
+set parameters of the optimization, constraints, and stopping
+criteria.  Here, \fBnlopt_set_ftol_rel\fR is merely an example of a
+possible stopping criterion.  You should link the resulting program
+with the linker flags \-lnlopt \-lm on Unix.
+.fi
+.SH DESCRIPTION
+NLopt is a library for nonlinear optimization.  It attempts to
+minimize (or maximize) a given nonlinear objective function
+.I f
+of
+.I n
+design variables, using the specified
+.IR algorithm ,
+possibly subject to linear or nonlinear constraints.  The optimum
+function value found is returned in \fIopt_f\fR (type double) with the
+corresponding design variable values returned in the (double) array
+.I x
+of length
+.IR n .
+The input values in
+.I x
+should be a starting guess for the optimum.
+.sp
+The parameters of the optimization are controlled via the object
+.I opt
+of type
+.BR nlopt_opt ,
+which is created by the function
+.B nlopt_create
+and disposed of by
+.BR nlopt_destroy .
+By calling various functions in the NLopt library, one can specify
+stopping criteria (e.g., a relative tolerance on the objective
+function value is specified by
+.BR nlopt_set_ftol_rel ),
+upper and/or lower bounds on the design parameters 
+.IR x ,
+and even arbitrary nonlinear inequality and equality constraints.
+.sp
+By changing the parameter
+.I algorithm
+among several predefined constants described below, one can switch easily
+between a variety of minimization algorithms.  Some of these algorithms
+require the gradient (derivatives) of the function to be supplied via
+.IR f ,
+and other algorithms do not require derivatives.  Some of the
+algorithms attempt to find a global optimum within the given bounds,
+and others find only a local optimum.  Most of the algorithms only
+handle the case where there are no nonlinear constraints.  The NLopt
+library is a wrapper around several free/open-source minimization
+packages, as well as some new implementations of published
+optimization algorithms.  You could, of course, compile and call these
+packages separately, and in some cases this will provide greater
+flexibility than is available via NLopt.  However, depending upon the
+specific function being optimized, the different algorithms will vary
+in effectiveness.  The intent of NLopt is to allow you to quickly
+switch between algorithms in order to experiment with them for your
+problem, by providing a simple unified interface to these subroutines.
+.SH OBJECTIVE FUNCTION
+The objective function is specified by calling one of:
+.sp
+.BI "  nlopt_result nlopt_set_min_objective(nlopt_opt " "opt" , 
+.br
+.BI "                                       nlopt_func " "f" ,
+.br
+.BI "                                       void* " "f_data" );
+.br
+.BI "  nlopt_result nlopt_set_max_objective(nlopt_opt " "opt" , 
+.br
+.BI "                                       nlopt_func " "f" ,
+.br
+.BI "                                       void* " "f_data" );
+.sp
+depending on whether one wishes to minimize or maximize the objective
+function
+.IR f ,
+respectively.  The function
+.I f
+should be of the form:
+.sp
+.BI "  double f(unsigned " "n" , 
+.br
+.BI "           const double* " "x" , 
+.br
+.BI "           double* " "grad" , 
+.br
+.BI "           void* " "f_data" );
+.sp
+The return value should be the value of the function at the point
+.IR x ,
+where
+.I x
+points to an array of length
+.I n
+of the design variables.  The dimension
+.I n
+is identical to the one passed to
+.BR nlopt_create .
+.sp
+In addition, if the argument
+.I grad
+is not NULL, then
+.I grad
+points to an array of length
+.I n
+which should (upon return) be set to the gradient of the function with
+respect to the design variables at
+.IR x .
+That is,
+.IR grad[i]
+should upon return contain the partial derivative df/dx[i],
+for 0 <= i < n, if
+.I grad
+is non-NULL.
+Not all of the optimization algorithms (below) use the gradient information:
+for algorithms listed as "derivative-free," the 
+.I grad
+argument will always be NULL and need never be computed.  (For
+algorithms that do use gradient information, however,
+.I grad
+may still be NULL for some calls.)
+.sp
+The 
+.I f_data
+argument is the same as the one passed to 
+.B nlopt_set_min_objective
+or
+.BR nlopt_set_max_objective ,
+and may be used to pass any additional data through to the function.
+(That is, it may be a pointer to some caller-defined data
+structure/type containing information your function needs, which you
+convert from void* by a typecast.)
+.SH BOUND CONSTRAINTS
+Most of the algorithms in NLopt are designed for minimization of
+functions with simple bound constraints on the inputs.  That is, the
+input vectors x[i] are constrainted to lie in a hyperrectangle lb[i]
+<= x[i] <= ub[i] for 0 <= i < n.  These bounds are specified by
+passing arrays
+.I lb
+and
+.I ub
+of length
+.I n
+to one or both of the functions:
+.sp
+.BI "  nlopt_result nlopt_set_lower_bounds(nlopt_opt " "opt" , 
+.br
+.BI "                                      const double* " "lb" ); 
+.br
+.BI "  nlopt_result nlopt_set_upper_bounds(nlopt_opt " "opt" , 
+.br
+.BI "                                      const double* " "ub" ); 
+.sp
+If a lower/upper bound is not set, the default is no bound
+(unconstrained, i.e. a bound of infinity); it is possible to have
+lower bounds but not upper bounds or vice versa.  Alternatively, the
+user can call one of the above functions and explicitly pass a lower
+bound of \-HUGE_VAL and/or an upper bound of +HUGE_VAL for some design
+variables to make them have no lower/upper bound, respectively.
+(HUGE_VAL is the standard C constant for a floating-point infinity,
+found in the math.h header file.)
+.sp
+Note, however, that some of the algorithms in NLopt, in particular
+most of the global-optimization algorithms, do not support unconstrained
+optimization and will return an error if you do not supply finite lower
+and upper bounds.
+.sp
+For convenience, the following two functions are supplied in order to
+set the lower/upper bounds for all design variables to a single
+constant (so that you don't have to fill an array with a constant value):
+.sp
+.BI "  nlopt_result nlopt_set_lower_bounds1(nlopt_opt " "opt" , 
+.br
+.BI "                                       double " "lb" ); 
+.br
+.BI "  nlopt_result nlopt_set_upper_bounds1(nlopt_opt " "opt" , 
+.br
+.BI "                                       double " "ub" ); 
+.sp
+.SH NONLINEAR CONSTRAINTS
+Several of the algorithms in NLopt (MMA and ORIG_DIRECT) also support
+arbitrary nonlinear inequality constraints, and some also allow
+nonlinear equality constraints (COBYLA, SLSQP, ISRES, and AUGLAG).
+For these algorithms, you can specify as many nonlinear constraints as
+you wish by calling the following functions multiple times.
+.sp
+In particular, a nonlinear inequality constraint of the form 
+\fIfc\fR(\fIx\fR) <= 0, where the function
+.I fc
+is of the same form as the objective function described above,
+can be specified by calling:
+.sp
+.BI "  nlopt_result nlopt_add_inequality_constraint(nlopt_opt " "opt" , 
+.br
+.BI "                                               nlopt_func " "fc" ,
+.br
+.BI "                                               void* " "fc_data" ,
+.br
+.BI "                                               double " "tol" );
+.sp
+Just as for the objective function, 
+.I fc_data
+is a pointer to arbitrary user data that will be passed through to the
+.I fc
+function whenever it is called.  The parameter
+.I tol
+is a tolerance that is used for the purpose of stopping criteria only:
+a point
+.I x
+is considered feasible for judging whether to stop the optimization if
+\fIfc\fR(\fIx\fR) <= \fItol\fR.  A tolerance of zero means that NLopt
+will try not to consider any \fIx\fR to be converged unless
+.I fc
+is strictly non-positive; generally, at least a small positive tolerance is
+advisable to reduce sensitivity to rounding errors.
+
+A nonlinear equality constraint of the form 
+\fIh\fR(\fIx\fR) = 0, where the function
+.I h
+is of the same form as the objective function described above,
+can be specified by calling:
+.sp
+.BI "  nlopt_result nlopt_add_equality_constraint(nlopt_opt " "opt" , 
+.br
+.BI "                                             nlopt_func " "h" ,
+.br
+.BI "                                             void* " "h_data" ,
+.br
+.BI "                                             double " "tol" );
+.sp
+Just as for the objective function, 
+.I h_data
+is a pointer to arbitrary user data that will be passed through to the
+.I h
+function whenever it is called.  The parameter
+.I tol
+is a tolerance that is used for the purpose of stopping criteria only:
+a point
+.I x
+is considered feasible for judging whether to stop the optimization if
+|\fIh\fR(\fIx\fR)| <= \fItol\fR.  For equality constraints, a small
+positive tolerance is strongly advised in order to allow NLopt to 
+converge even if the equality constraint is slightly nonzero.
+.sp
+(For any algorithm listed as "derivative-free" below, the
+.I grad
+argument to \fIfc\fR or \fIh\fR will always be NULL and need never be
+computed.)
+.sp
+To remove all of the inequality and/or equality constraints from 
+a given problem \fIopt\fR, you can call the following functions:
+.sp
+.BI "  nlopt_result nlopt_remove_inequality_constraints(nlopt_opt " "opt" );
+.br
+.BI "  nlopt_result nlopt_remove_equality_constraints(nlopt_opt " "opt" );
+.SH ALGORITHMS
+The 
+.I algorithm
+parameter specifies the optimization algorithm (for more detail on
+these, see the README files in the source-code subdirectories), and
+can take on any of the following constant values.
+.sp
+Constants with
+.B _G{N,D}_
+in their names
+refer to global optimization methods, whereas
+.B _L{N,D}_
+refers to local optimization methods (that try to find a local optimum
+starting from the starting guess
+.IR x ).
+Constants with
+.B _{G,L}N_
+refer to non-gradient (derivative-free) algorithms that do not require the
+objective function to supply a gradient, whereas
+.B _{G,L}D_
+refers to derivative-based algorithms that require the objective
+function to supply a gradient.  (Especially for local optimization,
+derivative-based algorithms are generally superior to derivative-free
+ones: the gradient is good to have 
+.I if 
+you can compute it cheaply, e.g. via an adjoint method.)
+.sp
+The algorithm specified for a given problem
+.I opt
+is returned by the function:
+.sp
+.BI "  nlopt_algorithm nlopt_get_algorithm(nlopt_opt " "opt" );
+.sp
+The available algorithms are:
+.TP 
+.B NLOPT_GN_DIRECT_L
+Perform a global (G) derivative-free (N) optimization using the
+DIRECT-L search algorithm by Jones et al. as modified by Gablonsky et
+al. to be more weighted towards local search.  Does not support
+unconstrainted optimization.  There are also several other variants of
+the DIRECT algorithm that are supported:
+.BR NLOPT_GLOBAL_DIRECT ,
+which is the original DIRECT algorithm;
+.BR NLOPT_GLOBAL_DIRECT_L_RAND ,
+a slightly randomized version of DIRECT-L that may be better in
+high-dimensional search spaces;
+.BR NLOPT_GLOBAL_DIRECT_NOSCAL ,
+.BR NLOPT_GLOBAL_DIRECT_L_NOSCAL ,
+and
+.BR NLOPT_GLOBAL_DIRECT_L_RAND_NOSCAL ,
+which are versions of DIRECT where the dimensions are not rescaled to
+a unit hypercube (which means that dimensions with larger bounds are
+given more weight).
+.TP 
+.B NLOPT_GN_ORIG_DIRECT_L
+A global (G) derivative-free optimization using the DIRECT-L algorithm
+as above, along with
+.B NLOPT_GN_ORIG_DIRECT
+which is the original DIRECT algorithm.  Unlike 
+.B NLOPT_GN_DIRECT_L 
+above, these two algorithms refer to code based on the original
+Fortran code of Gablonsky et al., which has some hard-coded
+limitations on the number of subdivisions etc. and does not support
+all of the NLopt stopping criteria, but on the other hand it supports
+arbitrary nonlinear inequality constraints.
+.TP 
+.B NLOPT_GD_STOGO
+Global (G) optimization using the StoGO algorithm by Madsen et al.  StoGO
+exploits gradient information (D) (which must be supplied by the
+objective) for its local searches, and performs the global search by a
+branch-and-bound technique.  Only bound-constrained optimization
+is supported.  There is also another variant of this algorithm,
+.BR NLOPT_GD_STOGO_RAND ,
+which is a randomized version of the StoGO search scheme.  The StoGO
+algorithms are only available if NLopt is compiled with C++ code
+enabled, and should be linked via \-lnlopt_cxx instead of \-lnlopt (via
+a C++ compiler, in order to link the C++ standard libraries).
+.TP 
+.B NLOPT_LN_NELDERMEAD
+Perform a local (L) derivative-free (N) optimization, starting at
+.IR x ,
+using the Nelder-Mead simplex algorithm, modified to support bound
+constraints.  Nelder-Mead, while popular, is known to occasionally
+fail to converge for some objective functions, so it should be used
+with caution.  Anecdotal evidence, on the other hand, suggests that it
+works fairly well for some cases that are hard to handle otherwise,
+e.g. noisy/discontinuous objectives.  See also
+.B NLOPT_LN_SBPLX
+below.
+.TP 
+.B NLOPT_LN_SBPLX
+Perform a local (L) derivative-free (N) optimization, starting at
+.IR x ,
+using an algorithm based on the Subplex algorithm of Rowan et al.,
+which is an improved variant of Nelder-Mead (above).  Our
+implementation does not use Rowan's original code, and has some minor
+modifications such as explicit support for bound constraints.  (Like
+Nelder-Mead, Subplex often works well in practice, even for
+noisy/discontinuous objectives, but there is no rigorous guarantee that it
+will converge.)
+.TP
+.B NLOPT_LN_PRAXIS
+Local (L) derivative-free (N) optimization using the principal-axis
+method, based on code by Richard Brent.  Designed for unconstrained
+optimization, although bound constraints are supported too (via the
+inefficient method of returning +Inf when the constraints are violated).
+.TP
+.B NLOPT_LD_LBFGS
+Local (L) gradient-based (D) optimization using the limited-memory BFGS
+(L-BFGS) algorithm.  (The objective function must supply the
+gradient.)  Unconstrained optimization is supported in addition to
+simple bound constraints (see above).  Based on an implementation by
+Luksan et al.
+.TP
+.B NLOPT_LD_VAR2
+Local (L) gradient-based (D) optimization using a shifted limited-memory
+variable-metric method based on code by Luksan et al., supporting both
+unconstrained and bound-constrained optimization.  
+.B NLOPT_LD_VAR2
+uses a rank-2 method, while 
+.B .B NLOPT_LD_VAR1
+is another variant using a rank-1 method.
+.TP
+.B NLOPT_LD_TNEWTON_PRECOND_RESTART
+Local (L) gradient-based (D) optimization using an
+LBFGS-preconditioned truncated Newton method with steepest-descent
+restarting, based on code by Luksan et al., supporting both
+unconstrained and bound-constrained optimization.  There are several
+other variants of this algorithm:
+.B NLOPT_LD_TNEWTON_PRECOND 
+(same without restarting), 
+.B NLOPT_LD_TNEWTON_RESTART
+(same without preconditioning), and
+.B NLOPT_LD_TNEWTON
+(same without restarting or preconditioning).
+.TP
+.B NLOPT_GN_CRS2_LM
+Global (G) derivative-free (N) optimization using the controlled random
+search (CRS2) algorithm of Price, with the "local mutation" (LM)
+modification suggested by Kaelo and Ali.
+.TP
+.B NLOPT_GN_ISRES
+Global (G) derivative-free (N) optimization using a genetic algorithm
+(mutation and differential evolution), using a stochastic ranking to
+handle nonlinear inequality and equality constraints as suggested by
+Runarsson and Yao.
+.TP
+\fBNLOPT_G_MLSL_LDS\fR, \fBNLOPT_G_MLSL\fR 
+Global (G) optimization using the multi-level single-linkage (MLSL)
+algorithm with a low-discrepancy sequence (LDS) or pseudorandom
+numbers, respectively.  This algorithm executes a low-discrepancy
+or pseudorandom sequence of local searches, with a clustering
+heuristic to avoid multiple local searches for the same local optimum.
+The local search algorithm must be specified, along with termination
+criteria/tolerances for the local searches, by
+\fInlopt_set_local_optimizer\fR.  (This subsidiary algorithm can be
+with or without derivatives, and determines whether the objective
+function needs gradients.)
+.TP
+\fBNLOPT_LD_MMA\fR, \fBNLOPT_LD_CCSAQ\fR 
+Local (L) gradient-based (D) optimization using the method of moving
+asymptotes (MMA), or rather a refined version of the algorithm as
+published by Svanberg (2002).  (NLopt uses an independent
+free-software/open-source implementation of Svanberg's algorithm.) CCSAQ
+is a related algorithm from Svanberg's paper which uses a local quadratic
+approximation rather than the more-complicated MMA model; the two usually
+have similar convergence rates.
+The
+.B NLOPT_LD_MMA
+algorithm supports both bound-constrained and unconstrained
+optimization, and also supports an arbitrary number (\fIm\fR) of
+nonlinear inequality (not equality) constraints as described above.
+.TP
+.B NLOPT_LD_SLSQP
+Local (L) gradient-based (D) optimization using sequential quadratic
+programming and BFGS updates, supporting arbitrary nonlinear
+inequality and equality constraints, based on the code by Dieter Kraft
+(1988) adapted for use by the SciPy project.  Note that this algorithm
+uses dense-matrix methods requiring O(\fIn\fR^2) storage and
+O(\fIn\fR^3) time, making it less practical for problems involving
+more than a few thousand parameters.
+.TP
+.B NLOPT_LN_COBYLA
+Local (L) derivative-free (N) optimization using the COBYLA algorithm
+of Powell (Constrained Optimization BY Linear Approximations).
+The
+.B NLOPT_LN_COBYLA
+algorithm supports both bound-constrained and unconstrained
+optimization, and also supports an arbitrary number (\fIm\fR) of
+nonlinear inequality/equality constraints as described above.
+.TP
+.B NLOPT_LN_NEWUOA
+Local (L) derivative-free (N) optimization using a variant of the
+NEWUOA algorithm of Powell, based on successive quadratic
+approximations of the objective function. We have modified the
+algorithm to support bound constraints.  The original NEWUOA algorithm
+is also available, as
+.BR NLOPT_LN_NEWUOA ,
+but this algorithm ignores the bound constraints
+.I lb
+and 
+.IR ub ,
+and so it should only be used for unconstrained problems.  Mostly
+superseded by BOBYQA.
+.TP
+.B NLOPT_LN_BOBYQA
+Local (L) derivative-free (N) optimization using the BOBYQA algorithm
+of Powell, based on successive quadratic approximations of the
+objective function, supporting bound constraints.
+.TP
+.B NLOPT_AUGLAG
+Optimize an objective with nonlinear inequality/equality constraints
+via an unconstrained (or bound-constrained) optimization algorithm,
+using a gradually increasing "augmented Lagrangian" penalty for
+violated constraints.  Requires you to specify another optimization
+algorithm for optimizing the objective+penalty function, using
+\fInlopt_set_local_optimizer\fR.  (This subsidiary algorithm can be
+global or local and with or without derivatives, but you must specify
+its own termination criteria.)  A variant, \fBNLOPT_AUGLAG_EQ\fR, only
+uses the penalty approach for equality constraints, while inequality
+constraints are handled directly by the subsidiary algorithm (restricting
+the choice of subsidiary algorithms to those that can handle inequality
+constraints).
+.SH STOPPING CRITERIA
+Multiple stopping criteria for the optimization are supported, as
+specified by the functions to modify a given optimization problem
+.BR opt .
+The optimization halts whenever any one of these criteria is
+satisfied.  In some cases, the precise interpretation of the stopping
+criterion depends on the optimization algorithm above (although we
+have tried to make them as consistent as reasonably possible), and
+some algorithms do not support all of the stopping criteria.
+.sp
+Important: you do not need to use all of the stopping criteria!  In most
+cases, you only need one or two, and can omit the remainder (all criteria
+are disabled by default).
+.TP
+.BI "nlopt_result nlopt_set_stopval(nlopt_opt " "opt" ,
+.br
+.BI "                        double " stopval );
+.sp
+Stop when an objective value of at least
+.I stopval
+is found: stop minimizing when a value <= \fIstopval\fR is found, or
+stop maximizing when a value >= \fIstopval\fR is found.  (Setting
+\fIstopval\fR to \-HUGE_VAL for minimizing or +HUGE_VAL for maximizing
+disables this stopping criterion.)
+.TP
+.BI "nlopt_result nlopt_set_ftol_rel(nlopt_opt " "opt" ,
+.br
+.BI "                         double " tol );
+.sp
+Set relative tolerance on function value: stop when an optimization step
+(or an estimate of the optimum) changes the function value by less
+than
+.I tol
+multiplied by the absolute value of the function value.  (If there is any chance that your optimum function value is close to zero, you might want to set an absolute tolerance with
+.B nlopt_set_ftol_abs
+as well.)  Criterion is disabled if \fItol\fR is non-positive.
+.TP
+.BI "nlopt_result nlopt_set_ftol_abs(nlopt_opt " "opt" ,
+.br
+.BI "                         double " tol );
+.sp
+Set absolute tolerance on function value: stop when an optimization step
+(or an estimate of the optimum) changes the function value by less
+than
+.IR tol .
+Criterion is disabled if \fItol\fR is non-positive.
+.TP
+.BI "nlopt_result nlopt_set_xtol_rel(nlopt_opt " "opt" ,
+.br
+.BI "                         double " tol );
+.sp
+Set relative tolerance on design variables: stop when an optimization step
+(or an estimate of the optimum) changes every design variable by less
+than
+.I tol
+multiplied by the absolute value of the design variable.  (If there is
+any chance that an optimal design variable is close to zero, you
+might want to set an absolute tolerance with
+.B nlopt_set_xtol_abs
+as well.)  Criterion is disabled if \fItol\fR is non-positive.
+.TP
+.BI "nlopt_result nlopt_set_xtol_abs(nlopt_opt " "opt" ,
+.br
+.BI "                         const double* " tol );
+.sp
+Set absolute tolerances on design variables.  \fItol\fR is a pointer
+to an array of length
+.I
+n giving the tolerances: stop when an
+optimization step (or an estimate of the optimum) changes every design
+variable
+.IR x [i]
+by less than
+.IR tol [i].
+.sp
+For convenience, the following function may be used to set the absolute tolerances in all \fIn\fR design variables to the same value:
+.sp
+.BI "  nlopt_result nlopt_set_xtol_abs1(nlopt_opt " "opt" ,
+.br
+.BI "                                   double " tol );
+.sp
+Criterion is disabled if \fItol\fR is non-positive.
+.TP
+.BI "nlopt_result nlopt_set_maxeval(nlopt_opt " "opt" ,
+.br
+.BI "                        int " maxeval );
+.sp
+Stop when the number of function evaluations exceeds
+.IR maxeval .
+(This is not a strict maximum: the number of function evaluations may
+exceed
+.I maxeval 
+slightly, depending upon the algorithm.)  Criterion is disabled
+if \fImaxeval\fR is non-positive.
+.TP
+.BI "nlopt_result nlopt_set_maxtime(nlopt_opt " "opt" ,
+.br
+.BI "                        double " maxtime );
+.sp
+Stop when the optimization time (in seconds) exceeds
+.IR maxtime .
+(This is not a strict maximum: the time may
+exceed
+.I maxtime
+slightly, depending upon the algorithm and on how slow your function
+evaluation is.)  Criterion is disabled if \fImaxtime\fR is non-positive.
+.SH RETURN VALUE
+Most of the NLopt functions return an enumerated constant
+of type
+.BR nlopt_result ,
+which takes on one of the following values:
+.SS Successful termination (positive return values):
+.TP
+.B NLOPT_SUCCESS
+Generic success return value.
+.TP
+.B NLOPT_STOPVAL_REACHED
+Optimization stopped because
+.I stopval
+(above) was reached.
+.TP
+.B NLOPT_FTOL_REACHED
+Optimization stopped because
+.I ftol_rel
+or
+.I ftol_abs
+(above) was reached.
+.TP
+.B NLOPT_XTOL_REACHED
+Optimization stopped because
+.I xtol_rel
+or
+.I xtol_abs
+(above) was reached.
+.TP
+.B NLOPT_MAXEVAL_REACHED
+Optimization stopped because
+.I maxeval
+(above) was reached.
+.TP
+.B NLOPT_MAXTIME_REACHED
+Optimization stopped because
+.I maxtime
+(above) was reached.
+.SS Error codes (negative return values):
+.TP
+.B NLOPT_FAILURE
+Generic failure code.
+.TP
+.B NLOPT_INVALID_ARGS
+Invalid arguments (e.g. lower bounds are bigger than upper bounds, an
+unknown algorithm was specified, etcetera).
+.TP
+.B NLOPT_OUT_OF_MEMORY
+Ran out of memory.
+.TP
+.B NLOPT_ROUNDOFF_LIMITED
+Halted because roundoff errors limited progress.
+.TP
+.B NLOPT_FORCED_STOP
+Halted because the user called \fBnlopt_force_stop\fR(\fIopt\fR) on
+the optimization's \fBnlopt_opt\fR object \fIopt\fR from the user's
+objective function.
+.SH LOCAL OPTIMIZER
+Some of the algorithms, especially MLSL and AUGLAG, use a different
+optimization algorithm as a subroutine, typically for local
+optimization.  You can change the local search algorithm and its
+tolerances by calling:
+.sp
+.BI "  nlopt_result nlopt_set_local_optimizer(nlopt_opt " "opt" , 
+.br
+.BI "                                         const nlopt_opt " "local_opt" );
+.sp
+Here, \fIlocal_opt\fR is another \fBnlopt_opt\fR object whose
+parameters are used to determine the local search algorithm and
+stopping criteria.  (The objective function, bounds, and
+nonlinear-constraint parameters of \fIlocal_opt\fR are ignored.)  The
+dimension \fIn\fR of \fIlocal_opt\fR must match that of \fIopt\fR.
+.sp
+This function makes a copy of the \fIlocal_opt\fR object, so you can
+freely destroy your original \fIlocal_opt\fR afterwards.
+.SH INITIAL STEP SIZE
+For derivative-free local-optimization algorithms, the optimizer must
+somehow decide on some initial step size to perturb \fIx\fR by when it
+begins the optimization.  This step size should be big enough that the
+value of the objective changes significantly, but not too big if you
+want to find the local optimum nearest to \fIx\fR.  By default, NLopt
+chooses this initial step size heuristically from the bounds,
+tolerances, and other information, but this may not always be the best
+choice.
+.sp
+You can modify the initial step size by calling:
+.sp
+.BI "  nlopt_result nlopt_set_initial_step(nlopt_opt " "opt" , 
+.br
+.BI "                                      const double* " "dx" );
+.sp
+Here, \fIdx\fR is an array of length \fIn\fR containing the (nonzero)
+initial step size for each component of the design parameters \fIx\fR.
+For convenience, if you want to set the step sizes in every direction
+to be the same value, you can instead call:
+.sp
+.BI "  nlopt_result nlopt_set_initial_step1(nlopt_opt " "opt" , 
+.br
+.BI "                                       double " "dx" );
+.SH STOCHASTIC POPULATION
+Several of the stochastic search algorithms (e.g., CRS, MLSL, and
+ISRES) start by generating some initial "population" of random points
+\fIx\fR.  By default, this initial population size is chosen
+heuristically in some algorithm-specific way, but the initial
+population can by changed by calling:
+.sp
+.BI "  nlopt_result nlopt_set_population(nlopt_opt " "opt" , 
+.br
+.BI "                                    unsigned " "pop" );
+.sp
+(A \fIpop\fR of zero implies that the heuristic default will be used.)
+.SH PSEUDORANDOM NUMBERS
+For stochastic optimization algorithms, we use pseudorandom numbers generated
+by the Mersenne Twister algorithm, based on code from Makoto Matsumoto.
+By default, the seed for the random numbers is generated from the system
+time, so that they will be different each time you run the program.  If
+you want to use deterministic random numbers, you can set the seed by
+calling:
+.sp
+.BI "            void nlopt_srand(unsigned long " "seed" );
+.sp
+Some of the algorithms also support using low-discrepancy sequences (LDS),
+sometimes known as quasi-random numbers.  NLopt uses the Sobol LDS, which
+is implemented for up to 1111 dimensions.
+.SH AUTHORS
+Written by Steven G. Johnson.
+.PP
+Copyright (c) 2007-2014 Massachusetts Institute of Technology.
+.SH "SEE ALSO"
+nlopt_minimize(3)
diff --git a/api/nlopt.f b/api/nlopt.f
new file mode 100644 (file)
index 0000000..5f0ac82
--- /dev/null
@@ -0,0 +1,108 @@
+      integer NLOPT_GN_DIRECT
+      parameter (NLOPT_GN_DIRECT=0)
+      integer NLOPT_GN_DIRECT_L
+      parameter (NLOPT_GN_DIRECT_L=1)
+      integer NLOPT_GN_DIRECT_L_RAND
+      parameter (NLOPT_GN_DIRECT_L_RAND=2)
+      integer NLOPT_GN_DIRECT_NOSCAL
+      parameter (NLOPT_GN_DIRECT_NOSCAL=3)
+      integer NLOPT_GN_DIRECT_L_NOSCAL
+      parameter (NLOPT_GN_DIRECT_L_NOSCAL=4)
+      integer NLOPT_GN_DIRECT_L_RAND_NOSCAL
+      parameter (NLOPT_GN_DIRECT_L_RAND_NOSCAL=5)
+      integer NLOPT_GN_ORIG_DIRECT
+      parameter (NLOPT_GN_ORIG_DIRECT=6)
+      integer NLOPT_GN_ORIG_DIRECT_L
+      parameter (NLOPT_GN_ORIG_DIRECT_L=7)
+      integer NLOPT_GD_STOGO
+      parameter (NLOPT_GD_STOGO=8)
+      integer NLOPT_GD_STOGO_RAND
+      parameter (NLOPT_GD_STOGO_RAND=9)
+      integer NLOPT_LD_LBFGS_NOCEDAL
+      parameter (NLOPT_LD_LBFGS_NOCEDAL=10)
+      integer NLOPT_LD_LBFGS
+      parameter (NLOPT_LD_LBFGS=11)
+      integer NLOPT_LN_PRAXIS
+      parameter (NLOPT_LN_PRAXIS=12)
+      integer NLOPT_LD_VAR1
+      parameter (NLOPT_LD_VAR1=13)
+      integer NLOPT_LD_VAR2
+      parameter (NLOPT_LD_VAR2=14)
+      integer NLOPT_LD_TNEWTON
+      parameter (NLOPT_LD_TNEWTON=15)
+      integer NLOPT_LD_TNEWTON_RESTART
+      parameter (NLOPT_LD_TNEWTON_RESTART=16)
+      integer NLOPT_LD_TNEWTON_PRECOND
+      parameter (NLOPT_LD_TNEWTON_PRECOND=17)
+      integer NLOPT_LD_TNEWTON_PRECOND_RESTART
+      parameter (NLOPT_LD_TNEWTON_PRECOND_RESTART=18)
+      integer NLOPT_GN_CRS2_LM
+      parameter (NLOPT_GN_CRS2_LM=19)
+      integer NLOPT_GN_MLSL
+      parameter (NLOPT_GN_MLSL=20)
+      integer NLOPT_GD_MLSL
+      parameter (NLOPT_GD_MLSL=21)
+      integer NLOPT_GN_MLSL_LDS
+      parameter (NLOPT_GN_MLSL_LDS=22)
+      integer NLOPT_GD_MLSL_LDS
+      parameter (NLOPT_GD_MLSL_LDS=23)
+      integer NLOPT_LD_MMA
+      parameter (NLOPT_LD_MMA=24)
+      integer NLOPT_LN_COBYLA
+      parameter (NLOPT_LN_COBYLA=25)
+      integer NLOPT_LN_NEWUOA
+      parameter (NLOPT_LN_NEWUOA=26)
+      integer NLOPT_LN_NEWUOA_BOUND
+      parameter (NLOPT_LN_NEWUOA_BOUND=27)
+      integer NLOPT_LN_NELDERMEAD
+      parameter (NLOPT_LN_NELDERMEAD=28)
+      integer NLOPT_LN_SBPLX
+      parameter (NLOPT_LN_SBPLX=29)
+      integer NLOPT_LN_AUGLAG
+      parameter (NLOPT_LN_AUGLAG=30)
+      integer NLOPT_LD_AUGLAG
+      parameter (NLOPT_LD_AUGLAG=31)
+      integer NLOPT_LN_AUGLAG_EQ
+      parameter (NLOPT_LN_AUGLAG_EQ=32)
+      integer NLOPT_LD_AUGLAG_EQ
+      parameter (NLOPT_LD_AUGLAG_EQ=33)
+      integer NLOPT_LN_BOBYQA
+      parameter (NLOPT_LN_BOBYQA=34)
+      integer NLOPT_GN_ISRES
+      parameter (NLOPT_GN_ISRES=35)
+      integer NLOPT_AUGLAG
+      parameter (NLOPT_AUGLAG=36)
+      integer NLOPT_AUGLAG_EQ
+      parameter (NLOPT_AUGLAG_EQ=37)
+      integer NLOPT_G_MLSL
+      parameter (NLOPT_G_MLSL=38)
+      integer NLOPT_G_MLSL_LDS
+      parameter (NLOPT_G_MLSL_LDS=39)
+      integer NLOPT_LD_SLSQP
+      parameter (NLOPT_LD_SLSQP=40)
+      integer NLOPT_LD_CCSAQ
+      parameter (NLOPT_LD_CCSAQ=41)
+      integer NLOPT_GN_ESCH
+      parameter (NLOPT_GN_ESCH=42)
+      integer NLOPT_FAILURE
+      parameter (NLOPT_FAILURE=-1)
+      integer NLOPT_INVALID_ARGS
+      parameter (NLOPT_INVALID_ARGS=-2)
+      integer NLOPT_OUT_OF_MEMORY
+      parameter (NLOPT_OUT_OF_MEMORY=-3)
+      integer NLOPT_ROUNDOFF_LIMITED
+      parameter (NLOPT_ROUNDOFF_LIMITED=-4)
+      integer NLOPT_FORCED_STOP
+      parameter (NLOPT_FORCED_STOP=-5)
+      integer NLOPT_SUCCESS
+      parameter (NLOPT_SUCCESS=1)
+      integer NLOPT_STOPVAL_REACHED
+      parameter (NLOPT_STOPVAL_REACHED=2)
+      integer NLOPT_FTOL_REACHED
+      parameter (NLOPT_FTOL_REACHED=3)
+      integer NLOPT_XTOL_REACHED
+      parameter (NLOPT_XTOL_REACHED=4)
+      integer NLOPT_MAXEVAL_REACHED
+      parameter (NLOPT_MAXEVAL_REACHED=5)
+      integer NLOPT_MAXTIME_REACHED
+      parameter (NLOPT_MAXTIME_REACHED=6)
diff --git a/api/nlopt.h b/api/nlopt.h
new file mode 100644 (file)
index 0000000..b9bb619
--- /dev/null
@@ -0,0 +1,379 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef NLOPT_H
+#define NLOPT_H
+
+#include <stddef.h> /* for ptrdiff_t and size_t */
+
+/* Change 0 to 1 to use stdcall convention under Win32 */
+#if 0 && (defined(_WIN32) || defined(__WIN32__))
+#  if defined(__GNUC__)
+#    define NLOPT_STDCALL __attribute__((stdcall))
+#  elif defined(_MSC_VER) || defined(_ICC) || defined(_STDCALL_SUPPORTED)
+#    define NLOPT_STDCALL __stdcall
+#  else
+#    define NLOPT_STDCALL
+#  endif
+#else
+#  define NLOPT_STDCALL
+#endif
+
+/* for Windows compilers, you should add a line
+           #define NLOPT_DLL
+   when using NLopt from a DLL, in order to do the proper
+   Windows importing nonsense. */
+#if defined(NLOPT_DLL) && (defined(_WIN32) || defined(__WIN32__)) && !defined(__LCC__)
+/* annoying Windows syntax for calling functions in a DLL */
+#  if defined(NLOPT_DLL_EXPORT)
+#    define NLOPT_EXTERN(T) extern __declspec(dllexport) T NLOPT_STDCALL
+#  else
+#    define NLOPT_EXTERN(T) extern __declspec(dllimport) T NLOPT_STDCALL
+#  endif
+#else
+#  define NLOPT_EXTERN(T) extern T NLOPT_STDCALL
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef double (*nlopt_func)(unsigned n, const double *x,
+                            double *gradient, /* NULL if not needed */
+                            void *func_data);
+
+typedef void (*nlopt_mfunc)(unsigned m, double *result,
+                           unsigned n, const double *x,
+                            double *gradient, /* NULL if not needed */
+                            void *func_data);
+
+/* A preconditioner, which preconditions v at x to return vpre. 
+   (The meaning of "preconditioning" is algorithm-dependent.) */
+typedef void (*nlopt_precond)(unsigned n, const double *x, const double *v,
+                             double *vpre, void *data);
+
+typedef enum {
+     /* Naming conventions:
+
+        NLOPT_{G/L}{D/N}_* 
+           = global/local derivative/no-derivative optimization, 
+              respectively 
+       *_RAND algorithms involve some randomization.
+
+       *_NOSCAL algorithms are *not* scaled to a unit hypercube
+                (i.e. they are sensitive to the units of x)
+       */
+
+     NLOPT_GN_DIRECT = 0,
+     NLOPT_GN_DIRECT_L,
+     NLOPT_GN_DIRECT_L_RAND,
+     NLOPT_GN_DIRECT_NOSCAL,
+     NLOPT_GN_DIRECT_L_NOSCAL,
+     NLOPT_GN_DIRECT_L_RAND_NOSCAL,
+
+     NLOPT_GN_ORIG_DIRECT,
+     NLOPT_GN_ORIG_DIRECT_L,
+
+     NLOPT_GD_STOGO,
+     NLOPT_GD_STOGO_RAND,
+
+     NLOPT_LD_LBFGS_NOCEDAL,
+
+     NLOPT_LD_LBFGS,
+
+     NLOPT_LN_PRAXIS,
+
+     NLOPT_LD_VAR1,
+     NLOPT_LD_VAR2,
+
+     NLOPT_LD_TNEWTON,
+     NLOPT_LD_TNEWTON_RESTART,
+     NLOPT_LD_TNEWTON_PRECOND,
+     NLOPT_LD_TNEWTON_PRECOND_RESTART,
+
+     NLOPT_GN_CRS2_LM,
+
+     NLOPT_GN_MLSL,
+     NLOPT_GD_MLSL,
+     NLOPT_GN_MLSL_LDS,
+     NLOPT_GD_MLSL_LDS,
+
+     NLOPT_LD_MMA,
+
+     NLOPT_LN_COBYLA,
+
+     NLOPT_LN_NEWUOA,
+     NLOPT_LN_NEWUOA_BOUND,
+
+     NLOPT_LN_NELDERMEAD,
+     NLOPT_LN_SBPLX,
+
+     NLOPT_LN_AUGLAG,
+     NLOPT_LD_AUGLAG,
+     NLOPT_LN_AUGLAG_EQ,
+     NLOPT_LD_AUGLAG_EQ,
+
+     NLOPT_LN_BOBYQA,
+
+     NLOPT_GN_ISRES,
+
+     /* new variants that require local_optimizer to be set,
+       not with older constants for backwards compatibility */
+     NLOPT_AUGLAG,
+     NLOPT_AUGLAG_EQ,
+     NLOPT_G_MLSL,
+     NLOPT_G_MLSL_LDS,
+
+     NLOPT_LD_SLSQP,
+
+     NLOPT_LD_CCSAQ,
+
+     NLOPT_GN_ESCH,
+
+     NLOPT_NUM_ALGORITHMS /* not an algorithm, just the number of them */
+} nlopt_algorithm;
+
+NLOPT_EXTERN(const char *) nlopt_algorithm_name(nlopt_algorithm a);
+
+typedef enum {
+     NLOPT_FAILURE = -1, /* generic failure code */
+     NLOPT_INVALID_ARGS = -2,
+     NLOPT_OUT_OF_MEMORY = -3,
+     NLOPT_ROUNDOFF_LIMITED = -4,
+     NLOPT_FORCED_STOP = -5,
+     NLOPT_SUCCESS = 1, /* generic success code */
+     NLOPT_STOPVAL_REACHED = 2,
+     NLOPT_FTOL_REACHED = 3,
+     NLOPT_XTOL_REACHED = 4,
+     NLOPT_MAXEVAL_REACHED = 5,
+     NLOPT_MAXTIME_REACHED = 6
+} nlopt_result;
+
+#define NLOPT_MINF_MAX_REACHED NLOPT_STOPVAL_REACHED
+
+NLOPT_EXTERN(void) nlopt_srand(unsigned long seed);
+NLOPT_EXTERN(void) nlopt_srand_time(void);
+
+NLOPT_EXTERN(void) nlopt_version(int *major, int *minor, int *bugfix);
+
+/*************************** OBJECT-ORIENTED API **************************/
+/* The style here is that we create an nlopt_opt "object" (an opaque pointer),
+   then set various optimization parameters, and then execute the
+   algorithm.  In this way, we can add more and more optimization parameters
+   (including algorithm-specific ones) without breaking backwards
+   compatibility, having functions with zillions of parameters, or
+   relying non-reentrantly on global variables.*/
+
+struct nlopt_opt_s; /* opaque structure, defined internally */
+typedef struct nlopt_opt_s *nlopt_opt;
+
+/* the only immutable parameters of an optimization are the algorithm and
+   the dimension n of the problem, since changing either of these could
+   have side-effects on lots of other parameters */
+NLOPT_EXTERN(nlopt_opt) nlopt_create(nlopt_algorithm algorithm, unsigned n);
+NLOPT_EXTERN(void) nlopt_destroy(nlopt_opt opt);
+NLOPT_EXTERN(nlopt_opt) nlopt_copy(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_optimize(nlopt_opt opt, double *x,
+                                        double *opt_f);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_min_objective(nlopt_opt opt, nlopt_func f, 
+                                                 void *f_data);
+NLOPT_EXTERN(nlopt_result) nlopt_set_max_objective(nlopt_opt opt, nlopt_func f, 
+                                                 void *f_data);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_precond_min_objective(nlopt_opt opt, nlopt_func f, nlopt_precond pre, void *f_data);
+NLOPT_EXTERN(nlopt_result) nlopt_set_precond_max_objective(nlopt_opt opt, nlopt_func f, nlopt_precond pre, void *f_data);
+
+NLOPT_EXTERN(nlopt_algorithm) nlopt_get_algorithm(const nlopt_opt opt);
+NLOPT_EXTERN(unsigned) nlopt_get_dimension(const nlopt_opt opt);
+
+/* constraints: */
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_lower_bounds(nlopt_opt opt, 
+                                                const double *lb);
+NLOPT_EXTERN(nlopt_result) nlopt_set_lower_bounds1(nlopt_opt opt, double lb);
+NLOPT_EXTERN(nlopt_result) nlopt_get_lower_bounds(const nlopt_opt opt, 
+                                                double *lb);
+NLOPT_EXTERN(nlopt_result) nlopt_set_upper_bounds(nlopt_opt opt, 
+                                                const double *ub);
+NLOPT_EXTERN(nlopt_result) nlopt_set_upper_bounds1(nlopt_opt opt, double ub);
+NLOPT_EXTERN(nlopt_result) nlopt_get_upper_bounds(const nlopt_opt opt,
+                                                double *ub);
+
+NLOPT_EXTERN(nlopt_result) nlopt_remove_inequality_constraints(nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_add_inequality_constraint(nlopt_opt opt,
+                                                         nlopt_func fc,
+                                                         void *fc_data,
+                                                         double tol);
+NLOPT_EXTERN(nlopt_result) nlopt_add_precond_inequality_constraint(
+     nlopt_opt opt, nlopt_func fc, nlopt_precond pre, void *fc_data,
+     double tol);
+NLOPT_EXTERN(nlopt_result) nlopt_add_inequality_mconstraint(nlopt_opt opt,
+                                                           unsigned m,
+                                                           nlopt_mfunc fc,
+                                                           void *fc_data,
+                                                           const double *tol);
+
+NLOPT_EXTERN(nlopt_result) nlopt_remove_equality_constraints(nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_add_equality_constraint(nlopt_opt opt,
+                                                       nlopt_func h,
+                                                       void *h_data,
+                                                       double tol);
+NLOPT_EXTERN(nlopt_result) nlopt_add_precond_equality_constraint(
+     nlopt_opt opt, nlopt_func h, nlopt_precond pre, void *h_data,
+     double tol);
+NLOPT_EXTERN(nlopt_result) nlopt_add_equality_mconstraint(nlopt_opt opt,
+                                                         unsigned m,
+                                                         nlopt_mfunc h,
+                                                         void *h_data,
+                                                         const double *tol);
+
+/* stopping criteria: */
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_stopval(nlopt_opt opt, double stopval);
+NLOPT_EXTERN(double) nlopt_get_stopval(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_ftol_rel(nlopt_opt opt, double tol);
+NLOPT_EXTERN(double) nlopt_get_ftol_rel(const nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_set_ftol_abs(nlopt_opt opt, double tol);
+NLOPT_EXTERN(double) nlopt_get_ftol_abs(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_xtol_rel(nlopt_opt opt, double tol);
+NLOPT_EXTERN(double) nlopt_get_xtol_rel(const nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_set_xtol_abs1(nlopt_opt opt, double tol);
+NLOPT_EXTERN(nlopt_result) nlopt_set_xtol_abs(nlopt_opt opt, const double *tol);
+NLOPT_EXTERN(nlopt_result) nlopt_get_xtol_abs(const nlopt_opt opt,
+                                            double *tol);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_maxeval(nlopt_opt opt, int maxeval);
+NLOPT_EXTERN(int) nlopt_get_maxeval(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_maxtime(nlopt_opt opt, double maxtime);
+NLOPT_EXTERN(double) nlopt_get_maxtime(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_force_stop(nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_set_force_stop(nlopt_opt opt, int val);
+NLOPT_EXTERN(int) nlopt_get_force_stop(const nlopt_opt opt);
+
+/* more algorithm-specific parameters */
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_local_optimizer(nlopt_opt opt, 
+                                                   const nlopt_opt local_opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_population(nlopt_opt opt, unsigned pop);
+NLOPT_EXTERN(unsigned) nlopt_get_population(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_vector_storage(nlopt_opt opt, unsigned dim);
+NLOPT_EXTERN(unsigned) nlopt_get_vector_storage(const nlopt_opt opt);
+
+NLOPT_EXTERN(nlopt_result) nlopt_set_default_initial_step(nlopt_opt opt, 
+                                                        const double *x);
+NLOPT_EXTERN(nlopt_result) nlopt_set_initial_step(nlopt_opt opt, 
+                                                const double *dx);
+NLOPT_EXTERN(nlopt_result) nlopt_set_initial_step1(nlopt_opt opt, double dx);
+NLOPT_EXTERN(nlopt_result) nlopt_get_initial_step(const nlopt_opt opt, 
+                                                const double *x, double *dx);
+
+/* the following are functions mainly designed to be used internally
+   by the Fortran and SWIG wrappers, allow us to tel nlopt_destroy and
+   nlopt_copy to do something to the f_data pointers (e.g. free or
+   duplicate them, respectively) */
+typedef void* (*nlopt_munge)(void *p);
+NLOPT_EXTERN(void) nlopt_set_munge(nlopt_opt opt,
+                                 nlopt_munge munge_on_destroy,
+                                 nlopt_munge munge_on_copy);
+typedef void* (*nlopt_munge2)(void *p, void *data);
+NLOPT_EXTERN(void) nlopt_munge_data(nlopt_opt opt,
+                                    nlopt_munge2 munge, void *data);
+
+/*************************** DEPRECATED API **************************/
+/* The new "object-oriented" API is preferred, since it allows us to
+   gracefully add new features and algorithm-specific options in a
+   re-entrant way, and we can automatically assume reasonable defaults
+   for unspecified parameters. */
+
+/* Where possible (e.g. for gcc >= 3.1), enable a compiler warning
+   for code that uses a deprecated function */
+#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__==3 && __GNUC_MINOR__ > 0))
+#  define NLOPT_DEPRECATED __attribute__((deprecated))
+#else
+#  define NLOPT_DEPRECATED 
+#endif
+
+typedef double (*nlopt_func_old)(int n, const double *x,
+                                double *gradient, /* NULL if not needed */
+                                void *func_data);
+
+NLOPT_EXTERN(nlopt_result) nlopt_minimize(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     int maxeval, double maxtime) NLOPT_DEPRECATED;
+
+NLOPT_EXTERN(nlopt_result) nlopt_minimize_constrained(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     int m, nlopt_func_old fc, void *fc_data, ptrdiff_t fc_datum_size,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     int maxeval, double maxtime) NLOPT_DEPRECATED;
+
+NLOPT_EXTERN(nlopt_result) nlopt_minimize_econstrained(
+     nlopt_algorithm algorithm,
+     int n, nlopt_func_old f, void *f_data,
+     int m, nlopt_func_old fc, void *fc_data, ptrdiff_t fc_datum_size,
+     int p, nlopt_func_old h, void *h_data, ptrdiff_t h_datum_size,
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf, /* out: minimum */
+     double minf_max, double ftol_rel, double ftol_abs,
+     double xtol_rel, const double *xtol_abs,
+     double htol_rel, double htol_abs,
+     int maxeval, double maxtime) NLOPT_DEPRECATED;
+
+NLOPT_EXTERN(void) nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
+                                            nlopt_algorithm *nonderiv,
+                                            int *maxeval) NLOPT_DEPRECATED;
+NLOPT_EXTERN(void) nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
+                                            nlopt_algorithm nonderiv,
+                                            int maxeval) NLOPT_DEPRECATED;
+
+NLOPT_EXTERN(int) nlopt_get_stochastic_population(void) NLOPT_DEPRECATED;
+NLOPT_EXTERN(void) nlopt_set_stochastic_population(int pop) NLOPT_DEPRECATED;
+
+/*********************************************************************/
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
diff --git a/api/nlopt.hpp b/api/nlopt.hpp
new file mode 100644 (file)
index 0000000..b22af0b
--- /dev/null
@@ -0,0 +1,596 @@
+/* Copyright (c) 2007-2011 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+// C++ style wrapper around NLopt API
+// nlopt.hpp is AUTOMATICALLY GENERATED from nlopt-in.hpp - edit the latter!
+
+#ifndef NLOPT_HPP
+#define NLOPT_HPP
+
+#include <nlopt.h>
+
+#include <vector>
+#include <stdexcept>
+#include <new>
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+
+// convenience overloading for below (not in nlopt:: since has nlopt_ prefix)
+inline nlopt_result nlopt_get_initial_step(const nlopt_opt opt, double *dx) {
+      return nlopt_get_initial_step(opt, (const double *) NULL, dx);
+}
+
+namespace nlopt {
+
+  //////////////////////////////////////////////////////////////////////
+  // nlopt::* namespace versions of the C enumerated types
+  //          AUTOMATICALLY GENERATED, DO NOT EDIT
+  // GEN_ENUMS_HERE
+  enum algorithm {
+     GN_DIRECT = 0,
+     GN_DIRECT_L,
+     GN_DIRECT_L_RAND,
+     GN_DIRECT_NOSCAL,
+     GN_DIRECT_L_NOSCAL,
+     GN_DIRECT_L_RAND_NOSCAL,
+     GN_ORIG_DIRECT,
+     GN_ORIG_DIRECT_L,
+     GD_STOGO,
+     GD_STOGO_RAND,
+     LD_LBFGS_NOCEDAL,
+     LD_LBFGS,
+     LN_PRAXIS,
+     LD_VAR1,
+     LD_VAR2,
+     LD_TNEWTON,
+     LD_TNEWTON_RESTART,
+     LD_TNEWTON_PRECOND,
+     LD_TNEWTON_PRECOND_RESTART,
+     GN_CRS2_LM,
+     GN_MLSL,
+     GD_MLSL,
+     GN_MLSL_LDS,
+     GD_MLSL_LDS,
+     LD_MMA,
+     LN_COBYLA,
+     LN_NEWUOA,
+     LN_NEWUOA_BOUND,
+     LN_NELDERMEAD,
+     LN_SBPLX,
+     LN_AUGLAG,
+     LD_AUGLAG,
+     LN_AUGLAG_EQ,
+     LD_AUGLAG_EQ,
+     LN_BOBYQA,
+     GN_ISRES,
+     AUGLAG,
+     AUGLAG_EQ,
+     G_MLSL,
+     G_MLSL_LDS,
+     LD_SLSQP,
+     LD_CCSAQ,
+     GN_ESCH,
+     NUM_ALGORITHMS /* not an algorithm, just the number of them */
+  };
+  enum result {
+     FAILURE = -1, /* generic failure code */
+     INVALID_ARGS = -2,
+     OUT_OF_MEMORY = -3,
+     ROUNDOFF_LIMITED = -4,
+     FORCED_STOP = -5,
+     SUCCESS = 1, /* generic success code */
+     STOPVAL_REACHED = 2,
+     FTOL_REACHED = 3,
+     XTOL_REACHED = 4,
+     MAXEVAL_REACHED = 5,
+     MAXTIME_REACHED = 6
+  };
+  // GEN_ENUMS_HERE
+  //////////////////////////////////////////////////////////////////////
+
+  typedef nlopt_func func; // nlopt::func synoynm
+  typedef nlopt_mfunc mfunc; // nlopt::mfunc synoynm
+
+  // alternative to nlopt_func that takes std::vector<double>
+  // ... unfortunately requires a data copy
+  typedef double (*vfunc)(const std::vector<double> &x,
+                         std::vector<double> &grad, void *data);
+
+  //////////////////////////////////////////////////////////////////////
+  
+  // NLopt-specific exceptions (corresponding to error codes):
+  class roundoff_limited : public std::runtime_error {
+  public:
+    roundoff_limited() : std::runtime_error("nlopt roundoff-limited") {}
+  };
+
+  class forced_stop : public std::runtime_error {
+  public:
+    forced_stop() : std::runtime_error("nlopt forced stop") {}
+  };
+
+  //////////////////////////////////////////////////////////////////////
+
+  class opt {
+  private:
+    nlopt_opt o;
+    
+    void mythrow(nlopt_result ret) const {
+      switch (ret) {
+      case NLOPT_FAILURE: throw std::runtime_error("nlopt failure");
+      case NLOPT_OUT_OF_MEMORY: throw std::bad_alloc();
+      case NLOPT_INVALID_ARGS: throw std::invalid_argument("nlopt invalid argument");
+      case NLOPT_ROUNDOFF_LIMITED: throw roundoff_limited();
+      case NLOPT_FORCED_STOP: throw forced_stop();
+      default: break;
+      }
+    }
+
+    typedef struct {
+      opt *o;
+      mfunc mf; func f; void *f_data;
+      vfunc vf;
+      nlopt_munge munge_destroy, munge_copy; // non-NULL for SWIG wrappers
+    } myfunc_data;
+
+    // free/destroy f_data in nlopt_destroy and nlopt_copy, respectively
+    static void *free_myfunc_data(void *p) { 
+      myfunc_data *d = (myfunc_data *) p;
+      if (d) {
+       if (d->f_data && d->munge_destroy) d->munge_destroy(d->f_data);
+       delete d;
+      }
+      return NULL;
+    }
+    static void *dup_myfunc_data(void *p) {
+      myfunc_data *d = (myfunc_data *) p;
+      if (d) {
+       void *f_data;
+       if (d->f_data && d->munge_copy) {
+         f_data = d->munge_copy(d->f_data);
+         if (!f_data) return NULL;
+       }
+       else
+         f_data = d->f_data;
+       myfunc_data *dnew = new myfunc_data;
+       if (dnew) {
+         *dnew = *d;
+         dnew->f_data = f_data;
+       }
+       return (void*) dnew;
+      }
+      else return NULL;
+    }
+
+    // nlopt_func wrapper that catches exceptions
+    static double myfunc(unsigned n, const double *x, double *grad, void *d_) {
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       return d->f(n, x, grad, d->f_data);
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      return HUGE_VAL;
+    }
+
+    // nlopt_mfunc wrapper that catches exceptions
+    static void mymfunc(unsigned m, double *result,
+                       unsigned n, const double *x, double *grad, void *d_) {
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       d->mf(m, result, n, x, grad, d->f_data);
+       return;
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      for (unsigned i = 0; i < m; ++i) result[i] = HUGE_VAL;
+    }
+
+    std::vector<double> xtmp, gradtmp, gradtmp0; // scratch for myvfunc
+
+    // nlopt_func wrapper, using std::vector<double>
+    static double myvfunc(unsigned n, const double *x, double *grad, void *d_){
+      myfunc_data *d = reinterpret_cast<myfunc_data*>(d_);
+      try {
+       std::vector<double> &xv = d->o->xtmp;
+       if (n) std::memcpy(&xv[0], x, n * sizeof(double));
+       double val=d->vf(xv, grad ? d->o->gradtmp : d->o->gradtmp0, d->f_data);
+       if (grad && n) {
+         std::vector<double> &gradv = d->o->gradtmp;
+         std::memcpy(grad, &gradv[0], n * sizeof(double));
+       }
+       return val;
+      }
+      catch (std::bad_alloc&)
+       { d->o->forced_stop_reason = NLOPT_OUT_OF_MEMORY; }
+      catch (std::invalid_argument&)
+       { d->o->forced_stop_reason = NLOPT_INVALID_ARGS; }
+      catch (roundoff_limited&)
+       { d->o->forced_stop_reason = NLOPT_ROUNDOFF_LIMITED; }
+      catch (forced_stop&)
+       { d->o->forced_stop_reason = NLOPT_FORCED_STOP; }
+      catch (...)
+       { d->o->forced_stop_reason = NLOPT_FAILURE; }
+      d->o->force_stop(); // stop gracefully, opt::optimize will re-throw
+      return HUGE_VAL;
+    }
+
+    void alloc_tmp() {
+      if (xtmp.size() != nlopt_get_dimension(o)) {
+       xtmp = std::vector<double>(nlopt_get_dimension(o));
+       gradtmp = std::vector<double>(nlopt_get_dimension(o));
+      }
+    }
+
+    result last_result;
+    double last_optf;
+    nlopt_result forced_stop_reason;
+
+  public:
+    // Constructors etc.
+    opt() : o(NULL), xtmp(0), gradtmp(0), gradtmp0(0), 
+           last_result(nlopt::FAILURE), last_optf(HUGE_VAL),
+           forced_stop_reason(NLOPT_FORCED_STOP) {}
+    ~opt() { nlopt_destroy(o); }
+    opt(algorithm a, unsigned n) : 
+      o(nlopt_create(nlopt_algorithm(a), n)), 
+      xtmp(0), gradtmp(0), gradtmp0(0),
+      last_result(nlopt::FAILURE), last_optf(HUGE_VAL),
+      forced_stop_reason(NLOPT_FORCED_STOP) {
+      if (!o) throw std::bad_alloc();
+      nlopt_set_munge(o, free_myfunc_data, dup_myfunc_data);
+    }
+    opt(const opt& f) : o(nlopt_copy(f.o)), 
+                       xtmp(f.xtmp), gradtmp(f.gradtmp), gradtmp0(0),
+                       last_result(f.last_result), last_optf(f.last_optf),
+                       forced_stop_reason(f.forced_stop_reason) {
+      if (f.o && !o) throw std::bad_alloc();
+    }
+    opt& operator=(opt const& f) {
+      if (this == &f) return *this; // self-assignment
+      nlopt_destroy(o);
+      o = nlopt_copy(f.o);
+      if (f.o && !o) throw std::bad_alloc();
+      xtmp = f.xtmp; gradtmp = f.gradtmp;
+      last_result = f.last_result; last_optf = f.last_optf;
+      forced_stop_reason = f.forced_stop_reason;
+      return *this;
+    }
+
+    // Do the optimization:
+    result optimize(std::vector<double> &x, double &opt_f) {
+      if (o && nlopt_get_dimension(o) != x.size())
+        throw std::invalid_argument("dimension mismatch");
+      forced_stop_reason = NLOPT_FORCED_STOP;
+      nlopt_result ret = nlopt_optimize(o, x.empty() ? NULL : &x[0], &opt_f);
+      last_result = result(ret);
+      last_optf = opt_f;
+      if (ret == NLOPT_FORCED_STOP)
+       mythrow(forced_stop_reason);
+      mythrow(ret);
+      return last_result;
+    }
+
+    // variant mainly useful for SWIG wrappers:
+    std::vector<double> optimize(const std::vector<double> &x0) {
+      std::vector<double> x(x0);
+      last_result = optimize(x, last_optf);
+      return x;
+    }
+    result last_optimize_result() const { return last_result; }
+    double last_optimum_value() const { return last_optf; }
+
+    // accessors:
+    algorithm get_algorithm() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return algorithm(nlopt_get_algorithm(o));
+    }
+    const char *get_algorithm_name() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return nlopt_algorithm_name(nlopt_get_algorithm(o));
+    }
+    unsigned get_dimension() const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      return nlopt_get_dimension(o);
+    }
+
+    // Set the objective function
+    void set_min_objective(func f, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_min_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_min_objective(vfunc vf, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_min_objective(o, myvfunc, d)); // d freed via o
+      alloc_tmp();
+    }
+    void set_max_objective(func f, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_max_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_max_objective(vfunc vf, void *f_data) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_set_max_objective(o, myvfunc, d)); // d freed via o
+      alloc_tmp();
+    }
+
+    // for internal use in SWIG wrappers -- variant that
+    // takes ownership of f_data, with munging for destroy/copy
+    void set_min_objective(func f, void *f_data,
+                          nlopt_munge md, nlopt_munge mc) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_set_min_objective(o, myfunc, d)); // d freed via o
+    }
+    void set_max_objective(func f, void *f_data,
+                          nlopt_munge md, nlopt_munge mc) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_set_max_objective(o, myfunc, d)); // d freed via o
+    }
+
+    // Nonlinear constraints:
+
+    void remove_inequality_constraints() {
+      nlopt_result ret = nlopt_remove_inequality_constraints(o);
+      mythrow(ret);
+    }
+    void add_inequality_constraint(func f, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_constraint(o, myfunc, d, tol));
+    }
+    void add_inequality_constraint(vfunc vf, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_constraint(o, myvfunc, d, tol));
+      alloc_tmp();
+    }
+    void add_inequality_mconstraint(mfunc mf, void *f_data, 
+                                   const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d, 
+                                              tol.empty() ? NULL : &tol[0]));
+    }
+
+    void remove_equality_constraints() {
+      nlopt_result ret = nlopt_remove_equality_constraints(o);
+      mythrow(ret);
+    }
+    void add_equality_constraint(func f, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_constraint(o, myfunc, d, tol));
+    }
+    void add_equality_constraint(vfunc vf, void *f_data, double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = NULL; d->f_data = f_data; d->mf = NULL; d->vf = vf;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_constraint(o, myvfunc, d, tol));
+      alloc_tmp();
+    }
+    void add_equality_mconstraint(mfunc mf, void *f_data, 
+                                 const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = d->munge_copy = NULL;
+      mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d, 
+                                            tol.empty() ? NULL : &tol[0]));
+    }
+
+    // For internal use in SWIG wrappers (see also above)
+    void add_inequality_constraint(func f, void *f_data, 
+                                  nlopt_munge md, nlopt_munge mc,
+                                  double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_inequality_constraint(o, myfunc, d, tol));
+    }
+    void add_equality_constraint(func f, void *f_data, 
+                                nlopt_munge md, nlopt_munge mc,
+                                double tol=0) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->f = f; d->f_data = f_data; d->mf = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_equality_constraint(o, myfunc, d, tol));
+    }
+    void add_inequality_mconstraint(mfunc mf, void *f_data, 
+                                   nlopt_munge md, nlopt_munge mc,
+                                   const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d, 
+                                              tol.empty() ? NULL : &tol[0]));
+    }
+    void add_equality_mconstraint(mfunc mf, void *f_data, 
+                                 nlopt_munge md, nlopt_munge mc,
+                                 const std::vector<double> &tol) {
+      myfunc_data *d = new myfunc_data;
+      if (!d) throw std::bad_alloc();
+      d->o = this; d->mf = mf; d->f_data = f_data; d->f = NULL; d->vf = NULL;
+      d->munge_destroy = md; d->munge_copy = mc;
+      mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d, 
+                                            tol.empty() ? NULL : &tol[0]));
+    }
+
+#define NLOPT_GETSET_VEC(name)                                         \
+    void set_##name(double val) {                                      \
+      mythrow(nlopt_set_##name##1(o, val));                            \
+    }                                                                  \
+    void get_##name(std::vector<double> &v) const {                    \
+      if (o && nlopt_get_dimension(o) != v.size())                     \
+        throw std::invalid_argument("dimension mismatch");             \
+      mythrow(nlopt_get_##name(o, v.empty() ? NULL : &v[0]));          \
+    }                                                                  \
+    std::vector<double> get_##name() const {                   \
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");    \
+      std::vector<double> v(nlopt_get_dimension(o));                   \
+      get_##name(v);                                                   \
+      return v;                                                                \
+    }                                                                  \
+    void set_##name(const std::vector<double> &v) {                    \
+      if (o && nlopt_get_dimension(o) != v.size())                     \
+        throw std::invalid_argument("dimension mismatch");             \
+      mythrow(nlopt_set_##name(o, v.empty() ? NULL : &v[0]));          \
+    }
+
+    NLOPT_GETSET_VEC(lower_bounds)
+    NLOPT_GETSET_VEC(upper_bounds)
+
+    // stopping criteria:
+
+#define NLOPT_GETSET(T, name)                                          \
+    T get_##name() const {                                             \
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");    \
+      return nlopt_get_##name(o);                                      \
+    }                                                                  \
+    void set_##name(T name) {                                          \
+      mythrow(nlopt_set_##name(o, name));                              \
+    }
+    NLOPT_GETSET(double, stopval)
+    NLOPT_GETSET(double, ftol_rel)
+    NLOPT_GETSET(double, ftol_abs)
+    NLOPT_GETSET(double, xtol_rel)
+    NLOPT_GETSET_VEC(xtol_abs)
+    NLOPT_GETSET(int, maxeval)
+    NLOPT_GETSET(double, maxtime)
+
+    NLOPT_GETSET(int, force_stop)
+    void force_stop() { set_force_stop(1); }
+
+    // algorithm-specific parameters:
+
+    void set_local_optimizer(const opt &lo) {
+      nlopt_result ret = nlopt_set_local_optimizer(o, lo.o);
+      mythrow(ret);
+    }
+
+    NLOPT_GETSET(unsigned, population)
+    NLOPT_GETSET(unsigned, vector_storage)
+    NLOPT_GETSET_VEC(initial_step)
+
+    void set_default_initial_step(const std::vector<double> &x) {
+      nlopt_result ret 
+       = nlopt_set_default_initial_step(o, x.empty() ? NULL : &x[0]);
+      mythrow(ret);
+    }
+    void get_initial_step(const std::vector<double> &x, std::vector<double> &dx) const {
+      if (o && (nlopt_get_dimension(o) != x.size()
+               || nlopt_get_dimension(o) != dx.size()))
+        throw std::invalid_argument("dimension mismatch");
+      nlopt_result ret = nlopt_get_initial_step(o, x.empty() ? NULL : &x[0],
+                                               dx.empty() ? NULL : &dx[0]);
+      mythrow(ret);
+    }
+    std::vector<double> get_initial_step_(const std::vector<double> &x) const {
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+      std::vector<double> v(nlopt_get_dimension(o));
+      get_initial_step(x, v);
+      return v;
+    }
+  };
+
+#undef NLOPT_GETSET
+#undef NLOPT_GETSET_VEC
+
+  //////////////////////////////////////////////////////////////////////
+
+  inline void srand(unsigned long seed) { nlopt_srand(seed); }
+  inline void srand_time() { nlopt_srand_time(); }
+  inline void version(int &major, int &minor, int &bugfix) {
+    nlopt_version(&major, &minor, &bugfix);
+  }
+  inline int version_major() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return major;
+  }
+  inline int version_minor() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return minor;
+  }
+  inline int version_bugfix() {
+    int major, minor, bugfix;
+    nlopt_version(&major, &minor, &bugfix);
+    return bugfix;
+  }
+  inline const char *algorithm_name(algorithm a) {
+    return nlopt_algorithm_name(nlopt_algorithm(a));
+  }
+
+  //////////////////////////////////////////////////////////////////////
+
+} // namespace nlopt
+
+#endif /* NLOPT_HPP */
diff --git a/api/optimize.c b/api/optimize.c
new file mode 100644 (file)
index 0000000..49b8d34
--- /dev/null
@@ -0,0 +1,874 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <math.h>
+#include <float.h>
+
+#include "nlopt-internal.h"
+
+/*********************************************************************/
+
+#ifndef HAVE_ISNAN
+static int my_isnan(double x) { return x != x; }
+#  define isnan my_isnan
+#endif
+
+/*********************************************************************/
+
+#include "praxis.h"
+#include "direct.h"
+
+#ifdef WITH_CXX
+#  include "stogo.h"
+#endif
+
+#include "cdirect.h"
+
+#include "luksan.h"
+
+#include "crs.h"
+
+#include "mlsl.h"
+#include "mma.h"
+#include "cobyla.h"
+#include "newuoa.h"
+#include "neldermead.h"
+#include "auglag.h"
+#include "bobyqa.h"
+#include "isres.h"
+#include "esch.h"
+#include "slsqp.h"
+
+/*********************************************************************/
+
+static double f_bound(int n, const double *x, void *data_)
+{
+     int i;
+     nlopt_opt data = (nlopt_opt) data_;
+     double f;
+
+     /* some methods do not support bound constraints, but support
+       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 HUGE_VAL;
+
+     f = data->f((unsigned) n, x, NULL, data->f_data);
+     return (isnan(f) || nlopt_isinf(f) ? HUGE_VAL : f);
+}
+
+static double f_noderiv(int n, const double *x, void *data_)
+{
+     nlopt_opt data = (nlopt_opt) data_;
+     return data->f((unsigned) n, x, NULL, data->f_data);
+}
+
+static double f_direct(int n, const double *x, int *undefined, void *data_)
+{
+     nlopt_opt data = (nlopt_opt) data_;
+     double *work = (double*) data->work;
+     double f;
+     unsigned i, j;
+     f = data->f((unsigned) n, x, NULL, data->f_data);
+     *undefined = isnan(f) || nlopt_isinf(f);
+     if (nlopt_get_force_stop(data)) return f;
+     for (i = 0; i < data->m && !*undefined; ++i) {
+         nlopt_eval_constraint(work, NULL, data->fc+i, (unsigned) n, x);
+         if (nlopt_get_force_stop(data)) return f;
+         for (j = 0; j < data->fc[i].m; ++j)
+              if (work[j] > 0)
+                   *undefined = 1;
+     }
+     return f;
+}
+
+/*********************************************************************/
+
+/* get min(dx) for algorithms requiring a scalar initial step size */
+static nlopt_result initial_step(nlopt_opt opt, const double *x, double *step)
+{
+     unsigned freedx = 0, i;
+
+     if (!opt->dx) {
+         freedx = 1;
+         if (nlopt_set_default_initial_step(opt, x) != NLOPT_SUCCESS)
+              return NLOPT_OUT_OF_MEMORY;
+     }
+
+     *step = HUGE_VAL;
+     for (i = 0; i < opt->n; ++i)
+         if (*step > fabs(opt->dx[i]))
+              *step = fabs(opt->dx[i]);
+
+     if (freedx) { free(opt->dx); opt->dx = NULL; }
+     return NLOPT_SUCCESS;
+}
+
+/*********************************************************************/
+
+/* return true if [lb,ub] is finite in every dimension (n dimensions) */
+static int finite_domain(unsigned n, const double *lb, const double *ub)
+{
+     unsigned i;
+     for (i = 0; i < n; ++i)
+         if (nlopt_isinf(ub[i] - lb[i])) return 0;
+     return 1;
+}
+
+/*********************************************************************/
+/* wrapper functions, only for derivative-free methods, that
+   eliminate dimensions with lb == ub.   (The gradient-based methods
+   should handle this case directly, since they operate on much
+   larger vectors where I am loathe to make copies unnecessarily.) */
+
+typedef struct {
+     nlopt_func f;
+     nlopt_mfunc mf;
+     void *f_data;
+     unsigned n; /* true dimension */
+     double *x; /* scratch vector of length n */
+     double *grad; /* optional scratch vector of length n */
+     const double *lb, *ub; /* bounds, of length n */
+} elimdim_data;
+
+static void *elimdim_makedata(nlopt_func f, nlopt_mfunc mf, void *f_data,
+                             unsigned n, double *x, const double *lb,
+                             const double *ub, double *grad)
+{
+     elimdim_data *d = (elimdim_data *) malloc(sizeof(elimdim_data));
+     if (!d) return NULL;
+     d->f = f; d->mf = mf; d->f_data = f_data; d->n = n; d->x = x;
+     d->lb = lb; d->ub = ub;
+     d->grad = grad;
+     return d;
+}
+
+static double elimdim_func(unsigned n0, const double *x0, double *grad, void *d_)
+{
+     elimdim_data *d = (elimdim_data *) d_;
+     double *x = d->x;
+     const double *lb = d->lb, *ub = d->ub;
+     double val;
+     unsigned n = d->n, i, j;
+
+     (void) n0; /* unused */
+     for (i = j = 0; i < n; ++i) {
+         if (lb[i] == ub[i])
+              x[i] = lb[i];
+         else /* assert: j < n0 */
+              x[i] = x0[j++];
+     }
+     val = d->f(n, x, grad ? d->grad : NULL, d->f_data);
+     if (grad) {
+         /* assert: d->grad != NULL */
+         for (i = j = 0; i < n; ++i)
+              if (lb[i] != ub[i])
+                   grad[j++] = d->grad[i];
+     }
+     return val;
+}
+
+
+static void elimdim_mfunc(unsigned m, double *result,
+                         unsigned n0, const double *x0, double *grad, void *d_)
+{
+     elimdim_data *d = (elimdim_data *) d_;
+     double *x = d->x;
+     const double *lb = d->lb, *ub = d->ub;
+     unsigned n = d->n, i, j;
+
+     (void) n0; /* unused */
+     (void) grad; /* assert: grad == NULL */
+     for (i = j = 0; i < n; ++i) {
+         if (lb[i] == ub[i])
+              x[i] = lb[i];
+         else /* assert: j < n0 */
+              x[i] = x0[j++];
+     }
+     d->mf(m, result, n, x, NULL, d->f_data);
+}
+
+/* compute the eliminated dimension: number of dims with lb[i] != ub[i] */
+static unsigned elimdim_dimension(unsigned n, const double *lb, const double *ub)
+{
+     unsigned n0 = 0, i;
+     for (i = 0; i < n; ++i) n0 += lb[i] != ub[i] ? 1U : 0;
+     return n0;
+}
+
+/* modify v to "shrunk" version, with dimensions for lb[i] == ub[i] elim'ed */
+static void elimdim_shrink(unsigned n, double *v,
+                          const double *lb, const double *ub)
+{
+     unsigned i, j;
+     if (v)
+         for (i = j = 0; i < n; ++i)
+              if (lb[i] != ub[i])
+                   v[j++] = v[i];
+}
+
+/* inverse of elimdim_shrink */
+static void elimdim_expand(unsigned n, double *v,
+                          const double *lb, const double *ub)
+{
+     unsigned i, j;
+     if (v && n > 0) {
+         j = elimdim_dimension(n, lb, ub) - 1;
+         for (i = n - 1; i > 0; --i) {
+              if (lb[i] != ub[i])
+                   v[i] = v[j--];
+              else
+                   v[i] = lb[i];
+         }
+         if (lb[0] == ub[0])
+              v[0] = lb[0];
+     }
+}
+
+/* given opt, create a new opt with equal-constraint dimensions eliminated */
+static nlopt_opt elimdim_create(nlopt_opt opt)
+{
+     nlopt_opt opt0 = nlopt_copy(opt);
+     double *x, *grad = NULL;
+     unsigned i;
+     
+     if (!opt0) return NULL;
+     x = (double *) malloc(sizeof(double) * opt->n);
+     if (opt->n && !x) { nlopt_destroy(opt0); return NULL; }
+
+     if (opt->algorithm == NLOPT_GD_STOGO
+         || opt->algorithm == NLOPT_GD_STOGO_RAND) {
+         grad = (double *) malloc(sizeof(double) * opt->n);
+         if (opt->n && !grad) goto bad;
+     }
+
+     opt0->n = elimdim_dimension(opt->n, opt->lb, opt->ub);
+     elimdim_shrink(opt->n, opt0->lb, opt->lb, opt->ub);
+     elimdim_shrink(opt->n, opt0->ub, opt->lb, opt->ub);
+     elimdim_shrink(opt->n, opt0->xtol_abs, opt->lb, opt->ub);
+     elimdim_shrink(opt->n, opt0->dx, opt->lb, opt->ub);
+
+     opt0->munge_on_destroy = opt0->munge_on_copy = NULL;
+
+     opt0->f = elimdim_func;
+     opt0->f_data = elimdim_makedata(opt->f, NULL, opt->f_data,
+                                    opt->n, x, opt->lb, opt->ub, grad);
+     if (!opt0->f_data) goto bad;
+
+     for (i = 0; i < opt->m; ++i) {
+         opt0->fc[i].f = elimdim_func;
+         opt0->fc[i].mf = elimdim_mfunc;
+         opt0->fc[i].f_data = elimdim_makedata(opt->fc[i].f, opt->fc[i].mf,
+                                               opt->fc[i].f_data,
+                                               opt->n, x, opt->lb, opt->ub,
+                                               NULL);
+         if (!opt0->fc[i].f_data) goto bad;
+     }
+
+     for (i = 0; i < opt->p; ++i) {
+         opt0->h[i].f = elimdim_func;
+         opt0->h[i].mf = elimdim_mfunc;
+         opt0->h[i].f_data = elimdim_makedata(opt->h[i].f, opt->h[i].mf,
+                                              opt->h[i].f_data,
+                                              opt->n, x, opt->lb, opt->ub,
+                                              NULL);
+         if (!opt0->h[i].f_data) goto bad;
+     }
+
+     return opt0;
+bad:
+     free(grad);
+     free(x);
+     nlopt_destroy(opt0);
+     return NULL;
+}
+
+/* like nlopt_destroy, but also frees elimdim_data */
+static void elimdim_destroy(nlopt_opt opt)
+{
+     unsigned i;
+     if (!opt) return;
+
+     free(((elimdim_data*) opt->f_data)->x);
+     free(((elimdim_data*) opt->f_data)->grad);
+     free(opt->f_data); opt->f_data = NULL;
+
+     for (i = 0; i < opt->m; ++i) {
+         free(opt->fc[i].f_data);
+         opt->fc[i].f_data = NULL;
+     }
+     for (i = 0; i < opt->p; ++i) {
+         free(opt->h[i].f_data);
+         opt->h[i].f_data = NULL;
+     }
+
+     nlopt_destroy(opt);
+}
+
+/* return whether to use elimdim wrapping. */
+static int elimdim_wrapcheck(nlopt_opt opt)
+{
+     if (!opt) return 0;
+     if (elimdim_dimension(opt->n, opt->lb, opt->ub) == opt->n) return 0;
+     switch (opt->algorithm) {
+        case NLOPT_GN_DIRECT:
+        case NLOPT_GN_DIRECT_L: 
+        case NLOPT_GN_DIRECT_L_RAND: 
+        case NLOPT_GN_DIRECT_NOSCAL:
+        case NLOPT_GN_DIRECT_L_NOSCAL: 
+        case NLOPT_GN_DIRECT_L_RAND_NOSCAL: 
+        case NLOPT_GN_ORIG_DIRECT:
+        case NLOPT_GN_ORIG_DIRECT_L:
+         case NLOPT_GN_CRS2_LM:
+        case NLOPT_LN_PRAXIS:
+        case NLOPT_LN_COBYLA:
+        case NLOPT_LN_NEWUOA:
+        case NLOPT_LN_NEWUOA_BOUND:
+        case NLOPT_LN_BOBYQA:
+        case NLOPT_LN_NELDERMEAD:
+        case NLOPT_LN_SBPLX:
+        case NLOPT_GN_ISRES:
+        case NLOPT_GN_ESCH:
+        case NLOPT_GD_STOGO:
+         case NLOPT_GD_STOGO_RAND:
+             return 1;
+
+        default: return 0;
+     }
+}
+
+/*********************************************************************/
+
+#define POP(defaultpop) (opt->stochastic_population > 0 ?              \
+                         opt->stochastic_population :                  \
+                         (nlopt_stochastic_population > 0 ?            \
+                         nlopt_stochastic_population : (defaultpop)))
+
+/* unlike nlopt_optimize() below, only handles minimization case */
+static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
+{
+     const double *lb, *ub;
+     nlopt_algorithm algorithm;
+     nlopt_func f; void *f_data;
+     unsigned n, i;
+     int ni;
+     nlopt_stopping stop;
+
+     if (!opt || !x || !minf || !opt->f
+        || opt->maximize) return NLOPT_INVALID_ARGS;
+
+     /* reset stopping flag */
+     nlopt_set_force_stop(opt, 0);
+     opt->force_stop_child = NULL;
+     
+     /* copy a few params to local vars for convenience */
+     n = opt->n;
+     ni = (int) n; /* most of the subroutines take "int" arg */
+     lb = opt->lb; ub = opt->ub;
+     algorithm = opt->algorithm;
+     f = opt->f; f_data = opt->f_data;
+
+     if (n == 0) { /* trivial case: no degrees of freedom */
+         *minf = opt->f(n, x, NULL, opt->f_data);
+         return NLOPT_SUCCESS;
+     }
+
+     *minf = HUGE_VAL;
+     
+     /* make sure rand generator is inited */
+     nlopt_srand_time_default(); /* default is non-deterministic */
+
+     /* check bound constraints */
+     for (i = 0; i < n; ++i)
+         if (lb[i] > ub[i] || x[i] < lb[i] || x[i] > ub[i])
+              return NLOPT_INVALID_ARGS;
+
+     stop.n = n;
+     stop.minf_max = opt->stopval;
+     stop.ftol_rel = opt->ftol_rel;
+     stop.ftol_abs = opt->ftol_abs;
+     stop.xtol_rel = opt->xtol_rel;
+     stop.xtol_abs = opt->xtol_abs;
+     stop.nevals = 0;
+     stop.maxeval = opt->maxeval;
+     stop.maxtime = opt->maxtime;
+     stop.start = nlopt_seconds();
+     stop.force_stop = &(opt->force_stop);
+
+     switch (algorithm) {
+        case NLOPT_GN_DIRECT:
+        case NLOPT_GN_DIRECT_L: 
+        case NLOPT_GN_DIRECT_L_RAND: 
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             return cdirect(ni, f, f_data, 
+                            lb, ub, x, minf, &stop, 0.0, 
+                            (algorithm != NLOPT_GN_DIRECT)
+                            + 3 * (algorithm == NLOPT_GN_DIRECT_L_RAND 
+                                   ? 2 : (algorithm != NLOPT_GN_DIRECT))
+                            + 9 * (algorithm == NLOPT_GN_DIRECT_L_RAND 
+                                   ? 1 : (algorithm != NLOPT_GN_DIRECT)));
+             
+        case NLOPT_GN_DIRECT_NOSCAL:
+        case NLOPT_GN_DIRECT_L_NOSCAL: 
+        case NLOPT_GN_DIRECT_L_RAND_NOSCAL: 
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             return cdirect_unscaled(ni, f, f_data, lb, ub, x, minf, 
+                                     &stop, 0.0, 
+                                     (algorithm != NLOPT_GN_DIRECT)
+                                     + 3 * (algorithm == NLOPT_GN_DIRECT_L_RAND ? 2 : (algorithm != NLOPT_GN_DIRECT))
+                                     + 9 * (algorithm == NLOPT_GN_DIRECT_L_RAND ? 1 : (algorithm != NLOPT_GN_DIRECT)));
+             
+        case NLOPT_GN_ORIG_DIRECT:
+        case NLOPT_GN_ORIG_DIRECT_L: {
+             direct_return_code dret;
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             opt->work = malloc(sizeof(double) *
+                                nlopt_max_constraint_dim(opt->m,
+                                                         opt->fc));
+             if (!opt->work) return NLOPT_OUT_OF_MEMORY;
+             dret = direct_optimize(f_direct, opt, ni, lb, ub, x, minf,
+                                    stop.maxeval, -1,
+                                    stop.start, stop.maxtime,
+                                    0.0, 0.0,
+                                    pow(stop.xtol_rel, (double) n), -1.0,
+                                    stop.force_stop,
+                                    stop.minf_max, 0.0,
+                                    NULL, 
+                                    algorithm == NLOPT_GN_ORIG_DIRECT
+                                    ? DIRECT_ORIGINAL
+                                    : DIRECT_GABLONSKY);
+             free(opt->work); opt->work = NULL;
+             switch (dret) {
+                 case DIRECT_INVALID_BOUNDS:
+                 case DIRECT_MAXFEVAL_TOOBIG:
+                 case DIRECT_INVALID_ARGS:
+                      return NLOPT_INVALID_ARGS;
+                 case DIRECT_INIT_FAILED:
+                 case DIRECT_SAMPLEPOINTS_FAILED:
+                 case DIRECT_SAMPLE_FAILED:
+                      return NLOPT_FAILURE;
+                 case DIRECT_MAXFEVAL_EXCEEDED:
+                 case DIRECT_MAXITER_EXCEEDED:
+                      return NLOPT_MAXEVAL_REACHED;
+                 case DIRECT_MAXTIME_EXCEEDED:
+                      return NLOPT_MAXTIME_REACHED;
+                 case DIRECT_GLOBAL_FOUND:
+                      return NLOPT_MINF_MAX_REACHED;
+                 case DIRECT_VOLTOL:
+                 case DIRECT_SIGMATOL:
+                      return NLOPT_XTOL_REACHED;
+                 case DIRECT_OUT_OF_MEMORY:
+                      return NLOPT_OUT_OF_MEMORY;
+                 case DIRECT_FORCED_STOP:
+                      return NLOPT_FORCED_STOP;
+             }
+             break;
+        }
+
+        case NLOPT_GD_STOGO:
+        case NLOPT_GD_STOGO_RAND:
+#ifdef WITH_CXX
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             if (!stogo_minimize(ni, f, f_data, x, minf, lb, ub, &stop,
+                                 algorithm == NLOPT_GD_STOGO
+                                 ? 0 : (int) POP(2*n)))
+                  return NLOPT_FAILURE;
+             break;
+#else
+             return NLOPT_INVALID_ARGS;
+#endif
+
+#if 0
+             /* lacking a free/open-source license, we no longer use
+                Rowan's code, and instead use by "sbplx" re-implementation */
+        case NLOPT_LN_SUBPLEX: {
+             int iret, freedx = 0;
+             if (!opt->dx) {
+                  freedx = 1;
+                  if (nlopt_set_default_initial_step(opt, x) != NLOPT_SUCCESS)
+                       return NLOPT_OUT_OF_MEMORY;
+             }                
+             iret = nlopt_subplex(f_bound, minf, x, n, opt, &stop, opt->dx);
+             if (freedx) { free(opt->dx); opt->dx = NULL; }
+             switch (iret) {
+                 case -2: return NLOPT_INVALID_ARGS;
+                 case -20: return NLOPT_FORCED_STOP;
+                 case -10: return NLOPT_MAXTIME_REACHED;
+                 case -1: return NLOPT_MAXEVAL_REACHED;
+                 case 0: return NLOPT_XTOL_REACHED;
+                 case 1: return NLOPT_SUCCESS;
+                 case 2: return NLOPT_MINF_MAX_REACHED;
+                 case 20: return NLOPT_FTOL_REACHED;
+                 case -200: return NLOPT_OUT_OF_MEMORY;
+                 default: return NLOPT_FAILURE; /* unknown return code */
+             }
+             break;
+        }
+#endif
+
+        case NLOPT_LN_PRAXIS: {
+             double step;
+             if (initial_step(opt, x, &step) != NLOPT_SUCCESS)
+                  return NLOPT_OUT_OF_MEMORY;
+             return praxis_(0.0, DBL_EPSILON, 
+                            step, ni, x, f_bound, opt, &stop, minf);
+        }
+
+        case NLOPT_LD_LBFGS: 
+             return luksan_plis(ni, f, f_data, lb, ub, x, minf, 
+                                &stop, opt->vector_storage);
+
+        case NLOPT_LD_VAR1: 
+        case NLOPT_LD_VAR2: 
+             return luksan_plip(ni, f, f_data, lb, ub, x, minf, 
+                                &stop, opt->vector_storage,
+                                algorithm == NLOPT_LD_VAR1 ? 1 : 2);
+
+        case NLOPT_LD_TNEWTON: 
+        case NLOPT_LD_TNEWTON_RESTART: 
+        case NLOPT_LD_TNEWTON_PRECOND: 
+        case NLOPT_LD_TNEWTON_PRECOND_RESTART: 
+             return luksan_pnet(ni, f, f_data, lb, ub, x, minf,
+                                &stop, opt->vector_storage,
+                                1 + (algorithm - NLOPT_LD_TNEWTON) % 2,
+                                1 + (algorithm - NLOPT_LD_TNEWTON) / 2);
+
+        case NLOPT_GN_CRS2_LM:
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             return crs_minimize(ni, f, f_data, lb, ub, x, minf, &stop, 
+                                 (int) POP(0), 0);
+
+        case NLOPT_G_MLSL:
+        case NLOPT_G_MLSL_LDS:
+        case NLOPT_GN_MLSL:
+        case NLOPT_GD_MLSL:
+        case NLOPT_GN_MLSL_LDS:
+        case NLOPT_GD_MLSL_LDS: {
+             nlopt_opt local_opt = opt->local_opt;
+             nlopt_result ret;
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             if (!local_opt && (algorithm == NLOPT_G_MLSL 
+                                || algorithm == NLOPT_G_MLSL_LDS))
+                  return NLOPT_INVALID_ARGS;
+             if (!local_opt) { /* default */
+                  nlopt_algorithm local_alg = (algorithm == NLOPT_GN_MLSL ||
+                                               algorithm == NLOPT_GN_MLSL_LDS)
+                       ? nlopt_local_search_alg_nonderiv
+                       : nlopt_local_search_alg_deriv;
+                  /* don't call MLSL recursively! */
+                  if (local_alg >= NLOPT_GN_MLSL
+                      && local_alg <= NLOPT_GD_MLSL_LDS)
+                       local_alg = (algorithm == NLOPT_GN_MLSL ||
+                                    algorithm == NLOPT_GN_MLSL_LDS)
+                            ? NLOPT_LN_COBYLA : NLOPT_LD_MMA;
+                  local_opt = nlopt_create(local_alg, n);
+                  if (!local_opt) return NLOPT_FAILURE;
+                  nlopt_set_ftol_rel(local_opt, opt->ftol_rel);
+                  nlopt_set_ftol_abs(local_opt, opt->ftol_abs);
+                  nlopt_set_xtol_rel(local_opt, opt->xtol_rel);
+                  nlopt_set_xtol_abs(local_opt, opt->xtol_abs);
+                  nlopt_set_maxeval(local_opt, nlopt_local_search_maxeval);
+             }
+             if (opt->dx) nlopt_set_initial_step(local_opt, opt->dx);
+             for (i = 0; i < n && stop.xtol_abs[i] > 0; ++i) ;
+             if (local_opt->ftol_rel <= 0 && local_opt->ftol_abs <= 0 &&
+                 local_opt->xtol_rel <= 0 && i < n) {
+                  /* it is not sensible to call MLSL without *some*
+                     nonzero tolerance for the local search */
+                  nlopt_set_ftol_rel(local_opt, 1e-15);
+                  nlopt_set_xtol_rel(local_opt, 1e-7);
+             }
+             opt->force_stop_child = local_opt;
+             ret = mlsl_minimize(ni, f, f_data, lb, ub, x, minf, &stop,
+                                 local_opt, (int) POP(0),
+                                 algorithm >= NLOPT_GN_MLSL_LDS &&
+                                 algorithm != NLOPT_G_MLSL);
+             opt->force_stop_child = NULL;
+             if (!opt->local_opt) nlopt_destroy(local_opt);
+             return ret;
+        }
+
+        case NLOPT_LD_MMA: case NLOPT_LD_CCSAQ: {
+             nlopt_opt dual_opt;
+             nlopt_result ret;
+#define LO(param, def) (opt->local_opt ? opt->local_opt->param : (def))
+             dual_opt = nlopt_create(LO(algorithm,
+                                        nlopt_local_search_alg_deriv),
+                                     nlopt_count_constraints(opt->m,
+                                                             opt->fc));
+             if (!dual_opt) return NLOPT_FAILURE;
+             nlopt_set_ftol_rel(dual_opt, LO(ftol_rel, 1e-14));
+             nlopt_set_ftol_abs(dual_opt, LO(ftol_abs, 0.0));
+             nlopt_set_maxeval(dual_opt, LO(maxeval, 100000));
+#undef LO
+
+             if (algorithm == NLOPT_LD_MMA)
+                  ret = mma_minimize(n, f, f_data, opt->m, opt->fc,
+                                     lb, ub, x, minf, &stop, dual_opt);
+             else
+                  ret = ccsa_quadratic_minimize(
+                       n, f, f_data, opt->m, opt->fc, opt->pre,
+                       lb, ub, x, minf, &stop, dual_opt);
+             nlopt_destroy(dual_opt);
+             return ret;
+        }
+
+        case NLOPT_LN_COBYLA: {
+             nlopt_result ret;
+             int freedx = 0;
+             if (!opt->dx) {
+                  freedx = 1;
+                  if (nlopt_set_default_initial_step(opt, x) != NLOPT_SUCCESS)
+                       return NLOPT_OUT_OF_MEMORY;
+             }
+             return cobyla_minimize(n, f, f_data, 
+                                    opt->m, opt->fc,
+                                    opt->p, opt->h,
+                                    lb, ub, x, minf, &stop,
+                                    opt->dx);
+             if (freedx) { free(opt->dx); opt->dx = NULL; }
+             return ret;
+        }
+                                    
+        case NLOPT_LN_NEWUOA: {
+             double step;
+             if (initial_step(opt, x, &step) != NLOPT_SUCCESS)
+                  return NLOPT_OUT_OF_MEMORY;
+             return newuoa(ni, 2*n+1, x, 0, 0, step,
+                           &stop, minf, f_noderiv, opt);
+        }
+                                    
+        case NLOPT_LN_NEWUOA_BOUND: {
+             double step;
+             if (initial_step(opt, x, &step) != NLOPT_SUCCESS)
+                  return NLOPT_OUT_OF_MEMORY;
+             return newuoa(ni, 2*n+1, x, lb, ub, step,
+                           &stop, minf, f_noderiv, opt);
+        }
+
+        case NLOPT_LN_BOBYQA: {
+             nlopt_result ret;
+             int freedx = 0;
+             if (!opt->dx) {
+                  freedx = 1;
+                  if (nlopt_set_default_initial_step(opt, x) != NLOPT_SUCCESS)
+                       return NLOPT_OUT_OF_MEMORY;
+             }
+             ret = bobyqa(ni, 2*n+1, x, lb, ub, opt->dx,
+                          &stop, minf, opt->f, opt->f_data);
+             if (freedx) { free(opt->dx); opt->dx = NULL; }
+             return ret;
+        }
+
+        case NLOPT_LN_NELDERMEAD: 
+        case NLOPT_LN_SBPLX: 
+        {
+             nlopt_result ret;
+             int freedx = 0;
+             if (!opt->dx) {
+                  freedx = 1;
+                  if (nlopt_set_default_initial_step(opt, x) != NLOPT_SUCCESS)
+                       return NLOPT_OUT_OF_MEMORY;
+             }
+             if (algorithm == NLOPT_LN_NELDERMEAD)
+                  ret= nldrmd_minimize(ni,f,f_data,lb,ub,x,minf,opt->dx,&stop);
+             else
+                  ret= sbplx_minimize(ni,f,f_data,lb,ub,x,minf,opt->dx,&stop);
+             if (freedx) { free(opt->dx); opt->dx = NULL; }
+             return ret;
+        }
+
+        case NLOPT_AUGLAG:
+        case NLOPT_AUGLAG_EQ:
+        case NLOPT_LN_AUGLAG:
+        case NLOPT_LN_AUGLAG_EQ:
+        case NLOPT_LD_AUGLAG:
+        case NLOPT_LD_AUGLAG_EQ: {
+             nlopt_opt local_opt = opt->local_opt;
+             nlopt_result ret;
+             if ((algorithm == NLOPT_AUGLAG || algorithm == NLOPT_AUGLAG_EQ)
+                 && !local_opt)
+                  return NLOPT_INVALID_ARGS;
+             if (!local_opt) { /* default */
+                  local_opt = nlopt_create(
+                       algorithm == NLOPT_LN_AUGLAG || 
+                       algorithm == NLOPT_LN_AUGLAG_EQ
+                       ? nlopt_local_search_alg_nonderiv
+                       : nlopt_local_search_alg_deriv, n);
+                  if (!local_opt) return NLOPT_FAILURE;
+                  nlopt_set_ftol_rel(local_opt, opt->ftol_rel);
+                  nlopt_set_ftol_abs(local_opt, opt->ftol_abs);
+                  nlopt_set_xtol_rel(local_opt, opt->xtol_rel);
+                  nlopt_set_xtol_abs(local_opt, opt->xtol_abs);
+                  nlopt_set_maxeval(local_opt, nlopt_local_search_maxeval);
+             }
+             if (opt->dx) nlopt_set_initial_step(local_opt, opt->dx);
+             opt->force_stop_child = local_opt;
+             ret = auglag_minimize(ni, f, f_data, 
+                                   opt->m, opt->fc, 
+                                   opt->p, opt->h,
+                                   lb, ub, x, minf, &stop,
+                                   local_opt,
+                                   algorithm == NLOPT_AUGLAG_EQ
+                                   || algorithm == NLOPT_LN_AUGLAG_EQ
+                                   || algorithm == NLOPT_LD_AUGLAG_EQ);
+             opt->force_stop_child = NULL;
+             if (!opt->local_opt) nlopt_destroy(local_opt);
+             return ret;
+        }
+
+        case NLOPT_GN_ISRES:
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             return isres_minimize(ni, f, f_data, 
+                                   (int) (opt->m), opt->fc,
+                                   (int) (opt->p), opt->h,
+                                   lb, ub, x, minf, &stop,
+                                   (int) POP(0));
+
+       case NLOPT_GN_ESCH:
+             if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
+             return chevolutionarystrategy(n, f, f_data, 
+                                           lb, ub, x, minf, &stop,
+                                           (unsigned) POP(0),
+                                           (unsigned) (POP(0)*1.5));
+
+        case NLOPT_LD_SLSQP:
+             return nlopt_slsqp(n, f, f_data,
+                                opt->m, opt->fc,
+                                opt->p, opt->h,
+                                lb, ub, x, minf, &stop);
+                                    
+        default:
+             return NLOPT_INVALID_ARGS;
+     }
+
+     return NLOPT_SUCCESS; /* never reached */
+}
+
+/*********************************************************************/
+
+typedef struct {
+     nlopt_func f;
+     nlopt_precond pre;
+     void *f_data;
+} f_max_data;
+
+/* wrapper for maximizing: just flip the sign of f and grad */
+static double f_max(unsigned n, const double *x, double *grad, void *data)
+{
+     f_max_data *d = (f_max_data *) data;
+     double val = d->f(n, x, grad, d->f_data);
+     if (grad) {
+         unsigned i;
+         for (i = 0; i < n; ++i)
+              grad[i] = -grad[i];
+     }
+     return -val;
+}
+
+static void pre_max(unsigned n, const double *x, const double *v,
+                   double *vpre, void *data)
+{
+     f_max_data *d = (f_max_data *) data;
+     unsigned i;
+     d->pre(n, x, v, vpre, d->f_data);
+     for (i = 0; i < n; ++i) vpre[i] = -vpre[i];
+}
+
+nlopt_result 
+NLOPT_STDCALL nlopt_optimize(nlopt_opt opt, double *x, double *opt_f)
+{
+     nlopt_func f; void *f_data; nlopt_precond pre;
+     f_max_data fmd;
+     int maximize;
+     nlopt_result ret;
+
+     if (!opt || !opt_f || !opt->f) return NLOPT_INVALID_ARGS;
+     f = opt->f; f_data = opt->f_data; pre = opt->pre;
+
+     /* for maximizing, just minimize the f_max wrapper, which 
+       flips the sign of everything */
+     if ((maximize = opt->maximize)) {
+         fmd.f = f; fmd.f_data = f_data; fmd.pre = pre;
+         opt->f = f_max; opt->f_data = &fmd; 
+         if (opt->pre) opt->pre = pre_max;
+         opt->stopval = -opt->stopval;
+         opt->maximize = 0;
+     }
+
+     { /* possibly eliminate lb == ub dimensions for some algorithms */
+         nlopt_opt elim_opt = opt;
+         if (elimdim_wrapcheck(opt)) {
+              elim_opt = elimdim_create(opt);
+              if (!elim_opt) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+              elimdim_shrink(opt->n, x, opt->lb, opt->ub);
+         }
+
+         ret = nlopt_optimize_(elim_opt, x, opt_f);
+
+         if (elim_opt != opt) {
+              elimdim_destroy(elim_opt);
+              elimdim_expand(opt->n, x, opt->lb, opt->ub);
+         }
+     }
+
+done:
+     if (maximize) { /* restore original signs */
+         opt->maximize = maximize;
+         opt->stopval = -opt->stopval;
+         opt->f = f; opt->f_data = f_data; opt->pre = pre;
+         *opt_f = -*opt_f;
+     }
+
+     return ret;
+}
+
+/*********************************************************************/
+
+nlopt_result nlopt_optimize_limited(nlopt_opt opt, double *x, double *minf,
+                                   int maxeval, double maxtime)
+{
+     int save_maxeval;
+     double save_maxtime;
+     nlopt_result ret;
+
+     if (!opt) return NLOPT_INVALID_ARGS;
+
+     save_maxeval = nlopt_get_maxeval(opt);
+     save_maxtime = nlopt_get_maxtime(opt);
+     
+     /* override opt limits if maxeval and/or maxtime are more stringent */
+     if (save_maxeval <= 0 || (maxeval > 0 && maxeval < save_maxeval))
+         nlopt_set_maxeval(opt, maxeval);
+     if (save_maxtime <= 0 || (maxtime > 0 && maxtime < save_maxtime))
+         nlopt_set_maxtime(opt, maxtime);
+
+     ret = nlopt_optimize(opt, x, minf);
+
+     nlopt_set_maxeval(opt, save_maxeval);
+     nlopt_set_maxtime(opt, save_maxtime);
+
+     return ret;
+}
+
+/*********************************************************************/
diff --git a/api/options.c b/api/options.c
new file mode 100644 (file)
index 0000000..d6d1827
--- /dev/null
@@ -0,0 +1,753 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <float.h>
+
+#include "nlopt-internal.h"
+
+/*************************************************************************/
+
+void NLOPT_STDCALL nlopt_destroy(nlopt_opt opt)
+{
+     if (opt) {
+         unsigned i;
+         if (opt->munge_on_destroy) {
+              nlopt_munge munge = opt->munge_on_destroy;
+              munge(opt->f_data);
+              for (i = 0; i < opt->m; ++i)
+                   munge(opt->fc[i].f_data);
+              for (i = 0; i < opt->p; ++i)
+                   munge(opt->h[i].f_data);
+         }
+         for (i = 0; i < opt->m; ++i)
+              free(opt->fc[i].tol);
+         for (i = 0; i < opt->p; ++i)
+              free(opt->h[i].tol);
+         free(opt->lb); free(opt->ub);
+         free(opt->xtol_abs);
+         free(opt->fc);
+         free(opt->h);
+         nlopt_destroy(opt->local_opt);
+         free(opt->dx);
+         free(opt->work);
+         free(opt);
+     }
+}
+
+nlopt_opt NLOPT_STDCALL nlopt_create(nlopt_algorithm algorithm, unsigned n)
+{
+     nlopt_opt opt;
+
+     if (((int) algorithm) < 0 || algorithm >= NLOPT_NUM_ALGORITHMS)
+         return NULL;
+
+     opt = (nlopt_opt) malloc(sizeof(struct nlopt_opt_s));
+     if (opt) {
+         opt->algorithm = algorithm;
+         opt->n = n;
+         opt->f = NULL; opt->f_data = NULL; opt->pre = NULL;
+         opt->maximize = 0;
+         opt->munge_on_destroy = opt->munge_on_copy = NULL;
+
+         opt->lb = opt->ub = NULL;
+         opt->m = opt->m_alloc = 0;
+         opt->fc = NULL;
+         opt->p = opt->p_alloc = 0;
+         opt->h = NULL;
+
+         opt->stopval = -HUGE_VAL;
+         opt->ftol_rel = opt->ftol_abs = 0;
+         opt->xtol_rel = 0; opt->xtol_abs = NULL;
+         opt->maxeval = 0;
+         opt->maxtime = 0;
+         opt->force_stop = 0;
+         opt->force_stop_child = NULL;
+
+         opt->local_opt = NULL;
+         opt->stochastic_population = 0;
+         opt->vector_storage = 0;
+         opt->dx = NULL;
+         opt->work = NULL;
+
+         if (n > 0) {
+              opt->lb = (double *) malloc(sizeof(double) * (n));
+              if (!opt->lb) goto oom;
+              opt->ub = (double *) malloc(sizeof(double) * (n));
+              if (!opt->ub) goto oom;
+              opt->xtol_abs = (double *) malloc(sizeof(double) * (n));
+              if (!opt->xtol_abs) goto oom;
+              nlopt_set_lower_bounds1(opt, -HUGE_VAL);
+              nlopt_set_upper_bounds1(opt, +HUGE_VAL);
+              nlopt_set_xtol_abs1(opt, 0.0);
+         }
+     }
+
+     return opt;
+
+oom:
+     nlopt_destroy(opt);
+     return NULL;
+}
+
+nlopt_opt NLOPT_STDCALL nlopt_copy(const nlopt_opt opt)
+{
+     nlopt_opt nopt = NULL;
+     unsigned i;
+     if (opt) {
+         nlopt_munge munge;
+         nopt = (nlopt_opt) malloc(sizeof(struct nlopt_opt_s));
+         *nopt = *opt;
+         nopt->lb = nopt->ub = nopt->xtol_abs = NULL;
+         nopt->fc = nopt->h = NULL;
+         nopt->m_alloc = nopt->p_alloc = 0;
+         nopt->local_opt = NULL;
+         nopt->dx = NULL;
+         nopt->work = NULL;
+         opt->force_stop_child = NULL;
+
+         munge = nopt->munge_on_copy;
+         if (munge && nopt->f_data)
+              if (!(nopt->f_data = munge(nopt->f_data))) goto oom;
+
+         if (opt->n > 0) {
+              nopt->lb = (double *) malloc(sizeof(double) * (opt->n));
+              if (!opt->lb) goto oom;
+              nopt->ub = (double *) malloc(sizeof(double) * (opt->n));
+              if (!opt->ub) goto oom;
+              nopt->xtol_abs = (double *) malloc(sizeof(double) * (opt->n));
+              if (!opt->xtol_abs) goto oom;
+              
+              memcpy(nopt->lb, opt->lb, sizeof(double) * (opt->n));
+              memcpy(nopt->ub, opt->ub, sizeof(double) * (opt->n));
+              memcpy(nopt->xtol_abs, opt->xtol_abs, sizeof(double) * (opt->n));
+         }
+
+         if (opt->m) {
+              nopt->m_alloc = opt->m;
+              nopt->fc = (nlopt_constraint *) malloc(sizeof(nlopt_constraint)
+                                                     * (opt->m));
+              if (!nopt->fc) goto oom;
+              memcpy(nopt->fc, opt->fc, sizeof(nlopt_constraint) * (opt->m));
+              for (i = 0; i < opt->m; ++i) nopt->fc[i].tol = NULL;
+              if (munge)
+                   for (i = 0; i < opt->m; ++i)
+                        if (nopt->fc[i].f_data &&
+                            !(nopt->fc[i].f_data
+                              = munge(nopt->fc[i].f_data)))
+                             goto oom;
+              for (i = 0; i < opt->m; ++i)
+                   if (opt->fc[i].tol) {
+                        nopt->fc[i].tol = (double *) malloc(sizeof(double)
+                                                            * nopt->fc[i].m);
+                        if (!nopt->fc[i].tol) goto oom;
+                        memcpy(nopt->fc[i].tol, opt->fc[i].tol,
+                               sizeof(double) * nopt->fc[i].m);
+                   }
+         }
+
+         if (opt->p) {
+              nopt->p_alloc = opt->p;
+              nopt->h = (nlopt_constraint *) malloc(sizeof(nlopt_constraint)
+                                                    * (opt->p));
+              if (!nopt->h) goto oom;
+              memcpy(nopt->h, opt->h, sizeof(nlopt_constraint) * (opt->p));
+              for (i = 0; i < opt->p; ++i) nopt->h[i].tol = NULL;
+              if (munge)
+                   for (i = 0; i < opt->p; ++i)
+                        if (nopt->h[i].f_data &&
+                            !(nopt->h[i].f_data
+                              = munge(nopt->h[i].f_data)))
+                             goto oom;
+              for (i = 0; i < opt->p; ++i)
+                   if (opt->h[i].tol) {
+                        nopt->h[i].tol = (double *) malloc(sizeof(double)
+                                                            * nopt->h[i].m);
+                        if (!nopt->h[i].tol) goto oom;
+                        memcpy(nopt->h[i].tol, opt->h[i].tol,
+                               sizeof(double) * nopt->h[i].m);
+                   }
+         }
+
+         if (opt->local_opt) {
+              nopt->local_opt = nlopt_copy(opt->local_opt);
+              if (!nopt->local_opt) goto oom;
+         }
+
+         if (opt->dx) {
+              nopt->dx = (double *) malloc(sizeof(double) * (opt->n));
+              if (!nopt->dx) goto oom;
+              memcpy(nopt->dx, opt->dx, sizeof(double) * (opt->n));
+         }
+     }
+     return nopt;
+
+oom:
+     nopt->munge_on_destroy = NULL; // better to leak mem than crash
+     nlopt_destroy(nopt);
+     return NULL;
+}
+
+/*************************************************************************/
+
+nlopt_result NLOPT_STDCALL nlopt_set_precond_min_objective(nlopt_opt opt,
+                                                          nlopt_func f, 
+                                                          nlopt_precond pre,
+                                                          void *f_data)
+{
+     if (opt) {
+         if (opt->munge_on_destroy) opt->munge_on_destroy(opt->f_data);
+         opt->f = f; opt->f_data = f_data; opt->pre = pre;
+         opt->maximize = 0;
+         if (nlopt_isinf(opt->stopval) && opt->stopval > 0)
+              opt->stopval = -HUGE_VAL; /* switch default from max to min */
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result NLOPT_STDCALL nlopt_set_min_objective(nlopt_opt opt,
+                                                  nlopt_func f, void *f_data)
+{
+     return nlopt_set_precond_min_objective(opt, f, NULL, f_data);
+}
+
+nlopt_result NLOPT_STDCALL nlopt_set_precond_max_objective(nlopt_opt opt, 
+                                                          nlopt_func f, 
+                                                          nlopt_precond pre,
+                                                          void *f_data)
+{
+     if (opt) {
+         if (opt->munge_on_destroy) opt->munge_on_destroy(opt->f_data);
+         opt->f = f; opt->f_data = f_data; opt->pre = pre;
+         opt->maximize = 1;
+         if (nlopt_isinf(opt->stopval) && opt->stopval < 0)
+              opt->stopval = +HUGE_VAL; /* switch default from min to max */
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result NLOPT_STDCALL nlopt_set_max_objective(nlopt_opt opt,
+                                                  nlopt_func f, void *f_data)
+{
+     return nlopt_set_precond_max_objective(opt, f, NULL, f_data);
+}
+
+/*************************************************************************/
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_lower_bounds(nlopt_opt opt, const double *lb)
+{
+     if (opt && (opt->n == 0 || lb)) {
+         memcpy(opt->lb, lb, sizeof(double) * (opt->n));
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_lower_bounds1(nlopt_opt opt, double lb)
+{
+     if (opt) {
+         unsigned i;
+         for (i = 0; i < opt->n; ++i)
+              opt->lb[i] = lb;
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_get_lower_bounds(const nlopt_opt opt, double *lb)
+{
+     if (opt && (opt->n == 0 || lb)) {
+         memcpy(lb, opt->lb, sizeof(double) * (opt->n));
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_upper_bounds(nlopt_opt opt, const double *ub)
+{
+     if (opt && (opt->n == 0 || ub)) {
+         memcpy(opt->ub, ub, sizeof(double) * (opt->n));
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_upper_bounds1(nlopt_opt opt, double ub)
+{
+     if (opt) {
+         unsigned i;
+         for (i = 0; i < opt->n; ++i)
+              opt->ub[i] = ub;
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_get_upper_bounds(const nlopt_opt opt, double *ub)
+{
+     if (opt && (opt->n == 0 || ub)) {
+         memcpy(ub, opt->ub, sizeof(double) * (opt->n));
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+/*************************************************************************/
+
+#define AUGLAG_ALG(a) ((a) == NLOPT_AUGLAG ||          \
+                      (a) == NLOPT_AUGLAG_EQ ||        \
+                      (a) == NLOPT_LN_AUGLAG ||        \
+                      (a) == NLOPT_LN_AUGLAG_EQ ||     \
+                      (a) == NLOPT_LD_AUGLAG ||        \
+                      (a) == NLOPT_LD_AUGLAG_EQ)
+
+nlopt_result
+NLOPT_STDCALL nlopt_remove_inequality_constraints(nlopt_opt opt)
+{
+     unsigned i;
+     if (!opt) return NLOPT_INVALID_ARGS;
+     if (opt->munge_on_destroy) {
+         nlopt_munge munge = opt->munge_on_destroy;
+         for (i = 0; i < opt->m; ++i)
+              munge(opt->fc[i].f_data);
+     }
+     for (i = 0; i < opt->m; ++i)
+         free(opt->fc[i].tol);
+     free(opt->fc);
+     opt->fc = NULL;
+     opt->m = opt->m_alloc = 0;
+     return NLOPT_SUCCESS;
+}
+
+static nlopt_result add_constraint(unsigned *m, unsigned *m_alloc,
+                                  nlopt_constraint **c,
+                                  unsigned fm, nlopt_func fc, nlopt_mfunc mfc,
+                                  nlopt_precond pre,
+                                  void *fc_data,
+                                  const double *tol)
+{
+     double *tolcopy;
+     unsigned i;
+
+     if ((fc && mfc) || (fc && fm != 1) || (!fc && !mfc))
+         return NLOPT_INVALID_ARGS;
+     if (tol) 
+         for (i = 0; i < fm; ++i) if (tol[i] < 0) return NLOPT_INVALID_ARGS;
+     
+     tolcopy = (double *) malloc(sizeof(double) * fm);
+     if (fm && !tolcopy) return NLOPT_OUT_OF_MEMORY;
+     if (tol)
+         memcpy(tolcopy, tol, sizeof(double) * fm);
+     else
+         for (i = 0; i < fm; ++i) tolcopy[i] = 0;
+
+     *m += 1;
+     if (*m > *m_alloc) {
+         /* allocate by repeated doubling so that 
+            we end up with O(log m) mallocs rather than O(m). */
+         *m_alloc = 2 * (*m);
+         *c = (nlopt_constraint *) realloc(*c,
+                                           sizeof(nlopt_constraint)
+                                           * (*m_alloc));
+         if (!*c) {
+              *m_alloc = *m = 0;
+              free(tolcopy);
+              return NLOPT_OUT_OF_MEMORY;
+         }
+     }
+     
+     (*c)[*m - 1].m = fm;
+     (*c)[*m - 1].f = fc;
+     (*c)[*m - 1].pre = pre;
+     (*c)[*m - 1].mf = mfc;
+     (*c)[*m - 1].f_data = fc_data;
+     (*c)[*m - 1].tol = tolcopy;
+     return NLOPT_SUCCESS;
+}
+
+static int inequality_ok(nlopt_algorithm algorithm) {
+     /* nonlinear constraints are only supported with some algorithms */
+     return (algorithm == NLOPT_LD_MMA || algorithm == NLOPT_LD_CCSAQ 
+            || algorithm == NLOPT_LD_SLSQP
+            || algorithm == NLOPT_LN_COBYLA
+            || AUGLAG_ALG(algorithm) 
+            || algorithm == NLOPT_GN_ISRES
+            || algorithm == NLOPT_GN_ORIG_DIRECT
+            || algorithm == NLOPT_GN_ORIG_DIRECT_L);
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_inequality_mconstraint(nlopt_opt opt, unsigned m,
+                                              nlopt_mfunc fc, void *fc_data,
+                                              const double *tol)
+{
+     nlopt_result ret;
+     if (!m) { /* empty constraints are always ok */
+         if (opt && opt->munge_on_destroy) opt->munge_on_destroy(fc_data);
+         return NLOPT_SUCCESS;
+     }
+     if (!opt || !inequality_ok(opt->algorithm)) ret = NLOPT_INVALID_ARGS;
+     else ret = add_constraint(&opt->m, &opt->m_alloc, &opt->fc,
+                              m, NULL, fc, NULL, fc_data, tol);
+     if (ret < 0 && opt && opt->munge_on_destroy)
+         opt->munge_on_destroy(fc_data);
+     return ret;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_precond_inequality_constraint(nlopt_opt opt,
+                                                     nlopt_func fc, 
+                                                     nlopt_precond pre,
+                                                     void *fc_data,
+                                                     double tol)
+{
+     nlopt_result ret;
+     if (!opt || !inequality_ok(opt->algorithm)) ret = NLOPT_INVALID_ARGS;
+     else ret = add_constraint(&opt->m, &opt->m_alloc, &opt->fc,
+                              1, fc, NULL, pre, fc_data, &tol);
+     if (ret < 0 && opt && opt->munge_on_destroy)
+         opt->munge_on_destroy(fc_data);
+     return ret;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_inequality_constraint(nlopt_opt opt,
+                                             nlopt_func fc, void *fc_data,
+                                             double tol)
+{
+     return nlopt_add_precond_inequality_constraint(opt, fc, NULL, fc_data,
+                                                   tol);
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_remove_equality_constraints(nlopt_opt opt)
+{
+     unsigned i;
+     if (!opt) return NLOPT_INVALID_ARGS;
+     if (opt->munge_on_destroy) {
+         nlopt_munge munge = opt->munge_on_destroy;
+         for (i = 0; i < opt->p; ++i)
+              munge(opt->h[i].f_data);
+     }
+     for (i = 0; i < opt->p; ++i)
+         free(opt->h[i].tol);
+     free(opt->h);
+     opt->h = NULL;
+     opt->p = opt->p_alloc = 0;
+     return NLOPT_SUCCESS;
+}
+
+static int equality_ok(nlopt_algorithm algorithm) {
+     /* equality constraints (h(x) = 0) only via some algorithms */
+     return (AUGLAG_ALG(algorithm) 
+            || algorithm == NLOPT_LD_SLSQP
+            || algorithm == NLOPT_GN_ISRES
+            || algorithm == NLOPT_LN_COBYLA);
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_equality_mconstraint(nlopt_opt opt, unsigned m,
+                                            nlopt_mfunc fc, void *fc_data,
+                                            const double *tol)
+{
+     nlopt_result ret;
+     if (!m) { /* empty constraints are always ok */
+         if (opt && opt->munge_on_destroy) opt->munge_on_destroy(fc_data);
+         return NLOPT_SUCCESS;
+     }
+     if (!opt || !equality_ok(opt->algorithm)
+        || nlopt_count_constraints(opt->p, opt->h) + m > opt->n) 
+         ret = NLOPT_INVALID_ARGS;
+     else ret = add_constraint(&opt->p, &opt->p_alloc, &opt->h,
+                              m, NULL, fc, NULL, fc_data, tol);
+     if (ret < 0 && opt && opt->munge_on_destroy)
+         opt->munge_on_destroy(fc_data);
+     return ret;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_precond_equality_constraint(nlopt_opt opt,
+                                                   nlopt_func fc,
+                                                   nlopt_precond pre,
+                                                   void *fc_data,
+                                                   double tol)
+{
+     nlopt_result ret;
+     if (!opt || !equality_ok(opt->algorithm)
+        || nlopt_count_constraints(opt->p, opt->h) + 1 > opt->n)
+         ret = NLOPT_INVALID_ARGS;
+     else ret = add_constraint(&opt->p, &opt->p_alloc, &opt->h,
+                              1, fc, NULL, pre, fc_data, &tol);
+     if (ret < 0 && opt && opt->munge_on_destroy)
+         opt->munge_on_destroy(fc_data);
+     return ret;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_equality_constraint(nlopt_opt opt,
+                                           nlopt_func fc, void *fc_data,
+                                           double tol)
+{
+     return nlopt_add_precond_equality_constraint(opt, fc, NULL, fc_data, tol);
+}
+
+/*************************************************************************/
+
+#define SET(param, T, arg)                                             \
+   nlopt_result NLOPT_STDCALL nlopt_set_##param(nlopt_opt opt, T arg)  \
+   {                                                                   \
+       if (opt) {                                                      \
+            opt->arg = arg;                                            \
+            return NLOPT_SUCCESS;                                      \
+       }                                                               \
+       return NLOPT_INVALID_ARGS;                                      \
+   }
+
+
+#define GET(param, T, arg) T NLOPT_STDCALL     \
+   nlopt_get_##param(const nlopt_opt opt) {    \
+        return opt->arg;                       \
+   }
+
+#define GETSET(param, T, arg) GET(param, T, arg) SET(param, T, arg)
+
+GETSET(stopval, double, stopval)
+
+GETSET(ftol_rel, double, ftol_rel)
+GETSET(ftol_abs, double, ftol_abs)
+GETSET(xtol_rel, double, xtol_rel)
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_xtol_abs(nlopt_opt opt, const double *xtol_abs)
+{
+     if (opt) {
+         memcpy(opt->xtol_abs, xtol_abs, opt->n * sizeof(double));
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_xtol_abs1(nlopt_opt opt, double xtol_abs)
+{
+     if (opt) {
+         unsigned i;
+         for (i = 0; i < opt->n; ++i)
+              opt->xtol_abs[i] = xtol_abs;
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_get_xtol_abs(const nlopt_opt opt, double *xtol_abs)
+{
+     memcpy(xtol_abs, opt->xtol_abs, opt->n * sizeof(double));
+     return NLOPT_SUCCESS;
+}
+
+GETSET(maxeval, int, maxeval)
+
+GETSET(maxtime, double, maxtime)
+
+/*************************************************************************/
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_force_stop(nlopt_opt opt, int force_stop)
+{
+     if (opt) {
+         opt->force_stop = force_stop;
+         if (opt->force_stop_child)
+              return nlopt_set_force_stop(opt->force_stop_child, force_stop);
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+GET(force_stop, int, force_stop)
+nlopt_result NLOPT_STDCALL nlopt_force_stop(nlopt_opt opt) { 
+     return nlopt_set_force_stop(opt, 1); 
+}
+
+/*************************************************************************/
+
+GET(algorithm, nlopt_algorithm, algorithm)
+GET(dimension, unsigned, n)
+
+/*************************************************************************/
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_local_optimizer(nlopt_opt opt,
+                                       const nlopt_opt local_opt)
+{
+     if (opt) {
+         if (local_opt && local_opt->n != opt->n) return NLOPT_INVALID_ARGS;
+         nlopt_destroy(opt->local_opt);
+         opt->local_opt = nlopt_copy(local_opt);
+         if (local_opt) {
+              if (!opt->local_opt) return NLOPT_OUT_OF_MEMORY;
+              nlopt_set_lower_bounds(opt->local_opt, opt->lb);
+              nlopt_set_upper_bounds(opt->local_opt, opt->ub);
+              nlopt_remove_inequality_constraints(opt->local_opt);
+              nlopt_remove_equality_constraints(opt->local_opt);
+              nlopt_set_min_objective(opt->local_opt, NULL, NULL);
+              nlopt_set_munge(opt->local_opt, NULL, NULL);
+              opt->local_opt->force_stop = 0;
+         }
+         return NLOPT_SUCCESS;
+     }
+     return NLOPT_INVALID_ARGS;
+}
+
+/*************************************************************************/
+
+GETSET(population, unsigned, stochastic_population)
+GETSET(vector_storage, unsigned, vector_storage)
+
+/*************************************************************************/
+
+nlopt_result NLOPT_STDCALL nlopt_set_initial_step1(nlopt_opt opt, double dx)
+{
+     unsigned i;
+     if (!opt || dx == 0) return NLOPT_INVALID_ARGS;
+     if (!opt->dx && opt->n > 0) {
+         opt->dx = (double *) malloc(sizeof(double) * (opt->n));
+         if (!opt->dx) return NLOPT_OUT_OF_MEMORY;
+     }
+     for (i = 0; i < opt->n; ++i) opt->dx[i] = dx;
+     return NLOPT_SUCCESS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_initial_step(nlopt_opt opt, const double *dx)
+{
+     unsigned i;
+     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;
+     memcpy(opt->dx, dx, sizeof(double) * (opt->n));
+     return NLOPT_SUCCESS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_get_initial_step(const nlopt_opt opt, const double *x, 
+                                    double *dx)
+{
+     if (!opt) return NLOPT_INVALID_ARGS;
+     if (!opt->n) return NLOPT_SUCCESS;
+     if (!opt->dx) {
+         nlopt_opt o = (nlopt_opt) opt; /* discard const temporarily */
+         nlopt_result ret = nlopt_set_default_initial_step(o, x);
+         if (ret != NLOPT_SUCCESS) return ret;
+         memcpy(dx, o->dx, sizeof(double) * (opt->n));
+         free(o->dx); o->dx = NULL; /* don't save, since x-dependent */
+     }
+     else
+         memcpy(dx, opt->dx, sizeof(double) * (opt->n));
+     return NLOPT_SUCCESS;
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_set_default_initial_step(nlopt_opt opt, const double *x)
+{
+     const double *lb, *ub;
+     unsigned i;
+
+     if (!opt || !x) return NLOPT_INVALID_ARGS;
+     lb = opt->lb; ub = opt->ub;
+
+     if (!opt->dx && nlopt_set_initial_step1(opt, 1) == NLOPT_OUT_OF_MEMORY)
+         return NLOPT_OUT_OF_MEMORY;
+
+     /* crude heuristics for initial step size of nonderivative algorithms */
+     for (i = 0; i < opt->n; ++i) {
+         double step = HUGE_VAL;
+
+         if (!nlopt_isinf(ub[i]) && !nlopt_isinf(lb[i])
+             && (ub[i] - lb[i]) * 0.25 < step && ub[i] > lb[i])
+              step = (ub[i] - lb[i]) * 0.25;
+         if (!nlopt_isinf(ub[i]) 
+             && ub[i] - x[i] < step && ub[i] > x[i])
+              step = (ub[i] - x[i]) * 0.75;
+         if (!nlopt_isinf(lb[i]) 
+             && x[i] - lb[i] < step && x[i] > lb[i])
+              step = (x[i] - lb[i]) * 0.75;
+
+         if (nlopt_isinf(step)) {
+              if (!nlopt_isinf(ub[i]) 
+                  && fabs(ub[i] - x[i]) < fabs(step))
+                   step = (ub[i] - x[i]) * 1.1;
+              if (!nlopt_isinf(lb[i]) 
+                  && fabs(x[i] - lb[i]) < fabs(step))
+                   step = (x[i] - lb[i]) * 1.1;
+         }
+         if (nlopt_isinf(step) || step == 0) {
+              step = x[i];
+         }
+         if (nlopt_isinf(step) || step == 0)
+              step = 1;
+         
+         opt->dx[i] = step;
+     }
+     return NLOPT_SUCCESS;
+}
+
+/*************************************************************************/
+
+void NLOPT_STDCALL nlopt_set_munge(nlopt_opt opt,
+                                  nlopt_munge munge_on_destroy,
+                                  nlopt_munge munge_on_copy) {
+     if (opt) {
+         opt->munge_on_destroy = munge_on_destroy;
+         opt->munge_on_copy = munge_on_copy;
+     }
+}
+
+void NLOPT_STDCALL nlopt_munge_data(nlopt_opt opt,
+                                    nlopt_munge2 munge, void *data) {
+     if (opt && munge) {
+          unsigned i;
+          opt->f_data = munge(opt->f_data, data);
+          for (i = 0; i < opt->m; ++i)
+               opt->fc[i].f_data = munge(opt->fc[i].f_data, data);
+          for (i = 0; i < opt->p; ++i)
+               opt->h[i].f_data = munge(opt->h[i].f_data, data);
+     }
+}
+
+/*************************************************************************/
diff --git a/auglag/Makefile.am b/auglag/Makefile.am
new file mode 100644 (file)
index 0000000..7795415
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libauglag.la
+libauglag_la_SOURCES = auglag.c auglag.h
+
+EXTRA_DIST = README
diff --git a/auglag/Makefile.in b/auglag/Makefile.in
new file mode 100644 (file)
index 0000000..580732b
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = auglag
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libauglag_la_LIBADD =
+am_libauglag_la_OBJECTS = auglag.lo
+libauglag_la_OBJECTS = $(am_libauglag_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libauglag_la_SOURCES)
+DIST_SOURCES = $(libauglag_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libauglag.la
+libauglag_la_SOURCES = auglag.c auglag.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu auglag/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu auglag/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libauglag.la: $(libauglag_la_OBJECTS) $(libauglag_la_DEPENDENCIES) $(EXTRA_libauglag_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libauglag_la_OBJECTS) $(libauglag_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auglag.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/auglag/README b/auglag/README
new file mode 100644 (file)
index 0000000..e1f8c2f
--- /dev/null
@@ -0,0 +1,25 @@
+This directory contains my implementation of the "augmented Lagrangian"
+method to express constrained optimization problems (including equality
+constraints) in terms of unconstrained optimization problems (or just
+inequality constraints, or just box constraints).
+
+I used the algorithm description (but no source code) from the outline
+in the paper:
+
+       E. G. Birgin and J. M. Martinez, "Improving ultimate convergence
+       of an augmented Lagrangian method," Optimization Methods and
+       Software vol. 23, no. 2, p. 177-195 (2008). 
+
+       http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.72.6121
+
+(The authors of this paper have their own free-software implementation
+of this idea and its variations, in the TANGO project:
+http://www.ime.usp.br/~egbirgin/tango/ ....I did *not* use any code
+from TANGO here, or even look at the TANGO code.  TANGO is GPLed, and
+I'm trying to keep NLopt at most LGPLed.)
+
+The code in this directory is under the same MIT license as the rest
+of my code in NLopt (see ../COPYRIGHT).
+
+Steven G. Johnson
+November 2008
diff --git a/auglag/auglag.c b/auglag/auglag.c
new file mode 100644 (file)
index 0000000..f43934e
--- /dev/null
@@ -0,0 +1,289 @@
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "auglag.h"
+
+int auglag_verbose = 0;
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+/***************************************************************************/
+
+typedef struct {
+     nlopt_func f; void *f_data;
+     int m, mm; nlopt_constraint *fc;
+     int p, pp; nlopt_constraint *h;
+     double rho, *lambda, *mu;
+     double *restmp, *gradtmp;
+     nlopt_stopping *stop;
+} auglag_data;
+
+/* the augmented lagrangian objective function */
+static double auglag(unsigned n, const double *x, double *grad, void *data)
+{
+     auglag_data *d = (auglag_data *) data;
+     double *gradtmp = grad ? d->gradtmp : NULL;
+     double *restmp = d->restmp;
+     double rho = d->rho;
+     const double *lambda = d->lambda, *mu = d->mu;
+     double L;
+     int i, ii;
+     unsigned j, k;
+
+     L = d->f(n, x, grad, d->f_data);
+     d->stop->nevals++;
+     if (nlopt_stop_forced(d->stop)) return L;
+
+     for (ii = i = 0; i < d->p; ++i) {
+         nlopt_eval_constraint(restmp, gradtmp, d->h + i, n, x);
+         if (nlopt_stop_forced(d->stop)) return L;
+         for (k = 0; k < d->h[i].m; ++k) {
+              double h = restmp[k] + lambda[ii++] / rho;
+              L += 0.5 * rho * h*h;
+              if (grad) for (j = 0; j < n; ++j) 
+                             grad[j] += (rho * h) * gradtmp[k*n + j];
+         }
+     }
+
+     for (ii = i = 0; i < d->m; ++i) {
+         nlopt_eval_constraint(restmp, gradtmp, d->fc + i, n, x);
+         if (nlopt_stop_forced(d->stop)) return L;
+         for (k = 0; k < d->fc[i].m; ++k) {
+              double fc = restmp[k] + mu[ii++] / rho;
+              if (fc > 0) {
+                   L += 0.5 * rho * fc*fc;
+                   if (grad) for (j = 0; j < n; ++j) 
+                                  grad[j] += (rho * fc) * gradtmp[k*n + j];
+              }
+         }
+     }
+
+     return L;
+}
+
+/***************************************************************************/
+
+nlopt_result auglag_minimize(int n, nlopt_func f, void *f_data,
+                            int m, nlopt_constraint *fc,
+                            int p, nlopt_constraint *h,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            nlopt_stopping *stop,
+                            nlopt_opt sub_opt, int sub_has_fc)
+{
+     auglag_data d;
+     nlopt_result ret = NLOPT_SUCCESS;
+     double ICM = HUGE_VAL, minf_penalty = HUGE_VAL, penalty;
+     double *xcur = NULL, fcur;
+     int i, ii, k, feasible, minf_feasible = 0;
+     int auglag_iters = 0;
+     int max_constraint_dim;
+
+     /* magic parameters from Birgin & Martinez */
+     const double tau = 0.5, gam = 10;
+     const double lam_min = -1e20, lam_max = 1e20, mu_max = 1e20;
+
+     d.f = f; d.f_data = f_data;
+     d.m = m; d.fc = fc;
+     d.p = p; d.h = h;
+     d.stop = stop;
+
+     /* whether we handle inequality constraints via the augmented
+       Lagrangian penalty function, or directly in the sub-algorithm */
+     if (sub_has_fc)
+         d.m = 0;
+     else
+         m = 0;
+
+     max_constraint_dim = MAX(nlopt_max_constraint_dim(d.m, fc),
+                             nlopt_max_constraint_dim(d.p, h));
+
+     d.mm = nlopt_count_constraints(d.m, fc);
+     d.pp = nlopt_count_constraints(d.p, h);
+
+     ret = nlopt_set_min_objective(sub_opt, auglag, &d); if (ret<0) return ret;
+     ret = nlopt_set_lower_bounds(sub_opt, lb); if (ret<0) return ret;
+     ret = nlopt_set_upper_bounds(sub_opt, ub); if (ret<0) return ret;
+     ret = nlopt_set_stopval(sub_opt, 
+                            d.m==0 && d.p==0 ? stop->minf_max : -HUGE_VAL);
+     if (ret<0) return ret;
+     ret = nlopt_remove_inequality_constraints(sub_opt); if (ret<0) return ret;
+     ret = nlopt_remove_equality_constraints(sub_opt); if (ret<0) return ret;
+     for (i = 0; i < m; ++i) {
+         if (fc[i].f)
+              ret = nlopt_add_inequality_constraint(sub_opt,
+                                                    fc[i].f, fc[i].f_data,
+                                                    fc[i].tol[0]);
+         else
+              ret = nlopt_add_inequality_mconstraint(sub_opt, fc[i].m, 
+                                                     fc[i].mf, fc[i].f_data,
+                                                     fc[i].tol);
+         if (ret < 0) return ret;
+     }
+
+     xcur = (double *) malloc(sizeof(double) * (n
+                                               + max_constraint_dim * (1 + n)
+                                               + d.pp + d.mm));
+     if (!xcur) return NLOPT_OUT_OF_MEMORY;
+     memcpy(xcur, x, sizeof(double) * n);
+
+     d.restmp = xcur + n;
+     d.gradtmp = d.restmp + max_constraint_dim;
+     memset(d.gradtmp, 0, sizeof(double) * (n*max_constraint_dim + d.pp+d.mm));
+     d.lambda = d.gradtmp + n * max_constraint_dim;
+     d.mu = d.lambda + d.pp;
+
+     *minf = HUGE_VAL;
+
+     /* starting rho suggested by B & M */
+     if (d.p > 0 || d.m > 0) {
+         double con2 = 0;
+         d.stop->nevals++;
+         fcur = f(n, xcur, NULL, f_data);
+         if (nlopt_stop_forced(stop)) {
+              ret = NLOPT_FORCED_STOP; goto done; }
+         penalty = 0;
+         feasible = 1;
+         for (i = 0; i < d.p; ++i) {
+              nlopt_eval_constraint(d.restmp, NULL, d.h + i, n, xcur);
+              if (nlopt_stop_forced(stop)) {
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              for (k = 0; k < d.h[i].m; ++k) {
+                   double hi = d.restmp[k];
+                   penalty += fabs(hi);
+                   feasible = feasible && fabs(hi) <= h[i].tol[k];
+                   con2 += hi * hi;
+              }
+         }
+         for (i = 0; i < d.m; ++i) {
+              nlopt_eval_constraint(d.restmp, NULL, d.fc + i, n, xcur);
+              if (nlopt_stop_forced(stop)) {
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              for (k = 0; k < d.fc[i].m; ++k) {
+                   double fci = d.restmp[k];
+                   penalty += fci > 0 ? fci : 0;
+                   feasible = feasible && fci <= fc[i].tol[k];
+                   if (fci > 0) con2 += fci * fci;
+              }
+         }
+         *minf = fcur;
+         minf_penalty = penalty;
+         minf_feasible = feasible;
+         d.rho = MAX(1e-6, MIN(10, 2 * fabs(*minf) / con2));
+     }
+     else
+         d.rho = 1; /* whatever, doesn't matter */
+
+     if (auglag_verbose) {
+         printf("auglag: initial rho=%g\nauglag initial lambda=", d.rho);
+         for (i = 0; i < d.pp; ++i) printf(" %g", d.lambda[i]);
+         printf("\nauglag initial mu = ");
+         for (i = 0; i < d.mm; ++i) printf(" %g", d.mu[i]);
+         printf("\n");
+     }
+
+     do {
+         double prev_ICM = ICM;
+         
+         ret = nlopt_optimize_limited(sub_opt, xcur, &fcur,
+                                      stop->maxeval - stop->nevals,
+                                      stop->maxtime - (nlopt_seconds() 
+                                                       - stop->start));
+         if (auglag_verbose)
+              printf("auglag: subopt return code %d\n", ret);
+         if (ret < 0) break;
+         
+         d.stop->nevals++;
+         fcur = f(n, xcur, NULL, f_data);
+         if (nlopt_stop_forced(stop)) {
+              ret = NLOPT_FORCED_STOP; goto done; }
+         if (auglag_verbose)
+              printf("auglag: fcur = %g\n", fcur);
+         
+         ICM = 0;
+         penalty = 0;
+         feasible = 1;
+         for (i = ii = 0; i < d.p; ++i) {
+              nlopt_eval_constraint(d.restmp, NULL, d.h + i, n, xcur);
+              if (nlopt_stop_forced(stop)) {
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              for (k = 0; k < d.h[i].m; ++k) {
+                   double hi = d.restmp[k];
+                   double newlam = d.lambda[ii] + d.rho * hi;
+                   penalty += fabs(hi);
+                   feasible = feasible && fabs(hi) <= h[i].tol[k];
+                   ICM = MAX(ICM, fabs(hi));
+                   d.lambda[ii++] = MIN(MAX(lam_min, newlam), lam_max);
+              }
+         }
+         for (i = ii = 0; i < d.m; ++i) {
+              nlopt_eval_constraint(d.restmp, NULL, d.fc + i, n, xcur);
+              if (nlopt_stop_forced(stop)) {
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              for (k = 0; k < d.fc[i].m; ++k) {
+                   double fci = d.restmp[k];
+                   double newmu = d.mu[ii] + d.rho * fci;
+                   penalty += fci > 0 ? fci : 0;
+                   feasible = feasible && fci <= fc[i].tol[k];
+                   ICM = MAX(ICM, fabs(MAX(fci, -d.mu[ii] / d.rho)));
+                   d.mu[ii++] = MIN(MAX(0.0, newmu), mu_max);
+              }
+         }
+         if (ICM > tau * prev_ICM) {
+              d.rho *= gam;
+         }
+
+         auglag_iters++;
+         
+         if (auglag_verbose) {
+              printf("auglag %d: ICM=%g (%sfeasible), rho=%g\nauglag lambda=",
+                     auglag_iters, ICM, feasible ? "" : "not ", d.rho);
+              for (i = 0; i < d.pp; ++i) printf(" %g", d.lambda[i]);
+              printf("\nauglag %d: mu = ", auglag_iters);
+              for (i = 0; i < d.mm; ++i) printf(" %g", d.mu[i]);
+              printf("\n");
+         }
+
+         if ((feasible && (!minf_feasible || penalty < minf_penalty
+                           || fcur < *minf)) || 
+             (!minf_feasible && penalty < minf_penalty)) {
+              ret = NLOPT_SUCCESS;
+              if (feasible) {
+                   if (fcur < stop->minf_max) 
+                        ret = NLOPT_MINF_MAX_REACHED;
+                   else if (nlopt_stop_ftol(stop, fcur, *minf)) 
+                        ret = NLOPT_FTOL_REACHED;
+                   else if (nlopt_stop_x(stop, xcur, x))
+                        ret = NLOPT_XTOL_REACHED;
+              }
+              *minf = fcur;
+              minf_penalty = penalty;
+              minf_feasible = feasible;
+              memcpy(x, xcur, sizeof(double) * n);
+              if (ret != NLOPT_SUCCESS) break;
+         }
+
+         if (nlopt_stop_forced(stop)) {ret = NLOPT_FORCED_STOP; break;}
+         if (nlopt_stop_evals(stop)) {ret = NLOPT_MAXEVAL_REACHED; break;}
+          if (nlopt_stop_time(stop)) {ret = NLOPT_MAXTIME_REACHED; break;}
+
+         /* TODO: use some other stopping criterion on ICM? */
+         /* The paper uses ICM <= epsilon and DFM <= epsilon, where
+            DFM is a measure of the size of the Lagrangian gradient.
+            Besides the fact that these kinds of absolute tolerances
+            (non-scale-invariant) are unsatisfying and it is not
+            clear how the user should specify it, the ICM <= epsilon
+            condition seems not too different from requiring feasibility,
+            especially now that the user can provide constraint-specific
+            tolerances analogous to epsilon. */
+         if (ICM == 0) return NLOPT_FTOL_REACHED;
+     } while (1);
+
+done:
+     free(xcur);
+     return ret;
+}
diff --git a/auglag/auglag.h b/auglag/auglag.h
new file mode 100644 (file)
index 0000000..d2d006e
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef AUGLAG_H
+#define AUGLAG_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+extern int auglag_verbose;
+
+nlopt_result auglag_minimize(int n, nlopt_func f, void *f_data,
+                            int m, nlopt_constraint *fc,
+                            int p, nlopt_constraint *h,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            nlopt_stopping *stop,
+                            nlopt_opt sub_opt, int sub_has_fc);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..05b709b
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+configure_args=""
+configure="yes"
+
+while test $# -ge 1; do
+    case $1 in
+       --verbose) verbose=yes ;;
+       --enable-*) configure_args="$configure_args $1" ;;
+       --disable-*) configure_args="$configure_args $1" ;;
+       --with-*) configure_args="$configure_args $1" ;;
+       --without-*) configure_args="$configure_args $1" ;;
+       --no-configure) configure="no" ;;
+       *) echo "unknown argument $1"; exit 1 ;;
+    esac
+    shift
+done
+
+touch swig/nlopt.scm.in
+
+cp README.md README
+
+# paranoia: sometimes autoconf doesn't get things right the first time
+autoreconf --verbose --install --symlink --force
+autoreconf --verbose --install --symlink --force
+autoreconf --verbose --install --symlink --force
+
+if test "$configure" = "yes"
+then
+  config=good # hackery so darcs_test still outputs config.log w/failed configure
+
+  ./configure --enable-maintainer-mode $configure_args || config=bad
+
+  if test x$verbose = xyes; then
+      cat config.log
+  fi
+
+  test $config = bad && exit 1
+fi
\ No newline at end of file
diff --git a/bobyqa/COPYRIGHT b/bobyqa/COPYRIGHT
new file mode 100644 (file)
index 0000000..ef653d4
--- /dev/null
@@ -0,0 +1,23 @@
+/* Copyright (c) 2009 M. J. D. Powell (mjdp@cam.ac.uk)
+ * Modifications Copyright (c) 2010 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
diff --git a/bobyqa/Makefile.am b/bobyqa/Makefile.am
new file mode 100644 (file)
index 0000000..71f2d9b
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libbobyqa.la
+libbobyqa_la_SOURCES = bobyqa.c bobyqa.h
+
+EXTRA_DIST = README README.orig COPYRIGHT
diff --git a/bobyqa/Makefile.in b/bobyqa/Makefile.in
new file mode 100644 (file)
index 0000000..f989371
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = bobyqa
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libbobyqa_la_LIBADD =
+am_libbobyqa_la_OBJECTS = bobyqa.lo
+libbobyqa_la_OBJECTS = $(am_libbobyqa_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libbobyqa_la_SOURCES)
+DIST_SOURCES = $(libbobyqa_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libbobyqa.la
+libbobyqa_la_SOURCES = bobyqa.c bobyqa.h
+EXTRA_DIST = README README.orig COPYRIGHT
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bobyqa/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu bobyqa/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libbobyqa.la: $(libbobyqa_la_OBJECTS) $(libbobyqa_la_DEPENDENCIES) $(EXTRA_libbobyqa_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libbobyqa_la_OBJECTS) $(libbobyqa_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bobyqa.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bobyqa/README b/bobyqa/README
new file mode 100644 (file)
index 0000000..c87ce61
--- /dev/null
@@ -0,0 +1,20 @@
+This is the BOBYQA software by M. J. D. Powell, which performs
+derivative-free unconstrained optimization using an iteratively
+constructred quadratic approximation for the objective function.  See:
+
+        M. J. D. Powell, "The BOBYQA algorithm for bound constrained
+        optimization without derivatives," Department of Applied
+       Mathematics and Theoretical Physics, Cambridge England,
+       technical report NA2009/06 (2009).
+
+       http://www.damtp.cam.ac.uk/user/na/NA_papers/NA2009_06.pdf
+       http://plato.asu.edu/ftp/other_software/bobyqa.zip
+
+The C translation by S. G. Johnson (2009) includes a few minor
+modifications, mainly to use the NLopt stopping criteria (and to
+take the objective function as an argument rather than a global).
+
+The original Fortran code was released by Powell with "no restrictions
+or charges", and the C translation by S. G. Johnson is released in a
+similar spirit under the MIT License (see the COPYRIGHT file in this
+directory).
diff --git a/bobyqa/README.orig b/bobyqa/README.orig
new file mode 100644 (file)
index 0000000..8a81d98
--- /dev/null
@@ -0,0 +1,60 @@
+===========================================================================
+On 8/13/09 added the paper on BOBYQA
+===========================================================================
+
+For simplicity, the Makefi;e has been replaced by a one-line compile
+script "comp" which needs to be adjusted if the compiler name is not
+f77. All Fortran files are in bobyla.f. Compiling and running bobyqa
+should produce results similar to those in RESULTS.
+                                         Hans Mittelmann, Jan 2009
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+     The Fortran version of BOBYQA is attached. Its purpose is to seek
+the least value of a function F of several variables, when derivatives
+are not available, where F is specified by the user through a subroutine
+called CALFUN. The name BOBYQA denotes Bound Approximation BY Quadratic
+Approximation, the constraints being lower and upper bounds on every
+variable, which can be set to huge values for unconstrained variables.
+The algorithm is intended to change the variables to values that are close
+to a local minimum of F. The user, however, should assume responsibility for
+finding out if the calculations are satisfactory, by considering carefully
+the values of F that occur. The BOBYQA software has been developed from the
+method of the paper "The NEWUOA software for unconstrained minimization
+without derivatives", in Large-Scale Nonlinear Optimization, editors G. Di
+Pillo and M. Roma, Springer (2006), pages 255-297. A report that describes
+the details of the development is going to be written soon.
+
+     The attachments in sequence are a suitable Makefile, followed by a main
+program and a CALFUN routine for the "Invdist2" problem, in order to provide
+an example for testing. Then BOBYQA and its six auxiliary routines, namely
+BOBYQB, ALTMOV, PRELIM, RESCUE, TRSBOX and UPDATE, are given. Finally, the
+computed output that the author obtained for the Invdist2 problems is listed.
+
+     In addition to providing CALFUN, an initial vector of variables and
+the lower and upper bounds, the user has to set the values of the parameters
+RHOBEG, RHOEND and NPT. After scaling the individual variables if necessary,
+so that the magnitudes of their expected changes are similar, RHOBEG is the
+initial steplength for changes to the variables, a reasonable choice being
+the mesh size of a coarse grid search. Further, RHOEND should be suitable for
+a search on a very fine grid. Typically, the software calculates a vector
+of variables that is within distance 10*RHOEND of a local minimum. Another
+consideration is that every trial vector of variables is forced to satisfy
+the lower and upper bounds, but there has to be room to make a search in all
+directions. Therefore an error return occurs if the difference between the
+bounds on any variable is less than 2*RHOBEG. The parameter NPT specifies
+the number of interpolation conditions on each quadratic model, the value
+NPT=2*N+1 being recommended for a start, where N is the number of variables.
+It is often worthwhile to try other choices too, but much larger values tend
+to be inefficient, because the amount of routine work of each iteration is
+of magnitude NPT**2, and because the achievement of adequate accuracy in some
+matrix calculations becomes more difficult. Some excellent numerical results
+have been found in the case NPT=N+6 even with more than 100 variables.
+
+     The way of calling BOBYQA should be clear from the Invdist2 examples
+and from the comments near the beginning of SUBROUTINE BOBYQA. There are no
+restrictions on or charges for the use of the software. I hope that the time
+and effort I have spent on developing the package will be helpful to much
+research and to many applications.
+
+January 5th, 2009                    M.J.D. Powell (mjdp@cam.ac.uk)
+
diff --git a/bobyqa/bobyqa.c b/bobyqa/bobyqa.c
new file mode 100644 (file)
index 0000000..8fc454b
--- /dev/null
@@ -0,0 +1,3269 @@
+/* BOBYQA derivative-free optimization code by M. J. D. Powell.
+   Original Fortran code by Powell (2009).  Converted via v2c,
+   cleaned up, and incorporated into NLopt by S. G. Johnson (2009).
+   See README. */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bobyqa.h"
+
+typedef double (*bobyqa_func)(int n, const double *x, void *func_data);
+
+#define MIN2(a,b) ((a) <= (b) ? (a) : (b))
+#define MAX2(a,b) ((a) >= (b) ? (a) : (b))
+#define IABS(x) ((x) < 0 ? -(x) : (x))
+
+static void update_(int *n, int *npt, double *bmat, 
+       double *zmat, int *ndim, double *vlag, double *beta, 
+       double *denom, int *knew, double *w)
+{
+    /* System generated locals */
+    int bmat_dim1, bmat_offset, zmat_dim1, zmat_offset, i__1, i__2;
+    double d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, k, jl, jp;
+    double one, tau, temp;
+    int nptm;
+    double zero, alpha, tempa, tempb, ztest;
+
+
+/*     The arrays BMAT and ZMAT are updated, as required by the new position */
+/*     of the interpolation point that has the index KNEW. The vector VLAG has */
+/*     N+NPT components, set on entry to the first NPT and last N components */
+/*     of the product Hw in equation (4.11) of the Powell (2006) paper on */
+/*     NEWUOA. Further, BETA is set on entry to the value of the parameter */
+/*     with that name, and DENOM is set to the denominator of the updating */
+/*     formula. Elements of ZMAT may be treated as zero if their moduli are */
+/*     at most ZTEST. The first NDIM elements of W are used for working space. */
+
+/*     Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --vlag;
+    --w;
+
+    /* Function Body */
+    one = 1.;
+    zero = 0.;
+    nptm = *npt - *n - 1;
+    ztest = zero;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       i__2 = nptm;
+       for (j = 1; j <= i__2; ++j) {
+/* L10: */
+/* Computing MAX */
+           d__2 = ztest, d__3 = (d__1 = zmat[k + j * zmat_dim1], fabs(d__1));
+           ztest = MAX2(d__2,d__3);
+       }
+    }
+    ztest *= 1e-20;
+
+/*     Apply the rotations that put zeros in the KNEW-th row of ZMAT. */
+
+    jl = 1;
+    i__2 = nptm;
+    for (j = 2; j <= i__2; ++j) {
+       if ((d__1 = zmat[*knew + j * zmat_dim1], fabs(d__1)) > ztest) {
+/* Computing 2nd power */
+           d__1 = zmat[*knew + zmat_dim1];
+/* Computing 2nd power */
+           d__2 = zmat[*knew + j * zmat_dim1];
+           temp = sqrt(d__1 * d__1 + d__2 * d__2);
+           tempa = zmat[*knew + zmat_dim1] / temp;
+           tempb = zmat[*knew + j * zmat_dim1] / temp;
+           i__1 = *npt;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               temp = tempa * zmat[i__ + zmat_dim1] + tempb * zmat[i__ + j * 
+                       zmat_dim1];
+               zmat[i__ + j * zmat_dim1] = tempa * zmat[i__ + j * zmat_dim1] 
+                       - tempb * zmat[i__ + zmat_dim1];
+/* L20: */
+               zmat[i__ + zmat_dim1] = temp;
+           }
+       }
+       zmat[*knew + j * zmat_dim1] = zero;
+/* L30: */
+    }
+
+/*     Put the first NPT components of the KNEW-th column of HLAG into W, */
+/*     and calculate the parameters of the updating formula. */
+
+    i__2 = *npt;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       w[i__] = zmat[*knew + zmat_dim1] * zmat[i__ + zmat_dim1];
+/* L40: */
+    }
+    alpha = w[*knew];
+    tau = vlag[*knew];
+    vlag[*knew] -= one;
+
+/*     Complete the updating of ZMAT. */
+
+    temp = sqrt(*denom);
+    tempb = zmat[*knew + zmat_dim1] / temp;
+    tempa = tau / temp;
+    i__2 = *npt;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L50: */
+       zmat[i__ + zmat_dim1] = tempa * zmat[i__ + zmat_dim1] - tempb * vlag[
+               i__];
+    }
+
+/*     Finally, update the matrix BMAT. */
+
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       jp = *npt + j;
+       w[jp] = bmat[*knew + j * bmat_dim1];
+       tempa = (alpha * vlag[jp] - tau * w[jp]) / *denom;
+       tempb = (-(*beta) * w[jp] - tau * vlag[jp]) / *denom;
+       i__1 = jp;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           bmat[i__ + j * bmat_dim1] = bmat[i__ + j * bmat_dim1] + tempa * 
+                   vlag[i__] + tempb * w[i__];
+           if (i__ > *npt) {
+               bmat[jp + (i__ - *npt) * bmat_dim1] = bmat[i__ + j * 
+                       bmat_dim1];
+           }
+/* L60: */
+       }
+    }
+} /* update_ */
+
+static nlopt_result rescue_(int *n, int *npt, const double *xl, const double *xu, 
+                   /* int *maxfun */
+                   nlopt_stopping *stop,
+                   bobyqa_func calfun, void *calfun_data,
+        double *xbase, double *xpt, double *fval, double *xopt, double *gopt,
+        double *hq, double *pq, double *bmat, double *zmat, 
+       int *ndim, double *sl, double *su, /* int *nf,  */
+       double *delta, int *kopt, double *vlag, double *
+       ptsaux, double *ptsid, double *w)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2, i__3;
+    double d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    double f;
+    int i__, j, k, ih, jp, ip, iq, np, iw;
+    double xp, xq, den;
+    int ihp;
+    double one;
+    int ihq, jpn, kpt;
+    double sum, diff, half, beta;
+    int kold;
+    double winc;
+    int nrem, knew;
+    double temp, bsum;
+    int nptm;
+    double zero, hdiag, fbase, sfrac, denom, vquad, sumpq;
+    double dsqmin, distsq, vlmxsq;
+
+
+/*     The arguments N, NPT, XL, XU, MAXFUN, XBASE, XPT, FVAL, XOPT, */
+/*       GOPT, HQ, PQ, BMAT, ZMAT, NDIM, SL and SU have the same meanings as */
+/*       the corresponding arguments of BOBYQB on the entry to RESCUE. */
+/*     NF is maintained as the number of calls of CALFUN so far, except that */
+/*       NF is set to -1 if the value of MAXFUN prevents further progress. */
+/*     KOPT is maintained so that FVAL(KOPT) is the least calculated function */
+/*       value. Its correct value must be given on entry. It is updated if a */
+/*       new least function value is found, but the corresponding changes to */
+/*       XOPT and GOPT have to be made later by the calling program. */
+/*     DELTA is the current trust region radius. */
+/*     VLAG is a working space vector that will be used for the values of the */
+/*       provisional Lagrange functions at each of the interpolation points. */
+/*       They are part of a product that requires VLAG to be of length NDIM. */
+/*     PTSAUX is also a working space array. For J=1,2,...,N, PTSAUX(1,J) and */
+/*       PTSAUX(2,J) specify the two positions of provisional interpolation */
+/*       points when a nonzero step is taken along e_J (the J-th coordinate */
+/*       direction) through XBASE+XOPT, as specified below. Usually these */
+/*       steps have length DELTA, but other lengths are chosen if necessary */
+/*       in order to satisfy the given bounds on the variables. */
+/*     PTSID is also a working space array. It has NPT components that denote */
+/*       provisional new positions of the original interpolation points, in */
+/*       case changes are needed to restore the linear independence of the */
+/*       interpolation conditions. The K-th point is a candidate for change */
+/*       if and only if PTSID(K) is nonzero. In this case let p and q be the */
+/*       int parts of PTSID(K) and (PTSID(K)-p) multiplied by N+1. If p */
+/*       and q are both positive, the step from XBASE+XOPT to the new K-th */
+/*       interpolation point is PTSAUX(1,p)*e_p + PTSAUX(1,q)*e_q. Otherwise */
+/*       the step is PTSAUX(1,p)*e_p or PTSAUX(2,q)*e_q in the cases q=0 or */
+/*       p=0, respectively. */
+/*     The first NDIM+NPT elements of the array W are used for working space. */
+/*     The final elements of BMAT and ZMAT are set in a well-conditioned way */
+/*       to the values that are appropriate for the new interpolation points. */
+/*     The elements of GOPT, HQ and PQ are also revised to the values that are */
+/*       appropriate to the final quadratic model. */
+
+/*     Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xl;
+    --xu;
+    --xbase;
+    --fval;
+    --xopt;
+    --gopt;
+    --hq;
+    --pq;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --sl;
+    --su;
+    --vlag;
+    ptsaux -= 3;
+    --ptsid;
+    --w;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    zero = 0.;
+    np = *n + 1;
+    sfrac = half / (double) np;
+    nptm = *npt - np;
+
+/*     Shift the interpolation points so that XOPT becomes the origin, and set */
+/*     the elements of ZMAT to zero. The value of SUMPQ is required in the */
+/*     updating of HQ below. The squares of the distances from XOPT to the */
+/*     other interpolation points are set at the end of W. Increments of WINC */
+/*     may be added later to these squares to balance the consideration of */
+/*     the choice of point that is going to become current. */
+
+    sumpq = zero;
+    winc = zero;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       distsq = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           xpt[k + j * xpt_dim1] -= xopt[j];
+/* L10: */
+/* Computing 2nd power */
+           d__1 = xpt[k + j * xpt_dim1];
+           distsq += d__1 * d__1;
+       }
+       sumpq += pq[k];
+       w[*ndim + k] = distsq;
+       winc = MAX2(winc,distsq);
+       i__2 = nptm;
+       for (j = 1; j <= i__2; ++j) {
+/* L20: */
+           zmat[k + j * zmat_dim1] = zero;
+       }
+    }
+
+/*     Update HQ so that HQ and PQ define the second derivatives of the model */
+/*     after XBASE has been shifted to the trust region centre. */
+
+    ih = 0;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       w[j] = half * sumpq * xopt[j];
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L30: */
+           w[j] += pq[k] * xpt[k + j * xpt_dim1];
+       }
+       i__1 = j;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           ++ih;
+/* L40: */
+           hq[ih] = hq[ih] + w[i__] * xopt[j] + w[j] * xopt[i__];
+       }
+    }
+
+/*     Shift XBASE, SL, SU and XOPT. Set the elements of BMAT to zero, and */
+/*     also set the elements of PTSAUX. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       xbase[j] += xopt[j];
+       sl[j] -= xopt[j];
+       su[j] -= xopt[j];
+       xopt[j] = zero;
+/* Computing MIN */
+       d__1 = *delta, d__2 = su[j];
+       ptsaux[(j << 1) + 1] = MIN2(d__1,d__2);
+/* Computing MAX */
+       d__1 = -(*delta), d__2 = sl[j];
+       ptsaux[(j << 1) + 2] = MAX2(d__1,d__2);
+       if (ptsaux[(j << 1) + 1] + ptsaux[(j << 1) + 2] < zero) {
+           temp = ptsaux[(j << 1) + 1];
+           ptsaux[(j << 1) + 1] = ptsaux[(j << 1) + 2];
+           ptsaux[(j << 1) + 2] = temp;
+       }
+       if ((d__2 = ptsaux[(j << 1) + 2], fabs(d__2)) < half * (d__1 = ptsaux[(
+               j << 1) + 1], fabs(d__1))) {
+           ptsaux[(j << 1) + 2] = half * ptsaux[(j << 1) + 1];
+       }
+       i__2 = *ndim;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L50: */
+           bmat[i__ + j * bmat_dim1] = zero;
+       }
+    }
+    fbase = fval[*kopt];
+
+/*     Set the identifiers of the artificial interpolation points that are */
+/*     along a coordinate direction from XOPT, and set the corresponding */
+/*     nonzero elements of BMAT and ZMAT. */
+
+    ptsid[1] = sfrac;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       jp = j + 1;
+       jpn = jp + *n;
+       ptsid[jp] = (double) j + sfrac;
+       if (jpn <= *npt) {
+           ptsid[jpn] = (double) j / (double) np + sfrac;
+           temp = one / (ptsaux[(j << 1) + 1] - ptsaux[(j << 1) + 2]);
+           bmat[jp + j * bmat_dim1] = -temp + one / ptsaux[(j << 1) + 1];
+           bmat[jpn + j * bmat_dim1] = temp + one / ptsaux[(j << 1) + 2];
+           bmat[j * bmat_dim1 + 1] = -bmat[jp + j * bmat_dim1] - bmat[jpn + 
+                   j * bmat_dim1];
+           zmat[j * zmat_dim1 + 1] = sqrt(2.) / (d__1 = ptsaux[(j << 1) + 1] 
+                   * ptsaux[(j << 1) + 2], fabs(d__1));
+           zmat[jp + j * zmat_dim1] = zmat[j * zmat_dim1 + 1] * ptsaux[(j << 
+                   1) + 2] * temp;
+           zmat[jpn + j * zmat_dim1] = -zmat[j * zmat_dim1 + 1] * ptsaux[(j 
+                   << 1) + 1] * temp;
+       } else {
+           bmat[j * bmat_dim1 + 1] = -one / ptsaux[(j << 1) + 1];
+           bmat[jp + j * bmat_dim1] = one / ptsaux[(j << 1) + 1];
+/* Computing 2nd power */
+           d__1 = ptsaux[(j << 1) + 1];
+           bmat[j + *npt + j * bmat_dim1] = -half * (d__1 * d__1);
+       }
+/* L60: */
+    }
+
+/*     Set any remaining identifiers with their nonzero elements of ZMAT. */
+
+    if (*npt >= *n + np) {
+       i__2 = *npt;
+       for (k = np << 1; k <= i__2; ++k) {
+           iw = (int) (((double) (k - np) - half) / (double) (*n)
+                   );
+           ip = k - np - iw * *n;
+           iq = ip + iw;
+           if (iq > *n) {
+               iq -= *n;
+           }
+           ptsid[k] = (double) ip + (double) iq / (double) np + 
+                   sfrac;
+           temp = one / (ptsaux[(ip << 1) + 1] * ptsaux[(iq << 1) + 1]);
+           zmat[(k - np) * zmat_dim1 + 1] = temp;
+           zmat[ip + 1 + (k - np) * zmat_dim1] = -temp;
+           zmat[iq + 1 + (k - np) * zmat_dim1] = -temp;
+/* L70: */
+           zmat[k + (k - np) * zmat_dim1] = temp;
+       }
+    }
+    nrem = *npt;
+    kold = 1;
+    knew = *kopt;
+
+/*     Reorder the provisional points in the way that exchanges PTSID(KOLD) */
+/*     with PTSID(KNEW). */
+
+L80:
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       temp = bmat[kold + j * bmat_dim1];
+       bmat[kold + j * bmat_dim1] = bmat[knew + j * bmat_dim1];
+/* L90: */
+       bmat[knew + j * bmat_dim1] = temp;
+    }
+    i__2 = nptm;
+    for (j = 1; j <= i__2; ++j) {
+       temp = zmat[kold + j * zmat_dim1];
+       zmat[kold + j * zmat_dim1] = zmat[knew + j * zmat_dim1];
+/* L100: */
+       zmat[knew + j * zmat_dim1] = temp;
+    }
+    ptsid[kold] = ptsid[knew];
+    ptsid[knew] = zero;
+    w[*ndim + knew] = zero;
+    --nrem;
+    if (knew != *kopt) {
+       temp = vlag[kold];
+       vlag[kold] = vlag[knew];
+       vlag[knew] = temp;
+
+/*     Update the BMAT and ZMAT matrices so that the status of the KNEW-th */
+/*     interpolation point can be changed from provisional to original. The */
+/*     branch to label 350 occurs if all the original points are reinstated. */
+/*     The nonnegative values of W(NDIM+K) are required in the search below. */
+
+       update_(n, npt, &bmat[bmat_offset], &zmat[zmat_offset], ndim, &vlag[1]
+               , &beta, &denom, &knew, &w[1]);
+       if (nrem == 0) {
+           goto L350;
+       }
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L110: */
+           w[*ndim + k] = (d__1 = w[*ndim + k], fabs(d__1));
+       }
+    }
+
+/*     Pick the index KNEW of an original interpolation point that has not */
+/*     yet replaced one of the provisional interpolation points, giving */
+/*     attention to the closeness to XOPT and to previous tries with KNEW. */
+
+L120:
+    dsqmin = zero;
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       if (w[*ndim + k] > zero) {
+           if (dsqmin == zero || w[*ndim + k] < dsqmin) {
+               knew = k;
+               dsqmin = w[*ndim + k];
+           }
+       }
+/* L130: */
+    }
+    if (dsqmin == zero) {
+       goto L260;
+    }
+
+/*     Form the W-vector of the chosen original interpolation point. */
+
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+/* L140: */
+       w[*npt + j] = xpt[knew + j * xpt_dim1];
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       sum = zero;
+       if (k == *kopt) {
+       } else if (ptsid[k] == zero) {
+           i__1 = *n;
+           for (j = 1; j <= i__1; ++j) {
+/* L150: */
+               sum += w[*npt + j] * xpt[k + j * xpt_dim1];
+           }
+       } else {
+           ip = (int) ptsid[k];
+           if (ip > 0) {
+               sum = w[*npt + ip] * ptsaux[(ip << 1) + 1];
+           }
+           iq = (int) ((double) np * ptsid[k] - (double) (ip * 
+                   np));
+           if (iq > 0) {
+               iw = 1;
+               if (ip == 0) {
+                   iw = 2;
+               }
+               sum += w[*npt + iq] * ptsaux[iw + (iq << 1)];
+           }
+       }
+/* L160: */
+       w[k] = half * sum * sum;
+    }
+
+/*     Calculate VLAG and BETA for the required updating of the H matrix if */
+/*     XPT(KNEW,.) is reinstated in the set of interpolation points. */
+
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       sum = zero;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+/* L170: */
+           sum += bmat[k + j * bmat_dim1] * w[*npt + j];
+       }
+/* L180: */
+       vlag[k] = sum;
+    }
+    beta = zero;
+    i__2 = nptm;
+    for (j = 1; j <= i__2; ++j) {
+       sum = zero;
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L190: */
+           sum += zmat[k + j * zmat_dim1] * w[k];
+       }
+       beta -= sum * sum;
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L200: */
+           vlag[k] += sum * zmat[k + j * zmat_dim1];
+       }
+    }
+    bsum = zero;
+    distsq = zero;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       sum = zero;
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L210: */
+           sum += bmat[k + j * bmat_dim1] * w[k];
+       }
+       jp = j + *npt;
+       bsum += sum * w[jp];
+       i__2 = *ndim;
+       for (ip = *npt + 1; ip <= i__2; ++ip) {
+/* L220: */
+           sum += bmat[ip + j * bmat_dim1] * w[ip];
+       }
+       bsum += sum * w[jp];
+       vlag[jp] = sum;
+/* L230: */
+/* Computing 2nd power */
+       d__1 = xpt[knew + j * xpt_dim1];
+       distsq += d__1 * d__1;
+    }
+    beta = half * distsq * distsq + beta - bsum;
+    vlag[*kopt] += one;
+
+/*     KOLD is set to the index of the provisional interpolation point that is */
+/*     going to be deleted to make way for the KNEW-th original interpolation */
+/*     point. The choice of KOLD is governed by the avoidance of a small value */
+/*     of the denominator in the updating calculation of UPDATE. */
+
+    denom = zero;
+    vlmxsq = zero;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       if (ptsid[k] != zero) {
+           hdiag = zero;
+           i__2 = nptm;
+           for (j = 1; j <= i__2; ++j) {
+/* L240: */
+/* Computing 2nd power */
+               d__1 = zmat[k + j * zmat_dim1];
+               hdiag += d__1 * d__1;
+           }
+/* Computing 2nd power */
+           d__1 = vlag[k];
+           den = beta * hdiag + d__1 * d__1;
+           if (den > denom) {
+               kold = k;
+               denom = den;
+           }
+       }
+/* L250: */
+/* Computing MAX */
+/* Computing 2nd power */
+       d__3 = vlag[k];
+       d__1 = vlmxsq, d__2 = d__3 * d__3;
+       vlmxsq = MAX2(d__1,d__2);
+    }
+    if (denom <= vlmxsq * .01) {
+       w[*ndim + knew] = -w[*ndim + knew] - winc;
+       goto L120;
+    }
+    goto L80;
+
+/*     When label 260 is reached, all the final positions of the interpolation */
+/*     points have been chosen although any changes have not been included yet */
+/*     in XPT. Also the final BMAT and ZMAT matrices are complete, but, apart */
+/*     from the shift of XBASE, the updating of the quadratic model remains to */
+/*     be done. The following cycle through the new interpolation points begins */
+/*     by putting the new point in XPT(KPT,.) and by setting PQ(KPT) to zero, */
+/*     except that a RETURN occurs if MAXFUN prohibits another value of F. */
+
+L260:
+    i__1 = *npt;
+    for (kpt = 1; kpt <= i__1; ++kpt) {
+       if (ptsid[kpt] == zero) {
+           goto L340;
+       }
+
+       if (nlopt_stop_forced(stop)) return NLOPT_FORCED_STOP;
+       else if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+       else if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+
+       ih = 0;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           w[j] = xpt[kpt + j * xpt_dim1];
+           xpt[kpt + j * xpt_dim1] = zero;
+           temp = pq[kpt] * w[j];
+           i__3 = j;
+           for (i__ = 1; i__ <= i__3; ++i__) {
+               ++ih;
+/* L270: */
+               hq[ih] += temp * w[i__];
+           }
+       }
+       pq[kpt] = zero;
+       ip = (int) ptsid[kpt];
+       iq = (int) ((double) np * ptsid[kpt] - (double) (ip * np))
+               ;
+       if (ip > 0) {
+           xp = ptsaux[(ip << 1) + 1];
+           xpt[kpt + ip * xpt_dim1] = xp;
+       }
+       if (iq > 0) {
+           xq = ptsaux[(iq << 1) + 1];
+           if (ip == 0) {
+               xq = ptsaux[(iq << 1) + 2];
+           }
+           xpt[kpt + iq * xpt_dim1] = xq;
+       }
+
+/*     Set VQUAD to the value of the current model at the new point. */
+
+       vquad = fbase;
+       if (ip > 0) {
+           ihp = (ip + ip * ip) / 2;
+           vquad += xp * (gopt[ip] + half * xp * hq[ihp]);
+       }
+       if (iq > 0) {
+           ihq = (iq + iq * iq) / 2;
+           vquad += xq * (gopt[iq] + half * xq * hq[ihq]);
+           if (ip > 0) {
+               iw = MAX2(ihp,ihq) - (i__3 = ip - iq, IABS(i__3));
+               vquad += xp * xq * hq[iw];
+           }
+       }
+       i__3 = *npt;
+       for (k = 1; k <= i__3; ++k) {
+           temp = zero;
+           if (ip > 0) {
+               temp += xp * xpt[k + ip * xpt_dim1];
+           }
+           if (iq > 0) {
+               temp += xq * xpt[k + iq * xpt_dim1];
+           }
+/* L280: */
+           vquad += half * pq[k] * temp * temp;
+       }
+
+/*     Calculate F at the new interpolation point, and set DIFF to the factor */
+/*     that is going to multiply the KPT-th Lagrange function when the model */
+/*     is updated to provide interpolation to the new function value. */
+
+       i__3 = *n;
+       for (i__ = 1; i__ <= i__3; ++i__) {
+/* Computing MIN */
+/* Computing MAX */
+           d__3 = xl[i__], d__4 = xbase[i__] + xpt[kpt + i__ * xpt_dim1];
+           d__1 = MAX2(d__3,d__4), d__2 = xu[i__];
+           w[i__] = MIN2(d__1,d__2);
+           if (xpt[kpt + i__ * xpt_dim1] == sl[i__]) {
+               w[i__] = xl[i__];
+           }
+           if (xpt[kpt + i__ * xpt_dim1] == su[i__]) {
+               w[i__] = xu[i__];
+           }
+/* L290: */
+       }
+
+       stop->nevals++;
+       f = calfun(*n, &w[1], calfun_data);
+       fval[kpt] = f;
+       if (f < fval[*kopt]) {
+           *kopt = kpt;
+       }
+       if (nlopt_stop_forced(stop)) return NLOPT_FORCED_STOP;
+       else if (f < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+       else if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+       else if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+
+       diff = f - vquad;
+
+/*     Update the quadratic model. The RETURN from the subroutine occurs when */
+/*     all the new interpolation points are included in the model. */
+
+       i__3 = *n;
+       for (i__ = 1; i__ <= i__3; ++i__) {
+/* L310: */
+           gopt[i__] += diff * bmat[kpt + i__ * bmat_dim1];
+       }
+       i__3 = *npt;
+       for (k = 1; k <= i__3; ++k) {
+           sum = zero;
+           i__2 = nptm;
+           for (j = 1; j <= i__2; ++j) {
+/* L320: */
+               sum += zmat[k + j * zmat_dim1] * zmat[kpt + j * zmat_dim1];
+           }
+           temp = diff * sum;
+           if (ptsid[k] == zero) {
+               pq[k] += temp;
+           } else {
+               ip = (int) ptsid[k];
+               iq = (int) ((double) np * ptsid[k] - (double) (ip 
+                       * np));
+               ihq = (iq * iq + iq) / 2;
+               if (ip == 0) {
+/* Computing 2nd power */
+                   d__1 = ptsaux[(iq << 1) + 2];
+                   hq[ihq] += temp * (d__1 * d__1);
+               } else {
+                   ihp = (ip * ip + ip) / 2;
+/* Computing 2nd power */
+                   d__1 = ptsaux[(ip << 1) + 1];
+                   hq[ihp] += temp * (d__1 * d__1);
+                   if (iq > 0) {
+/* Computing 2nd power */
+                       d__1 = ptsaux[(iq << 1) + 1];
+                       hq[ihq] += temp * (d__1 * d__1);
+                       iw = MAX2(ihp,ihq) - (i__2 = iq - ip, IABS(i__2));
+                       hq[iw] += temp * ptsaux[(ip << 1) + 1] * ptsaux[(iq <<
+                                1) + 1];
+                   }
+               }
+           }
+/* L330: */
+       }
+       ptsid[kpt] = zero;
+L340:
+       ;
+    }
+L350:
+    return NLOPT_SUCCESS;
+} /* rescue_ */
+
+static void altmov_(int *n, int *npt, double *xpt, 
+       double *xopt, double *bmat, double *zmat, int *ndim, 
+       double *sl, double *su, int *kopt, int *knew, 
+       double *adelt, double *xnew, double *xalt, double *
+       alpha, double *cauchy, double *glag, double *hcol, 
+       double *w)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2;
+    double d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    int i__, j, k;
+    double ha, gw, one, diff, half;
+    int ilbd, isbd;
+    double slbd;
+    int iubd;
+    double vlag, subd, temp;
+    int ksav;
+    double step, zero, curv;
+    int iflag;
+    double scale, csave, tempa, tempb, tempd, const__, sumin, ggfree;
+    int ibdsav;
+    double dderiv, bigstp, predsq, presav, distsq, stpsav, wfixsq, wsqsav;
+
+
+/*     The arguments N, NPT, XPT, XOPT, BMAT, ZMAT, NDIM, SL and SU all have */
+/*       the same meanings as the corresponding arguments of BOBYQB. */
+/*     KOPT is the index of the optimal interpolation point. */
+/*     KNEW is the index of the interpolation point that is going to be moved. */
+/*     ADELT is the current trust region bound. */
+/*     XNEW will be set to a suitable new position for the interpolation point */
+/*       XPT(KNEW,.). Specifically, it satisfies the SL, SU and trust region */
+/*       bounds and it should provide a large denominator in the next call of */
+/*       UPDATE. The step XNEW-XOPT from XOPT is restricted to moves along the */
+/*       straight lines through XOPT and another interpolation point. */
+/*     XALT also provides a large value of the modulus of the KNEW-th Lagrange */
+/*       function subject to the constraints that have been mentioned, its main */
+/*       difference from XNEW being that XALT-XOPT is a constrained version of */
+/*       the Cauchy step within the trust region. An exception is that XALT is */
+/*       not calculated if all components of GLAG (see below) are zero. */
+/*     ALPHA will be set to the KNEW-th diagonal element of the H matrix. */
+/*     CAUCHY will be set to the square of the KNEW-th Lagrange function at */
+/*       the step XALT-XOPT from XOPT for the vector XALT that is returned, */
+/*       except that CAUCHY is set to zero if XALT is not calculated. */
+/*     GLAG is a working space vector of length N for the gradient of the */
+/*       KNEW-th Lagrange function at XOPT. */
+/*     HCOL is a working space vector of length NPT for the second derivative */
+/*       coefficients of the KNEW-th Lagrange function. */
+/*     W is a working space vector of length 2N that is going to hold the */
+/*       constrained Cauchy step from XOPT of the Lagrange function, followed */
+/*       by the downhill version of XALT when the uphill step is calculated. */
+
+/*     Set the first NPT components of W to the leading elements of the */
+/*     KNEW-th column of the H matrix. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xopt;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --sl;
+    --su;
+    --xnew;
+    --xalt;
+    --glag;
+    --hcol;
+    --w;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    zero = 0.;
+    const__ = one + sqrt(2.);
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+/* L10: */
+       hcol[k] = zero;
+    }
+    i__1 = *npt - *n - 1;
+    for (j = 1; j <= i__1; ++j) {
+       temp = zmat[*knew + j * zmat_dim1];
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L20: */
+           hcol[k] += temp * zmat[k + j * zmat_dim1];
+       }
+    }
+    *alpha = hcol[*knew];
+    ha = half * *alpha;
+
+/*     Calculate the gradient of the KNEW-th Lagrange function at XOPT. */
+
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L30: */
+       glag[i__] = bmat[*knew + i__ * bmat_dim1];
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       temp = zero;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+/* L40: */
+           temp += xpt[k + j * xpt_dim1] * xopt[j];
+       }
+       temp = hcol[k] * temp;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L50: */
+           glag[i__] += temp * xpt[k + i__ * xpt_dim1];
+       }
+    }
+
+/*     Search for a large denominator along the straight lines through XOPT */
+/*     and another interpolation point. SLBD and SUBD will be lower and upper */
+/*     bounds on the step along each of these lines in turn. PREDSQ will be */
+/*     set to the square of the predicted denominator for each line. PRESAV */
+/*     will be set to the largest admissible value of PREDSQ that occurs. */
+
+    presav = zero;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       if (k == *kopt) {
+           goto L80;
+       }
+       dderiv = zero;
+       distsq = zero;
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           temp = xpt[k + i__ * xpt_dim1] - xopt[i__];
+           dderiv += glag[i__] * temp;
+/* L60: */
+           distsq += temp * temp;
+       }
+       subd = *adelt / sqrt(distsq);
+       slbd = -subd;
+       ilbd = 0;
+       iubd = 0;
+       sumin = MIN2(one,subd);
+
+/*     Revise SLBD and SUBD if necessary because of the bounds in SL and SU. */
+
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           temp = xpt[k + i__ * xpt_dim1] - xopt[i__];
+           if (temp > zero) {
+               if (slbd * temp < sl[i__] - xopt[i__]) {
+                   slbd = (sl[i__] - xopt[i__]) / temp;
+                   ilbd = -i__;
+               }
+               if (subd * temp > su[i__] - xopt[i__]) {
+/* Computing MAX */
+                   d__1 = sumin, d__2 = (su[i__] - xopt[i__]) / temp;
+                   subd = MAX2(d__1,d__2);
+                   iubd = i__;
+               }
+           } else if (temp < zero) {
+               if (slbd * temp > su[i__] - xopt[i__]) {
+                   slbd = (su[i__] - xopt[i__]) / temp;
+                   ilbd = i__;
+               }
+               if (subd * temp < sl[i__] - xopt[i__]) {
+/* Computing MAX */
+                   d__1 = sumin, d__2 = (sl[i__] - xopt[i__]) / temp;
+                   subd = MAX2(d__1,d__2);
+                   iubd = -i__;
+               }
+           }
+/* L70: */
+       }
+
+/*     Seek a large modulus of the KNEW-th Lagrange function when the index */
+/*     of the other interpolation point on the line through XOPT is KNEW. */
+
+       if (k == *knew) {
+           diff = dderiv - one;
+           step = slbd;
+           vlag = slbd * (dderiv - slbd * diff);
+           isbd = ilbd;
+           temp = subd * (dderiv - subd * diff);
+           if (fabs(temp) > fabs(vlag)) {
+               step = subd;
+               vlag = temp;
+               isbd = iubd;
+           }
+           tempd = half * dderiv;
+           tempa = tempd - diff * slbd;
+           tempb = tempd - diff * subd;
+           if (tempa * tempb < zero) {
+               temp = tempd * tempd / diff;
+               if (fabs(temp) > fabs(vlag)) {
+                   step = tempd / diff;
+                   vlag = temp;
+                   isbd = 0;
+               }
+           }
+
+/*     Search along each of the other lines through XOPT and another point. */
+
+       } else {
+           step = slbd;
+           vlag = slbd * (one - slbd);
+           isbd = ilbd;
+           temp = subd * (one - subd);
+           if (fabs(temp) > fabs(vlag)) {
+               step = subd;
+               vlag = temp;
+               isbd = iubd;
+           }
+           if (subd > half) {
+               if (fabs(vlag) < .25) {
+                   step = half;
+                   vlag = .25;
+                   isbd = 0;
+               }
+           }
+           vlag *= dderiv;
+       }
+
+/*     Calculate PREDSQ for the current line search and maintain PRESAV. */
+
+       temp = step * (one - step) * distsq;
+       predsq = vlag * vlag * (vlag * vlag + ha * temp * temp);
+       if (predsq > presav) {
+           presav = predsq;
+           ksav = k;
+           stpsav = step;
+           ibdsav = isbd;
+       }
+L80:
+       ;
+    }
+
+/*     Construct XNEW in a way that satisfies the bound constraints exactly. */
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp = xopt[i__] + stpsav * (xpt[ksav + i__ * xpt_dim1] - xopt[i__]);
+/* L90: */
+/* Computing MAX */
+/* Computing MIN */
+       d__3 = su[i__];
+       d__1 = sl[i__], d__2 = MIN2(d__3,temp);
+       xnew[i__] = MAX2(d__1,d__2);
+    }
+    if (ibdsav < 0) {
+       xnew[-ibdsav] = sl[-ibdsav];
+    }
+    if (ibdsav > 0) {
+       xnew[ibdsav] = su[ibdsav];
+    }
+
+/*     Prepare for the iterative method that assembles the constrained Cauchy */
+/*     step in W. The sum of squares of the fixed components of W is formed in */
+/*     WFIXSQ, and the free components of W are set to BIGSTP. */
+
+    bigstp = *adelt + *adelt;
+    iflag = 0;
+L100:
+    wfixsq = zero;
+    ggfree = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       w[i__] = zero;
+/* Computing MIN */
+       d__1 = xopt[i__] - sl[i__], d__2 = glag[i__];
+       tempa = MIN2(d__1,d__2);
+/* Computing MAX */
+       d__1 = xopt[i__] - su[i__], d__2 = glag[i__];
+       tempb = MAX2(d__1,d__2);
+       if (tempa > zero || tempb < zero) {
+           w[i__] = bigstp;
+/* Computing 2nd power */
+           d__1 = glag[i__];
+           ggfree += d__1 * d__1;
+       }
+/* L110: */
+    }
+    if (ggfree == zero) {
+       *cauchy = zero;
+       goto L200;
+    }
+
+/*     Investigate whether more components of W can be fixed. */
+
+L120:
+    temp = *adelt * *adelt - wfixsq;
+    if (temp > zero) {
+       wsqsav = wfixsq;
+       step = sqrt(temp / ggfree);
+       ggfree = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (w[i__] == bigstp) {
+               temp = xopt[i__] - step * glag[i__];
+               if (temp <= sl[i__]) {
+                   w[i__] = sl[i__] - xopt[i__];
+/* Computing 2nd power */
+                   d__1 = w[i__];
+                   wfixsq += d__1 * d__1;
+               } else if (temp >= su[i__]) {
+                   w[i__] = su[i__] - xopt[i__];
+/* Computing 2nd power */
+                   d__1 = w[i__];
+                   wfixsq += d__1 * d__1;
+               } else {
+/* Computing 2nd power */
+                   d__1 = glag[i__];
+                   ggfree += d__1 * d__1;
+               }
+           }
+/* L130: */
+       }
+       if (wfixsq > wsqsav && ggfree > zero) {
+           goto L120;
+       }
+    }
+
+/*     Set the remaining free components of W and all components of XALT, */
+/*     except that W may be scaled later. */
+
+    gw = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (w[i__] == bigstp) {
+           w[i__] = -step * glag[i__];
+/* Computing MAX */
+/* Computing MIN */
+           d__3 = su[i__], d__4 = xopt[i__] + w[i__];
+           d__1 = sl[i__], d__2 = MIN2(d__3,d__4);
+           xalt[i__] = MAX2(d__1,d__2);
+       } else if (w[i__] == zero) {
+           xalt[i__] = xopt[i__];
+       } else if (glag[i__] > zero) {
+           xalt[i__] = sl[i__];
+       } else {
+           xalt[i__] = su[i__];
+       }
+/* L140: */
+       gw += glag[i__] * w[i__];
+    }
+
+/*     Set CURV to the curvature of the KNEW-th Lagrange function along W. */
+/*     Scale W by a factor less than one if that can reduce the modulus of */
+/*     the Lagrange function at XOPT+W. Set CAUCHY to the final value of */
+/*     the square of this function. */
+
+    curv = zero;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       temp = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L150: */
+           temp += xpt[k + j * xpt_dim1] * w[j];
+       }
+/* L160: */
+       curv += hcol[k] * temp * temp;
+    }
+    if (iflag == 1) {
+       curv = -curv;
+    }
+    if (curv > -gw && curv < -const__ * gw) {
+       scale = -gw / curv;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           temp = xopt[i__] + scale * w[i__];
+/* L170: */
+/* Computing MAX */
+/* Computing MIN */
+           d__3 = su[i__];
+           d__1 = sl[i__], d__2 = MIN2(d__3,temp);
+           xalt[i__] = MAX2(d__1,d__2);
+       }
+/* Computing 2nd power */
+       d__1 = half * gw * scale;
+       *cauchy = d__1 * d__1;
+    } else {
+/* Computing 2nd power */
+       d__1 = gw + half * curv;
+       *cauchy = d__1 * d__1;
+    }
+
+/*     If IFLAG is zero, then XALT is calculated as before after reversing */
+/*     the sign of GLAG. Thus two XALT vectors become available. The one that */
+/*     is chosen is the one that gives the larger value of CAUCHY. */
+
+    if (iflag == 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           glag[i__] = -glag[i__];
+/* L180: */
+           w[*n + i__] = xalt[i__];
+       }
+       csave = *cauchy;
+       iflag = 1;
+       goto L100;
+    }
+    if (csave > *cauchy) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L190: */
+           xalt[i__] = w[*n + i__];
+       }
+       *cauchy = csave;
+    }
+L200:
+    return;
+} /* altmov_ */
+
+static void trsbox_(int *n, int *npt, double *xpt, 
+       double *xopt, double *gopt, double *hq, double *pq, 
+       double *sl, double *su, double *delta, double *xnew, 
+       double *d__, double *gnew, double *xbdi, double *s, 
+       double *hs, double *hred, double *dsq, double *crvmin)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, i__1, i__2;
+    double d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    int i__, j, k, ih;
+    double ds;
+    int iu;
+    double dhd, dhs, cth, one, shs, sth, ssq, half, beta, sdec, blen;
+    int iact, nact;
+    double angt, qred;
+    int isav;
+    double temp, zero, xsav, xsum, angbd, dredg, sredg;
+    int iterc;
+    double resid, delsq, ggsav, tempa, tempb, ratio, sqstp, redmax, 
+           dredsq, redsav, onemin, gredsq, rednew;
+    int itcsav;
+    double rdprev, rdnext, stplen, stepsq;
+    int itermax;
+
+
+/*     The arguments N, NPT, XPT, XOPT, GOPT, HQ, PQ, SL and SU have the same */
+/*       meanings as the corresponding arguments of BOBYQB. */
+/*     DELTA is the trust region radius for the present calculation, which */
+/*       seeks a small value of the quadratic model within distance DELTA of */
+/*       XOPT subject to the bounds on the variables. */
+/*     XNEW will be set to a new vector of variables that is approximately */
+/*       the one that minimizes the quadratic model within the trust region */
+/*       subject to the SL and SU constraints on the variables. It satisfies */
+/*       as equations the bounds that become active during the calculation. */
+/*     D is the calculated trial step from XOPT, generated iteratively from an */
+/*       initial value of zero. Thus XNEW is XOPT+D after the final iteration. */
+/*     GNEW holds the gradient of the quadratic model at XOPT+D. It is updated */
+/*       when D is updated. */
+/*     XBDI is a working space vector. For I=1,2,...,N, the element XBDI(I) is */
+/*       set to -1.0, 0.0, or 1.0, the value being nonzero if and only if the */
+/*       I-th variable has become fixed at a bound, the bound being SL(I) or */
+/*       SU(I) in the case XBDI(I)=-1.0 or XBDI(I)=1.0, respectively. This */
+/*       information is accumulated during the construction of XNEW. */
+/*     The arrays S, HS and HRED are also used for working space. They hold the */
+/*       current search direction, and the changes in the gradient of Q along S */
+/*       and the reduced D, respectively, where the reduced D is the same as D, */
+/*       except that the components of the fixed variables are zero. */
+/*     DSQ will be set to the square of the length of XNEW-XOPT. */
+/*     CRVMIN is set to zero if D reaches the trust region boundary. Otherwise */
+/*       it is set to the least curvature of H that occurs in the conjugate */
+/*       gradient searches that are not restricted by any constraints. The */
+/*       value CRVMIN=-1.0D0 is set, however, if all of these searches are */
+/*       constrained. */
+
+/*     A version of the truncated conjugate gradient is applied. If a line */
+/*     search is restricted by a constraint, then the procedure is restarted, */
+/*     the values of the variables that are at their bounds being fixed. If */
+/*     the trust region boundary is reached, then further changes may be made */
+/*     to D, each one being in the two dimensional space that is spanned */
+/*     by the current D and the gradient of Q at XOPT+D, staying on the trust */
+/*     region boundary. Termination occurs when the reduction in Q seems to */
+/*     be close to the greatest reduction that can be achieved. */
+
+/*     Set some constants. */
+
+    /* Parameter adjustments */
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xopt;
+    --gopt;
+    --hq;
+    --pq;
+    --sl;
+    --su;
+    --xnew;
+    --d__;
+    --gnew;
+    --xbdi;
+    --s;
+    --hs;
+    --hred;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    onemin = -1.;
+    zero = 0.;
+
+/*     The sign of GOPT(I) gives the sign of the change to the I-th variable */
+/*     that will reduce Q from its value at XOPT. Thus XBDI(I) shows whether */
+/*     or not to fix the I-th variable at one of its bounds initially, with */
+/*     NACT being set to the number of fixed variables. D and GNEW are also */
+/*     set for the first iteration. DELSQ is the upper bound on the sum of */
+/*     squares of the free variables. QRED is the reduction in Q so far. */
+
+    iterc = 0;
+    nact = 0;
+    sqstp = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       xbdi[i__] = zero;
+       if (xopt[i__] <= sl[i__]) {
+           if (gopt[i__] >= zero) {
+               xbdi[i__] = onemin;
+           }
+       } else if (xopt[i__] >= su[i__]) {
+           if (gopt[i__] <= zero) {
+               xbdi[i__] = one;
+           }
+       }
+       if (xbdi[i__] != zero) {
+           ++nact;
+       }
+       d__[i__] = zero;
+/* L10: */
+       gnew[i__] = gopt[i__];
+    }
+    delsq = *delta * *delta;
+    qred = zero;
+    *crvmin = onemin;
+
+/*     Set the next search direction of the conjugate gradient method. It is */
+/*     the steepest descent direction initially and when the iterations are */
+/*     restarted because a variable has just been fixed by a bound, and of */
+/*     course the components of the fixed variables are zero. ITERMAX is an */
+/*     upper bound on the indices of the conjugate gradient iterations. */
+
+L20:
+    beta = zero;
+L30:
+    stepsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] != zero) {
+           s[i__] = zero;
+       } else if (beta == zero) {
+           s[i__] = -gnew[i__];
+       } else {
+           s[i__] = beta * s[i__] - gnew[i__];
+       }
+/* L40: */
+/* Computing 2nd power */
+       d__1 = s[i__];
+       stepsq += d__1 * d__1;
+    }
+    if (stepsq == zero) {
+       goto L190;
+    }
+    if (beta == zero) {
+       gredsq = stepsq;
+       itermax = iterc + *n - nact;
+    }
+    if (gredsq * delsq <= qred * 1e-4 * qred) {
+       goto L190;
+    }
+
+/*     Multiply the search direction by the second derivative matrix of Q and */
+/*     calculate some scalars for the choice of steplength. Then set BLEN to */
+/*     the length of the the step to the trust region boundary and STPLEN to */
+/*     the steplength, ignoring the simple bounds. */
+
+    goto L210;
+L50:
+    resid = delsq;
+    ds = zero;
+    shs = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] == zero) {
+/* Computing 2nd power */
+           d__1 = d__[i__];
+           resid -= d__1 * d__1;
+           ds += s[i__] * d__[i__];
+           shs += s[i__] * hs[i__];
+       }
+/* L60: */
+    }
+    if (resid <= zero) {
+       goto L90;
+    }
+    temp = sqrt(stepsq * resid + ds * ds);
+    if (ds < zero) {
+       blen = (temp - ds) / stepsq;
+    } else {
+       blen = resid / (temp + ds);
+    }
+    stplen = blen;
+    if (shs > zero) {
+/* Computing MIN */
+       d__1 = blen, d__2 = gredsq / shs;
+       stplen = MIN2(d__1,d__2);
+    }
+
+/*     Reduce STPLEN if necessary in order to preserve the simple bounds, */
+/*     letting IACT be the index of the new constrained variable. */
+
+    iact = 0;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (s[i__] != zero) {
+           xsum = xopt[i__] + d__[i__];
+           if (s[i__] > zero) {
+               temp = (su[i__] - xsum) / s[i__];
+           } else {
+               temp = (sl[i__] - xsum) / s[i__];
+           }
+           if (temp < stplen) {
+               stplen = temp;
+               iact = i__;
+           }
+       }
+/* L70: */
+    }
+
+/*     Update CRVMIN, GNEW and D. Set SDEC to the decrease that occurs in Q. */
+
+    sdec = zero;
+    if (stplen > zero) {
+       ++iterc;
+       temp = shs / stepsq;
+       if (iact == 0 && temp > zero) {
+           *crvmin = MIN2(*crvmin,temp);
+           if (*crvmin == onemin) {
+               *crvmin = temp;
+           }
+       }
+       ggsav = gredsq;
+       gredsq = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           gnew[i__] += stplen * hs[i__];
+           if (xbdi[i__] == zero) {
+/* Computing 2nd power */
+               d__1 = gnew[i__];
+               gredsq += d__1 * d__1;
+           }
+/* L80: */
+           d__[i__] += stplen * s[i__];
+       }
+/* Computing MAX */
+       d__1 = stplen * (ggsav - half * stplen * shs);
+       sdec = MAX2(d__1,zero);
+       qred += sdec;
+    }
+
+/*     Restart the conjugate gradient method if it has hit a new bound. */
+
+    if (iact > 0) {
+       ++nact;
+       xbdi[iact] = one;
+       if (s[iact] < zero) {
+           xbdi[iact] = onemin;
+       }
+/* Computing 2nd power */
+       d__1 = d__[iact];
+       delsq -= d__1 * d__1;
+       if (delsq <= zero) {
+           goto L90;
+       }
+       goto L20;
+    }
+
+/*     If STPLEN is less than BLEN, then either apply another conjugate */
+/*     gradient iteration or RETURN. */
+
+    if (stplen < blen) {
+       if (iterc == itermax) {
+           goto L190;
+       }
+       if (sdec <= qred * .01) {
+           goto L190;
+       }
+       beta = gredsq / ggsav;
+       goto L30;
+    }
+L90:
+    *crvmin = zero;
+
+/*     Prepare for the alternative iteration by calculating some scalars */
+/*     and by multiplying the reduced D by the second derivative matrix of */
+/*     Q, where S holds the reduced D in the call of GGMULT. */
+
+L100:
+    if (nact >= *n - 1) {
+       goto L190;
+    }
+    dredsq = zero;
+    dredg = zero;
+    gredsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] == zero) {
+/* Computing 2nd power */
+           d__1 = d__[i__];
+           dredsq += d__1 * d__1;
+           dredg += d__[i__] * gnew[i__];
+/* Computing 2nd power */
+           d__1 = gnew[i__];
+           gredsq += d__1 * d__1;
+           s[i__] = d__[i__];
+       } else {
+           s[i__] = zero;
+       }
+/* L110: */
+    }
+    itcsav = iterc;
+    goto L210;
+
+/*     Let the search direction S be a linear combination of the reduced D */
+/*     and the reduced G that is orthogonal to the reduced D. */
+
+L120:
+    ++iterc;
+    temp = gredsq * dredsq - dredg * dredg;
+    if (temp <= qred * 1e-4 * qred) {
+       goto L190;
+    }
+    temp = sqrt(temp);
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] == zero) {
+           s[i__] = (dredg * d__[i__] - dredsq * gnew[i__]) / temp;
+       } else {
+           s[i__] = zero;
+       }
+/* L130: */
+    }
+    sredg = -temp;
+
+/*     By considering the simple bounds on the variables, calculate an upper */
+/*     bound on the tangent of half the angle of the alternative iteration, */
+/*     namely ANGBD, except that, if already a free variable has reached a */
+/*     bound, there is a branch back to label 100 after fixing that variable. */
+
+    angbd = one;
+    iact = 0;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] == zero) {
+           tempa = xopt[i__] + d__[i__] - sl[i__];
+           tempb = su[i__] - xopt[i__] - d__[i__];
+           if (tempa <= zero) {
+               ++nact;
+               xbdi[i__] = onemin;
+               goto L100;
+           } else if (tempb <= zero) {
+               ++nact;
+               xbdi[i__] = one;
+               goto L100;
+           }
+           ratio = one;
+/* Computing 2nd power */
+           d__1 = d__[i__];
+/* Computing 2nd power */
+           d__2 = s[i__];
+           ssq = d__1 * d__1 + d__2 * d__2;
+/* Computing 2nd power */
+           d__1 = xopt[i__] - sl[i__];
+           temp = ssq - d__1 * d__1;
+           if (temp > zero) {
+               temp = sqrt(temp) - s[i__];
+               if (angbd * temp > tempa) {
+                   angbd = tempa / temp;
+                   iact = i__;
+                   xsav = onemin;
+               }
+           }
+/* Computing 2nd power */
+           d__1 = su[i__] - xopt[i__];
+           temp = ssq - d__1 * d__1;
+           if (temp > zero) {
+               temp = sqrt(temp) + s[i__];
+               if (angbd * temp > tempb) {
+                   angbd = tempb / temp;
+                   iact = i__;
+                   xsav = one;
+               }
+           }
+       }
+/* L140: */
+    }
+
+/*     Calculate HHD and some curvatures for the alternative iteration. */
+
+    goto L210;
+L150:
+    shs = zero;
+    dhs = zero;
+    dhd = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (xbdi[i__] == zero) {
+           shs += s[i__] * hs[i__];
+           dhs += d__[i__] * hs[i__];
+           dhd += d__[i__] * hred[i__];
+       }
+/* L160: */
+    }
+
+/*     Seek the greatest reduction in Q for a range of equally spaced values */
+/*     of ANGT in [0,ANGBD], where ANGT is the tangent of half the angle of */
+/*     the alternative iteration. */
+
+    redmax = zero;
+    isav = 0;
+    redsav = zero;
+    iu = (int) (angbd * 17. + 3.1);
+    i__1 = iu;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       angt = angbd * (double) i__ / (double) iu;
+       sth = (angt + angt) / (one + angt * angt);
+       temp = shs + angt * (angt * dhd - dhs - dhs);
+       rednew = sth * (angt * dredg - sredg - half * sth * temp);
+       if (rednew > redmax) {
+           redmax = rednew;
+           isav = i__;
+           rdprev = redsav;
+       } else if (i__ == isav + 1) {
+           rdnext = rednew;
+       }
+/* L170: */
+       redsav = rednew;
+    }
+
+/*     Return if the reduction is zero. Otherwise, set the sine and cosine */
+/*     of the angle of the alternative iteration, and calculate SDEC. */
+
+    if (isav == 0) {
+       goto L190;
+    }
+    if (isav < iu) {
+       temp = (rdnext - rdprev) / (redmax + redmax - rdprev - rdnext);
+       angt = angbd * ((double) isav + half * temp) / (double) iu;
+    }
+    cth = (one - angt * angt) / (one + angt * angt);
+    sth = (angt + angt) / (one + angt * angt);
+    temp = shs + angt * (angt * dhd - dhs - dhs);
+    sdec = sth * (angt * dredg - sredg - half * sth * temp);
+    if (sdec <= zero) {
+       goto L190;
+    }
+
+/*     Update GNEW, D and HRED. If the angle of the alternative iteration */
+/*     is restricted by a bound on a free variable, that variable is fixed */
+/*     at the bound. */
+
+    dredg = zero;
+    gredsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       gnew[i__] = gnew[i__] + (cth - one) * hred[i__] + sth * hs[i__];
+       if (xbdi[i__] == zero) {
+           d__[i__] = cth * d__[i__] + sth * s[i__];
+           dredg += d__[i__] * gnew[i__];
+/* Computing 2nd power */
+           d__1 = gnew[i__];
+           gredsq += d__1 * d__1;
+       }
+/* L180: */
+       hred[i__] = cth * hred[i__] + sth * hs[i__];
+    }
+    qred += sdec;
+    if (iact > 0 && isav == iu) {
+       ++nact;
+       xbdi[iact] = xsav;
+       goto L100;
+    }
+
+/*     If SDEC is sufficiently small, then RETURN after setting XNEW to */
+/*     XOPT+D, giving careful attention to the bounds. */
+
+    if (sdec > qred * .01) {
+       goto L120;
+    }
+L190:
+    *dsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing MAX */
+/* Computing MIN */
+       d__3 = xopt[i__] + d__[i__], d__4 = su[i__];
+       d__1 = MIN2(d__3,d__4), d__2 = sl[i__];
+       xnew[i__] = MAX2(d__1,d__2);
+       if (xbdi[i__] == onemin) {
+           xnew[i__] = sl[i__];
+       }
+       if (xbdi[i__] == one) {
+           xnew[i__] = su[i__];
+       }
+       d__[i__] = xnew[i__] - xopt[i__];
+/* L200: */
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       *dsq += d__1 * d__1;
+    }
+    return;
+/*     The following instructions multiply the current S-vector by the second */
+/*     derivative matrix of the quadratic model, putting the product in HS. */
+/*     They are reached from three different parts of the software above and */
+/*     they can be regarded as an external subroutine. */
+
+L210:
+    ih = 0;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       hs[j] = zero;
+       i__2 = j;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           ++ih;
+           if (i__ < j) {
+               hs[j] += hq[ih] * s[i__];
+           }
+/* L220: */
+           hs[i__] += hq[ih] * s[j];
+       }
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       if (pq[k] != zero) {
+           temp = zero;
+           i__1 = *n;
+           for (j = 1; j <= i__1; ++j) {
+/* L230: */
+               temp += xpt[k + j * xpt_dim1] * s[j];
+           }
+           temp *= pq[k];
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+/* L240: */
+               hs[i__] += temp * xpt[k + i__ * xpt_dim1];
+           }
+       }
+/* L250: */
+    }
+    if (*crvmin != zero) {
+       goto L50;
+    }
+    if (iterc > itcsav) {
+       goto L150;
+    }
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L260: */
+       hred[i__] = hs[i__];
+    }
+    goto L120;
+} /* trsbox_ */
+
+static nlopt_result prelim_(int *n, int *npt, double *x, 
+       const double *xl, const double *xu, double *rhobeg, 
+                   nlopt_stopping *stop,
+                   bobyqa_func calfun, void *calfun_data,
+        double *xbase, double *xpt, double *fval,
+        double *gopt, double *hq, double *pq, double *bmat, 
+       double *zmat, int *ndim, double *sl, double *su, 
+                   int *kopt)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2;
+    double d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    double f;
+    int i__, j, k, ih, np, nfm;
+    double one;
+    int nfx, ipt, jpt;
+    double two, fbeg, diff, half, temp, zero, recip, stepa, stepb;
+    int itemp;
+    double rhosq;
+
+    int nf;
+
+/*     The arguments N, NPT, X, XL, XU, RHOBEG, and MAXFUN are the */
+/*       same as the corresponding arguments in SUBROUTINE BOBYQA. */
+/*     The arguments XBASE, XPT, FVAL, HQ, PQ, BMAT, ZMAT, NDIM, SL and SU */
+/*       are the same as the corresponding arguments in BOBYQB, the elements */
+/*       of SL and SU being set in BOBYQA. */
+/*     GOPT is usually the gradient of the quadratic model at XOPT+XBASE, but */
+/*       it is set by PRELIM to the gradient of the quadratic model at XBASE. */
+/*       If XOPT is nonzero, BOBYQB will change it to its usual value later. */
+/*     NF is maintaned as the number of calls of CALFUN so far. */
+/*     KOPT will be such that the least calculated value of F so far is at */
+/*       the point XPT(KOPT,.)+XBASE in the space of the variables. */
+
+/*     SUBROUTINE PRELIM sets the elements of XBASE, XPT, FVAL, GOPT, HQ, PQ, */
+/*     BMAT and ZMAT for the first iteration, and it maintains the values of */
+/*     NF and KOPT. The vector X is also changed by PRELIM. */
+
+/*     Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --x;
+    --xl;
+    --xu;
+    --xbase;
+    --fval;
+    --gopt;
+    --hq;
+    --pq;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --sl;
+    --su;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    two = 2.;
+    zero = 0.;
+    rhosq = *rhobeg * *rhobeg;
+    recip = one / rhosq;
+    np = *n + 1;
+
+/*     Set XBASE to the initial vector of variables, and set the initial */
+/*     elements of XPT, BMAT, HQ, PQ and ZMAT to zero. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       xbase[j] = x[j];
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L10: */
+           xpt[k + j * xpt_dim1] = zero;
+       }
+       i__2 = *ndim;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L20: */
+           bmat[i__ + j * bmat_dim1] = zero;
+       }
+    }
+    i__2 = *n * np / 2;
+    for (ih = 1; ih <= i__2; ++ih) {
+/* L30: */
+       hq[ih] = zero;
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       pq[k] = zero;
+       i__1 = *npt - np;
+       for (j = 1; j <= i__1; ++j) {
+/* L40: */
+           zmat[k + j * zmat_dim1] = zero;
+       }
+    }
+
+/*     Begin the initialization procedure. NF becomes one more than the number */
+/*     of function values so far. The coordinates of the displacement of the */
+/*     next initial interpolation point from XBASE are set in XPT(NF+1,.). */
+
+    nf = 0;
+L50:
+    nfm = nf;
+    nfx = nf - *n;
+    ++(nf);
+    if (nfm <= *n << 1) {
+       if (nfm >= 1 && nfm <= *n) {
+           stepa = *rhobeg;
+           if (su[nfm] == zero) {
+               stepa = -stepa;
+           }
+           xpt[nf + nfm * xpt_dim1] = stepa;
+       } else if (nfm > *n) {
+           stepa = xpt[nf - *n + nfx * xpt_dim1];
+           stepb = -(*rhobeg);
+           if (sl[nfx] == zero) {
+/* Computing MIN */
+               d__1 = two * *rhobeg, d__2 = su[nfx];
+               stepb = MIN2(d__1,d__2);
+           }
+           if (su[nfx] == zero) {
+/* Computing MAX */
+               d__1 = -two * *rhobeg, d__2 = sl[nfx];
+               stepb = MAX2(d__1,d__2);
+           }
+           xpt[nf + nfx * xpt_dim1] = stepb;
+       }
+    } else {
+       itemp = (nfm - np) / *n;
+       jpt = nfm - itemp * *n - *n;
+       ipt = jpt + itemp;
+       if (ipt > *n) {
+           itemp = jpt;
+           jpt = ipt - *n;
+           ipt = itemp;
+       }
+       xpt[nf + ipt * xpt_dim1] = xpt[ipt + 1 + ipt * xpt_dim1];
+       xpt[nf + jpt * xpt_dim1] = xpt[jpt + 1 + jpt * xpt_dim1];
+    }
+
+/*     Calculate the next value of F. The least function value so far and */
+/*     its index are required. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MIN */
+/* Computing MAX */
+       d__3 = xl[j], d__4 = xbase[j] + xpt[nf + j * xpt_dim1];
+       d__1 = MAX2(d__3,d__4), d__2 = xu[j];
+       x[j] = MIN2(d__1,d__2);
+       if (xpt[nf + j * xpt_dim1] == sl[j]) {
+           x[j] = xl[j];
+       }
+       if (xpt[nf + j * xpt_dim1] == su[j]) {
+           x[j] = xu[j];
+       }
+/* L60: */
+    }
+    stop->nevals++;
+    f = calfun(*n, &x[1], calfun_data);
+    fval[nf] = f;
+    if (nf == 1) {
+       fbeg = f;
+       *kopt = 1;
+    } else if (f < fval[*kopt]) {
+       *kopt = nf;
+    }
+
+/*     Set the nonzero initial elements of BMAT and the quadratic model in the */
+/*     cases when NF is at most 2*N+1. If NF exceeds N+1, then the positions */
+/*     of the NF-th and (NF-N)-th interpolation points may be switched, in */
+/*     order that the function value at the first of them contributes to the */
+/*     off-diagonal second derivative terms of the initial quadratic model. */
+
+    if (nf <= (*n << 1) + 1) {
+       if (nf >= 2 && nf <= *n + 1) {
+           gopt[nfm] = (f - fbeg) / stepa;
+           if (*npt < nf + *n) {
+               bmat[nfm * bmat_dim1 + 1] = -one / stepa;
+               bmat[nf + nfm * bmat_dim1] = one / stepa;
+               bmat[*npt + nfm + nfm * bmat_dim1] = -half * rhosq;
+           }
+       } else if (nf >= *n + 2) {
+           ih = nfx * (nfx + 1) / 2;
+           temp = (f - fbeg) / stepb;
+           diff = stepb - stepa;
+           hq[ih] = two * (temp - gopt[nfx]) / diff;
+           gopt[nfx] = (gopt[nfx] * stepb - temp * stepa) / diff;
+           if (stepa * stepb < zero) {
+               if (f < fval[nf - *n]) {
+                   fval[nf] = fval[nf - *n];
+                   fval[nf - *n] = f;
+                   if (*kopt == nf) {
+                       *kopt = nf - *n;
+                   }
+                   xpt[nf - *n + nfx * xpt_dim1] = stepb;
+                   xpt[nf + nfx * xpt_dim1] = stepa;
+               }
+           }
+           bmat[nfx * bmat_dim1 + 1] = -(stepa + stepb) / (stepa * stepb);
+           bmat[nf + nfx * bmat_dim1] = -half / xpt[nf - *n + nfx * 
+                   xpt_dim1];
+           bmat[nf - *n + nfx * bmat_dim1] = -bmat[nfx * bmat_dim1 + 1] - 
+                   bmat[nf + nfx * bmat_dim1];
+           zmat[nfx * zmat_dim1 + 1] = sqrt(two) / (stepa * stepb);
+           zmat[nf + nfx * zmat_dim1] = sqrt(half) / rhosq;
+           zmat[nf - *n + nfx * zmat_dim1] = -zmat[nfx * zmat_dim1 + 1] - 
+                   zmat[nf + nfx * zmat_dim1];
+       }
+
+/*     Set the off-diagonal second derivatives of the Lagrange functions and */
+/*     the initial quadratic model. */
+
+    } else {
+       ih = ipt * (ipt - 1) / 2 + jpt;
+       zmat[nfx * zmat_dim1 + 1] = recip;
+       zmat[nf + nfx * zmat_dim1] = recip;
+       zmat[ipt + 1 + nfx * zmat_dim1] = -recip;
+       zmat[jpt + 1 + nfx * zmat_dim1] = -recip;
+       temp = xpt[nf + ipt * xpt_dim1] * xpt[nf + jpt * xpt_dim1];
+       hq[ih] = (fbeg - fval[ipt + 1] - fval[jpt + 1] + f) / temp;
+    }
+    if (nlopt_stop_forced(stop)) return NLOPT_FORCED_STOP;
+    else if (f < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+    else if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+    else if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+    if (nf < *npt) {
+       goto L50;
+    }
+    return NLOPT_SUCCESS;
+} /* prelim_ */
+
+static nlopt_result bobyqb_(int *n, int *npt, double *x, 
+       const double *xl, const double *xu, double *rhobeg, double *
+       rhoend, 
+                           nlopt_stopping *stop,
+                           bobyqa_func calfun, void *calfun_data,
+                           double *minf,
+        double *xbase, 
+       double *xpt, double *fval, double *xopt, double *gopt,
+        double *hq, double *pq, double *bmat, double *zmat, 
+       int *ndim, double *sl, double *su, double *xnew, 
+       double *xalt, double *d__, double *vlag, double *w)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2, i__3;
+    double d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    double f;
+    int i__, j, k, ih, jj, nh, ip, jp;
+    double dx;
+    int np;
+    double den, one, ten, dsq, rho, sum, two, diff, half, beta, gisq;
+    int knew;
+    double temp, suma, sumb, bsum, fopt;
+    int kopt, nptm;
+    double zero, curv;
+    int ksav;
+    double gqsq, dist, sumw, sumz, diffa, diffb, diffc, hdiag;
+    int kbase;
+    double alpha, delta, adelt, denom, fsave, bdtol, delsq;
+    int nresc, nfsav;
+    double ratio, dnorm, vquad, pqold, tenth;
+    int itest;
+    double sumpq, scaden;
+    double errbig, cauchy, fracsq, biglsq, densav;
+    double bdtest;
+    double crvmin, frhosq;
+    double distsq;
+    int ntrits;
+    double xoptsq;
+
+    nlopt_result rc = NLOPT_SUCCESS, rc2;
+
+/*     The arguments N, NPT, X, XL, XU, RHOBEG, RHOEND, and MAXFUN */
+/*       are identical to the corresponding arguments in SUBROUTINE BOBYQA. */
+/*     XBASE holds a shift of origin that should reduce the contributions */
+/*       from rounding errors to values of the model and Lagrange functions. */
+/*     XPT is a two-dimensional array that holds the coordinates of the */
+/*       interpolation points relative to XBASE. */
+/*     FVAL holds the values of F at the interpolation points. */
+/*     XOPT is set to the displacement from XBASE of the trust region centre. */
+/*     GOPT holds the gradient of the quadratic model at XBASE+XOPT. */
+/*     HQ holds the explicit second derivatives of the quadratic model. */
+/*     PQ contains the parameters of the implicit second derivatives of the */
+/*       quadratic model. */
+/*     BMAT holds the last N columns of H. */
+/*     ZMAT holds the factorization of the leading NPT by NPT submatrix of H, */
+/*       this factorization being ZMAT times ZMAT^T, which provides both the */
+/*       correct rank and positive semi-definiteness. */
+/*     NDIM is the first dimension of BMAT and has the value NPT+N. */
+/*     SL and SU hold the differences XL-XBASE and XU-XBASE, respectively. */
+/*       All the components of every XOPT are going to satisfy the bounds */
+/*       SL(I) .LEQ. XOPT(I) .LEQ. SU(I), with appropriate equalities when */
+/*       XOPT is on a constraint boundary. */
+/*     XNEW is chosen by SUBROUTINE TRSBOX or ALTMOV. Usually XBASE+XNEW is the */
+/*       vector of variables for the next call of CALFUN. XNEW also satisfies */
+/*       the SL and SU constraints in the way that has just been mentioned. */
+/*     XALT is an alternative to XNEW, chosen by ALTMOV, that may replace XNEW */
+/*       in order to increase the denominator in the updating of UPDATE. */
+/*     D is reserved for a trial step from XOPT, which is usually XNEW-XOPT. */
+/*     VLAG contains the values of the Lagrange functions at a new point X. */
+/*       They are part of a product that requires VLAG to be of length NDIM. */
+/*     W is a one-dimensional array that is used for working space. Its length */
+/*       must be at least 3*NDIM = 3*(NPT+N). */
+
+/*     Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --x;
+    --xl;
+    --xu;
+    --xbase;
+    --fval;
+    --xopt;
+    --gopt;
+    --hq;
+    --pq;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --sl;
+    --su;
+    --xnew;
+    --xalt;
+    --d__;
+    --vlag;
+    --w;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    ten = 10.;
+    tenth = .1;
+    two = 2.;
+    zero = 0.;
+    np = *n + 1;
+    nptm = *npt - np;
+    nh = *n * np / 2;
+
+/*     The call of PRELIM sets the elements of XBASE, XPT, FVAL, GOPT, HQ, PQ, */
+/*     BMAT and ZMAT for the first iteration, with the corresponding values of */
+/*     of NF and KOPT, which are the number of calls of CALFUN so far and the */
+/*     index of the interpolation point at the trust region centre. Then the */
+/*     initial XOPT is set too. The branch to label 720 occurs if MAXFUN is */
+/*     less than NPT. GOPT will be updated if KOPT is different from KBASE. */
+
+    rc2 = prelim_(n, npt, &x[1], &xl[1], &xu[1], rhobeg, 
+                 stop, calfun, calfun_data,
+           &xbase[1], &xpt[xpt_offset], &fval[1], &gopt[1], &hq[1], &pq[1], &bmat[
+           bmat_offset], &zmat[zmat_offset], ndim, &sl[1], &su[1], &kopt);
+    xoptsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       xopt[i__] = xpt[kopt + i__ * xpt_dim1];
+/* L10: */
+/* Computing 2nd power */
+       d__1 = xopt[i__];
+       xoptsq += d__1 * d__1;
+    }
+    fsave = fval[1];
+    if (rc2 != NLOPT_SUCCESS) {
+      rc = rc2;
+      goto L720;
+    }
+    kbase = 1;
+
+/*     Complete the settings that are required for the iterative procedure. */
+
+    rho = *rhobeg;
+    delta = rho;
+    nresc = stop->nevals;
+    ntrits = 0;
+    diffa = zero;
+    diffb = zero;
+    itest = 0;
+    nfsav = stop->nevals;
+
+/*     Update GOPT if necessary before the first iteration and after each */
+/*     call of RESCUE that makes a call of CALFUN. */
+
+L20:
+    if (kopt != kbase) {
+       ih = 0;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           i__2 = j;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               ++ih;
+               if (i__ < j) {
+                   gopt[j] += hq[ih] * xopt[i__];
+               }
+/* L30: */
+               gopt[i__] += hq[ih] * xopt[j];
+           }
+       }
+       if (stop->nevals > *npt) {
+           i__2 = *npt;
+           for (k = 1; k <= i__2; ++k) {
+               temp = zero;
+               i__1 = *n;
+               for (j = 1; j <= i__1; ++j) {
+/* L40: */
+                   temp += xpt[k + j * xpt_dim1] * xopt[j];
+               }
+               temp = pq[k] * temp;
+               i__1 = *n;
+               for (i__ = 1; i__ <= i__1; ++i__) {
+/* L50: */
+                   gopt[i__] += temp * xpt[k + i__ * xpt_dim1];
+               }
+           }
+       }
+    }
+
+/*     Generate the next point in the trust region that provides a small value */
+/*     of the quadratic model subject to the constraints on the variables. */
+/*     The int NTRITS is set to the number "trust region" iterations that */
+/*     have occurred since the last "alternative" iteration. If the length */
+/*     of XNEW-XOPT is less than HALF*RHO, however, then there is a branch to */
+/*     label 650 or 680 with NTRITS=-1, instead of calculating F at XNEW. */
+
+L60:
+    trsbox_(n, npt, &xpt[xpt_offset], &xopt[1], &gopt[1], &hq[1], &pq[1], &sl[
+           1], &su[1], &delta, &xnew[1], &d__[1], &w[1], &w[np], &w[np + *n],
+            &w[np + (*n << 1)], &w[np + *n * 3], &dsq, &crvmin);
+/* Computing MIN */
+    d__1 = delta, d__2 = sqrt(dsq);
+    dnorm = MIN2(d__1,d__2);
+    if (dnorm < half * rho) {
+       ntrits = -1;
+/* Computing 2nd power */
+       d__1 = ten * rho;
+       distsq = d__1 * d__1;
+       if (stop->nevals <= nfsav + 2) {
+           goto L650;
+       }
+
+/*     The following choice between labels 650 and 680 depends on whether or */
+/*     not our work with the current RHO seems to be complete. Either RHO is */
+/*     decreased or termination occurs if the errors in the quadratic model at */
+/*     the last three interpolation points compare favourably with predictions */
+/*     of likely improvements to the model within distance HALF*RHO of XOPT. */
+
+/* Computing MAX */
+       d__1 = MAX2(diffa,diffb);
+       errbig = MAX2(d__1,diffc);
+       frhosq = rho * .125 * rho;
+       if (crvmin > zero && errbig > frhosq * crvmin) {
+           goto L650;
+       }
+       bdtol = errbig / rho;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           bdtest = bdtol;
+           if (xnew[j] == sl[j]) {
+               bdtest = w[j];
+           }
+           if (xnew[j] == su[j]) {
+               bdtest = -w[j];
+           }
+           if (bdtest < bdtol) {
+               curv = hq[(j + j * j) / 2];
+               i__2 = *npt;
+               for (k = 1; k <= i__2; ++k) {
+/* L70: */
+/* Computing 2nd power */
+                   d__1 = xpt[k + j * xpt_dim1];
+                   curv += pq[k] * (d__1 * d__1);
+               }
+               bdtest += half * curv * rho;
+               if (bdtest < bdtol) {
+                   goto L650;
+               }
+           }
+/* L80: */
+       }
+       goto L680;
+    }
+    ++ntrits;
+
+/*     Severe cancellation is likely to occur if XOPT is too far from XBASE. */
+/*     If the following test holds, then XBASE is shifted so that XOPT becomes */
+/*     zero. The appropriate changes are made to BMAT and to the second */
+/*     derivatives of the current model, beginning with the changes to BMAT */
+/*     that do not depend on ZMAT. VLAG is used temporarily for working space. */
+
+L90:
+    if (dsq <= xoptsq * .001) {
+       fracsq = xoptsq * .25;
+       sumpq = zero;
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+           sumpq += pq[k];
+           sum = -half * xoptsq;
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+/* L100: */
+               sum += xpt[k + i__ * xpt_dim1] * xopt[i__];
+           }
+           w[*npt + k] = sum;
+           temp = fracsq - half * sum;
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               w[i__] = bmat[k + i__ * bmat_dim1];
+               vlag[i__] = sum * xpt[k + i__ * xpt_dim1] + temp * xopt[i__];
+               ip = *npt + i__;
+               i__3 = i__;
+               for (j = 1; j <= i__3; ++j) {
+/* L110: */
+                   bmat[ip + j * bmat_dim1] = bmat[ip + j * bmat_dim1] + w[
+                           i__] * vlag[j] + vlag[i__] * w[j];
+               }
+           }
+       }
+
+/*     Then the revisions of BMAT that depend on ZMAT are calculated. */
+
+       i__3 = nptm;
+       for (jj = 1; jj <= i__3; ++jj) {
+           sumz = zero;
+           sumw = zero;
+           i__2 = *npt;
+           for (k = 1; k <= i__2; ++k) {
+               sumz += zmat[k + jj * zmat_dim1];
+               vlag[k] = w[*npt + k] * zmat[k + jj * zmat_dim1];
+/* L120: */
+               sumw += vlag[k];
+           }
+           i__2 = *n;
+           for (j = 1; j <= i__2; ++j) {
+               sum = (fracsq * sumz - half * sumw) * xopt[j];
+               i__1 = *npt;
+               for (k = 1; k <= i__1; ++k) {
+/* L130: */
+                   sum += vlag[k] * xpt[k + j * xpt_dim1];
+               }
+               w[j] = sum;
+               i__1 = *npt;
+               for (k = 1; k <= i__1; ++k) {
+/* L140: */
+                   bmat[k + j * bmat_dim1] += sum * zmat[k + jj * zmat_dim1];
+               }
+           }
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ip = i__ + *npt;
+               temp = w[i__];
+               i__2 = i__;
+               for (j = 1; j <= i__2; ++j) {
+/* L150: */
+                   bmat[ip + j * bmat_dim1] += temp * w[j];
+               }
+           }
+       }
+
+/*     The following instructions complete the shift, including the changes */
+/*     to the second derivative parameters of the quadratic model. */
+
+       ih = 0;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           w[j] = -half * sumpq * xopt[j];
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+               w[j] += pq[k] * xpt[k + j * xpt_dim1];
+/* L160: */
+               xpt[k + j * xpt_dim1] -= xopt[j];
+           }
+           i__1 = j;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ++ih;
+               hq[ih] = hq[ih] + w[i__] * xopt[j] + xopt[i__] * w[j];
+/* L170: */
+               bmat[*npt + i__ + j * bmat_dim1] = bmat[*npt + j + i__ * 
+                       bmat_dim1];
+           }
+       }
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           xbase[i__] += xopt[i__];
+           xnew[i__] -= xopt[i__];
+           sl[i__] -= xopt[i__];
+           su[i__] -= xopt[i__];
+/* L180: */
+           xopt[i__] = zero;
+       }
+       xoptsq = zero;
+    }
+    if (ntrits == 0) {
+       goto L210;
+    }
+    goto L230;
+
+/*     XBASE is also moved to XOPT by a call of RESCUE. This calculation is */
+/*     more expensive than the previous shift, because new matrices BMAT and */
+/*     ZMAT are generated from scratch, which may include the replacement of */
+/*     interpolation points whose positions seem to be causing near linear */
+/*     dependence in the interpolation conditions. Therefore RESCUE is called */
+/*     only if rounding errors have reduced by at least a factor of two the */
+/*     denominator of the formula for updating the H matrix. It provides a */
+/*     useful safeguard, but is not invoked in most applications of BOBYQA. */
+
+L190:
+    nfsav = stop->nevals;
+    kbase = kopt;
+    rc2 = rescue_(n, npt, &xl[1], &xu[1], 
+                 stop, calfun, calfun_data,
+                 &xbase[1], &xpt[xpt_offset], &fval[1], &xopt[1], &gopt[1],
+                 &hq[1], &pq[1], &bmat[bmat_offset], &zmat[zmat_offset], ndim,
+                 &sl[1], &su[1], &delta, &kopt, &vlag[1],
+                 &w[1], &w[*n + np], &w[*ndim + np]);
+
+/*     XOPT is updated now in case the branch below to label 720 is taken. */
+/*     Any updating of GOPT occurs after the branch below to label 20, which */
+/*     leads to a trust region iteration as does the branch to label 60. */
+
+    xoptsq = zero;
+    if (kopt != kbase) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           xopt[i__] = xpt[kopt + i__ * xpt_dim1];
+/* L200: */
+/* Computing 2nd power */
+           d__1 = xopt[i__];
+           xoptsq += d__1 * d__1;
+       }
+    }
+    if (rc2 != NLOPT_SUCCESS) { 
+      rc = rc2;
+      goto L720; 
+    }
+    nresc = stop->nevals;
+    if (nfsav < stop->nevals) {
+       nfsav = stop->nevals;
+       goto L20;
+    }
+    if (ntrits > 0) {
+       goto L60;
+    }
+
+/*     Pick two alternative vectors of variables, relative to XBASE, that */
+/*     are suitable as new positions of the KNEW-th interpolation point. */
+/*     Firstly, XNEW is set to the point on a line through XOPT and another */
+/*     interpolation point that minimizes the predicted value of the next */
+/*     denominator, subject to ||XNEW - XOPT|| .LEQ. ADELT and to the SL */
+/*     and SU bounds. Secondly, XALT is set to the best feasible point on */
+/*     a constrained version of the Cauchy step of the KNEW-th Lagrange */
+/*     function, the corresponding value of the square of this function */
+/*     being returned in CAUCHY. The choice between these alternatives is */
+/*     going to be made when the denominator is calculated. */
+
+L210:
+    altmov_(n, npt, &xpt[xpt_offset], &xopt[1], &bmat[bmat_offset], &zmat[
+           zmat_offset], ndim, &sl[1], &su[1], &kopt, &knew, &adelt, &xnew[1]
+           , &xalt[1], &alpha, &cauchy, &w[1], &w[np], &w[*ndim + 1]);
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L220: */
+       d__[i__] = xnew[i__] - xopt[i__];
+    }
+
+/*     Calculate VLAG and BETA for the current choice of D. The scalar */
+/*     product of D with XPT(K,.) is going to be held in W(NPT+K) for */
+/*     use when VQUAD is calculated. */
+
+L230:
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       suma = zero;
+       sumb = zero;
+       sum = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           suma += xpt[k + j * xpt_dim1] * d__[j];
+           sumb += xpt[k + j * xpt_dim1] * xopt[j];
+/* L240: */
+           sum += bmat[k + j * bmat_dim1] * d__[j];
+       }
+       w[k] = suma * (half * suma + sumb);
+       vlag[k] = sum;
+/* L250: */
+       w[*npt + k] = suma;
+    }
+    beta = zero;
+    i__1 = nptm;
+    for (jj = 1; jj <= i__1; ++jj) {
+       sum = zero;
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L260: */
+           sum += zmat[k + jj * zmat_dim1] * w[k];
+       }
+       beta -= sum * sum;
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L270: */
+           vlag[k] += sum * zmat[k + jj * zmat_dim1];
+       }
+    }
+    dsq = zero;
+    bsum = zero;
+    dx = zero;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+/* Computing 2nd power */
+       d__1 = d__[j];
+       dsq += d__1 * d__1;
+       sum = zero;
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L280: */
+           sum += w[k] * bmat[k + j * bmat_dim1];
+       }
+       bsum += sum * d__[j];
+       jp = *npt + j;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L290: */
+           sum += bmat[jp + i__ * bmat_dim1] * d__[i__];
+       }
+       vlag[jp] = sum;
+       bsum += sum * d__[j];
+/* L300: */
+       dx += d__[j] * xopt[j];
+    }
+    beta = dx * dx + dsq * (xoptsq + dx + dx + half * dsq) + beta - bsum;
+    vlag[kopt] += one;
+
+/*     If NTRITS is zero, the denominator may be increased by replacing */
+/*     the step D of ALTMOV by a Cauchy step. Then RESCUE may be called if */
+/*     rounding errors have damaged the chosen denominator. */
+
+    if (ntrits == 0) {
+/* Computing 2nd power */
+       d__1 = vlag[knew];
+       denom = d__1 * d__1 + alpha * beta;
+       if (denom < cauchy && cauchy > zero) {
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               xnew[i__] = xalt[i__];
+/* L310: */
+               d__[i__] = xnew[i__] - xopt[i__];
+           }
+           cauchy = zero;
+           goto L230;
+       }
+/* Computing 2nd power */
+       d__1 = vlag[knew];
+       if (denom <= half * (d__1 * d__1)) {
+           if (stop->nevals > nresc) {
+               goto L190;
+           }
+           /* Return from BOBYQA because of much cancellation in a
+              denominator. */
+           rc = NLOPT_ROUNDOFF_LIMITED;
+           goto L720;
+       }
+
+/*     Alternatively, if NTRITS is positive, then set KNEW to the index of */
+/*     the next interpolation point to be deleted to make room for a trust */
+/*     region step. Again RESCUE may be called if rounding errors have damaged */
+/*     the chosen denominator, which is the reason for attempting to select */
+/*     KNEW before calculating the next value of the objective function. */
+
+    } else {
+       delsq = delta * delta;
+       scaden = zero;
+       biglsq = zero;
+       knew = 0;
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+           if (k == kopt) {
+               goto L350;
+           }
+           hdiag = zero;
+           i__1 = nptm;
+           for (jj = 1; jj <= i__1; ++jj) {
+/* L330: */
+/* Computing 2nd power */
+               d__1 = zmat[k + jj * zmat_dim1];
+               hdiag += d__1 * d__1;
+           }
+/* Computing 2nd power */
+           d__1 = vlag[k];
+           den = beta * hdiag + d__1 * d__1;
+           distsq = zero;
+           i__1 = *n;
+           for (j = 1; j <= i__1; ++j) {
+/* L340: */
+/* Computing 2nd power */
+               d__1 = xpt[k + j * xpt_dim1] - xopt[j];
+               distsq += d__1 * d__1;
+           }
+/* Computing MAX */
+/* Computing 2nd power */
+           d__3 = distsq / delsq;
+           d__1 = one, d__2 = d__3 * d__3;
+           temp = MAX2(d__1,d__2);
+           if (temp * den > scaden) {
+               scaden = temp * den;
+               knew = k;
+               denom = den;
+           }
+/* Computing MAX */
+/* Computing 2nd power */
+           d__3 = vlag[k];
+           d__1 = biglsq, d__2 = temp * (d__3 * d__3);
+           biglsq = MAX2(d__1,d__2);
+L350:
+           ;
+       }
+       if (scaden <= half * biglsq) {
+           if (stop->nevals > nresc) {
+               goto L190;
+           }
+           /* Return from BOBYQA because of much cancellation in a
+              denominator. */
+           rc = NLOPT_ROUNDOFF_LIMITED;
+           goto L720;
+       }
+    }
+
+/*     Put the variables for the next calculation of the objective function */
+/*       in XNEW, with any adjustments for the bounds. */
+
+
+/*     Calculate the value of the objective function at XBASE+XNEW, unless */
+/*       the limit on the number of calculations of F has been reached. */
+
+L360:
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* Computing MIN */
+/* Computing MAX */
+       d__3 = xl[i__], d__4 = xbase[i__] + xnew[i__];
+       d__1 = MAX2(d__3,d__4), d__2 = xu[i__];
+       x[i__] = MIN2(d__1,d__2);
+       if (xnew[i__] == sl[i__]) {
+           x[i__] = xl[i__];
+       }
+       if (xnew[i__] == su[i__]) {
+           x[i__] = xu[i__];
+       }
+/* L380: */
+    }
+
+    if (nlopt_stop_forced(stop)) rc = NLOPT_FORCED_STOP;
+    else if (nlopt_stop_evals(stop)) rc = NLOPT_MAXEVAL_REACHED;
+    else if (nlopt_stop_time(stop)) rc = NLOPT_MAXTIME_REACHED;
+    if (rc != NLOPT_SUCCESS) goto L720;
+
+    stop->nevals++;
+    f = calfun(*n, &x[1], calfun_data);
+    if (ntrits == -1) {
+       fsave = f;
+       rc = NLOPT_XTOL_REACHED;
+       if (fsave < fval[kopt]) { *minf = f; return rc; }
+       goto L720;
+    }
+
+    if (f < stop->minf_max) {
+      *minf = f;
+      return NLOPT_MINF_MAX_REACHED;
+    }
+
+/*     Use the quadratic model to predict the change in F due to the step D, */
+/*       and set DIFF to the error of this prediction. */
+
+    fopt = fval[kopt];
+    vquad = zero;
+    ih = 0;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       vquad += d__[j] * gopt[j];
+       i__1 = j;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           ++ih;
+           temp = d__[i__] * d__[j];
+           if (i__ == j) {
+               temp = half * temp;
+           }
+/* L410: */
+           vquad += hq[ih] * temp;
+       }
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+/* L420: */
+/* Computing 2nd power */
+       d__1 = w[*npt + k];
+       vquad += half * pq[k] * (d__1 * d__1);
+    }
+    diff = f - fopt - vquad;
+    diffc = diffb;
+    diffb = diffa;
+    diffa = fabs(diff);
+    if (dnorm > rho) {
+       nfsav = stop->nevals;
+    }
+
+/*     Pick the next value of DELTA after a trust region step. */
+
+    if (ntrits > 0) {
+       if (vquad >= zero) {
+         /* Return from BOBYQA because a trust region step has failed
+            to reduce Q. */
+         rc = NLOPT_ROUNDOFF_LIMITED; /* or FTOL_REACHED? */
+         goto L720;
+       }
+       ratio = (f - fopt) / vquad;
+       if (ratio <= tenth) {
+/* Computing MIN */
+           d__1 = half * delta;
+           delta = MIN2(d__1,dnorm);
+       } else if (ratio <= .7) {
+/* Computing MAX */
+           d__1 = half * delta;
+           delta = MAX2(d__1,dnorm);
+       } else {
+/* Computing MAX */
+           d__1 = half * delta, d__2 = dnorm + dnorm;
+           delta = MAX2(d__1,d__2);
+       }
+       if (delta <= rho * 1.5) {
+           delta = rho;
+       }
+
+/*     Recalculate KNEW and DENOM if the new F is less than FOPT. */
+
+       if (f < fopt) {
+           ksav = knew;
+           densav = denom;
+           delsq = delta * delta;
+           scaden = zero;
+           biglsq = zero;
+           knew = 0;
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+               hdiag = zero;
+               i__2 = nptm;
+               for (jj = 1; jj <= i__2; ++jj) {
+/* L440: */
+/* Computing 2nd power */
+                   d__1 = zmat[k + jj * zmat_dim1];
+                   hdiag += d__1 * d__1;
+               }
+/* Computing 2nd power */
+               d__1 = vlag[k];
+               den = beta * hdiag + d__1 * d__1;
+               distsq = zero;
+               i__2 = *n;
+               for (j = 1; j <= i__2; ++j) {
+/* L450: */
+/* Computing 2nd power */
+                   d__1 = xpt[k + j * xpt_dim1] - xnew[j];
+                   distsq += d__1 * d__1;
+               }
+/* Computing MAX */
+/* Computing 2nd power */
+               d__3 = distsq / delsq;
+               d__1 = one, d__2 = d__3 * d__3;
+               temp = MAX2(d__1,d__2);
+               if (temp * den > scaden) {
+                   scaden = temp * den;
+                   knew = k;
+                   denom = den;
+               }
+/* L460: */
+/* Computing MAX */
+/* Computing 2nd power */
+               d__3 = vlag[k];
+               d__1 = biglsq, d__2 = temp * (d__3 * d__3);
+               biglsq = MAX2(d__1,d__2);
+           }
+           if (scaden <= half * biglsq) {
+               knew = ksav;
+               denom = densav;
+           }
+       }
+    }
+
+/*     Update BMAT and ZMAT, so that the KNEW-th interpolation point can be */
+/*     moved. Also update the second derivative terms of the model. */
+
+    update_(n, npt, &bmat[bmat_offset], &zmat[zmat_offset], ndim, &vlag[1], &
+           beta, &denom, &knew, &w[1]);
+    ih = 0;
+    pqold = pq[knew];
+    pq[knew] = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp = pqold * xpt[knew + i__ * xpt_dim1];
+       i__2 = i__;
+       for (j = 1; j <= i__2; ++j) {
+           ++ih;
+/* L470: */
+           hq[ih] += temp * xpt[knew + j * xpt_dim1];
+       }
+    }
+    i__2 = nptm;
+    for (jj = 1; jj <= i__2; ++jj) {
+       temp = diff * zmat[knew + jj * zmat_dim1];
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L480: */
+           pq[k] += temp * zmat[k + jj * zmat_dim1];
+       }
+    }
+
+/*     Include the new interpolation point, and make the changes to GOPT at */
+/*     the old XOPT that are caused by the updating of the quadratic model. */
+
+    fval[knew] = f;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       xpt[knew + i__ * xpt_dim1] = xnew[i__];
+/* L490: */
+       w[i__] = bmat[knew + i__ * bmat_dim1];
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       suma = zero;
+       i__2 = nptm;
+       for (jj = 1; jj <= i__2; ++jj) {
+/* L500: */
+           suma += zmat[knew + jj * zmat_dim1] * zmat[k + jj * zmat_dim1];
+       }
+       if (nlopt_isinf(suma)) {
+         /* SGJ: detect singularity here (happend if we run
+            for too many iterations) ... is there another way to recover? */
+         rc = NLOPT_ROUNDOFF_LIMITED;
+         goto L720;
+       }
+       sumb = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L510: */
+           sumb += xpt[k + j * xpt_dim1] * xopt[j];
+       }
+       temp = suma * sumb;
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L520: */
+           w[i__] += temp * xpt[k + i__ * xpt_dim1];
+       }
+    }
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L530: */
+       gopt[i__] += diff * w[i__];
+    }
+
+/*     Update XOPT, GOPT and KOPT if the new calculated F is less than FOPT. */
+
+    if (f < fopt) {
+       kopt = knew;
+       xoptsq = zero;
+       ih = 0;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           xopt[j] = xnew[j];
+/* Computing 2nd power */
+           d__1 = xopt[j];
+           xoptsq += d__1 * d__1;
+           i__1 = j;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ++ih;
+               if (i__ < j) {
+                   gopt[j] += hq[ih] * d__[i__];
+               }
+/* L540: */
+               gopt[i__] += hq[ih] * d__[j];
+           }
+       }
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+           temp = zero;
+           i__2 = *n;
+           for (j = 1; j <= i__2; ++j) {
+/* L550: */
+               temp += xpt[k + j * xpt_dim1] * d__[j];
+           }
+           temp = pq[k] * temp;
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+/* L560: */
+               gopt[i__] += temp * xpt[k + i__ * xpt_dim1];
+           }
+       }
+       if (nlopt_stop_ftol(stop, f, fopt)) {
+             rc = NLOPT_FTOL_REACHED;
+            goto L720;
+        }
+    }
+
+/*     Calculate the parameters of the least Frobenius norm interpolant to */
+/*     the current data, the gradient of this interpolant at XOPT being put */
+/*     into VLAG(NPT+I), I=1,2,...,N. */
+
+    if (ntrits > 0) {
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+           vlag[k] = fval[k] - fval[kopt];
+/* L570: */
+           w[k] = zero;
+       }
+       i__2 = nptm;
+       for (j = 1; j <= i__2; ++j) {
+           sum = zero;
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+/* L580: */
+               sum += zmat[k + j * zmat_dim1] * vlag[k];
+           }
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+/* L590: */
+               w[k] += sum * zmat[k + j * zmat_dim1];
+           }
+       }
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+           sum = zero;
+           i__2 = *n;
+           for (j = 1; j <= i__2; ++j) {
+/* L600: */
+               sum += xpt[k + j * xpt_dim1] * xopt[j];
+           }
+           w[k + *npt] = w[k];
+/* L610: */
+           w[k] = sum * w[k];
+       }
+       gqsq = zero;
+       gisq = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           sum = zero;
+           i__2 = *npt;
+           for (k = 1; k <= i__2; ++k) {
+/* L620: */
+               sum = sum + bmat[k + i__ * bmat_dim1] * vlag[k] + xpt[k + i__ 
+                       * xpt_dim1] * w[k];
+           }
+           if (xopt[i__] == sl[i__]) {
+/* Computing MIN */
+               d__2 = zero, d__3 = gopt[i__];
+/* Computing 2nd power */
+               d__1 = MIN2(d__2,d__3);
+               gqsq += d__1 * d__1;
+/* Computing 2nd power */
+               d__1 = MIN2(zero,sum);
+               gisq += d__1 * d__1;
+           } else if (xopt[i__] == su[i__]) {
+/* Computing MAX */
+               d__2 = zero, d__3 = gopt[i__];
+/* Computing 2nd power */
+               d__1 = MAX2(d__2,d__3);
+               gqsq += d__1 * d__1;
+/* Computing 2nd power */
+               d__1 = MAX2(zero,sum);
+               gisq += d__1 * d__1;
+           } else {
+/* Computing 2nd power */
+               d__1 = gopt[i__];
+               gqsq += d__1 * d__1;
+               gisq += sum * sum;
+           }
+/* L630: */
+           vlag[*npt + i__] = sum;
+       }
+
+/*     Test whether to replace the new quadratic model by the least Frobenius */
+/*     norm interpolant, making the replacement if the test is satisfied. */
+
+       ++itest;
+       if (gqsq < ten * gisq) {
+           itest = 0;
+       }
+       if (itest >= 3) {
+           i__1 = MAX2(*npt,nh);
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               if (i__ <= *n) {
+                   gopt[i__] = vlag[*npt + i__];
+               }
+               if (i__ <= *npt) {
+                   pq[i__] = w[*npt + i__];
+               }
+               if (i__ <= nh) {
+                   hq[i__] = zero;
+               }
+               itest = 0;
+/* L640: */
+           }
+       }
+    }
+
+/*     If a trust region step has provided a sufficient decrease in F, then */
+/*     branch for another trust region calculation. The case NTRITS=0 occurs */
+/*     when the new interpolation point was reached by an alternative step. */
+
+    if (ntrits == 0) {
+       goto L60;
+    }
+    if (f <= fopt + tenth * vquad) {
+       goto L60;
+    }
+
+/*     Alternatively, find out if the interpolation points are close enough */
+/*       to the best point so far. */
+
+/* Computing MAX */
+/* Computing 2nd power */
+    d__3 = two * delta;
+/* Computing 2nd power */
+    d__4 = ten * rho;
+    d__1 = d__3 * d__3, d__2 = d__4 * d__4;
+    distsq = MAX2(d__1,d__2);
+L650:
+    knew = 0;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       sum = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L660: */
+/* Computing 2nd power */
+           d__1 = xpt[k + j * xpt_dim1] - xopt[j];
+           sum += d__1 * d__1;
+       }
+       if (sum > distsq) {
+           knew = k;
+           distsq = sum;
+       }
+/* L670: */
+    }
+
+/*     If KNEW is positive, then ALTMOV finds alternative new positions for */
+/*     the KNEW-th interpolation point within distance ADELT of XOPT. It is */
+/*     reached via label 90. Otherwise, there is a branch to label 60 for */
+/*     another trust region iteration, unless the calculations with the */
+/*     current RHO are complete. */
+
+    if (knew > 0) {
+       dist = sqrt(distsq);
+       if (ntrits == -1) {
+/* Computing MIN */
+           d__1 = tenth * delta, d__2 = half * dist;
+           delta = MIN2(d__1,d__2);
+           if (delta <= rho * 1.5) {
+               delta = rho;
+           }
+       }
+       ntrits = 0;
+/* Computing MAX */
+/* Computing MIN */
+       d__2 = tenth * dist;
+       d__1 = MIN2(d__2,delta);
+       adelt = MAX2(d__1,rho);
+       dsq = adelt * adelt;
+       goto L90;
+    }
+    if (ntrits == -1) {
+       goto L680;
+    }
+    if (ratio > zero) {
+       goto L60;
+    }
+    if (MAX2(delta,dnorm) > rho) {
+       goto L60;
+    }
+
+/*     The calculations with the current value of RHO are complete. Pick the */
+/*       next values of RHO and DELTA. */
+
+L680:
+    if (rho > *rhoend) {
+       delta = half * rho;
+       ratio = rho / *rhoend;
+       if (ratio <= 16.) {
+           rho = *rhoend;
+       } else if (ratio <= 250.) {
+           rho = sqrt(ratio) * *rhoend;
+       } else {
+           rho = tenth * rho;
+       }
+       delta = MAX2(delta,rho);
+       ntrits = 0;
+       nfsav = stop->nevals;
+       goto L60;
+    }
+
+/*     Return from the calculation, after another Newton-Raphson step, if */
+/*       it is too short to have been tried before. */
+
+    if (ntrits == -1) {
+       goto L360;
+    }
+L720:
+    /* originally: if (fval[kopt] <= fsave) -- changed by SGJ, since
+       this seems like a slight optimization to not update x[]
+       unnecessarily, at the expense of possibly not returning the
+       best x[] found so far if the algorithm is stopped suddenly
+       (e.g. runs out of time) ... it seems safer to execute this
+       unconditionally, and the efficiency loss seems negligible. */
+    {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing MIN */
+/* Computing MAX */
+           d__3 = xl[i__], d__4 = xbase[i__] + xopt[i__];
+           d__1 = MAX2(d__3,d__4), d__2 = xu[i__];
+           x[i__] = MIN2(d__1,d__2);
+           if (xopt[i__] == sl[i__]) {
+               x[i__] = xl[i__];
+           }
+           if (xopt[i__] == su[i__]) {
+               x[i__] = xu[i__];
+           }
+/* L730: */
+       }
+       f = fval[kopt];
+    }
+    *minf = f;
+    return rc;
+} /* bobyqb_ */
+
+/**************************************************************************/
+
+#define U(n) ((unsigned) (n))
+
+typedef struct {
+     double *s, *xs;
+     nlopt_func f; void *f_data;
+} rescale_fun_data;
+
+static double rescale_fun(int n, const double *x, void *d_)
+{
+     rescale_fun_data *d = (rescale_fun_data*) d_;
+     nlopt_unscale(U(n), d->s, x, d->xs);
+     return d->f(U(n), d->xs, NULL, d->f_data);
+}
+
+nlopt_result bobyqa(int n, int npt, double *x, 
+                   const double *xl, const double *xu, 
+                   const double *dx,
+                   nlopt_stopping *stop, double *minf,
+                   nlopt_func f, void *f_data)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Local variables */
+    int j, id, np, iw, igo, ihq, ixb, ixa, ifv, isl, jsl, ipq, ivl, ixn, 
+           ixo, ixp, isu, jsu, ndim;
+    double temp, zero;
+    int ibmat, izmat;
+
+    double rhobeg, rhoend;
+    double *w0 = NULL, *w;
+    nlopt_result ret;
+    double *s = NULL, *sxl = NULL, *sxu = NULL, *xs = NULL;
+    rescale_fun_data calfun_data;
+    
+    /* SGJ 2010: rescale parameters to make the initial step sizes dx
+                 equal in all directions */
+    s = nlopt_compute_rescaling(U(n), dx);
+    if (!s) return NLOPT_OUT_OF_MEMORY;
+
+    /* this statement must go before goto done, so that --x occurs */
+    nlopt_rescale(U(n), s, x, x); --x;
+
+    xs = (double *) malloc(sizeof(double) * (U(n)));
+
+    sxl = nlopt_new_rescaled(U(n), s, xl);
+    if (!sxl) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+    xl = sxl;
+    sxu = nlopt_new_rescaled(U(n), s, xu);
+    if (!sxu) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+    xu = sxu;
+    nlopt_reorder_bounds(n, sxl, sxu);
+
+    rhobeg = fabs(dx[0] / s[0]); /* equals all other dx[i] after rescaling */
+
+    calfun_data.s = s;
+    calfun_data.xs = xs;
+    calfun_data.f = f;
+    calfun_data.f_data = f_data;
+
+    /* SGJ, 2009: compute rhoend from NLopt stop info */
+    rhoend = stop->xtol_rel * (rhobeg);
+    for (j = 0; j < n; ++j)
+        if (rhoend < stop->xtol_abs[j] / fabs(s[j]))
+             rhoend = stop->xtol_abs[j] / fabs(s[j]);
+
+
+/*     This subroutine seeks the least value of a function of many variables, */
+/*     by applying a trust region method that forms quadratic models by */
+/*     interpolation. There is usually some freedom in the interpolation */
+/*     conditions, which is taken up by minimizing the Frobenius norm of */
+/*     the change to the second derivative of the model, beginning with the */
+/*     zero matrix. The values of the variables are constrained by upper and */
+/*     lower bounds. The arguments of the subroutine are as follows. */
+
+/*     N must be set to the number of variables and must be at least two. */
+/*     NPT is the number of interpolation conditions. Its value must be in */
+/*       the interval [N+2,(N+1)(N+2)/2]. Choices that exceed 2*N+1 are not */
+/*       recommended. */
+/*     Initial values of the variables must be set in X(1),X(2),...,X(N). They */
+/*       will be changed to the values that give the least calculated F. */
+/*     For I=1,2,...,N, XL(I) and XU(I) must provide the lower and upper */
+/*       bounds, respectively, on X(I). The construction of quadratic models */
+/*       requires XL(I) to be strictly less than XU(I) for each I. Further, */
+/*       the contribution to a model from changes to the I-th variable is */
+/*       damaged severely by rounding errors if XU(I)-XL(I) is too small. */
+/*     RHOBEG and RHOEND must be set to the initial and final values of a trust */
+/*       region radius, so both must be positive with RHOEND no greater than */
+/*       RHOBEG. Typically, RHOBEG should be about one tenth of the greatest */
+/*       expected change to a variable, while RHOEND should indicate the */
+/*       accuracy that is required in the final values of the variables. An */
+/*       error return occurs if any of the differences XU(I)-XL(I), I=1,...,N, */
+/*       is less than 2*RHOBEG. */
+/*     MAXFUN must be set to an upper bound on the number of calls of CALFUN. */
+/*     The array W will be used for working space. Its length must be at least */
+/*       (NPT+5)*(NPT+N)+3*N*(N+5)/2. */
+
+/*     SUBROUTINE CALFUN (N,X,F) has to be provided by the user. It must set */
+/*     F to the value of the objective function for the current values of the */
+/*     variables X(1),X(2),...,X(N), which are generated automatically in a */
+/*     way that satisfies the bounds given in XL and XU. */
+
+/*     Return if the value of NPT is unacceptable. */
+
+    /* Parameter adjustments */
+    --xu;
+    --xl;
+
+    /* Function Body */
+    np = n + 1;
+    if (npt < n + 2 || npt > (n + 2) * np / 2) {
+      /* Return from BOBYQA because NPT is not in the required interval */
+      ret = NLOPT_INVALID_ARGS;
+      goto done;
+    }
+
+/*     Partition the working space array, so that different parts of it can */
+/*     be treated separately during the calculation of BOBYQB. The partition */
+/*     requires the first (NPT+2)*(NPT+N)+3*N*(N+5)/2 elements of W plus the */
+/*     space that is taken by the last array in the argument list of BOBYQB. */
+
+    ndim = npt + n;
+    ixb = 1;
+    ixp = ixb + n;
+    ifv = ixp + n * npt;
+    ixo = ifv + npt;
+    igo = ixo + n;
+    ihq = igo + n;
+    ipq = ihq + n * np / 2;
+    ibmat = ipq + npt;
+    izmat = ibmat + ndim * n;
+    isl = izmat + npt * (npt - np);
+    isu = isl + n;
+    ixn = isu + n;
+    ixa = ixn + n;
+    id = ixa + n;
+    ivl = id + n;
+    iw = ivl + ndim;
+
+    w0 = (double *) malloc(sizeof(double) * U((npt+5)*(npt+n)+3*n*(n+5)/2));
+    if (!w0) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+    w = w0 - 1;
+
+/*   Return if there is insufficient space between the bounds. Modify the */
+/*   initial X if necessary in order to avoid conflicts between the bounds */
+/*   and the construction of the first quadratic model. The lower and upper */
+/*   bounds on moves from the updated X are set now, in the ISL and ISU */
+/*   partitions of W, in order to provide useful and exact information about */
+/*   components of X that become within distance RHOBEG from their bounds. */
+
+    zero = 0.;
+    i__1 = n;
+    for (j = 1; j <= i__1; ++j) {
+       temp = xu[j] - xl[j];
+       if (temp < rhobeg + rhobeg) {
+         /* Return from BOBYQA because one of the differences
+            XU(I)-XL(I)s is less than 2*RHOBEG. */
+            ret = NLOPT_INVALID_ARGS;
+            goto done;
+       }
+       jsl = isl + j - 1;
+       jsu = jsl + n;
+       w[jsl] = xl[j] - x[j];
+       w[jsu] = xu[j] - x[j];
+       if (w[jsl] >= -(rhobeg)) {
+           if (w[jsl] >= zero) {
+               x[j] = xl[j];
+               w[jsl] = zero;
+               w[jsu] = temp;
+           } else {
+               x[j] = xl[j] + rhobeg;
+               w[jsl] = -(rhobeg);
+/* Computing MAX */
+               d__1 = xu[j] - x[j];
+               w[jsu] = MAX2(d__1,rhobeg);
+           }
+       } else if (w[jsu] <= rhobeg) {
+           if (w[jsu] <= zero) {
+               x[j] = xu[j];
+               w[jsl] = -temp;
+               w[jsu] = zero;
+           } else {
+               x[j] = xu[j] - rhobeg;
+/* Computing MIN */
+               d__1 = xl[j] - x[j], d__2 = -(rhobeg);
+               w[jsl] = MIN2(d__1,d__2);
+               w[jsu] = rhobeg;
+           }
+       }
+/* L30: */
+    }
+
+/*     Make the call of BOBYQB. */
+
+    ret = bobyqb_(&n, &npt, &x[1], &xl[1], &xu[1], &rhobeg, &rhoend,
+                 stop, rescale_fun, &calfun_data, minf,
+                 &w[ixb], &w[ixp], &w[ifv], &w[ixo], &w[igo], &w[ihq], &w[ipq], 
+                 &w[ibmat], &w[izmat], &ndim, &w[isl], &w[isu], &w[ixn], &w[ixa],
+                 &w[id], &w[ivl], &w[iw]);
+
+done:
+    free(w0);
+    free(sxl);
+    free(sxu);
+    free(xs);
+    ++x; nlopt_unscale(U(n), s, x, x);
+    free(s);
+    return ret;
+} /* bobyqa_ */
+
diff --git a/bobyqa/bobyqa.h b/bobyqa/bobyqa.h
new file mode 100644 (file)
index 0000000..598753a
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef BOBYQA_H
+#define BOBYQA_H 1
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+
+extern nlopt_result bobyqa(int n, int npt, double *x, 
+                          const double *lb, const double *ub,
+                          const double *dx, 
+                          nlopt_stopping *stop, double *minf,
+                          nlopt_func f, void *f_data);
+
+#endif /* BOBYQA_H */
diff --git a/cdirect/Makefile.am b/cdirect/Makefile.am
new file mode 100644 (file)
index 0000000..b5695e7
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libcdirect.la
+libcdirect_la_SOURCES = cdirect.c hybrid.c cdirect.h
+
+EXTRA_DIST = README
diff --git a/cdirect/Makefile.in b/cdirect/Makefile.in
new file mode 100644 (file)
index 0000000..e1b4e93
--- /dev/null
@@ -0,0 +1,607 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = cdirect
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcdirect_la_LIBADD =
+am_libcdirect_la_OBJECTS = cdirect.lo hybrid.lo
+libcdirect_la_OBJECTS = $(am_libcdirect_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libcdirect_la_SOURCES)
+DIST_SOURCES = $(libcdirect_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libcdirect.la
+libcdirect_la_SOURCES = cdirect.c hybrid.c cdirect.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cdirect/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu cdirect/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libcdirect.la: $(libcdirect_la_OBJECTS) $(libcdirect_la_DEPENDENCIES) $(EXTRA_libcdirect_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libcdirect_la_OBJECTS) $(libcdirect_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdirect.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hybrid.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/cdirect/README b/cdirect/README
new file mode 100644 (file)
index 0000000..0685c93
--- /dev/null
@@ -0,0 +1,26 @@
+From-scratch re-implementation of the DIRECT and DIRECT-L algorithms
+described in:
+
+       D. R. Jones, C. D. Perttunen, and B. E. Stuckmann,
+       "Lipschitzian optimization without the lipschitz constant,"
+       J. Optimization Theory and Applications, vol. 79, p. 157 (1993).
+
+       J. M. Gablonsky and C. T. Kelley, "A locally-biased form
+       of the DIRECT algorithm," J. Global Optimization 21 (1),
+       p. 27-37 (2001).
+
+I re-implemented the algorithms for a couple of reasons.  First,
+because I was interested in the algorithms and wanted to play with
+them by trying some variations (originally, because I wanted to
+experiment with a hybrid approach combining DIRECT with local search
+algorithms, see hybrid.c).  Second, I wanted to remove some arbitrary
+restrictions in the original Fortran code, e.g. a fixed upper bound on
+the number of function evaluations.  Third, because it was fun to
+code.  As far as I can tell, my version converges in about the same
+number of iterations as Gablonsky's code (with occasional slight
+differences due to minor differences in how I break ties, etc.).
+
+The code in this directory is under the same MIT license as the rest
+of my code in NLopt (see ../COPYRIGHT).
+
+Steven G. Johnson
diff --git a/cdirect/cdirect.c b/cdirect/cdirect.c
new file mode 100644 (file)
index 0000000..165f8e8
--- /dev/null
@@ -0,0 +1,600 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+#include "cdirect.h"
+#include "redblack.h"
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+/***************************************************************************/
+/* basic data structure:
+ *
+ * a hyper-rectangle is stored as an array of length L = 2n+3, where [1]
+ * is the value (f) of the function at the center, [0] is the "size"
+ * measure (d) of the rectangle, [3..n+2] are the coordinates of the
+ * center (c), [n+3..2n+2] are the widths of the sides (w), and [2]
+ * is an "age" measure for tie-breaking purposes.
+ *
+ * we store the hyper-rectangles in a red-black tree, sorted by (d,f)
+ * in lexographic order, to allow us to perform quick convex-hull
+ * calculations (in the future, we might make this data structure
+ * more sophisticated based on the dynamic convex-hull literature).
+ *
+ * n > 0 always, of course.
+ */
+
+/* parameters of the search algorithm and various information that
+   needs to be passed around */
+typedef struct {
+     int n; /* dimension */
+     int L; /* size of each rectangle (2n+3) */
+     double magic_eps; /* Jones' epsilon parameter (1e-4 is recommended) */
+     int which_diam; /* which measure of hyper-rectangle diam to use:
+                       0 = Jones, 1 = Gablonsky */
+     int which_div; /* which way to divide rects:
+                      0: orig. Jones (divide all longest sides)
+                      1: Gablonsky (cubes divide all, rects longest)
+                      2: Jones Encyc. Opt.: pick random longest side */
+     int which_opt; /* which rects are considered "potentially optimal"
+                      0: Jones (all pts on cvx hull, even equal pts)
+                      1: Gablonsky DIRECT-L (pick one pt, if equal pts)
+                      2: ~ 1, but pick points randomly if equal pts 
+                   ... 2 seems to suck compared to just picking oldest pt */
+  
+     const double *lb, *ub;
+     nlopt_stopping *stop; /* stopping criteria */
+     nlopt_func f; void *f_data;
+     double *work; /* workspace, of length >= 2*n */
+     int *iwork; /* workspace, length >= n */
+     double minf, *xmin; /* minimum so far */
+     
+     /* red-black tree of hyperrects, sorted by (d,f,age) in
+       lexographical order */
+     rb_tree rtree;
+     int age; /* age for next new rect */
+     double **hull; /* array to store convex hull */
+     int hull_len; /* allocated length of hull array */
+} params;
+
+/***************************************************************************/
+
+/* Evaluate the "diameter" (d) of a rectangle of widths w[n] 
+
+   We round the result to single precision, which should be plenty for
+   the use we put the diameter to (rect sorting), to allow our
+   performance hack in convex_hull to work (in the Jones and Gablonsky
+   DIRECT algorithms, all of the rects fall into a few diameter
+   values, and we don't want rounding error to spoil this) */
+static double rect_diameter(int n, const double *w, const params *p)
+{
+     int i;
+     if (p->which_diam == 0) { /* Jones measure */
+         double sum = 0;
+         for (i = 0; i < n; ++i)
+              sum += w[i] * w[i];
+         /* distance from center to a vertex */
+         return ((float) (sqrt(sum) * 0.5)); 
+     }
+     else { /* Gablonsky measure */
+         double maxw = 0;
+         for (i = 0; i < n; ++i)
+              if (w[i] > maxw)
+                   maxw = w[i];
+         /* half-width of longest side */
+         return ((float) (maxw * 0.5));
+     }
+}
+
+#define ALLOC_RECT(rect, L) if (!(rect = (double*) malloc(sizeof(double)*(L)))) return NLOPT_OUT_OF_MEMORY
+
+static int sort_fv_compare(void *fv_, const void *a_, const void *b_)
+{
+     const double *fv = (const double *) fv_;
+     int a = *((const int *) a_), b = *((const int *) b_);
+     double fa = MIN(fv[2*a], fv[2*a+1]);
+     double fb = MIN(fv[2*b], fv[2*b+1]);
+     if (fa < fb)
+         return -1;
+     else if (fa > fb)
+         return +1;
+     else
+         return 0;
+}
+static void sort_fv(int n, double *fv, int *isort)
+{
+     int i;
+     for (i = 0; i < n; ++i) isort[i] = i;
+     nlopt_qsort_r(isort, (unsigned) n, sizeof(int), fv, sort_fv_compare);
+}
+
+static double function_eval(const double *x, params *p) {
+     double f = p->f(p->n, x, NULL, p->f_data);
+     if (f < p->minf) {
+         p->minf = f;
+         memcpy(p->xmin, x, sizeof(double) * p->n);
+     }
+     p->stop->nevals++;
+     return f;
+}
+#define FUNCTION_EVAL(fv,x,p,freeonerr) fv = function_eval(x, p); if (nlopt_stop_forced((p)->stop)) { free(freeonerr); return NLOPT_FORCED_STOP; } else if (p->minf < p->stop->minf_max) { free(freeonerr); return NLOPT_MINF_MAX_REACHED; } else if (nlopt_stop_evals((p)->stop)) { free(freeonerr); return NLOPT_MAXEVAL_REACHED; } else if (nlopt_stop_time((p)->stop)) { free(freeonerr); return NLOPT_MAXTIME_REACHED; }
+
+#define THIRD (0.3333333333333333333333)
+
+#define EQUAL_SIDE_TOL 5e-2 /* tolerance to equate side sizes */
+
+/* divide rectangle idiv in the list p->rects */
+static nlopt_result divide_rect(double *rdiv, params *p)
+{
+     int i;
+     const int n = p->n;
+     const int L = p->L;
+     double *c = rdiv + 3; /* center of rect to divide */
+     double *w = c + n; /* widths of rect to divide */
+     double wmax = w[0];
+     int imax = 0, nlongest = 0;
+     rb_node *node;
+
+     for (i = 1; i < n; ++i)
+         if (w[i] > wmax)
+              wmax = w[imax = i];
+     for (i = 0; i < n; ++i)
+         if (wmax - w[i] <= wmax * EQUAL_SIDE_TOL)
+              ++nlongest;
+     if (p->which_div == 1 || (p->which_div == 0 && nlongest == n)) {
+         /* trisect all longest sides, in increasing order of the average
+            function value along that direction */
+         double *fv = p->work;
+         int *isort = p->iwork;
+         for (i = 0; i < n; ++i) {
+              if (wmax - w[i] <= wmax * EQUAL_SIDE_TOL) {
+                   double csave = c[i];
+                   c[i] = csave - w[i] * THIRD;
+                   FUNCTION_EVAL(fv[2*i], c, p, 0);
+                   c[i] = csave + w[i] * THIRD;
+                   FUNCTION_EVAL(fv[2*i+1], c, p, 0);
+                   c[i] = csave;
+              }
+              else {
+                   fv[2*i] = fv[2*i+1] = HUGE_VAL;
+              }
+         }
+         sort_fv(n, fv, isort);
+         if (!(node = rb_tree_find(&p->rtree, rdiv)))
+              return NLOPT_FAILURE;
+         for (i = 0; i < nlongest; ++i) {
+              int k;
+              w[isort[i]] *= THIRD;
+              rdiv[0] = rect_diameter(n, w, p);
+              rdiv[2] = p->age++;
+              node = rb_tree_resort(&p->rtree, node);
+              for (k = 0; k <= 1; ++k) {
+                   double *rnew;
+                   ALLOC_RECT(rnew, L);
+                   memcpy(rnew, rdiv, sizeof(double) * L);
+                   rnew[3 + isort[i]] += w[isort[i]] * (2*k-1);
+                   rnew[1] = fv[2*isort[i]+k];
+                   rnew[2] = p->age++;
+                   if (!rb_tree_insert(&p->rtree, rnew)) {
+                        free(rnew);
+                        return NLOPT_OUT_OF_MEMORY;
+                   }
+              }
+         }
+     }
+     else {
+         int k;
+         if (nlongest > 1 && p->which_div == 2) { 
+               /* randomly choose longest side */
+              i = nlopt_iurand(nlongest);
+              for (k = 0; k < n; ++k)
+                   if (wmax - w[k] <= wmax * EQUAL_SIDE_TOL) {
+                        if (!i) { i = k; break; }
+                        --i;
+                   }
+         }
+         else
+              i = imax; /* trisect longest side */
+         if (!(node = rb_tree_find(&p->rtree, rdiv)))
+              return NLOPT_FAILURE;
+         w[i] *= THIRD;
+         rdiv[0] = rect_diameter(n, w, p);
+         rdiv[2] = p->age++;
+         node = rb_tree_resort(&p->rtree, node);
+         for (k = 0; k <= 1; ++k) {
+              double *rnew;
+              ALLOC_RECT(rnew, L);
+              memcpy(rnew, rdiv, sizeof(double) * L);
+              rnew[3 + i] += w[i] * (2*k-1);
+              FUNCTION_EVAL(rnew[1], rnew + 3, p, rnew);
+              rnew[2] = p->age++;
+              if (!rb_tree_insert(&p->rtree, rnew)) {
+                   free(rnew);
+                   return NLOPT_OUT_OF_MEMORY;
+              }
+         }
+     }
+     return NLOPT_SUCCESS;
+}
+
+/***************************************************************************/
+/* Convex hull algorithm, used later to find the potentially optimal
+   points.  What we really have in DIRECT is a "dynamic convex hull"
+   problem, since we are dynamically adding/removing points and
+   updating the hull, but I haven't implemented any of the fancy
+   algorithms for this problem yet. */
+
+/* Find the lower convex hull of a set of points (x,y) stored in a rb-tree
+   of pointers to {x,y} arrays sorted in lexographic order by (x,y).
+
+   Unlike standard convex hulls, we allow redundant points on the hull,
+   and even allow duplicate points if allow_dups is nonzero.
+
+   The return value is the number of points in the hull, with pointers
+   stored in hull[i] (should be an array of length >= t->N).
+*/
+static int convex_hull(rb_tree *t, double **hull, int allow_dups)
+{
+     int nhull = 0;
+     double minslope;
+     double xmin, xmax, yminmin, ymaxmin;
+     rb_node *n, *nmax;
+
+     /* Monotone chain algorithm [Andrew, 1979]. */
+
+     n = rb_tree_min(t);
+     if (!n) return 0;
+     nmax = rb_tree_max(t);
+
+     xmin = n->k[0];
+     yminmin = n->k[1];
+     xmax = nmax->k[0];
+
+     if (allow_dups)
+         do { /* include any duplicate points at (xmin,yminmin) */
+              hull[nhull++] = n->k;
+              n = rb_tree_succ(n);
+         } while (n && n->k[0] == xmin && n->k[1] == yminmin);
+     else
+         hull[nhull++] = n->k;
+
+     if (xmin == xmax) return nhull;
+
+     /* set nmax = min mode with x == xmax */
+#if 0
+     while (nmax->k[0] == xmax)
+         nmax = rb_tree_pred(nmax); /* non-NULL since xmin != xmax */
+     nmax = rb_tree_succ(nmax);
+#else
+     /* performance hack (see also below) */
+     {
+         double kshift[2];
+         kshift[0] = xmax * (1 - 1e-13);
+         kshift[1] = -HUGE_VAL;
+         nmax = rb_tree_find_gt(t, kshift); /* non-NULL since xmin != xmax */
+     }
+#endif
+
+     ymaxmin = nmax->k[1];
+     minslope = (ymaxmin - yminmin) / (xmax - xmin);
+
+     /* set n = first node with x != xmin */
+#if 0
+     while (n->k[0] == xmin)
+         n = rb_tree_succ(n); /* non-NULL since xmin != xmax */
+#else
+     /* performance hack (see also below) */
+     {
+         double kshift[2];
+         kshift[0] = xmin * (1 + 1e-13);
+         kshift[1] = -HUGE_VAL;
+         n = rb_tree_find_gt(t, kshift); /* non-NULL since xmin != xmax */
+     }
+#endif
+
+     for (; n != nmax; n = rb_tree_succ(n)) { 
+         double *k = n->k;
+         if (k[1] > yminmin + (k[0] - xmin) * minslope)
+              continue;
+
+         /* performance hack: most of the points in DIRECT lie along
+            vertical lines at a few x values, and we can exploit this */
+         if (nhull && k[0] == hull[nhull - 1][0]) { /* x == previous x */
+              if (k[1] > hull[nhull - 1][1]) {
+                   double kshift[2];
+                   /* because of the round to float in rect_diameter, above,
+                      it shouldn't be possible for two diameters (x values)
+                      to have a fractional difference < 1e-13.  Note
+                      that k[0] > 0 always in DIRECT */
+                   kshift[0] = k[0] * (1 + 1e-13);
+                   kshift[1] = -HUGE_VAL;
+                   n = rb_tree_pred(rb_tree_find_gt(t, kshift));
+                   continue;
+              }
+              else { /* equal y values, add to hull */
+                   if (allow_dups)
+                        hull[nhull++] = k;
+                   continue;
+              }
+         }
+
+         /* remove points until we are making a "left turn" to k */
+         while (nhull > 1) {
+              double *t1 = hull[nhull - 1], *t2;
+
+              /* because we allow equal points in our hull, we have
+                 to modify the standard convex-hull algorithm slightly:
+                 we need to look backwards in the hull list until we
+                 find a point t2 != t1 */
+              int it2 = nhull - 2;
+              do {
+                   t2 = hull[it2--];
+              } while (it2 >= 0 && t2[0] == t1[0] && t2[1] == t1[1]);
+              if (it2 < 0) break;
+
+              /* cross product (t1-t2) x (k-t2) > 0 for a left turn: */
+              if ((t1[0]-t2[0]) * (k[1]-t2[1])
+                  - (t1[1]-t2[1]) * (k[0]-t2[0]) >= 0)
+                   break;
+              --nhull;
+         }
+         hull[nhull++] = k;
+     }
+
+     if (allow_dups)
+         do { /* include any duplicate points at (xmax,ymaxmin) */
+              hull[nhull++] = nmax->k;
+              nmax = rb_tree_succ(nmax);
+         } while (nmax && nmax->k[0] == xmax && nmax->k[1] == ymaxmin);
+     else
+         hull[nhull++] = nmax->k;
+
+     return nhull;
+}
+
+/***************************************************************************/
+
+static int small(double *w, params *p)
+{
+     int i;
+     for (i = 0; i < p->n; ++i)
+         if (w[i] > p->stop->xtol_abs[i] &&
+             w[i] > (p->ub[i] - p->lb[i]) * p->stop->xtol_rel)
+              return 0;
+     return 1;
+}
+
+static nlopt_result divide_good_rects(params *p)
+{
+     const int n = p->n;
+     double **hull;
+     int nhull, i, xtol_reached = 1, divided_some = 0;
+     double magic_eps = p->magic_eps;
+
+     if (p->hull_len < p->rtree.N) {
+         p->hull_len += p->rtree.N;
+         p->hull = (double **) realloc(p->hull, sizeof(double*)*p->hull_len);
+         if (!p->hull) return NLOPT_OUT_OF_MEMORY;
+     }
+     nhull = convex_hull(&p->rtree, hull = p->hull, p->which_opt != 1);
+ divisions:
+     for (i = 0; i < nhull; ++i) {
+         double K1 = -HUGE_VAL, K2 = -HUGE_VAL, K;
+         int im, ip;
+
+         /* find unequal points before (im) and after (ip) to get slope */
+         for (im = i-1; im >= 0 && hull[im][0] == hull[i][0]; --im) ;
+         for (ip = i+1; ip < nhull && hull[ip][0] == hull[i][0]; ++ip) ;
+
+         if (im >= 0)
+              K1 = (hull[i][1] - hull[im][1]) / (hull[i][0] - hull[im][0]);
+         if (ip < nhull)
+              K2 = (hull[i][1] - hull[ip][1]) / (hull[i][0] - hull[ip][0]);
+         K = MAX(K1, K2);
+         if (hull[i][1] - K * hull[i][0]
+             <= p->minf - magic_eps * fabs(p->minf) || ip == nhull) {
+              /* "potentially optimal" rectangle, so subdivide */
+              nlopt_result ret = divide_rect(hull[i], p);
+              divided_some = 1;
+              if (ret != NLOPT_SUCCESS) return ret;
+              xtol_reached = xtol_reached && small(hull[i] + 3+n, p);
+         }
+
+         /* for the DIRECT-L variant, we only divide one rectangle out
+            of all points with equal diameter and function values
+            ... note that for p->which_opt == 1, i == ip-1 should be a no-op
+                anyway, since we set allow_dups=0 in convex_hull above */
+         if (p->which_opt == 1)
+              i = ip - 1; /* skip to next unequal point for next iteration */
+         else if (p->which_opt == 2) /* like DIRECT-L but randomized */
+              i += nlopt_iurand(ip - i); /* possibly do another equal pt */
+     }
+     if (!divided_some) {
+         if (magic_eps != 0) {
+              magic_eps = 0;
+              goto divisions; /* try again */
+         }
+         else { /* WTF? divide largest rectangle with smallest f */
+              /* (note that this code actually gets called from time
+                 to time, and the heuristic here seems to work well,
+                 but I don't recall this situation being discussed in
+                 the references?) */
+              rb_node *max = rb_tree_max(&p->rtree);
+              rb_node *pred = max;
+              double wmax = max->k[0];
+              do { /* note: this loop is O(N) worst-case time */
+                   max = pred;
+                   pred = rb_tree_pred(max);
+              } while (pred && pred->k[0] == wmax);
+              return divide_rect(max->k, p);
+         }
+     }
+     return xtol_reached ? NLOPT_XTOL_REACHED : NLOPT_SUCCESS;
+}
+
+/***************************************************************************/
+
+/* lexographic sort order (d,f,age) of hyper-rects, for red-black tree */
+int cdirect_hyperrect_compare(double *a, double *b)
+{
+     if (a[0] < b[0]) return -1;
+     if (a[0] > b[0]) return +1;
+     if (a[1] < b[1]) return -1;
+     if (a[1] > b[1]) return +1;
+     if (a[2] < b[2]) return -1;
+     if (a[2] > b[2]) return +1;
+     return (int) (a - b); /* tie-breaker, shouldn't be needed */
+}
+
+/***************************************************************************/
+
+nlopt_result cdirect_unscaled(int n, nlopt_func f, void *f_data,
+                             const double *lb, const double *ub,
+                             double *x,
+                             double *minf,
+                             nlopt_stopping *stop,
+                             double magic_eps, int which_alg)
+{
+     params p;
+     int i;
+     double *rnew;
+     nlopt_result ret = NLOPT_OUT_OF_MEMORY;
+
+     p.magic_eps = magic_eps;
+     p.which_diam = which_alg % 3;
+     p.which_div = (which_alg / 3) % 3;
+     p.which_opt = (which_alg / (3*3)) % 3;
+     p.lb = lb; p.ub = ub;
+     p.stop = stop;
+     p.n = n;
+     p.L = 2*n+3;
+     p.f = f;
+     p.f_data = f_data;
+     p.xmin = x;
+     p.minf = HUGE_VAL;
+     p.work = 0;
+     p.iwork = 0;
+     p.hull = 0;
+     p.age = 0;
+
+     rb_tree_init(&p.rtree, cdirect_hyperrect_compare);
+
+     p.work = (double *) malloc(sizeof(double) * (2*n));
+     if (!p.work) goto done;
+     p.iwork = (int *) malloc(sizeof(int) * n);
+     if (!p.iwork) goto done;
+     p.hull_len = 128; /* start with a reasonable number */
+     p.hull = (double **) malloc(sizeof(double *) * p.hull_len);
+     if (!p.hull) goto done;
+
+     if (!(rnew = (double *) malloc(sizeof(double) * p.L))) goto done;
+     for (i = 0; i < n; ++i) {
+         rnew[3+i] = 0.5 * (lb[i] + ub[i]);
+         rnew[3+n+i] = ub[i] - lb[i];
+     }
+     rnew[0] = rect_diameter(n, rnew+3+n, &p);
+     rnew[1] = function_eval(rnew+3, &p);
+     rnew[2] = p.age++;
+     if (!rb_tree_insert(&p.rtree, rnew)) {
+         free(rnew);
+         goto done;
+     }
+
+     ret = divide_rect(rnew, &p);
+     if (ret != NLOPT_SUCCESS) goto done;
+
+     while (1) {
+         double minf0 = p.minf;
+         ret = divide_good_rects(&p);
+         if (ret != NLOPT_SUCCESS) goto done;
+         if (p.minf < minf0 && nlopt_stop_f(p.stop, p.minf, minf0)) {
+              ret = NLOPT_FTOL_REACHED;
+              goto done;
+         }
+     }
+
+ done:
+     rb_tree_destroy_with_keys(&p.rtree);
+     free(p.hull);
+     free(p.iwork);
+     free(p.work);
+             
+     *minf = p.minf;
+     return ret;
+}
+
+/* in the conventional DIRECT-type algorithm, we first rescale our
+   coordinates to a unit hypercube ... we do this simply by
+   wrapping cdirect() around cdirect_unscaled(). */
+
+double cdirect_uf(unsigned n, const double *xu, double *grad, void *d_)
+{
+     cdirect_uf_data *d = (cdirect_uf_data *) d_;
+     double f;
+     unsigned i;
+     for (i = 0; i < n; ++i)
+         d->x[i] = d->lb[i] + xu[i] * (d->ub[i] - d->lb[i]);
+     f = d->f(n, d->x, grad, d->f_data);
+     if (grad)
+         for (i = 0; i < n; ++i)
+              grad[i] *= d->ub[i] - d->lb[i];
+     return f;
+}
+
+nlopt_result cdirect(int n, nlopt_func f, void *f_data,
+                     const double *lb, const double *ub,
+                     double *x,
+                     double *minf,
+                     nlopt_stopping *stop,
+                     double magic_eps, int which_alg)
+{
+     cdirect_uf_data d;
+     nlopt_result ret;
+     const double *xtol_abs_save;
+     int i;
+
+     d.f = f; d.f_data = f_data; d.lb = lb; d.ub = ub;
+     d.x = (double *) malloc(sizeof(double) * n*4);
+     if (!d.x) return NLOPT_OUT_OF_MEMORY;
+     
+     for (i = 0; i < n; ++i) {
+         x[i] = (x[i] - lb[i]) / (ub[i] - lb[i]);
+         d.x[n+i] = 0;
+         d.x[2*n+i] = 1;
+         d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]);
+     }
+     xtol_abs_save = stop->xtol_abs;
+     stop->xtol_abs = d.x + 3*n;
+     ret = cdirect_unscaled(n, cdirect_uf, &d, d.x+n, d.x+2*n, x, minf, stop,
+                           magic_eps, which_alg);
+     stop->xtol_abs = xtol_abs_save;
+     for (i = 0; i < n; ++i)
+         x[i] = lb[i]+ x[i] * (ub[i] - lb[i]);
+     free(d.x);
+     return ret;
+}
diff --git a/cdirect/cdirect.h b/cdirect/cdirect.h
new file mode 100644 (file)
index 0000000..69acb58
--- /dev/null
@@ -0,0 +1,80 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef CDIRECT_H
+#define CDIRECT_H
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+extern nlopt_result cdirect_unscaled(int n, nlopt_func f, void *f_data,
+                                    const double *lb, const double *ub,
+                                    double *x,
+                                    double *minf,
+                                    nlopt_stopping *stop,
+                                    double magic_eps, int which_alg);
+
+extern nlopt_result cdirect(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub,
+                           double *x,
+                           double *minf,
+                           nlopt_stopping *stop,
+                           double magic_eps, int which_alg);
+
+extern nlopt_result cdirect_hybrid(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub,
+                           double *x,
+                           double *minf,
+                           nlopt_stopping *stop,
+                           nlopt_algorithm local_alg,
+                           int local_maxeval,
+                           int randomized_div);
+
+extern nlopt_result cdirect_hybrid_unscaled(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub,
+                           double *x,
+                           double *minf,
+                           nlopt_stopping *stop,
+                           nlopt_algorithm local_alg,
+                           int local_maxeval,
+                           int randomized_div);
+
+/* internal routines and data structures: */
+extern int cdirect_hyperrect_compare(double *a, double *b);
+typedef struct {
+     nlopt_func f;
+     void *f_data;
+     double *x;
+     const double *lb, *ub;
+} cdirect_uf_data;
+extern double cdirect_uf(unsigned n, const double *xu, double *grad, void *d_);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* DIRECT_H */
diff --git a/cdirect/hybrid.c b/cdirect/hybrid.c
new file mode 100644 (file)
index 0000000..97103ba
--- /dev/null
@@ -0,0 +1,317 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+#include "cdirect.h"
+#include "redblack.h"
+
+/* Hybrid algorithm, inspired by DIRECT, that uses another local
+ * optimization algorithm within each rectangle, and then looks
+ * in the largest remaining rectangle (breaking ties by minimum
+ * function value and then by age. 
+ *
+ * Each hyperrect is represented by an array of length 3*n+3 consisting
+ * of (d, -f, -a, x, c, w), where d=diameter, f=f(x), a=age, x=local optimum
+ * c=center, w=widths.
+ */
+
+typedef struct {
+     int n; /* dimension */
+     int L; /* 3*n+3 */
+     const double *lb, *ub;
+     nlopt_stopping *stop; /* stopping criteria */
+     nlopt_func f; void *f_data;
+     double minf, *xmin; /* min so far */
+     rb_tree rtree; /* red-black tree of rects, sorted by (d,-f,-a) */
+     int age; /* age for next new rect */
+     double *work; /* workspace of length >= 2*n */
+     
+     nlopt_algorithm local_alg; /* local search algorithm */
+     int local_maxeval; /* max # local iterations (0 if unlimited) */
+
+     int randomized_div; /* 1 to use randomized division algorithm */
+} params;
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+#define THIRD (0.3333333333333333333333) /* 1/3 */
+
+/************************************************************************/
+
+static double fcount(int n, const double *x, double *grad, void *p_)
+{
+     params *p = (params *) p_;
+     p->stop->nevals++;
+     return p->f(n, x, grad, p->f_data);
+}
+
+static nlopt_result optimize_rect(double *r, params *p)
+{
+     int i, n = p->n;
+     double *lb = p->work, *ub = lb + n;
+     double *x = r + 3, *c = x + n, *w = c + n;
+     double t = nlopt_seconds();
+     double minf;
+     nlopt_stopping *stop = p->stop;
+     nlopt_result ret;
+     
+     if (stop->maxeval > 0 &&
+        stop->nevals >= stop->maxeval) return NLOPT_MAXEVAL_REACHED;
+     if (stop->maxtime > 0 &&
+        t - stop->start >= stop->maxtime) return NLOPT_MAXTIME_REACHED;
+
+     for (i = 0; i < n; ++i) {
+         lb[i] = c[i] - 0.5 * w[i];
+         ub[i] = c[i] + 0.5 * w[i];
+     }
+     ret = nlopt_minimize(p->local_alg, n, fcount, p, 
+                         lb, ub, x, &minf,
+                         stop->minf_max, stop->ftol_rel, stop->ftol_abs,
+                         stop->xtol_rel, stop->xtol_abs,
+                         p->local_maxeval > 0 ?
+                         MIN(p->local_maxeval, 
+                             stop->maxeval - stop->nevals)
+                         : stop->maxeval - stop->nevals,
+                         stop->maxtime - (t - stop->start));
+     r[1] = -minf;
+     if (ret > 0) {
+         if (minf < p->minf) {
+              p->minf = minf;
+              memcpy(p->xmin, x, sizeof(double) * n);
+              if (ret == NLOPT_MINF_MAX_REACHED) return ret;
+         }
+         return NLOPT_SUCCESS;
+     }
+     return ret;
+}
+
+/* given a hyperrect r, randomize the starting guess within the middle
+   third of the box (don't guess too close to edges) */
+static void randomize_x(int n, double *r)
+{
+     double *x = r + 3, *c = x + n, *w = c + n;
+     int i;
+     for (i = 0; i < n; ++i)
+         x[i] = nlopt_urand(c[i] - w[i]*(0.5*THIRD),
+                            c[i] + w[i]*(0.5*THIRD));
+}
+
+/************************************************************************/
+
+static double longest(int n, const double *w)
+{
+     double wmax = w[n-1];
+     for (n = n-2; n >= 0; n--) if (w[n] > wmax) wmax = w[n];
+     return wmax;
+}
+
+#define EQUAL_SIDE_TOL 5e-2 /* tolerance to equate side sizes */
+
+static nlopt_result divide_largest(params *p)
+{
+     int L = p->L;
+     int n = p->n;
+     rb_node *node = rb_tree_max(&p->rtree); /* just using it as a heap */
+     double minf_start = p->minf;
+     double *r = node->k, *rnew = NULL;
+     double *x = r + 3, *c = x + n, *w = c + n;
+     const double *lb = p->lb, *ub = p->ub;
+     int i, idiv;
+     double wmax;
+     nlopt_result ret;
+
+     /* printf("rect:, %d, %g, %g, %g, %g\n", p->stop->nevals, c[0], c[1], w[0], w[1]); */
+
+     /* check xtol */
+     for (i = 0; i < n; ++i)
+         if (w[i] > p->stop->xtol_rel * (ub[i] - lb[i])
+             && w[i] > p->stop->xtol_abs[i])
+              break;
+     if (i == n) return NLOPT_XTOL_REACHED;
+
+     if (p->randomized_div) { /* randomly pick among ~largest sides */
+         int nlongest = 0;
+         wmax = longest(n, w);
+         for (i = 0; i < n; ++i)
+              if (wmax - w[i] < EQUAL_SIDE_TOL * wmax) ++nlongest;
+         i = 1 + nlopt_iurand(nlongest);
+         for (idiv = 0; idiv < n; ++idiv) {
+              if (wmax - w[idiv] < EQUAL_SIDE_TOL * wmax) --i;
+              if (!i) break;
+         }
+     }
+     else { /* just pick first largest side */
+         wmax = w[idiv = 0];
+         for (i = 1; i < n; ++i) if (w[i] > wmax) wmax = w[idiv = i];
+     }
+
+     if (fabs(x[idiv] - c[idiv]) > (0.5 * THIRD) * w[idiv]) { /* bisect */
+         double deltac = (x[idiv] > c[idiv] ? 0.25 : -0.25) * w[idiv];
+         w[idiv] *= 0.5;
+         c[idiv] += deltac;
+         r[0] = longest(n, w); /* new diameter */
+         /* r[1] unchanged since still contains local optimum x */
+         r[2] = p->age--;
+         node = rb_tree_resort(&p->rtree, node);
+
+         rnew = (double *) malloc(sizeof(double) * L);
+         if (!rnew) return NLOPT_OUT_OF_MEMORY;
+         memcpy(rnew, r, sizeof(double) * L);
+         rnew[2] = p->age--;
+         rnew[3+n+idiv] -= deltac*2;
+         if (p->randomized_div)
+              randomize_x(n, rnew);
+         else
+              memcpy(rnew+3, rnew+3+n, sizeof(double) * n); /* x = c */
+         ret = optimize_rect(rnew, p);
+         if (ret != NLOPT_SUCCESS) { free(rnew); return ret; }
+         if (!rb_tree_insert(&p->rtree, rnew)) {
+              free(rnew); return NLOPT_OUT_OF_MEMORY;
+         }
+     }
+     else { /* trisect */
+         w[idiv] *= THIRD;
+         r[0] = longest(n, w);
+         /* r[1] unchanged since still contains local optimum x */
+         r[2] = p->age--;
+         node = rb_tree_resort(&p->rtree, node);
+
+         for (i = -1; i <= +1; i += 2) {
+              rnew = (double *) malloc(sizeof(double) * L);
+              if (!rnew) return NLOPT_OUT_OF_MEMORY;
+              memcpy(rnew, r, sizeof(double) * L);
+              rnew[2] = p->age--;
+              rnew[3+n+idiv] += w[i] * i;
+              if (p->randomized_div)
+                   randomize_x(n, rnew);
+              else
+                   memcpy(rnew+3, rnew+3+n, sizeof(double) * n); /* x = c */
+              ret = optimize_rect(rnew, p);
+              if (ret != NLOPT_SUCCESS) { free(rnew); return ret; }
+              if (!rb_tree_insert(&p->rtree, rnew)) {
+                   free(rnew); return NLOPT_OUT_OF_MEMORY;
+              }
+         }
+     }
+     if (p->minf < minf_start && nlopt_stop_f(p->stop, p->minf, minf_start))
+         return NLOPT_FTOL_REACHED;
+     return NLOPT_SUCCESS;
+}
+
+/************************************************************************/
+
+nlopt_result cdirect_hybrid_unscaled(int n, nlopt_func f, void *f_data,
+                                    const double *lb, const double *ub,
+                                    double *x,
+                                    double *minf,
+                                    nlopt_stopping *stop,
+                                    nlopt_algorithm local_alg,
+                                    int local_maxeval,
+                                    int randomized_div)
+{
+     params p;
+     int i;
+     double *rnew;
+     nlopt_result ret = NLOPT_OUT_OF_MEMORY;
+
+     p.n = n;
+     p.L = 3*n+3;
+     p.lb = lb; p.ub = ub;
+     p.stop = stop;
+     p.f = f;
+     p.f_data = f_data;
+     p.minf = HUGE_VAL;
+     p.xmin = x;
+     p.age = 0;
+     p.work = 0;
+     p.local_alg = local_alg;
+     p.local_maxeval = local_maxeval;
+     p.randomized_div = randomized_div;
+
+     rb_tree_init(&p.rtree, cdirect_hyperrect_compare);
+     p.work = (double *) malloc(sizeof(double) * (2*n));
+     if (!p.work) goto done;
+     
+     if (!(rnew = (double *) malloc(sizeof(double) * p.L))) goto done;
+     for (i = 0; i < n; ++i) {
+          rnew[3+i] = rnew[3+n+i] = 0.5 * (lb[i] + ub[i]);
+          rnew[3+2*n+i] = ub[i] - lb[i];
+     }
+     rnew[0] = longest(n, rnew+2*n);
+     rnew[2] = p.age--;
+     ret = optimize_rect(rnew, &p);
+     if (ret != NLOPT_SUCCESS) { free(rnew); goto done; }
+     if (!rb_tree_insert(&p.rtree, rnew)) { free(rnew); goto done; }
+
+     do {
+         ret = divide_largest(&p);
+     } while (ret == NLOPT_SUCCESS);
+
+ done:
+     rb_tree_destroy_with_keys(&p.rtree);
+     free(p.work);
+             
+     *minf = p.minf;
+     return ret;
+}
+
+/* rescaled to unit hypercube so that all x[i] are weighted equally  */
+nlopt_result cdirect_hybrid(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub,
+                           double *x,
+                           double *minf,
+                           nlopt_stopping *stop,
+                           nlopt_algorithm local_alg,
+                           int local_maxeval,
+                           int randomized_div)
+{
+     cdirect_uf_data d;
+     nlopt_result ret;
+     const double *xtol_abs_save;
+     int i;
+
+     d.f = f; d.f_data = f_data; d.lb = lb; d.ub = ub;
+     d.x = (double *) malloc(sizeof(double) * n*4);
+     if (!d.x) return NLOPT_OUT_OF_MEMORY;
+     
+     for (i = 0; i < n; ++i) {
+         x[i] = (x[i] - lb[i]) / (ub[i] - lb[i]);
+         d.x[n+i] = 0;
+         d.x[2*n+i] = 1;
+         d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]);
+     }
+     xtol_abs_save = stop->xtol_abs;
+     stop->xtol_abs = d.x + 3*n;
+     ret = cdirect_hybrid_unscaled(n, cdirect_uf, &d, d.x+n, d.x+2*n, 
+                                  x, minf, stop, local_alg, local_maxeval,
+                                  randomized_div);
+     stop->xtol_abs = xtol_abs_save;
+     for (i = 0; i < n; ++i)
+         x[i] = lb[i]+ x[i] * (ub[i] - lb[i]);
+     free(d.x);
+     return ret;
+}
diff --git a/cobyla/COPYRIGHT b/cobyla/COPYRIGHT
new file mode 100644 (file)
index 0000000..f5e0d95
--- /dev/null
@@ -0,0 +1,22 @@
+Copyright (c) 1992, Michael J. D. Powell (M.J.D.Powell@damtp.cam.ac.uk)
+Copyright (c) 2004, Jean-Sebastien Roy (js@jeannot.org)
+Copyright (c) 2008, Steven G. Johnson (stevenj@alum.mit.edu)
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/cobyla/Makefile.am b/cobyla/Makefile.am
new file mode 100644 (file)
index 0000000..2c5752a
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libcobyla.la
+libcobyla_la_SOURCES = cobyla.c cobyla.h
+
+EXTRA_DIST = README COPYRIGHT README.orig
diff --git a/cobyla/Makefile.in b/cobyla/Makefile.in
new file mode 100644 (file)
index 0000000..4befe21
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = cobyla
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcobyla_la_LIBADD =
+am_libcobyla_la_OBJECTS = cobyla.lo
+libcobyla_la_OBJECTS = $(am_libcobyla_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libcobyla_la_SOURCES)
+DIST_SOURCES = $(libcobyla_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libcobyla.la
+libcobyla_la_SOURCES = cobyla.c cobyla.h
+EXTRA_DIST = README COPYRIGHT README.orig
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cobyla/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu cobyla/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libcobyla.la: $(libcobyla_la_OBJECTS) $(libcobyla_la_DEPENDENCIES) $(EXTRA_libcobyla_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libcobyla_la_OBJECTS) $(libcobyla_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cobyla.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/cobyla/README b/cobyla/README
new file mode 100644 (file)
index 0000000..eb19f17
--- /dev/null
@@ -0,0 +1,42 @@
+This code implements COBYLA (Constrained Optimization BY Linear
+Approximations) algorithm derivative free optimization with nonlinear
+inequality constraints by M. J. D. Powell, described by:
+
+       M. J. D. Powell, "A direct search optimization method that
+       models the objective and constraint functions by linear
+       interpolation," in Advances in Optimization and Numerical
+       Analysis, eds. S. Gomez and J.-P. Hennart (Kluwer Academic:
+       Dordrecht, 1994), p. 51-67.
+
+and reviewed in:
+
+       M. J. D. Powell, "Direct search algorithms for optimization
+       calculations," Acta Numerica 7, 287-336 (1998).
+
+It constructs successive linear approximations of the objective
+function and constraints via a simplex of n+1 points (in n
+dimensions), and optimizes these approximations in a trust region at
+each step.
+
+The original code itself was written in Fortran by Powell, and
+apparently released without restrictions (like several of his other
+programs), and was converted to C in 2004 by Jean-Sebastien Roy
+(js@jeannot.org) for the SciPy project.  The C version was released
+under the attached license (basically the MIT license) at:
+       http://www.jeannot.org/~js/code/index.en.html#COBYLA
+
+It was incorporated into NLopt in 2008 by S. G. Johnson, and kept under
+the same MIT license.  In incorporating it into NLopt, SGJ adapted it
+to include the NLopt stopping conditions (the original code provided
+an x tolerance and a maximum number of function evaluations only).
+
+The original COBYLA did not have explicit support for bound
+constraints; these are included as linear constraints along with any
+other nonlinear constraints.  This is mostly fine---linear constraints
+are handled exactly by COBYLA's linear approximations.  However,
+occasionally COBYLA takes a "simplex" step, either to create the
+initial simplex or to fix a degenerate simplex, and these steps could
+violate the bound constraints.  SGJ modified COBYLA to explicitly
+honor the bound constraints in these cases, so that the
+objective/constraints are never evaluated outside of the bound
+constraints, without slowing convergence.
diff --git a/cobyla/README.orig b/cobyla/README.orig
new file mode 100644 (file)
index 0000000..09ead81
--- /dev/null
@@ -0,0 +1,74 @@
+# COBYLA : constrained optimization by linear approximation
+# Version 1.1
+# Copyright (c) 1992, Michael J. D. Powell (M.J.D.Powell@damtp.cam.ac.uk)
+# Copyright (c) 2004, J.S. Roy (js@jeannot.org)
+# See the LICENSE file for copyright information.
+# $Jeannot: README,v 1.7 2004/04/18 14:04:20 js Exp $
+
+This software is a C version of COBYLA2, a contrained optimization by linear
+approximation package developed by Michael J. D. Powell in Fortran.
+
+The original source code can be found at :
+http://plato.la.asu.edu/topics/problems/nlores.html
+
+Reference article for the method: Powell, J.M.D. (1992), "A Direct Search
+Optimization Method that Models the Objective and Constraint Functions by Linear
+Interpolation", DAMTP/NA5, Cambridge, England.
+
+This package was initially built by J.S. Roy to ease integration into SciPy.
+See: http://www.scipy.org/
+Many thanks to Michael J. D. Powell for allowing this to happen !
+
+This software, a derivative free non-linear optimizer, aims at minimizing the
+value of a nonlinear function subject to nonlinear constraints. It requires to
+be able to evaluate the function and the value of the constraints.
+
+COBYLA will try to make all the values of the constraints positive.
+So if you want to input a constraint j such as variable x[i] <= MAX, set:
+  constraint[j] = MAX - x[i]
+
+See the comments in cobyla.c for more details.
+
+This software has been converted from the Fortran into C and provides the
+following modifications :
+- reentrancy, no global variables or functions ;
+- ability to pass a pointer to the function to be optimized (to provide
+  access to constants) ;
+- ability to end the minimization at any time ;
+And other small changes.
+
+The last version (and other software) is avalaible at the URL :
+http://www.jeannot.org/~js/code/index.en.html
+
+A Python interface module is also provided.
+
+Contents :
+- cobyla.c : Source
+- cobyla.h : Header, and API documentation
+- LICENSE : License and copyright information
+- HISTORY : Release history
+- README : This file
+- example.c : A simple example
+- Makefile : Make file used to build the examples
+- moduleCobyla.c : the source of the python module
+- cobyla.py : the python module wrapper
+- example.py : an example for the python module
+- setup.py : the python installer
+
+Use is described in cobyla.h. For more information, see the example.
+The example can be built and executed by doing :
+  make test
+
+You may need to adjust the Makefile before building cobyla.
+
+To install the module in the current directory, use:
+ python setup.py build_ext --inplace
+To test it, execute:
+  python cobyla.py
+To install it globaly, use:
+ python setup.py install
+
+If you make use of this software, or if you make modifications to it (for a
+specific platform for example), you are encouraged to contact the author of
+this Fortran to C conversion at the following email : js@jeannot.org
+Thanks !
diff --git a/cobyla/cobyla.c b/cobyla/cobyla.c
new file mode 100644 (file)
index 0000000..bb3066b
--- /dev/null
@@ -0,0 +1,1859 @@
+/* cobyla : contrained optimization by linear approximation */
+
+/*
+ * Copyright (c) 1992, Michael J. D. Powell (M.J.D.Powell@damtp.cam.ac.uk)
+ * Copyright (c) 2004, Jean-Sebastien Roy (js@jeannot.org)
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This software is a C version of COBYLA2, a contrained optimization by linear
+ * approximation package developed by Michael J. D. Powell in Fortran.
+ * 
+ * The original source code can be found at :
+ * http://plato.la.asu.edu/topics/problems/nlores.html
+ */
+
+static char const rcsid[] =
+  "@(#) $Jeannot: cobyla.c,v 1.11 2004/04/18 09:51:36 js Exp $";
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "cobyla.h"
+
+/* SGJ, 2008: modified COBYLA code to take explicit account of bound
+   constraints.  Since bound constraints are linear, these should
+   already be handled exactly when COBYLA optimizes it linear model.
+   However, they were not handled properly when COBYLA created its
+   initial simplex, or when COBYLA updated unacceptable simplices.
+   Since NLopt guarantees that the objective will not be evaluated
+   outside the bound constraints, this required us to handle such
+   points by putting a slope discontinuity into the objective &
+   constraints (below), which slows convergence considerably for
+   smooth functions.  Instead, handling them explicitly prevents this
+   problem */
+#define ENFORCE_BOUNDS 1
+
+#define MIN2(a,b) ((a) <= (b) ? (a) : (b))
+#define MAX2(a,b) ((a) >= (b) ? (a) : (b))
+
+#define U(n) ((unsigned) (n))
+
+/**************************************************************************/
+/* SGJ, 2008: NLopt-style interface function: */
+
+typedef struct {
+     nlopt_func f;
+     void *f_data;
+     unsigned m_orig;
+     nlopt_constraint *fc;
+     unsigned p;
+     nlopt_constraint *h;
+     double *xtmp;
+     double *lb, *ub;
+     double *con_tol, *scale;
+     nlopt_stopping *stop;
+} func_wrap_state;
+
+static int func_wrap(int ni, int mi, double *x, double *f, double *con,
+                    func_wrap_state *s)
+{
+     unsigned n = U(ni);
+     unsigned i, j, k;
+     double *xtmp = s->xtmp;
+     const double *lb = s->lb, *ub = s->ub;
+
+     (void) mi; /* unused */
+
+     /* in nlopt, we guarante that the function is never evaluated outside
+       the lb and ub bounds, so we need force this with xtmp ... note
+       that this leads to discontinuity in the first derivative, which
+        slows convergence if we don't enable the ENFORCE_BOUNDS feature
+       above. */
+     for (j = 0; j < n; ++j) {
+         if (x[j] < lb[j]) xtmp[j] = lb[j];
+         else if (x[j] > ub[j]) xtmp[j] = ub[j];
+         else xtmp[j] = x[j];
+     }
+     nlopt_unscale(n, s->scale, xtmp, xtmp);
+
+     *f = s->f(n, xtmp, NULL, s->f_data);
+     if (nlopt_stop_forced(s->stop)) return 1;
+     i = 0;
+     for (j = 0; j < s->m_orig; ++j) {
+         nlopt_eval_constraint(con + i, NULL, s->fc+j, n, xtmp);
+         if (nlopt_stop_forced(s->stop)) return 1;
+         for (k = 0; k < s->fc[j].m; ++k)
+              con[i + k] = -con[i + k];
+         i += s->fc[j].m;
+     }
+     for (j = 0; j < s->p; ++j) {
+         nlopt_eval_constraint(con + i, NULL, s->h+j, n, xtmp);
+         if (nlopt_stop_forced(s->stop)) return 1;
+         for (k = 0; k < s->h[j].m; ++k)
+              con[(i + s->h[j].m) + k] = -con[i + k];
+         i += 2 * s->h[j].m;
+     }
+     for (j = 0; j < n; ++j) {
+         if (!nlopt_isinf(lb[j]))
+              con[i++] = x[j] - lb[j];
+         if (!nlopt_isinf(ub[j]))
+              con[i++] = ub[j] - x[j];
+     }
+     return 0;
+}
+
+/*
+ * Verbosity level
+ */
+typedef enum {
+  COBYLA_MSG_NONE = 0, /* No messages */
+  COBYLA_MSG_EXIT = 1, /* Exit reasons */
+  COBYLA_MSG_ITER = 2, /* Rho and Sigma changes */
+  COBYLA_MSG_INFO = 3 /* Informational messages */
+} cobyla_message;
+
+/*
+ * A function as required by cobyla
+ * state is a void pointer provided to the function at each call
+ *
+ * n     : the number of variables
+ * m     : the number of constraints
+ * x     : on input, then vector of variables (should not be modified)
+ * f     : on output, the value of the function
+ * con   : on output, the value of the constraints (vector of size m)
+ * state : on input, the value of the state variable as provided to cobyla
+ *
+ * COBYLA will try to make all the values of the constraints positive.
+ * So if you want to input a constraint j such as x[i] <= MAX, set:
+ *   con[j] = MAX - x[i]
+ * The function must returns 0 if no error occurs or 1 to immediately end the
+ * minimization.
+ *
+ */
+typedef int cobyla_function(int n, int m, double *x, double *f, double *con,
+  func_wrap_state *state);
+
+/*
+ * cobyla : minimize a function subject to constraints
+ *
+ * n         : number of variables (>=0)
+ * m         : number of constraints (>=0)
+ * x         : on input, initial estimate ; on output, the solution
+ * minf      : on output, minimum objective function
+ * rhobeg    : a reasonable initial change to the variables
+ * stop      : the NLopt stopping criteria
+ * lb, ub    : lower and upper bounds on x
+ * message   : see the cobyla_message enum
+ * calcfc    : the function to minimize (see cobyla_function)
+ * state     : used by function (see cobyla_function)
+ *
+ * The cobyla function returns the usual nlopt_result codes.
+ *
+ */
+extern nlopt_result cobyla(int n, int m, double *x, double *minf, double rhobeg, double rhoend, nlopt_stopping *stop, const double *lb, const double *ub,
+  int message, cobyla_function *calcfc, func_wrap_state *state);
+
+nlopt_result cobyla_minimize(unsigned n, nlopt_func f, void *f_data,
+                            unsigned m, nlopt_constraint *fc,
+                             unsigned p, nlopt_constraint *h,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            nlopt_stopping *stop,
+                            const double *dx)
+{
+     unsigned i, j;
+     func_wrap_state s;
+     nlopt_result ret;
+     double rhobeg, rhoend;
+
+     s.f = f; s.f_data = f_data;
+     s.m_orig = m;
+     s.fc = fc; 
+     s.p = p;
+     s.h = h;
+     s.stop = stop;
+     s.lb = s.ub = s.xtmp = s.con_tol = s.scale = NULL;
+
+     s.scale = nlopt_compute_rescaling(n, dx);
+     if (!s.scale) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+
+     s.lb = nlopt_new_rescaled(n, s.scale, lb);
+     if (!s.lb) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+     s.ub = nlopt_new_rescaled(n, s.scale, ub);
+     if (!s.ub) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+     nlopt_reorder_bounds(n, s.lb, s.ub);
+
+     s.xtmp = (double *) malloc(sizeof(double) * n);
+     if (!s.xtmp) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+
+     /* SGJ, 2008: compute rhoend from NLopt stop info */
+     rhobeg = fabs(dx[0] / s.scale[0]);
+     rhoend = stop->xtol_rel * (rhobeg);
+     for (j = 0; j < n; ++j)
+         if (rhoend < stop->xtol_abs[j] / fabs(s.scale[j]))
+              rhoend = stop->xtol_abs[j] / fabs(s.scale[j]);
+
+     /* each equality constraint gives two inequality constraints */
+     m = nlopt_count_constraints(m, fc) + 2 * nlopt_count_constraints(p, h);
+
+     /* add constraints for lower/upper bounds (if any) */
+     for (j = 0; j < n; ++j) {
+         if (!nlopt_isinf(lb[j]))
+              ++m;
+         if (!nlopt_isinf(ub[j]))
+              ++m;
+     }
+
+     s.con_tol = (double *) malloc(sizeof(double) * m);
+     if (m && !s.con_tol) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+
+     for (j = 0; j < m; ++j) s.con_tol[j] = 0;
+     for (j = i = 0; i < s.m_orig; ++i) {
+         unsigned ji = j, jnext = j + fc[i].m;
+         for (; j < jnext; ++j) s.con_tol[j] = fc[i].tol[j - ji];
+     }
+     for (i = 0; i < s.p; ++i) {
+         unsigned ji = j, jnext = j + h[i].m;
+         for (; j < jnext; ++j) s.con_tol[j] = h[i].tol[j - ji];
+         ji = j; jnext = j + h[i].m;
+         for (; j < jnext; ++j) s.con_tol[j] = h[i].tol[j - ji];
+     }
+
+     nlopt_rescale(n, s.scale, x, x);
+     ret = cobyla((int) n, (int) m, x, minf, rhobeg, rhoend,
+                 stop, s.lb, s.ub, COBYLA_MSG_NONE, 
+                 func_wrap, &s);
+     nlopt_unscale(n, s.scale, x, x);
+
+     /* make sure e.g. rounding errors didn't push us slightly out of bounds */
+     for (j = 0; j < n; ++j) {
+         if (x[j] < lb[j]) x[j] = lb[j];
+         if (x[j] > ub[j]) x[j] = ub[j];
+     }
+
+done:
+     free(s.con_tol);
+     free(s.xtmp);
+     free(s.ub);
+     free(s.lb);
+     free(s.scale);
+     return ret;
+}
+
+/**************************************************************************/
+
+/* SGJ, 2010: I find that it seems to increase robustness of the algorithm
+   if, on "simplex" steps (which are intended to improve the linear
+   independence of the simplex, not improve the objective), we multiply
+   the steps by pseudorandom numbers in [0,1).  Intuitively, pseudorandom
+   steps are likely to avoid any accidental dependency in the simplex
+   vertices.  However, since I still want COBYLA to be a deterministic
+   algorithm, and I don't care all that much about the quality of the
+   randomness here, I implement a simple linear congruential generator
+   rather than use nlopt_urand, and set the initial seed deterministically. */
+
+#if defined(HAVE_STDINT_H)
+#  include <stdint.h>
+#endif
+
+#ifndef HAVE_UINT32_T
+#  if SIZEOF_UNSIGNED_LONG == 4
+typedef unsigned long uint32_t;
+#  elif SIZEOF_UNSIGNED_INT == 4
+typedef unsigned int uint32_t;
+#  else
+#    error No 32-bit unsigned integer type
+#  endif
+#endif
+
+/* a simple linear congruential generator */
+
+static uint32_t lcg_rand(uint32_t *seed)
+{
+     return (*seed = *seed * 1103515245 + 12345);
+}
+
+static double lcg_urand(uint32_t *seed, double a, double b)
+{
+     return a + lcg_rand(seed) * (b - a) / ((uint32_t) -1);
+}
+
+/**************************************************************************/
+
+static nlopt_result cobylb(int *n, int *m, int *mpp, double *x, double *minf, double *rhobeg, double rhoend,
+  nlopt_stopping *stop, const double *lb, const double *ub, int *iprint, double *con, double *sim,
+  double *simi, double *datmat, double *a, double *vsig, double *veta,
+  double *sigbar, double *dx, double *w, int *iact, cobyla_function *calcfc,
+  func_wrap_state *state);
+static nlopt_result trstlp(int *n, int *m, double *a, double *b, double *rho,
+  double *dx, int *ifull, int *iact, double *z__, double *zdota, double *vmultc,
+  double *sdirn, double *dxnew, double *vmultd);
+
+/* ------------------------------------------------------------------------ */
+
+nlopt_result cobyla(int n, int m, double *x, double *minf, double rhobeg, double rhoend, nlopt_stopping *stop, const double *lb, const double *ub, int iprint,
+  cobyla_function *calcfc, func_wrap_state *state)
+{
+  int icon, isim, isigb, idatm, iveta, isimi, ivsig, iwork, ia, idx, mpp;
+  int *iact;
+  double *w;
+  nlopt_result rc;
+
+/*
+ * This subroutine minimizes an objective function F(X) subject to M
+ * inequality constraints on X, where X is a vector of variables that has 
+ * N components. The algorithm employs linear approximations to the 
+ * objective and constraint functions, the approximations being formed by 
+ * linear interpolation at N+1 points in the space of the variables. 
+ * We regard these interpolation points as vertices of a simplex. The 
+ * parameter RHO controls the size of the simplex and it is reduced 
+ * automatically from RHOBEG to RHOEND. For each RHO the subroutine tries 
+ * to achieve a good vector of variables for the current size, and then 
+ * RHO is reduced until the value RHOEND is reached. Therefore RHOBEG and 
+ * RHOEND should be set to reasonable initial changes to and the required 
+ * accuracy in the variables respectively, but this accuracy should be 
+ * viewed as a subject for experimentation because it is not guaranteed. 
+ * The subroutine has an advantage over many of its competitors, however, 
+ * which is that it treats each constraint individually when calculating 
+ * a change to the variables, instead of lumping the constraints together 
+ * into a single penalty function. The name of the subroutine is derived 
+ * from the phrase Constrained Optimization BY Linear Approximations. 
+ *
+ * The user must set the values of N, M, RHOBEG and RHOEND, and must 
+ * provide an initial vector of variables in X. Further, the value of 
+ * IPRINT should be set to 0, 1, 2 or 3, which controls the amount of 
+ * printing during the calculation. Specifically, there is no output if 
+ * IPRINT=0 and there is output only at the end of the calculation if 
+ * IPRINT=1. Otherwise each new value of RHO and SIGMA is printed. 
+ * Further, the vector of variables and some function information are 
+ * given either when RHO is reduced or when each new value of F(X) is 
+ * computed in the cases IPRINT=2 or IPRINT=3 respectively. Here SIGMA 
+ * is a penalty parameter, it being assumed that a change to X is an 
+ * improvement if it reduces the merit function 
+ *      F(X)+SIGMA*MAX(0.0,-C1(X),-C2(X),...,-CM(X)), 
+ * where C1,C2,...,CM denote the constraint functions that should become 
+ * nonnegative eventually, at least to the precision of RHOEND. In the 
+ * printed output the displayed term that is multiplied by SIGMA is 
+ * called MAXCV, which stands for 'MAXimum Constraint Violation'. The 
+ * argument MAXFUN is an int variable that must be set by the user to a 
+ * limit on the number of calls of CALCFC, the purpose of this routine being 
+ * given below. The value of MAXFUN will be altered to the number of calls 
+ * of CALCFC that are made. The arguments W and IACT provide real and 
+ * int arrays that are used as working space. Their lengths must be at 
+ * least N*(3*N+2*M+11)+4*M+6 and M+1 respectively. 
+ *
+ * In order to define the objective and constraint functions, we require 
+ * a subroutine that has the name and arguments 
+ *      SUBROUTINE CALCFC (N,M,X,F,CON) 
+ *      DIMENSION X(*),CON(*)  . 
+ * The values of N and M are fixed and have been defined already, while 
+ * X is now the current vector of variables. The subroutine should return 
+ * the objective and constraint functions at X in F and CON(1),CON(2), 
+ * ...,CON(M). Note that we are trying to adjust X so that F(X) is as 
+ * small as possible subject to the constraint functions being nonnegative. 
+ *
+ * Partition the working space array W to provide the storage that is needed 
+ * for the main calculation.
+ */
+
+  stop->nevals = 0;
+
+  if (n == 0)
+  {
+    if (iprint>=1) fprintf(stderr, "cobyla: N==0.\n");
+    return NLOPT_SUCCESS;
+  }
+
+  if (n < 0 || m < 0)
+  {
+    if (iprint>=1) fprintf(stderr, "cobyla: N<0 or M<0.\n");
+    return NLOPT_INVALID_ARGS;
+  }
+
+  /* workspace allocation */
+  w = (double*) malloc(U(n*(3*n+2*m+11)+4*m+6)*sizeof(*w));
+  if (w == NULL)
+  {
+    if (iprint>=1) fprintf(stderr, "cobyla: memory allocation error.\n");
+    return NLOPT_OUT_OF_MEMORY;
+  }
+  iact = (int*)malloc(U(m+1)*sizeof(*iact));
+  if (iact == NULL)
+  {
+    if (iprint>=1) fprintf(stderr, "cobyla: memory allocation error.\n");
+    free(w);
+    return NLOPT_OUT_OF_MEMORY;
+  }
+  
+  /* Parameter adjustments */
+  --iact;
+  --w;
+  --x;
+  --lb; --ub;
+
+  /* Function Body */
+  mpp = m + 2;
+  icon = 1;
+  isim = icon + mpp;
+  isimi = isim + n * n + n;
+  idatm = isimi + n * n;
+  ia = idatm + n * mpp + mpp;
+  ivsig = ia + m * n + n;
+  iveta = ivsig + n;
+  isigb = iveta + n;
+  idx = isigb + n;
+  iwork = idx + n;
+  rc = cobylb(&n, &m, &mpp, &x[1], minf, &rhobeg, rhoend, stop, &lb[1], &ub[1], &iprint,
+      &w[icon], &w[isim], &w[isimi], &w[idatm], &w[ia], &w[ivsig], &w[iveta],
+      &w[isigb], &w[idx], &w[iwork], &iact[1], calcfc, state);
+
+  /* Parameter adjustments (reverse) */
+  ++iact;
+  ++w;
+
+  free(w);
+  free(iact);
+  
+  return rc;
+} /* cobyla */
+
+/* ------------------------------------------------------------------------- */
+static nlopt_result cobylb(int *n, int *m, int *mpp,
+   double *x, double *minf, double *rhobeg, double rhoend,
+    nlopt_stopping *stop, const double *lb, const double *ub,
+    int *iprint, double *con, double *sim, double *simi, 
+    double *datmat, double *a, double *vsig, double *veta,
+     double *sigbar, double *dx, double *w, int *iact, cobyla_function *calcfc,
+     func_wrap_state *state)
+{
+  /* System generated locals */
+  int sim_dim1, sim_offset, simi_dim1, simi_offset, datmat_dim1, 
+      datmat_offset, a_dim1, a_offset, i__1, i__2, i__3;
+  double d__1, d__2;
+
+  /* Local variables */
+  double alpha, delta, denom, tempa, barmu;
+  double beta, cmin = 0.0, cmax = 0.0;
+  double cvmaxm, dxsign, prerem = 0.0;
+  double edgmax, pareta, prerec = 0.0, phimin, parsig = 0.0;
+  double gamma_;
+  double phi, rho, sum = 0.0;
+  double ratio, vmold, parmu, error, vmnew;
+  double resmax, cvmaxp;
+  double resnew, trured;
+  double temp, wsig, f;
+  double weta;
+  int i__, j, k, l;
+  int idxnew;
+  int iflag = 0;
+  int iptemp;
+  int isdirn, izdota;
+  int ivmc;
+  int ivmd;
+  int mp, np, iz, ibrnch;
+  int nbest, ifull, iptem, jdrop;
+  nlopt_result rc = NLOPT_SUCCESS;
+  uint32_t seed = (uint32_t) (*n + *m); /* arbitrary deterministic LCG seed */
+  int feasible;
+
+  /* SGJ, 2008: added code to keep track of minimum feasible function val */
+  *minf = HUGE_VAL;
+
+/* Set the initial values of some parameters. The last column of SIM holds */
+/* the optimal vertex of the current simplex, and the preceding N columns */
+/* hold the displacements from the optimal vertex to the other vertices. */
+/* Further, SIMI holds the inverse of the matrix that is contained in the */
+/* first N columns of SIM. */
+
+  /* Parameter adjustments */
+  a_dim1 = *n;
+  a_offset = 1 + a_dim1 * 1;
+  a -= a_offset;
+  simi_dim1 = *n;
+  simi_offset = 1 + simi_dim1 * 1;
+  simi -= simi_offset;
+  sim_dim1 = *n;
+  sim_offset = 1 + sim_dim1 * 1;
+  sim -= sim_offset;
+  datmat_dim1 = *mpp;
+  datmat_offset = 1 + datmat_dim1 * 1;
+  datmat -= datmat_offset;
+  --x;
+  --con;
+  --vsig;
+  --veta;
+  --sigbar;
+  --dx;
+  --w;
+  --iact;
+  --lb; --ub;
+
+  /* Function Body */
+  iptem = MIN2(*n,4);
+  iptemp = iptem + 1;
+  np = *n + 1;
+  mp = *m + 1;
+  alpha = .25;
+  beta = 2.1;
+  gamma_ = .5;
+  delta = 1.1;
+  rho = *rhobeg;
+  parmu = 0.;
+  if (*iprint >= 2) {
+    fprintf(stderr,
+      "cobyla: the initial value of RHO is %12.6E and PARMU is set to zero.\n",
+      rho);
+  }
+  temp = 1. / rho;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    double rhocur;
+    sim[i__ + np * sim_dim1] = x[i__];
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+      sim[i__ + j * sim_dim1] = 0.;
+      simi[i__ + j * simi_dim1] = 0.;
+    }
+    rhocur = rho;
+#if ENFORCE_BOUNDS
+    /* SGJ: make sure step rhocur stays inside [lb,ub] */
+    if (x[i__] + rhocur > ub[i__]) {
+        if (x[i__] - rhocur >= lb[i__])
+             rhocur = -rhocur;
+        else if (ub[i__] - x[i__] > x[i__] - lb[i__])
+             rhocur = 0.5 * (ub[i__] - x[i__]);
+        else
+             rhocur = 0.5 * (x[i__] - lb[i__]);
+    }
+#endif
+    sim[i__ + i__ * sim_dim1] = rhocur;
+    simi[i__ + i__ * simi_dim1] = 1.0 / rhocur;
+  }
+  jdrop = np;
+  ibrnch = 0;
+
+/* Make the next call of the user-supplied subroutine CALCFC. These */
+/* instructions are also used for calling CALCFC during the iterations of */
+/* the algorithm. */
+
+  /* SGJ comment: why the hell couldn't he just use a damn subroutine?
+     #*&!%*@ Fortran-66 spaghetti code */
+
+L40:
+  if (nlopt_stop_forced(stop)) rc = NLOPT_FORCED_STOP;
+  else if (stop->nevals > 0) {
+       if (nlopt_stop_evals(stop)) rc = NLOPT_MAXEVAL_REACHED;
+       else if (nlopt_stop_time(stop)) rc = NLOPT_MAXTIME_REACHED;
+  }
+  if (rc != NLOPT_SUCCESS) goto L600;
+
+  stop->nevals++;
+  if (calcfc(*n, *m, &x[1], &f, &con[1], state))
+  {
+    if (*iprint >= 1) {
+      fprintf(stderr, "cobyla: user requested end of minimization.\n");
+    }
+    rc = NLOPT_FORCED_STOP;
+    goto L600;
+  }
+
+  resmax = 0.;
+  feasible = 1; /* SGJ, 2010 */
+  if (*m > 0) {
+    i__1 = *m;
+    for (k = 1; k <= i__1; ++k) {
+      d__1 = resmax, d__2 = -con[k];
+      resmax = MAX2(d__1,d__2);
+      if (d__2 > state->con_tol[k-1])
+          feasible = 0; /* SGJ, 2010 */
+    }
+  }
+
+  /* SGJ, 2008: check for minf_max reached by feasible point */
+  if (f < stop->minf_max && feasible) {
+       rc = NLOPT_MINF_MAX_REACHED;
+       goto L620; /* not L600 because we want to use current x, f, resmax */
+  }
+
+  if (stop->nevals == *iprint - 1 || *iprint == 3) {
+    fprintf(stderr, "cobyla: NFVALS = %4d, F =%13.6E, MAXCV =%13.6E\n",
+           stop->nevals, f, resmax);
+    i__1 = iptem;
+    fprintf(stderr, "cobyla: X =");
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      if (i__>1) fprintf(stderr, "  ");
+      fprintf(stderr, "%13.6E", x[i__]);
+    }
+    if (iptem < *n) {
+      i__1 = *n;
+      for (i__ = iptemp; i__ <= i__1; ++i__) {
+        if (!((i__-1) % 4)) fprintf(stderr, "\ncobyla:  ");
+        fprintf(stderr, "%15.6E", x[i__]);
+      }
+    }
+    fprintf(stderr, "\n");
+  }
+  con[mp] = f;
+  con[*mpp] = resmax;
+  if (ibrnch == 1) {
+    goto L440;
+  }
+
+/* Set the recently calculated function values in a column of DATMAT. This */
+/* array has a column for each vertex of the current simplex, the entries of */
+/* each column being the values of the constraint functions (if any) */
+/* followed by the objective function and the greatest constraint violation */
+/* at the vertex. */
+
+  i__1 = *mpp;
+  for (k = 1; k <= i__1; ++k) {
+    datmat[k + jdrop * datmat_dim1] = con[k];
+  }
+  if (stop->nevals > np) {
+    goto L130;
+  }
+
+/* Exchange the new vertex of the initial simplex with the optimal vertex if */
+/* necessary. Then, if the initial simplex is not complete, pick its next */
+/* vertex and calculate the function values there. */
+
+  if (jdrop <= *n) {
+    if (datmat[mp + np * datmat_dim1] <= f) {
+      x[jdrop] = sim[jdrop + np * sim_dim1];
+    } else { /* improvement in function val */
+      double rhocur = x[jdrop] - sim[jdrop + np * sim_dim1];
+      /* SGJ: use rhocur instead of rho.  In original code, rhocur == rho
+              always, but I want to change this to ensure that simplex points
+              fall within [lb,ub]. */
+      sim[jdrop + np * sim_dim1] = x[jdrop];
+      i__1 = *mpp;
+      for (k = 1; k <= i__1; ++k) {
+        datmat[k + jdrop * datmat_dim1] = datmat[k + np * datmat_dim1]
+            ;
+        datmat[k + np * datmat_dim1] = con[k];
+      }
+      i__1 = jdrop;
+      for (k = 1; k <= i__1; ++k) {
+        sim[jdrop + k * sim_dim1] = -rhocur;
+        temp = 0.f;
+        i__2 = jdrop;
+        for (i__ = k; i__ <= i__2; ++i__) {
+          temp -= simi[i__ + k * simi_dim1];
+        }
+        simi[jdrop + k * simi_dim1] = temp;
+      }
+    }
+  }
+  if (stop->nevals <= *n) { /* evaluating initial simplex */
+    jdrop = stop->nevals;
+    /* SGJ: was += rho, but using sim[jdrop,jdrop] enforces consistency
+            if we change the stepsize above to stay in [lb,ub]. */
+    x[jdrop] += sim[jdrop + jdrop * sim_dim1];
+    goto L40;
+  }
+L130:
+  ibrnch = 1;
+
+/* Identify the optimal vertex of the current simplex. */
+
+L140:
+  phimin = datmat[mp + np * datmat_dim1] + parmu * datmat[*mpp + np * 
+      datmat_dim1];
+  nbest = np;
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    temp = datmat[mp + j * datmat_dim1] + parmu * datmat[*mpp + j * 
+        datmat_dim1];
+    if (temp < phimin) {
+      nbest = j;
+      phimin = temp;
+    } else if (temp == phimin && parmu == 0.) {
+      if (datmat[*mpp + j * datmat_dim1] < datmat[*mpp + nbest * 
+          datmat_dim1]) {
+        nbest = j;
+      }
+    }
+  }
+
+/* Switch the best vertex into pole position if it is not there already, */
+/* and also update SIM, SIMI and DATMAT. */
+
+  if (nbest <= *n) {
+    i__1 = *mpp;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = datmat[i__ + np * datmat_dim1];
+      datmat[i__ + np * datmat_dim1] = datmat[i__ + nbest * datmat_dim1]
+          ;
+      datmat[i__ + nbest * datmat_dim1] = temp;
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = sim[i__ + nbest * sim_dim1];
+      sim[i__ + nbest * sim_dim1] = 0.;
+      sim[i__ + np * sim_dim1] += temp;
+      tempa = 0.;
+      i__2 = *n;
+      for (k = 1; k <= i__2; ++k) {
+        sim[i__ + k * sim_dim1] -= temp;
+        tempa -= simi[k + i__ * simi_dim1];
+      }
+      simi[nbest + i__ * simi_dim1] = tempa;
+    }
+  }
+
+/* Make an error return if SIGI is a poor approximation to the inverse of */
+/* the leading N by N submatrix of SIG. */
+
+  error = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+      temp = 0.;
+      if (i__ == j) {
+        temp += -1.;
+      }
+      i__3 = *n;
+      for (k = 1; k <= i__3; ++k) if (sim[k + j * sim_dim1] != 0) {
+        temp += simi[i__ + k * simi_dim1] * sim[k + j * sim_dim1];
+      }
+      d__1 = error, d__2 = fabs(temp);
+      error = MAX2(d__1,d__2);
+    }
+  }
+  if (error > .1) {
+    if (*iprint >= 1) {
+      fprintf(stderr, "cobyla: rounding errors are becoming damaging.\n");
+    }
+    rc = NLOPT_ROUNDOFF_LIMITED;
+    goto L600;
+  }
+
+/* Calculate the coefficients of the linear approximations to the objective */
+/* and constraint functions, placing minus the objective function gradient */
+/* after the constraint gradients in the array A. The vector W is used for */
+/* working space. */
+
+  i__2 = mp;
+  for (k = 1; k <= i__2; ++k) {
+    con[k] = -datmat[k + np * datmat_dim1];
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+      w[j] = datmat[k + j * datmat_dim1] + con[k];
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = 0.;
+      i__3 = *n;
+      for (j = 1; j <= i__3; ++j) {
+        temp += w[j] * simi[j + i__ * simi_dim1];
+      }
+      if (k == mp) {
+        temp = -temp;
+      }
+      a[i__ + k * a_dim1] = temp;
+    }
+  }
+
+/* Calculate the values of sigma and eta, and set IFLAG=0 if the current */
+/* simplex is not acceptable. */
+
+  iflag = 1;
+  parsig = alpha * rho;
+  pareta = beta * rho;
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    wsig = 0.;
+    weta = 0.;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+      d__1 = simi[j + i__ * simi_dim1];
+      wsig += d__1 * d__1;
+      d__1 = sim[i__ + j * sim_dim1];
+      weta += d__1 * d__1;
+    }
+    vsig[j] = 1. / sqrt(wsig);
+    veta[j] = sqrt(weta);
+    if (vsig[j] < parsig || veta[j] > pareta) {
+      iflag = 0;
+    }
+  }
+
+/* If a new vertex is needed to improve acceptability, then decide which */
+/* vertex to drop from the simplex. */
+
+  if (ibrnch == 1 || iflag == 1) {
+    goto L370;
+  }
+  jdrop = 0;
+  temp = pareta;
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    if (veta[j] > temp) {
+      jdrop = j;
+      temp = veta[j];
+    }
+  }
+  if (jdrop == 0) {
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+      if (vsig[j] < temp) {
+        jdrop = j;
+        temp = vsig[j];
+      }
+    }
+  }
+
+/* Calculate the step to the new vertex and its sign. */
+
+  temp = gamma_ * rho * vsig[jdrop];
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    dx[i__] = temp * simi[jdrop + i__ * simi_dim1];
+  }
+  cvmaxp = 0.;
+  cvmaxm = 0.;
+  i__1 = mp;
+  for (k = 1; k <= i__1; ++k) {
+    sum = 0.;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+      sum += a[i__ + k * a_dim1] * dx[i__];
+    }
+    if (k < mp) {
+      temp = datmat[k + np * datmat_dim1];
+      d__1 = cvmaxp, d__2 = -sum - temp;
+      cvmaxp = MAX2(d__1,d__2);
+      d__1 = cvmaxm, d__2 = sum - temp;
+      cvmaxm = MAX2(d__1,d__2);
+    }
+  }
+  dxsign = 1.;
+  if (parmu * (cvmaxp - cvmaxm) > sum + sum) {
+    dxsign = -1.;
+  }
+
+/* Update the elements of SIM and SIMI, and set the next X. */
+
+  temp = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    /* SGJ, 2010: pseudo-randomize simplex steps (see LCG comments above) */
+    dx[i__] = dxsign * dx[i__] * lcg_urand(&seed, 0.01, 1);
+    /* SGJ: make sure dx step says in [lb,ub] */
+#if ENFORCE_BOUNDS
+    {
+        double xi = sim[i__ + np * sim_dim1];
+    fixdx:
+        if (xi + dx[i__] > ub[i__])
+             dx[i__] = -dx[i__];
+        if (xi + dx[i__] < lb[i__]) {
+             if (xi - dx[i__] <= ub[i__])
+                  dx[i__] = -dx[i__];
+             else { /* try again with halved step */
+                  dx[i__] *= 0.5;
+                  goto fixdx;
+             }
+        }
+    }
+#endif
+    sim[i__ + jdrop * sim_dim1] = dx[i__];
+    temp += simi[jdrop + i__ * simi_dim1] * dx[i__];
+  }
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    simi[jdrop + i__ * simi_dim1] /= temp;
+  }
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    if (j != jdrop) {
+      temp = 0.;
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        temp += simi[j + i__ * simi_dim1] * dx[i__];
+      }
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        simi[j + i__ * simi_dim1] -= temp * simi[jdrop + i__ * 
+            simi_dim1];
+      }
+    }
+    x[j] = sim[j + np * sim_dim1] + dx[j];
+  }
+  goto L40;
+
+/* Calculate DX=x(*)-x(0). Branch if the length of DX is less than 0.5*RHO. */
+
+L370:
+  iz = 1;
+  izdota = iz + *n * *n;
+  ivmc = izdota + *n;
+  isdirn = ivmc + mp;
+  idxnew = isdirn + *n;
+  ivmd = idxnew + *n;
+  rc = trstlp(n, m, &a[a_offset], &con[1], &rho, &dx[1], &ifull, &iact[1], &w[
+      iz], &w[izdota], &w[ivmc], &w[isdirn], &w[idxnew], &w[ivmd]);
+  if (rc != NLOPT_SUCCESS) goto L600;
+#if ENFORCE_BOUNDS
+  /* SGJ: since the bound constraints are linear, we should never get
+     a dx that lies outside the [lb,ub] constraints here, but we'll
+     enforce this anyway just to be paranoid */
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+       double xi = sim[i__ + np * sim_dim1];
+       if (xi + dx[i__] > ub[i__]) dx[i__] = ub[i__] - xi;
+       if (xi + dx[i__] < lb[i__]) dx[i__] = xi - lb[i__];
+  }
+#endif
+  if (ifull == 0) {
+    temp = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      d__1 = dx[i__];
+      temp += d__1 * d__1;
+    }
+    if (temp < rho * .25 * rho) {
+      ibrnch = 1;
+      goto L550;
+    }
+  }
+
+/* Predict the change to F and the new maximum constraint violation if the */
+/* variables are altered from x(0) to x(0)+DX. */
+
+  resnew = 0.;
+  con[mp] = 0.;
+  i__1 = mp;
+  for (k = 1; k <= i__1; ++k) {
+    sum = con[k];
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+      sum -= a[i__ + k * a_dim1] * dx[i__];
+    }
+    if (k < mp) {
+      resnew = MAX2(resnew,sum);
+    }
+  }
+
+/* Increase PARMU if necessary and branch back if this change alters the */
+/* optimal vertex. Otherwise PREREM and PREREC will be set to the predicted */
+/* reductions in the merit function and the maximum constraint violation */
+/* respectively. */
+
+  barmu = 0.;
+  prerec = datmat[*mpp + np * datmat_dim1] - resnew;
+  if (prerec > 0.) {
+    barmu = sum / prerec;
+  }
+  if (parmu < barmu * 1.5) {
+    parmu = barmu * 2.;
+    if (*iprint >= 2) {
+      fprintf(stderr, "cobyla: increase in PARMU to %12.6E\n", parmu);
+    }
+    phi = datmat[mp + np * datmat_dim1] + parmu * datmat[*mpp + np * 
+        datmat_dim1];
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+      temp = datmat[mp + j * datmat_dim1] + parmu * datmat[*mpp + j * 
+          datmat_dim1];
+      if (temp < phi) {
+        goto L140;
+      }
+      if (temp == phi && parmu == 0.f) {
+        if (datmat[*mpp + j * datmat_dim1] < datmat[*mpp + np * 
+            datmat_dim1]) {
+          goto L140;
+        }
+      }
+    }
+  }
+  prerem = parmu * prerec - sum;
+
+/* Calculate the constraint and objective functions at x(*). Then find the */
+/* actual reduction in the merit function. */
+
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    x[i__] = sim[i__ + np * sim_dim1] + dx[i__];
+  }
+  ibrnch = 1;
+  goto L40;
+L440:
+  vmold = datmat[mp + np * datmat_dim1] + parmu * datmat[*mpp + np * 
+      datmat_dim1];
+  vmnew = f + parmu * resmax;
+  trured = vmold - vmnew;
+  if (parmu == 0. && f == datmat[mp + np * datmat_dim1]) {
+    prerem = prerec;
+    trured = datmat[*mpp + np * datmat_dim1] - resmax;
+  }
+
+/* Begin the operations that decide whether x(*) should replace one of the */
+/* vertices of the current simplex, the change being mandatory if TRURED is */
+/* positive. Firstly, JDROP is set to the index of the vertex that is to be */
+/* replaced. */
+
+  ratio = 0.;
+  if (trured <= 0.f) {
+    ratio = 1.f;
+  }
+  jdrop = 0;
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    temp = 0.;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+      temp += simi[j + i__ * simi_dim1] * dx[i__];
+    }
+    temp = fabs(temp);
+    if (temp > ratio) {
+      jdrop = j;
+      ratio = temp;
+    }
+    sigbar[j] = temp * vsig[j];
+  }
+
+/* Calculate the value of ell. */
+
+  edgmax = delta * rho;
+  l = 0;
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    if (sigbar[j] >= parsig || sigbar[j] >= vsig[j]) {
+      temp = veta[j];
+      if (trured > 0.) {
+        temp = 0.;
+        i__2 = *n;
+        for (i__ = 1; i__ <= i__2; ++i__) {
+          d__1 = dx[i__] - sim[i__ + j * sim_dim1];
+          temp += d__1 * d__1;
+        }
+        temp = sqrt(temp);
+      }
+      if (temp > edgmax) {
+        l = j;
+        edgmax = temp;
+      }
+    }
+  }
+  if (l > 0) {
+    jdrop = l;
+  }
+  if (jdrop == 0) {
+    goto L550;
+  }
+
+/* Revise the simplex by updating the elements of SIM, SIMI and DATMAT. */
+
+  temp = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    sim[i__ + jdrop * sim_dim1] = dx[i__];
+    temp += simi[jdrop + i__ * simi_dim1] * dx[i__];
+  }
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    simi[jdrop + i__ * simi_dim1] /= temp;
+  }
+  i__1 = *n;
+  for (j = 1; j <= i__1; ++j) {
+    if (j != jdrop) {
+      temp = 0.;
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        temp += simi[j + i__ * simi_dim1] * dx[i__];
+      }
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        simi[j + i__ * simi_dim1] -= temp * simi[jdrop + i__ * 
+            simi_dim1];
+      }
+    }
+  }
+  i__1 = *mpp;
+  for (k = 1; k <= i__1; ++k) {
+    datmat[k + jdrop * datmat_dim1] = con[k];
+  }
+
+/* Branch back for further iterations with the current RHO. */
+
+  if (trured > 0. && trured >= prerem * .1) {
+    /* SGJ, 2010: following a suggestion in the SAS manual (which
+       mentions a similar modification to COBYLA, although they didn't
+       publish their source code), increase rho if predicted reduction
+       is sufficiently close to the actual reduction.  Otherwise,
+       COBLYA seems to easily get stuck making very small steps. 
+       Also require iflag != 0 (i.e., acceptable simplex), again
+       following SAS suggestion (otherwise I get convergence failure
+       in some cases.) */
+    if (trured >= prerem * 0.9 && trured <= prerem * 1.1 && iflag) {
+        rho *= 2.0;
+    }
+    goto L140;
+  }
+L550:
+  if (iflag == 0) {
+    ibrnch = 0;
+    goto L140;
+  }
+
+  /* SGJ, 2008: convergence tests for function vals; note that current
+     best val is stored in datmat[mp + np * datmat_dim1], or in f if
+     ifull == 1, and previous best is in *minf.  This seems like a
+     sensible place to put the convergence test, as it is the same
+     place that Powell checks the x tolerance (rho > rhoend). */
+  {
+       double fbest = ifull == 1 ? f : datmat[mp + np * datmat_dim1];
+       if (fbest < *minf && nlopt_stop_ftol(stop, fbest, *minf)) {
+           rc = NLOPT_FTOL_REACHED;
+           goto L600;
+       }
+       *minf = fbest;
+  }
+
+/* Otherwise reduce RHO if it is not at its least value and reset PARMU. */
+
+  if (rho > rhoend) {
+    rho *= .5;
+    if (rho <= rhoend * 1.5) {
+      rho = rhoend;
+    }
+    if (parmu > 0.) {
+      denom = 0.;
+      i__1 = mp;
+      for (k = 1; k <= i__1; ++k) {
+        cmin = datmat[k + np * datmat_dim1];
+        cmax = cmin;
+        i__2 = *n;
+        for (i__ = 1; i__ <= i__2; ++i__) {
+          d__1 = cmin, d__2 = datmat[k + i__ * datmat_dim1];
+          cmin = MIN2(d__1,d__2);
+          d__1 = cmax, d__2 = datmat[k + i__ * datmat_dim1];
+          cmax = MAX2(d__1,d__2);
+        }
+        if (k <= *m && cmin < cmax * .5) {
+          temp = MAX2(cmax,0.) - cmin;
+          if (denom <= 0.) {
+            denom = temp;
+          } else {
+            denom = MIN2(denom,temp);
+          }
+        }
+      }
+      if (denom == 0.) {
+        parmu = 0.;
+      } else if (cmax - cmin < parmu * denom) {
+        parmu = (cmax - cmin) / denom;
+      }
+    }
+    if (*iprint >= 2) {
+      fprintf(stderr, "cobyla: reduction in RHO to %12.6E and PARMU =%13.6E\n",
+        rho, parmu);
+    }
+    if (*iprint == 2) {
+      fprintf(stderr, "cobyla: NFVALS = %4d, F =%13.6E, MAXCV =%13.6E\n",
+        stop->nevals, datmat[mp + np * datmat_dim1], datmat[*mpp + np * datmat_dim1]);
+
+      fprintf(stderr, "cobyla: X =");
+      i__1 = iptem;
+      for (i__ = 1; i__ <= i__1; ++i__) {
+        if (i__>1) fprintf(stderr, "  ");
+        fprintf(stderr, "%13.6E", sim[i__ + np * sim_dim1]);
+      }
+      if (iptem < *n) {
+        i__1 = *n;
+        for (i__ = iptemp; i__ <= i__1; ++i__) {
+          if (!((i__-1) % 4)) fprintf(stderr, "\ncobyla:  ");
+          fprintf(stderr, "%15.6E", x[i__]);
+        }
+      }
+      fprintf(stderr, "\n");
+    }
+    goto L140;
+  }
+  else /* rho <= rhoend */
+       rc = rhoend > 0 ? NLOPT_XTOL_REACHED : NLOPT_ROUNDOFF_LIMITED;
+
+/* Return the best calculated values of the variables. */
+
+  if (*iprint >= 1) {
+    fprintf(stderr, "cobyla: normal return.\n");
+  }
+  if (ifull == 1) {
+    goto L620;
+  }
+L600:
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    x[i__] = sim[i__ + np * sim_dim1];
+  }
+  f = datmat[mp + np * datmat_dim1];
+  resmax = datmat[*mpp + np * datmat_dim1];
+L620:
+  *minf = f;
+  if (*iprint >= 1) {
+    fprintf(stderr, "cobyla: NFVALS = %4d, F =%13.6E, MAXCV =%13.6E\n",
+           stop->nevals, f, resmax);
+    i__1 = iptem;
+    fprintf(stderr, "cobyla: X =");
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      if (i__>1) fprintf(stderr, "  ");
+      fprintf(stderr, "%13.6E", x[i__]);
+    }
+    if (iptem < *n) {
+      i__1 = *n;
+      for (i__ = iptemp; i__ <= i__1; ++i__) {
+        if (!((i__-1) % 4)) fprintf(stderr, "\ncobyla:  ");
+        fprintf(stderr, "%15.6E", x[i__]);
+      }
+    }
+    fprintf(stderr, "\n");
+  }
+  return rc;
+} /* cobylb */
+
+/* ------------------------------------------------------------------------- */
+static nlopt_result trstlp(int *n, int *m, double *a, 
+    double *b, double *rho, double *dx, int *ifull, 
+    int *iact, double *z__, double *zdota, double *vmultc,
+     double *sdirn, double *dxnew, double *vmultd)
+{
+  /* System generated locals */
+  int a_dim1, a_offset, z_dim1, z_offset, i__1, i__2;
+  double d__1, d__2;
+
+  /* Local variables */
+  double alpha, tempa;
+  double beta;
+  double optnew, stpful, sum, tot, acca, accb;
+  double ratio, vsave, zdotv, zdotw, dd;
+  double sd;
+  double sp, ss, resold = 0.0, zdvabs, zdwabs, sumabs, resmax, optold;
+  double spabs;
+  double temp, step;
+  int icount;
+  int iout, i__, j, k;
+  int isave;
+  int kk;
+  int kl, kp, kw;
+  int nact, icon = 0, mcon;
+  int nactx = 0;
+
+
+/* This subroutine calculates an N-component vector DX by applying the */
+/* following two stages. In the first stage, DX is set to the shortest */
+/* vector that minimizes the greatest violation of the constraints */
+/*   A(1,K)*DX(1)+A(2,K)*DX(2)+...+A(N,K)*DX(N) .GE. B(K), K=2,3,...,M, */
+/* subject to the Euclidean length of DX being at most RHO. If its length is */
+/* strictly less than RHO, then we use the resultant freedom in DX to */
+/* minimize the objective function */
+/*      -A(1,M+1)*DX(1)-A(2,M+1)*DX(2)-...-A(N,M+1)*DX(N) */
+/* subject to no increase in any greatest constraint violation. This */
+/* notation allows the gradient of the objective function to be regarded as */
+/* the gradient of a constraint. Therefore the two stages are distinguished */
+/* by MCON .EQ. M and MCON .GT. M respectively. It is possible that a */
+/* degeneracy may prevent DX from attaining the target length RHO. Then the */
+/* value IFULL=0 would be set, but usually IFULL=1 on return. */
+
+/* In general NACT is the number of constraints in the active set and */
+/* IACT(1),...,IACT(NACT) are their indices, while the remainder of IACT */
+/* contains a permutation of the remaining constraint indices. Further, Z is */
+/* an orthogonal matrix whose first NACT columns can be regarded as the */
+/* result of Gram-Schmidt applied to the active constraint gradients. For */
+/* J=1,2,...,NACT, the number ZDOTA(J) is the scalar product of the J-th */
+/* column of Z with the gradient of the J-th active constraint. DX is the */
+/* current vector of variables and here the residuals of the active */
+/* constraints should be zero. Further, the active constraints have */
+/* nonnegative Lagrange multipliers that are held at the beginning of */
+/* VMULTC. The remainder of this vector holds the residuals of the inactive */
+/* constraints at DX, the ordering of the components of VMULTC being in */
+/* agreement with the permutation of the indices of the constraints that is */
+/* in IACT. All these residuals are nonnegative, which is achieved by the */
+/* shift RESMAX that makes the least residual zero. */
+
+/* Initialize Z and some other variables. The value of RESMAX will be */
+/* appropriate to DX=0, while ICON will be the index of a most violated */
+/* constraint if RESMAX is positive. Usually during the first stage the */
+/* vector SDIRN gives a search direction that reduces all the active */
+/* constraint violations by one simultaneously. */
+
+  /* Parameter adjustments */
+  z_dim1 = *n;
+  z_offset = 1 + z_dim1 * 1;
+  z__ -= z_offset;
+  a_dim1 = *n;
+  a_offset = 1 + a_dim1 * 1;
+  a -= a_offset;
+  --b;
+  --dx;
+  --iact;
+  --zdota;
+  --vmultc;
+  --sdirn;
+  --dxnew;
+  --vmultd;
+
+  /* Function Body */
+  *ifull = 1;
+  mcon = *m;
+  nact = 0;
+  resmax = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+      z__[i__ + j * z_dim1] = 0.;
+    }
+    z__[i__ + i__ * z_dim1] = 1.;
+    dx[i__] = 0.;
+  }
+  if (*m >= 1) {
+    i__1 = *m;
+    for (k = 1; k <= i__1; ++k) {
+      if (b[k] > resmax) {
+        resmax = b[k];
+        icon = k;
+      }
+    }
+    i__1 = *m;
+    for (k = 1; k <= i__1; ++k) {
+      iact[k] = k;
+      vmultc[k] = resmax - b[k];
+    }
+  }
+  if (resmax == 0.) {
+    goto L480;
+  }
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    sdirn[i__] = 0.;
+  }
+
+/* End the current stage of the calculation if 3 consecutive iterations */
+/* have either failed to reduce the best calculated value of the objective */
+/* function or to increase the number of active constraints since the best */
+/* value was calculated. This strategy prevents cycling, but there is a */
+/* remote possibility that it will cause premature termination. */
+
+L60:
+  optold = 0.;
+  icount = 0;
+L70:
+  if (mcon == *m) {
+    optnew = resmax;
+  } else {
+    optnew = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      optnew -= dx[i__] * a[i__ + mcon * a_dim1];
+    }
+  }
+  if (icount == 0 || optnew < optold) {
+    optold = optnew;
+    nactx = nact;
+    icount = 3;
+  } else if (nact > nactx) {
+    nactx = nact;
+    icount = 3;
+  } else {
+    --icount;
+    if (icount == 0) {
+      goto L490;
+    }
+  }
+
+/* If ICON exceeds NACT, then we add the constraint with index IACT(ICON) to */
+/* the active set. Apply Givens rotations so that the last N-NACT-1 columns */
+/* of Z are orthogonal to the gradient of the new constraint, a scalar */
+/* product being set to zero if its nonzero value could be due to computer */
+/* rounding errors. The array DXNEW is used for working space. */
+
+  if (icon <= nact) {
+    goto L260;
+  }
+  kk = iact[icon];
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    dxnew[i__] = a[i__ + kk * a_dim1];
+  }
+  tot = 0.;
+  k = *n;
+L100:
+  if (k > nact) {
+    sp = 0.;
+    spabs = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = z__[i__ + k * z_dim1] * dxnew[i__];
+      sp += temp;
+      spabs += fabs(temp);
+    }
+    acca = spabs + fabs(sp) * .1;
+    accb = spabs + fabs(sp) * .2;
+    if (spabs >= acca || acca >= accb) {
+      sp = 0.;
+    }
+    if (tot == 0.) {
+      tot = sp;
+    } else {
+      kp = k + 1;
+      temp = sqrt(sp * sp + tot * tot);
+      alpha = sp / temp;
+      beta = tot / temp;
+      tot = temp;
+      i__1 = *n;
+      for (i__ = 1; i__ <= i__1; ++i__) {
+        temp = alpha * z__[i__ + k * z_dim1] + beta * z__[i__ + kp * 
+            z_dim1];
+        z__[i__ + kp * z_dim1] = alpha * z__[i__ + kp * z_dim1] - 
+            beta * z__[i__ + k * z_dim1];
+        z__[i__ + k * z_dim1] = temp;
+      }
+    }
+    --k;
+    goto L100;
+  }
+
+/* Add the new constraint if this can be done without a deletion from the */
+/* active set. */
+
+  if (tot != 0.) {
+    ++nact;
+    zdota[nact] = tot;
+    vmultc[icon] = vmultc[nact];
+    vmultc[nact] = 0.;
+    goto L210;
+  }
+
+/* The next instruction is reached if a deletion has to be made from the */
+/* active set in order to make room for the new active constraint, because */
+/* the new constraint gradient is a linear combination of the gradients of */
+/* the old active constraints. Set the elements of VMULTD to the multipliers */
+/* of the linear combination. Further, set IOUT to the index of the */
+/* constraint to be deleted, but branch if no suitable index can be found. */
+
+  ratio = -1.;
+  k = nact;
+L130:
+  zdotv = 0.;
+  zdvabs = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    temp = z__[i__ + k * z_dim1] * dxnew[i__];
+    zdotv += temp;
+    zdvabs += fabs(temp);
+  }
+  acca = zdvabs + fabs(zdotv) * .1;
+  accb = zdvabs + fabs(zdotv) * .2;
+  if (zdvabs < acca && acca < accb) {
+    temp = zdotv / zdota[k];
+    if (temp > 0. && iact[k] <= *m) {
+      tempa = vmultc[k] / temp;
+      if (ratio < 0. || tempa < ratio) {
+        ratio = tempa;
+        iout = k;
+      }
+    }
+    if (k >= 2) {
+      kw = iact[k];
+      i__1 = *n;
+      for (i__ = 1; i__ <= i__1; ++i__) {
+        dxnew[i__] -= temp * a[i__ + kw * a_dim1];
+      }
+    }
+    vmultd[k] = temp;
+  } else {
+    vmultd[k] = 0.;
+  }
+  --k;
+  if (k > 0) {
+    goto L130;
+  }
+  if (ratio < 0.) {
+    goto L490;
+  }
+
+/* Revise the Lagrange multipliers and reorder the active constraints so */
+/* that the one to be replaced is at the end of the list. Also calculate the */
+/* new value of ZDOTA(NACT) and branch if it is not acceptable. */
+
+  i__1 = nact;
+  for (k = 1; k <= i__1; ++k) {
+    d__1 = 0., d__2 = vmultc[k] - ratio * vmultd[k];
+    vmultc[k] = MAX2(d__1,d__2);
+  }
+  if (icon < nact) {
+    isave = iact[icon];
+    vsave = vmultc[icon];
+    k = icon;
+L170:
+    kp = k + 1;
+    kw = iact[kp];
+    sp = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      sp += z__[i__ + k * z_dim1] * a[i__ + kw * a_dim1];
+    }
+    d__1 = zdota[kp];
+    temp = sqrt(sp * sp + d__1 * d__1);
+    alpha = zdota[kp] / temp;
+    beta = sp / temp;
+    zdota[kp] = alpha * zdota[k];
+    zdota[k] = temp;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = alpha * z__[i__ + kp * z_dim1] + beta * z__[i__ + k * 
+          z_dim1];
+      z__[i__ + kp * z_dim1] = alpha * z__[i__ + k * z_dim1] - beta * 
+          z__[i__ + kp * z_dim1];
+      z__[i__ + k * z_dim1] = temp;
+    }
+    iact[k] = kw;
+    vmultc[k] = vmultc[kp];
+    k = kp;
+    if (k < nact) {
+      goto L170;
+    }
+    iact[k] = isave;
+    vmultc[k] = vsave;
+  }
+  temp = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    temp += z__[i__ + nact * z_dim1] * a[i__ + kk * a_dim1];
+  }
+  if (temp == 0.) {
+    goto L490;
+  }
+  zdota[nact] = temp;
+  vmultc[icon] = 0.;
+  vmultc[nact] = ratio;
+
+/* Update IACT and ensure that the objective function continues to be */
+/* treated as the last active constraint when MCON>M. */
+
+L210:
+  iact[icon] = iact[nact];
+  iact[nact] = kk;
+  if (mcon > *m && kk != mcon) {
+    k = nact - 1;
+    sp = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      sp += z__[i__ + k * z_dim1] * a[i__ + kk * a_dim1];
+    }
+    d__1 = zdota[nact];
+    temp = sqrt(sp * sp + d__1 * d__1);
+    alpha = zdota[nact] / temp;
+    beta = sp / temp;
+    zdota[nact] = alpha * zdota[k];
+    zdota[k] = temp;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = alpha * z__[i__ + nact * z_dim1] + beta * z__[i__ + k * 
+          z_dim1];
+      z__[i__ + nact * z_dim1] = alpha * z__[i__ + k * z_dim1] - beta * 
+          z__[i__ + nact * z_dim1];
+      z__[i__ + k * z_dim1] = temp;
+    }
+    iact[nact] = iact[k];
+    iact[k] = kk;
+    temp = vmultc[k];
+    vmultc[k] = vmultc[nact];
+    vmultc[nact] = temp;
+  }
+
+/* If stage one is in progress, then set SDIRN to the direction of the next */
+/* change to the current vector of variables. */
+
+  if (mcon > *m) {
+    goto L320;
+  }
+  kk = iact[nact];
+  temp = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    temp += sdirn[i__] * a[i__ + kk * a_dim1];
+  }
+  temp += -1.;
+  temp /= zdota[nact];
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    sdirn[i__] -= temp * z__[i__ + nact * z_dim1];
+  }
+  goto L340;
+
+/* Delete the constraint that has the index IACT(ICON) from the active set. */
+
+L260:
+  if (icon < nact) {
+    isave = iact[icon];
+    vsave = vmultc[icon];
+    k = icon;
+L270:
+    kp = k + 1;
+    kk = iact[kp];
+    sp = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      sp += z__[i__ + k * z_dim1] * a[i__ + kk * a_dim1];
+    }
+    d__1 = zdota[kp];
+    temp = sqrt(sp * sp + d__1 * d__1);
+    alpha = zdota[kp] / temp;
+    beta = sp / temp;
+    zdota[kp] = alpha * zdota[k];
+    zdota[k] = temp;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      temp = alpha * z__[i__ + kp * z_dim1] + beta * z__[i__ + k * 
+          z_dim1];
+      z__[i__ + kp * z_dim1] = alpha * z__[i__ + k * z_dim1] - beta * 
+          z__[i__ + kp * z_dim1];
+      z__[i__ + k * z_dim1] = temp;
+    }
+    iact[k] = kk;
+    vmultc[k] = vmultc[kp];
+    k = kp;
+    if (k < nact) {
+      goto L270;
+    }
+    iact[k] = isave;
+    vmultc[k] = vsave;
+  }
+  --nact;
+
+/* If stage one is in progress, then set SDIRN to the direction of the next */
+/* change to the current vector of variables. */
+
+  if (mcon > *m) {
+    goto L320;
+  }
+  temp = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    temp += sdirn[i__] * z__[i__ + (nact + 1) * z_dim1];
+  }
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    sdirn[i__] -= temp * z__[i__ + (nact + 1) * z_dim1];
+  }
+  goto L340;
+
+/* Pick the next search direction of stage two. */
+
+L320:
+  temp = 1. / zdota[nact];
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    sdirn[i__] = temp * z__[i__ + nact * z_dim1];
+  }
+
+/* Calculate the step to the boundary of the trust region or take the step */
+/* that reduces RESMAX to zero. The two statements below that include the */
+/* factor 1.0E-6 prevent some harmless underflows that occurred in a test */
+/* calculation. Further, we skip the step if it could be zero within a */
+/* reasonable tolerance for computer rounding errors. */
+
+L340:
+  dd = *rho * *rho;
+  sd = 0.;
+  ss = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    if ((d__1 = dx[i__], fabs(d__1)) >= *rho * 1e-6f) {
+      d__2 = dx[i__];
+      dd -= d__2 * d__2;
+    }
+    sd += dx[i__] * sdirn[i__];
+    d__1 = sdirn[i__];
+    ss += d__1 * d__1;
+  }
+  if (dd <= 0.) {
+    goto L490;
+  }
+  temp = sqrt(ss * dd);
+  if (fabs(sd) >= temp * 1e-6f) {
+    temp = sqrt(ss * dd + sd * sd);
+  }
+  stpful = dd / (temp + sd);
+  step = stpful;
+  if (mcon == *m) {
+    acca = step + resmax * .1;
+    accb = step + resmax * .2;
+    if (step >= acca || acca >= accb) {
+      goto L480;
+    }
+    step = MIN2(step,resmax);
+  }
+
+  /* SGJ, 2010: check for error here */
+  if (nlopt_isinf(step)) return NLOPT_ROUNDOFF_LIMITED;
+
+/* Set DXNEW to the new variables if STEP is the steplength, and reduce */
+/* RESMAX to the corresponding maximum residual if stage one is being done. */
+/* Because DXNEW will be changed during the calculation of some Lagrange */
+/* multipliers, it will be restored to the following value later. */
+
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    dxnew[i__] = dx[i__] + step * sdirn[i__];
+  }
+  if (mcon == *m) {
+    resold = resmax;
+    resmax = 0.;
+    i__1 = nact;
+    for (k = 1; k <= i__1; ++k) {
+      kk = iact[k];
+      temp = b[kk];
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        temp -= a[i__ + kk * a_dim1] * dxnew[i__];
+      }
+      resmax = MAX2(resmax,temp);
+    }
+  }
+
+/* Set VMULTD to the VMULTC vector that would occur if DX became DXNEW. A */
+/* device is included to force VMULTD(K)=0.0 if deviations from this value */
+/* can be attributed to computer rounding errors. First calculate the new */
+/* Lagrange multipliers. */
+
+  k = nact;
+L390:
+  zdotw = 0.;
+  zdwabs = 0.;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    temp = z__[i__ + k * z_dim1] * dxnew[i__];
+    zdotw += temp;
+    zdwabs += fabs(temp);
+  }
+  acca = zdwabs + fabs(zdotw) * .1;
+  accb = zdwabs + fabs(zdotw) * .2;
+  if (zdwabs >= acca || acca >= accb) {
+    zdotw = 0.;
+  }
+  vmultd[k] = zdotw / zdota[k];
+  if (k >= 2) {
+    kk = iact[k];
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+      dxnew[i__] -= vmultd[k] * a[i__ + kk * a_dim1];
+    }
+    --k;
+    goto L390;
+  }
+  if (mcon > *m) {
+    d__1 = 0., d__2 = vmultd[nact];
+    vmultd[nact] = MAX2(d__1,d__2);
+  }
+
+/* Complete VMULTC by finding the new constraint residuals. */
+
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    dxnew[i__] = dx[i__] + step * sdirn[i__];
+  }
+  if (mcon > nact) {
+    kl = nact + 1;
+    i__1 = mcon;
+    for (k = kl; k <= i__1; ++k) {
+      kk = iact[k];
+      sum = resmax - b[kk];
+      sumabs = resmax + (d__1 = b[kk], fabs(d__1));
+      i__2 = *n;
+      for (i__ = 1; i__ <= i__2; ++i__) {
+        temp = a[i__ + kk * a_dim1] * dxnew[i__];
+        sum += temp;
+        sumabs += fabs(temp);
+      }
+      acca = sumabs + fabs(sum) * .1f;
+      accb = sumabs + fabs(sum) * .2f;
+      if (sumabs >= acca || acca >= accb) {
+        sum = 0.f;
+      }
+      vmultd[k] = sum;
+    }
+  }
+
+/* Calculate the fraction of the step from DX to DXNEW that will be taken. */
+
+  ratio = 1.;
+  icon = 0;
+  i__1 = mcon;
+  for (k = 1; k <= i__1; ++k) {
+    if (vmultd[k] < 0.) {
+      temp = vmultc[k] / (vmultc[k] - vmultd[k]);
+      if (temp < ratio) {
+        ratio = temp;
+        icon = k;
+      }
+    }
+  }
+
+/* Update DX, VMULTC and RESMAX. */
+
+  temp = 1. - ratio;
+  i__1 = *n;
+  for (i__ = 1; i__ <= i__1; ++i__) {
+    dx[i__] = temp * dx[i__] + ratio * dxnew[i__];
+  }
+  i__1 = mcon;
+  for (k = 1; k <= i__1; ++k) {
+    d__1 = 0., d__2 = temp * vmultc[k] + ratio * vmultd[k];
+    vmultc[k] = MAX2(d__1,d__2);
+  }
+  if (mcon == *m) {
+    resmax = resold + ratio * (resmax - resold);
+  }
+
+/* If the full step is not acceptable then begin another iteration. */
+/* Otherwise switch to stage two or end the calculation. */
+
+  if (icon > 0) {
+    goto L70;
+  }
+  if (step == stpful) {
+    goto L500;
+  }
+L480:
+  mcon = *m + 1;
+  icon = mcon;
+  iact[mcon] = mcon;
+  vmultc[mcon] = 0.;
+  goto L60;
+
+/* We employ any freedom that may be available to reduce the objective */
+/* function before returning a DX whose length is less than RHO. */
+
+L490:
+  if (mcon == *m) {
+    goto L480;
+  }
+  *ifull = 0;
+L500:
+  return NLOPT_SUCCESS;
+} /* trstlp */
diff --git a/cobyla/cobyla.h b/cobyla/cobyla.h
new file mode 100644 (file)
index 0000000..fd71ee1
--- /dev/null
@@ -0,0 +1,62 @@
+/* cobyla : contrained optimization by linear approximation */
+
+/*
+ * Copyright (c) 1992, Michael J. D. Powell (M.J.D.Powell@damtp.cam.ac.uk)
+ * Copyright (c) 2004, Jean-Sebastien Roy (js@jeannot.org)
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This software is a C version of COBYLA2, a contrained optimization by linear
+ * approximation package developed by Michael J. D. Powell in Fortran.
+ * 
+ * The original source code can be found at :
+ * http://plato.la.asu.edu/topics/problems/nlores.html
+ */
+
+/* $Jeannot: cobyla.h,v 1.10 2004/04/18 09:51:37 js Exp $ */
+
+#ifndef _COBYLA_
+#define _COBYLA_
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/* NLopt-style interface function */
+nlopt_result cobyla_minimize(unsigned n, nlopt_func f, void *f_data,
+                             unsigned m, nlopt_constraint *fc,
+                             unsigned p, nlopt_constraint *h,
+                             const double *lb, const double *ub, /* bounds */
+                             double *x, /* in: initial guess, out: minimizer */
+                             double *minf,
+                             nlopt_stopping *stop,
+                             const double *dx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _COBYLA_ */
diff --git a/compile b/compile
new file mode 100755 (executable)
index 0000000..531136b
--- /dev/null
+++ b/compile
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" ""       $nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+       # lazily determine how to convert abs files
+       case `uname -s` in
+         MINGW*)
+           file_conv=mingw
+           ;;
+         CYGWIN*)
+           file_conv=cygwin
+           ;;
+         *)
+           file_conv=wine
+           ;;
+       esac
+      fi
+      case $file_conv/,$2, in
+       *,$file_conv,*)
+         ;;
+       mingw/*)
+         file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+         ;;
+       cygwin/*)
+         file=`cygpath -m "$file" || echo "$file"`
+         ;;
+       wine/*)
+         file=`winepath -w "$file" || echo "$file"`
+         ;;
+      esac
+      ;;
+  esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+  func_file_conv "$1"
+  if test -z "$lib_path"; then
+    lib_path=$file
+  else
+    lib_path="$lib_path;$file"
+  fi
+  linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+  lib=$1
+  found=no
+  save_IFS=$IFS
+  IFS=';'
+  for dir in $lib_path $LIB
+  do
+    IFS=$save_IFS
+    if $shared && test -f "$dir/$lib.dll.lib"; then
+      found=yes
+      lib=$dir/$lib.dll.lib
+      break
+    fi
+    if test -f "$dir/$lib.lib"; then
+      found=yes
+      lib=$dir/$lib.lib
+      break
+    fi
+    if test -f "$dir/lib$lib.a"; then
+      found=yes
+      lib=$dir/lib$lib.a
+      break
+    fi
+  done
+  IFS=$save_IFS
+
+  if test "$found" != yes; then
+    lib=$lib.lib
+  fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+  # Assume a capable shell
+  lib_path=
+  shared=:
+  linker_opts=
+  for arg
+  do
+    if test -n "$eat"; then
+      eat=
+    else
+      case $1 in
+       -o)
+         # configure might choose to run compile as 'compile cc -o foo foo.c'.
+         eat=1
+         case $2 in
+           *.o | *.[oO][bB][jJ])
+             func_file_conv "$2"
+             set x "$@" -Fo"$file"
+             shift
+             ;;
+           *)
+             func_file_conv "$2"
+             set x "$@" -Fe"$file"
+             shift
+             ;;
+         esac
+         ;;
+       -I)
+         eat=1
+         func_file_conv "$2" mingw
+         set x "$@" -I"$file"
+         shift
+         ;;
+       -I*)
+         func_file_conv "${1#-I}" mingw
+         set x "$@" -I"$file"
+         shift
+         ;;
+       -l)
+         eat=1
+         func_cl_dashl "$2"
+         set x "$@" "$lib"
+         shift
+         ;;
+       -l*)
+         func_cl_dashl "${1#-l}"
+         set x "$@" "$lib"
+         shift
+         ;;
+       -L)
+         eat=1
+         func_cl_dashL "$2"
+         ;;
+       -L*)
+         func_cl_dashL "${1#-L}"
+         ;;
+       -static)
+         shared=false
+         ;;
+       -Wl,*)
+         arg=${1#-Wl,}
+         save_ifs="$IFS"; IFS=','
+         for flag in $arg; do
+           IFS="$save_ifs"
+           linker_opts="$linker_opts $flag"
+         done
+         IFS="$save_ifs"
+         ;;
+       -Xlinker)
+         eat=1
+         linker_opts="$linker_opts $2"
+         ;;
+       -*)
+         set x "$@" "$1"
+         shift
+         ;;
+       *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+         func_file_conv "$1"
+         set x "$@" -Tp"$file"
+         shift
+         ;;
+       *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+         func_file_conv "$1" mingw
+         set x "$@" "$file"
+         shift
+         ;;
+       *)
+         set x "$@" "$1"
+         shift
+         ;;
+      esac
+    fi
+    shift
+  done
+  if test -n "$linker_opts"; then
+    linker_opts="-link$linker_opts"
+  fi
+  exec "$@" $linker_opts
+  exit 1
+}
+
+eat=
+
+case $1 in
+  '')
+     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+    func_cl_wrapper "$@"      # Doesn't return...
+    ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+       # configure might choose to run compile as 'compile cc -o foo foo.c'.
+       # So we strip '-o arg' only if arg is an object.
+       eat=1
+       case $2 in
+         *.o | *.obj)
+           ofile=$2
+           ;;
+         *)
+           set x "$@" -o "$2"
+           shift
+           ;;
+       esac
+       ;;
+      *.c)
+       cfile=$1
+       set x "$@" "$1"
+       shift
+       ;;
+      *)
+       set x "$@" "$1"
+       shift
+       ;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no '-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # '.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config.guess b/config.guess
new file mode 100755 (executable)
index 0000000..b79252d
--- /dev/null
@@ -0,0 +1,1558 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-06-10'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches@gnu.org.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2013 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+       # If the system lacks a compiler, then just pick glibc.
+       # We could probably try harder.
+       LIBC=gnu
+
+       eval $set_cc_for_build
+       cat <<-EOF > $dummy.c
+       #include <features.h>
+       #if defined(__UCLIBC__)
+       LIBC=uclibc
+       #elif defined(__dietlibc__)
+       LIBC=dietlibc
+       #else
+       LIBC=gnu
+       #endif
+       EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+       ;;
+esac
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep -q __ELF__
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:Bitrig:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+       exitcode=$?
+       trap '' 0
+       exit $exitcode ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+       echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm*:riscos:*:*|arm*:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+       echo i386-pc-auroraux${UNAME_RELEASE}
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+       echo m68k-milan-mint${UNAME_RELEASE}
+       exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+       echo m68k-hades-mint${UNAME_RELEASE}
+       exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+       echo m68k-unknown-mint${UNAME_RELEASE}
+       exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+       # DG/UX returns AViiON for all architectures
+       UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[4567])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                   sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                   case "${sc_cpu_version}" in
+                     523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                     528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                     532)                      # CPU_PA_RISC2_0
+                       case "${sc_kernel_bits}" in
+                         32) HP_ARCH="hppa2.0n" ;;
+                         64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                       esac ;;
+                   esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^            //' << EOF >$dummy.c
+
+               #define _HPUX_SOURCE
+               #include <stdlib.h>
+               #include <unistd.h>
+
+               int main ()
+               {
+               #if defined(_SC_KERNEL_BITS)
+                   long bits = sysconf(_SC_KERNEL_BITS);
+               #endif
+                   long cpu  = sysconf (_SC_CPU_VERSION);
+
+                   switch (cpu)
+                       {
+                       case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+                       case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+                       case CPU_PA_RISC2_0:
+               #if defined(_SC_KERNEL_BITS)
+                           switch (bits)
+                               {
+                               case 64: puts ("hppa2.0w"); break;
+                               case 32: puts ("hppa2.0n"); break;
+                               default: puts ("hppa2.0"); break;
+                               } break;
+               #else  /* !defined(_SC_KERNEL_BITS) */
+                           puts ("hppa2.0"); break;
+               #endif
+                       default: puts ("hppa1.0"); break;
+                       }
+                   exit (0);
+               }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep -q __LP64__
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+       exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+       exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+       exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+       exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+       FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+       echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    5000:UNIX_System_V:4.*:*)
+       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+       FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+       echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       UNAME_PROCESSOR=`/usr/bin/uname -p`
+       case ${UNAME_PROCESSOR} in
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW64*:*)
+       echo ${UNAME_MACHINE}-pc-mingw64
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:MSYS*:*)
+       echo ${UNAME_MACHINE}-pc-msys
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           authenticamd | genuineintel | EM64T)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    8664:Windows_NT:*)
+       echo x86_64-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    aarch64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    aarch64_be:Linux:*:*)
+       UNAME_MACHINE=aarch64_be
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+       esac
+       objdump --private-headers /bin/sh | grep -q ld.so.1
+       if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    arc:Linux:*:* | arceb:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       else
+           if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+               | grep -q __ARM_PCS_VFP
+           then
+               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+           else
+               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+           fi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    cris:Linux:*:*)
+       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       exit ;;
+    crisv32:Linux:*:*)
+       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       exit ;;
+    frv:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    hexagon:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    i*86:Linux:*:*)
+       echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef ${UNAME_MACHINE}
+       #undef ${UNAME_MACHINE}el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=${UNAME_MACHINE}el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=${UNAME_MACHINE}
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+       ;;
+    or1k:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    or32:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-${LIBC}
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-${LIBC}
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+         PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+         *)    echo hppa-unknown-linux-${LIBC} ;;
+       esac
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-${LIBC}
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-${LIBC}
+       exit ;;
+    ppc64le:Linux:*:*)
+       echo powerpc64le-unknown-linux-${LIBC}
+       exit ;;
+    ppcle:Linux:*:*)
+       echo powerpcle-unknown-linux-${LIBC}
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    tile*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+       exit ;;
+    x86_64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+       # Unixware is an offshoot of SVR4, but it has its own version
+       # number series starting with 2...
+       # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+       # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+       # uname -m prints for DJGPP always 'pc', but it prints nothing about
+       # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+       exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*)  # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                       # says <Richard.M.Bartel@ccMail.Census.GOV>
+       echo i586-unisys-sysv4
+       exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+       exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
+    x86_64:Haiku:*:*)
+       echo x86_64-unknown-haiku
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       eval $set_cc_for_build
+       if test "$UNAME_PROCESSOR" = unknown ; then
+           UNAME_PROCESSOR=powerpc
+       fi
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               case $UNAME_PROCESSOR in
+                   i386) UNAME_PROCESSOR=x86_64 ;;
+                   powerpc) UNAME_PROCESSOR=powerpc64 ;;
+               esac
+           fi
+       fi
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NEO-?:NONSTOP_KERNEL:*:*)
+       echo neo-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSE-*:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+       echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+    x86_64:VMkernel:*:*)
+       echo ${UNAME_MACHINE}-unknown-esx
+       exit ;;
+esac
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+       "4"
+#else
+       ""
+#endif
+       ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..a6e4618
--- /dev/null
@@ -0,0 +1,138 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Bugfix version number. */
+#undef BUGFIX_VERSION
+
+/* Define to enable extra debugging code. */
+#undef DEBUG
+
+/* Define to 1 if you have the `BSDgettimeofday' function. */
+#undef HAVE_BSDGETTIMEOFDAY
+
+/* Define if the copysign function/macro is available. */
+#undef HAVE_COPYSIGN
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getpid' function. */
+#undef HAVE_GETPID
+
+/* Define if syscall(SYS_gettid) available. */
+#undef HAVE_GETTID_SYSCALL
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define if the isinf() function/macro is available. */
+#undef HAVE_ISINF
+
+/* Define if the isnan() function/macro is available. */
+#undef HAVE_ISNAN
+
+/* Define to 1 if you have the `m' library (-lm). */
+#undef HAVE_LIBM
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `qsort_r' function. */
+#undef HAVE_QSORT_R
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the `time' function. */
+#undef HAVE_TIME
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* Major version number. */
+#undef MAJOR_VERSION
+
+/* Minor version number. */
+#undef MINOR_VERSION
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* replacement for broken HUGE_VAL macro, if needed */
+#undef REPLACEMENT_HUGE_VAL
+
+/* The size of `unsigned int', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_INT
+
+/* The size of `unsigned long', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_LONG
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to C thread-local keyword, or to nothing if this is not supported in
+   your compiler. */
+#undef THREADLOCAL
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define if compiled including C++-based routines */
+#undef WITH_CXX
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
diff --git a/config.sub b/config.sub
new file mode 100755 (executable)
index 0000000..8b612ab
--- /dev/null
@@ -0,0 +1,1788 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-04-24'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches with a ChangeLog entry to config-patches@gnu.org.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2013 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray | -microblaze*)
+               os=
+               basic_machine=$1
+               ;;
+       -bluegene*)
+               os=-cnk
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*178)
+               os=-lynxos178
+               ;;
+       -lynx*5)
+               os=-lynxos5
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | aarch64 | aarch64_be \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arceb \
+       | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+       | avr | avr32 \
+       | be32 | be64 \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | epiphany \
+       | fido | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | hexagon \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | le32 | le64 \
+       | lm32 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64octeon | mips64octeonel \
+       | mips64orion | mips64orionel \
+       | mips64r5900 | mips64r5900el \
+       | mips64vr | mips64vrel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipsr5900 | mipsr5900el \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | moxie \
+       | mt \
+       | msp430 \
+       | nds32 | nds32le | nds32be \
+       | nios | nios2 | nios2eb | nios2el \
+       | ns16k | ns32k \
+       | open8 \
+       | or1k | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle \
+       | pyramid \
+       | rl78 | rx \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu \
+       | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+       | ubicom32 \
+       | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+       | we32k \
+       | x86 | xc16x | xstormy16 | xtensa \
+       | z8k | z80)
+               basic_machine=$basic_machine-unknown
+               ;;
+       c54x)
+               basic_machine=tic54x-unknown
+               ;;
+       c55x)
+               basic_machine=tic55x-unknown
+               ;;
+       c6x)
+               basic_machine=tic6x-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       strongarm | thumb | xscale)
+               basic_machine=arm-unknown
+               ;;
+       xgate)
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       xscaleeb)
+               basic_machine=armeb-unknown
+               ;;
+
+       xscaleel)
+               basic_machine=armel-unknown
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | aarch64-* | aarch64_be-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* | avr32-* \
+       | be32-* | be64-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | hexagon-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | le32-* | le64-* \
+       | lm32-* \
+       | m32c-* | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+       | microblaze-* | microblazeel-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64octeon-* | mips64octeonel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64r5900-* | mips64r5900el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipsr5900-* | mipsr5900el-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
+       | msp430-* \
+       | nds32-* | nds32le-* | nds32be-* \
+       | nios-* | nios2-* | nios2eb-* | nios2el-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | open8-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+       | pyramid-* \
+       | rl78-* | romp-* | rs6000-* | rx-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+       | tahoe-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tile*-* \
+       | tron-* \
+       | ubicom32-* \
+       | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+       | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* \
+       | xstormy16-* | xtensa*-* \
+       | ymp-* \
+       | z8k-* | z80-*)
+               ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aros)
+               basic_machine=i386-pc
+               os=-aros
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       bluegene*)
+               basic_machine=powerpc-ibm
+               os=-cnk
+               ;;
+       c54x-*)
+               basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c55x-*)
+               basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c6x-*)
+               basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       cegcc)
+               basic_machine=arm-unknown
+               os=-cegcc
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16 | cr16-*)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dicos)
+               basic_machine=i686-pc
+               os=-dicos
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       microblaze*)
+               basic_machine=microblaze-xilinx
+               ;;
+       mingw64)
+               basic_machine=x86_64-pc
+               os=-mingw64
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       msys)
+               basic_machine=i386-pc
+               os=-msys
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       nacl)
+               basic_machine=le32-unknown
+               os=-nacl
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       neo-tandem)
+               basic_machine=neo-tandem
+               ;;
+       nse-tandem)
+               basic_machine=nse-tandem
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc | ppcbe)    basic_machine=powerpc-unknown
+               ;;
+       ppc-* | ppcbe-*)
+               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rdos | rdos64)
+               basic_machine=x86_64-pc
+               os=-rdos
+               ;;
+       rdos32)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       strongarm-* | thumb-*)
+               basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tile*)
+               basic_machine=$basic_machine-unknown
+               os=-linux-gnu
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       xscale-* | xscalee[bl]-*)
+               basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       z80-*-coff)
+               basic_machine=z80-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+       # First match some system type aliases
+       # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -auroraux)
+               os=-auroraux
+               ;;
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+             | -sym* | -kopensolaris* | -plan9* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* | -aros* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -bitrig* | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+             | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+       -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+       -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -dicos*)
+               os=-dicos
+               ;;
+       -nacl*)
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       score-*)
+               os=-elf
+               ;;
+       spu-*)
+               os=-elf
+               ;;
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+       c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       hexagon-*)
+               os=-elf
+               ;;
+       tic54x-*)
+               os=-coff
+               ;;
+       tic55x-*)
+               os=-coff
+               ;;
+       tic6x-*)
+               os=-coff
+               ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+       mep-*)
+               os=-elf
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or1k-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -cnk*|-aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..b67c6b1
--- /dev/null
+++ b/configure
@@ -0,0 +1,20506 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for nlopt 2.4.2.
+#
+# Report bugs to <stevenj@alum.mit.edu>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+
+  test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
+      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: stevenj@alum.mit.edu about your system, including any
+$0: error possibly output before this message. Then install
+$0: a modern shell, or manually run the script under such a
+$0: shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='nlopt'
+PACKAGE_TARNAME='nlopt'
+PACKAGE_VERSION='2.4.2'
+PACKAGE_STRING='nlopt 2.4.2'
+PACKAGE_BUGREPORT='stevenj@alum.mit.edu'
+PACKAGE_URL=''
+
+ac_unique_file="api/nlopt.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+MEXSUFF
+WITH_MATLAB_FALSE
+WITH_MATLAB_TRUE
+MATLAB
+MEX
+MEX_INSTALL_DIR
+WITH_OCTAVE_FALSE
+WITH_OCTAVE_TRUE
+OCTAVE_CONFIG
+OCTAVE
+MKOCTFILE
+M_INSTALL_DIR
+OCT_INSTALL_DIR
+WITH_PYTHON_FALSE
+WITH_PYTHON_TRUE
+WITH_GUILE_FALSE
+WITH_GUILE_TRUE
+PYTHON_INCLUDES
+GUILE_LIBS
+GUILE_CPPFLAGS
+PYTHON_CONFIG
+pkgpyexecdir
+pyexecdir
+pkgpythondir
+pythondir
+PYTHON_PLATFORM
+PYTHON_EXEC_PREFIX
+PYTHON_PREFIX
+PYTHON_VERSION
+PYTHON
+GUILE
+GUILE_CONFIG
+GUILE_INSTALL_DIR
+NLOPT_SUFFIX
+CXXCPP
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+ac_ct_CXX
+CXXFLAGS
+CXX
+WITH_CXX_FALSE
+WITH_CXX_TRUE
+CPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+MANIFEST_TOOL
+RANLIB
+ac_ct_AR
+AR
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+LIBTOOL
+OBJDUMP
+DLLTOOL
+AS
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+LN_S
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+am__nodep
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+SHARED_VERSION_INFO
+MAINT
+MAINTAINER_MODE_FALSE
+MAINTAINER_MODE_TRUE
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_silent_rules
+enable_maintainer_mode
+enable_shared
+enable_dependency_tracking
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+with_sysroot
+enable_libtool_lock
+with_cxx
+with_mthreads
+with_threadlocal
+with_guile
+with_python
+with_octave
+with_matlab
+enable_debug
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+CXX
+CXXFLAGS
+CCC
+CXXCPP
+GUILE_INSTALL_DIR
+PYTHON
+PYTHON_CONFIG
+OCT_INSTALL_DIR
+M_INSTALL_DIR
+MKOCTFILE
+MEX_INSTALL_DIR
+MEX'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures nlopt 2.4.2 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking ...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/nlopt]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of nlopt 2.4.2:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-maintainer-mode
+                          enable make rules and dependencies not useful (and
+                          sometimes confusing) to the casual installer
+  --enable-shared[=PKGS]  build shared libraries [default=no]
+  --enable-dependency-tracking
+                          do not reject slow dependency extractors
+  --disable-dependency-tracking
+                          speeds up one-time build
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-debug          compile with extra runtime checks for debugging
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-sysroot=DIR Search for dependent libraries within DIR
+                        (or the compiler's sysroot if not specified).
+  --with-cxx              include C++-based routines
+  --with-mthreads         use -mthreads compiler flag
+  --without-threadlocal   no thread-local storage keyword
+  --without-guile         don't compile Guile plugin
+  --without-python        don't compile Python plugin
+  --without-octave        don't compile Octave plugin
+  --without-matlab        don't compile Matlab plugin
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  CXXCPP      C++ preprocessor
+  GUILE_INSTALL_DIR
+              where to install Guile plug-ins
+  PYTHON      the Python interpreter
+  PYTHON_CONFIG
+              python-config program
+  OCT_INSTALL_DIR
+              where to install GNU Octave .oct plug-ins
+  M_INSTALL_DIR
+              where to install GNU Octave .m plug-ins
+  MKOCTFILE   name of mkoctfile program to compile Octave plug-ins
+  MEX_INSTALL_DIR
+              where to install Matlab .mex plug-ins
+  MEX         name of mex program to compile Matlab plug-ins
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <stevenj@alum.mit.edu>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+nlopt configure 2.4.2
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ----------------------------------- ##
+## Report this to stevenj@alum.mit.edu ##
+## ----------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+                       if test $ac_lo -le $ac_mid; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by nlopt $as_me 2.4.2, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+SHARED_VERSION_INFO="8:2:8" # CURRENT:REVISION:AGE
+
+am__api_version='1.14'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$*" = "X"; then
+       # -L didn't work.
+       set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$*" != "X $srcdir/configure conftest.file" \
+       && test "$*" != "X conftest.file $srcdir/configure"; then
+
+       # If neither matched, then we have a broken ls.  This can happen
+       # if, for instance, CONFIG_SHELL is bash and it inherits a
+       # broken ls alias from the environment.  This has actually
+       # happened.  Such a system could not be considered "sane".
+       as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment" "$LINENO" 5
+     fi
+     if test "$2" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if ${ac_cv_path_mkdir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+       @$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='nlopt'
+ VERSION='2.4.2'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
+
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+
+
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+  fi
+fi
+ac_config_headers="$ac_config_headers config.h"
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
+    # Check whether --enable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then :
+  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
+else
+  USE_MAINTAINER_MODE=no
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
+$as_echo "$USE_MAINTAINER_MODE" >&6; }
+   if test $USE_MAINTAINER_MODE = yes; then
+  MAINTAINER_MODE_TRUE=
+  MAINTAINER_MODE_FALSE='#'
+else
+  MAINTAINER_MODE_TRUE='#'
+  MAINTAINER_MODE_FALSE=
+fi
+
+  MAINT=$MAINTAINER_MODE_TRUE
+
+
+
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=no
+fi
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+   case $ac_cv_prog_cc_stdc in #(
+  no) :
+    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
+$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
+if ${ac_cv_prog_cc_c99+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+#define debug(...) fprintf (stderr, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  your preprocessor is broken;
+#endif
+#if BIG_OK
+#else
+  your preprocessor is broken;
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static void
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str;
+  int number;
+  float fnumber;
+
+  while (*format)
+    {
+      switch (*format++)
+       {
+       case 's': // string
+         str = va_arg (args_copy, const char *);
+         break;
+       case 'd': // int
+         number = va_arg (args_copy, int);
+         break;
+       case 'f': // float
+         fnumber = va_arg (args_copy, double);
+         break;
+       default:
+         break;
+       }
+    }
+  va_end (args_copy);
+  va_end (args);
+}
+
+int
+main ()
+{
+
+  // Check bool.
+  _Bool success = false;
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  test_varargs ("s, d' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
+         || dynamic_array[ni.number - 1] != 543);
+
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c99" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c99"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c99" != xno; then :
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+else
+  ac_cv_prog_cc_stdc=no
+fi
+
+fi
+ ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
+$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
+  if ${ac_cv_prog_cc_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+
+  case $ac_cv_prog_cc_stdc in #(
+  no) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;; #(
+  '') :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
+$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AS"; then
+  ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AS="${ac_tool_prefix}as"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AS=$ac_cv_prog_AS
+if test -n "$AS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5
+$as_echo "$AS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AS"; then
+  ac_ct_AS=$AS
+  # Extract the first word of "as", so it can be a program name with args.
+set dummy as; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AS"; then
+  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AS="as"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AS=$ac_cv_prog_ac_ct_AS
+if test -n "$ac_ct_AS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5
+$as_echo "$ac_ct_AS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AS" = x; then
+    AS="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AS=$ac_ct_AS
+  fi
+else
+  AS="$ac_cv_prog_AS"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+  ;;
+esac
+
+test -z "$AS" && AS=as
+
+
+
+
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+case `pwd` in
+  *\ * | *\    *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.2'
+macro_revision='1.3337'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO ""
+}
+
+case "$ECHO" in
+  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     if test -z "$FGREP"; then
+  ac_path_FGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in fgrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_FGREP" || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_FGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_FGREP"; then
+    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_FGREP=$FGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       # Tru64's nm complains that /dev/null is an invalid object file
+       case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+       */dev/null* | *'Invalid file or object type'*)
+         lt_cv_path_NM="$tmp_nm -B"
+         break
+         ;;
+       *)
+         case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+         */dev/null*)
+           lt_cv_path_NM="$tmp_nm -p"
+           break
+           ;;
+         *)
+           lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+           continue # so that we can try to find one that supports BSD flags
+           ;;
+         esac
+         ;;
+       esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in dumpbin "link -dump"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in dumpbin "link -dump"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
+
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
+
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
+
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[         ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+                = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+             test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
+if ${lt_cv_to_host_file_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+        ;;
+    esac
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
+
+fi
+
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
+if ${lt_cv_to_tool_file_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+
+fi
+
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test "$GCC" != yes; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+    fi
+    ;;
+  esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
+if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh
+  # decide which to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
+  *)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+    ;;
+  esac
+  ;;
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+fi
+
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+$as_echo_n "checking for archiver @FILE support... " >&6; }
+if ${lt_cv_ar_at_file+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ar_at_file=no
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+      if test "$ac_status" -eq 0; then
+       # Ensure the archiver fails upon bogus file names.
+       rm -f conftest.$ac_objext libconftest.a
+       { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+       if test "$ac_status" -ne 0; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+$as_echo "$lt_cv_ar_at_file" >&6; }
+
+if test "x$lt_cv_ar_at_file" = xno; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[     ]\($symcode$symcode*\)[         ][      ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+       if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+         cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+LT_DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+         cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_globsym_save_LIBS=$LIBS
+         lt_globsym_save_CFLAGS=$CFLAGS
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS=$lt_globsym_save_LIBS
+         CFLAGS=$lt_globsym_save_CFLAGS
+       else
+         echo "cannot find nm_test_func in $nlist" >&5
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+  nm_file_list_spec='@'
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+$as_echo_n "checking for sysroot... " >&6; }
+
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+  withval=$with_sysroot;
+else
+  with_sysroot=no
+fi
+
+
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+   if test "$GCC" = yes; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
+$as_echo "${with_sysroot}" >&6; }
+   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+   ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+$as_echo "${lt_sysroot:-no}" >&6; }
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+       HPUX_IA64_MODE="32"
+       ;;
+      *ELF-64*)
+       HPUX_IA64_MODE="64"
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -melf32bsmip"
+         ;;
+       *N32*)
+         LD="${LD-ld} -melf32bmipn32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -melf64bmip"
+       ;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -32"
+         ;;
+       *N32*)
+         LD="${LD-ld} -n32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -64"
+         ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_i386_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_i386"
+           ;;
+         ppc64-*linux*|powerpc64-*linux*)
+           LD="${LD-ld} -m elf32ppclinux"
+           ;;
+         s390x-*linux*)
+           LD="${LD-ld} -m elf_s390"
+           ;;
+         sparc64-*linux*)
+           LD="${LD-ld} -m elf32_sparc"
+           ;;
+       esac
+       ;;
+      *64-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_x86_64_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_x86_64"
+           ;;
+         ppc*-*linux*|powerpc*-*linux*)
+           LD="${LD-ld} -m elf64ppc"
+           ;;
+         s390*-*linux*|s390*-*tpf*)
+           LD="${LD-ld} -m elf64_s390"
+           ;;
+         sparc*-*linux*)
+           LD="${LD-ld} -m elf64_sparc"
+           ;;
+       esac
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
+      *)
+       if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+         LD="${LD-ld} -64"
+       fi
+       ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MANIFEST_TOOL"; then
+  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+$as_echo "$MANIFEST_TOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+  # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_MANIFEST_TOOL"; then
+  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_MANIFEST_TOOL" = x; then
+    MANIFEST_TOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+  fi
+else
+  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+fi
+
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if ${lt_cv_path_mainfest_tool+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&5
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
+
+
+
+
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+       # By default we will add the -single_module flag. You can override
+       # by either setting the environment variable LT_MULTI_MODULE
+       # non-empty at configure time, or by adding -multi_module to the
+       # link flags.
+       rm -rf libconftest.dylib*
+       echo "int foo(void){return 1;}" > conftest.c
+       echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+       $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+         -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+       # If there is a non-empty error log, and "single_module"
+       # appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+         cat conftest.err >&5
+       # Otherwise, if the output was created with a 0 exit code from
+       # the compiler, it worked.
+       elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+         lt_cv_apple_cc_single_mod=yes
+       else
+         cat conftest.err >&5
+       fi
+       rm -rf libconftest.dylib*
+       rm -f conftest.*
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_ld_exported_symbols_list=yes
+else
+  lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+       LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if ${lt_cv_ld_force_load+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+      echo "$AR cru libconftest.a conftest.o" >&5
+      $AR cru libconftest.a conftest.o 2>&5
+      echo "$RANLIB libconftest.a" >&5
+      $RANLIB libconftest.a 2>&5
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+       cat conftest.err >&5
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+       lt_cv_ld_force_load=yes
+      else
+       cat conftest.err >&5
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+       10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+       10.[012]*)
+         _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+       10.*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+# Set options
+
+
+
+        enable_dlopen=no
+
+
+
+
+  # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+       IFS="$lt_save_ifs"
+       if test "X$lt_pkg" = "X$lt_p"; then
+         pic_mode=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+  *)
+    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+  esac
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+
+
+
+
+
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static=
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='-fPIC'
+       ;;
+      esac
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      lt_prog_compiler_wl='-Xlinker '
+      if test -n "$lt_prog_compiler_pic"; then
+        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+      fi
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      else
+       lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-KPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='--shared'
+       lt_prog_compiler_static='--static'
+       ;;
+      nagfor*)
+       # NAG Fortran compiler
+       lt_prog_compiler_wl='-Wl,-Wl,,'
+       lt_prog_compiler_pic='-PIC'
+       lt_prog_compiler_static='-Bstatic'
+       ;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fpic'
+       lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+       # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-qpic'
+       lt_prog_compiler_static='-qstaticlink'
+       ;;
+      *)
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+         # Sun Fortran 8.3 passes all unrecognized flags to the linker
+         lt_prog_compiler_pic='-KPIC'
+         lt_prog_compiler_static='-Bstatic'
+         lt_prog_compiler_wl=''
+         ;;
+       *Sun\ F* | *Sun*Fortran*)
+         lt_prog_compiler_pic='-KPIC'
+         lt_prog_compiler_static='-Bstatic'
+         lt_prog_compiler_wl='-Qoption ld '
+         ;;
+       *Sun\ C*)
+         # Sun C 5.9
+         lt_prog_compiler_pic='-KPIC'
+         lt_prog_compiler_static='-Bstatic'
+         lt_prog_compiler_wl='-Wl,'
+         ;;
+        *Intel*\ [CF]*Compiler*)
+         lt_prog_compiler_wl='-Wl,'
+         lt_prog_compiler_pic='-fPIC'
+         lt_prog_compiler_static='-static'
+         ;;
+       *Portland\ Group*)
+         lt_prog_compiler_wl='-Wl,'
+         lt_prog_compiler_pic='-fpic'
+         lt_prog_compiler_static='-Bstatic'
+         ;;
+       esac
+       ;;
+      esac
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+       lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic='-Kconform_pic'
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+$as_echo "$lt_cv_prog_compiler_pic" >&6; }
+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
+    case $host_os in
+      aix*)
+       # The AIX port of GNU ld has always aspired to compatibility
+       # with the native linker.  However, as the warning in the GNU ld
+       # block says, versions before 2.19.5* couldn't really create working
+       # shared libraries, regardless of the interface used.
+       case `$LD -v 2>&1` in
+         *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+         *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+         *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+         *)
+           lt_use_gnu_ld_interface=yes
+           ;;
+       esac
+       ;;
+      *)
+       lt_use_gnu_ld_interface=yes
+       ;;
+    esac
+  fi
+
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    haiku*)
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      link_all_deplibs=yes
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+       case $cc_basename in
+         diet\ *) tmp_diet=yes;;       # linux-dietlibc with static linking (!diet-dyn)
+       esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+        && test "$tmp_diet" = no
+      then
+       tmp_addflag=' $pic_flag'
+       tmp_sharedflag='-shared'
+       case $cc_basename,$host_cpu in
+        pgcc*)                         # Portland Group C compiler
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95* | pgfortran*)
+                                       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)        # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       lf95*)                          # Lahey Fortran 8.1
+         whole_archive_flag_spec=
+         tmp_sharedflag='--shared' ;;
+       xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+         tmp_sharedflag='-qmkshrobj'
+         tmp_addflag= ;;
+       nvcc*)  # Cuda Compiler Driver 2.2
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         compiler_needs_object=yes
+         ;;
+       esac
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ C*)                       # Sun C 5.9
+         whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         compiler_needs_object=yes
+         tmp_sharedflag='-G' ;;
+       *Sun\ F*)                       # Sun Fortran 8.3
+         tmp_sharedflag='-G' ;;
+       esac
+       archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+           cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+           echo "local: *; };" >> $output_objdir/$libname.ver~
+           $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+       case $cc_basename in
+       xlf* | bgf* | bgxlf* | mpixlf*)
+         # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+         whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+         archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+         if test "x$supports_anon_versioning" = xyes; then
+           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+             cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+             echo "local: *; };" >> $output_objdir/$libname.ver~
+             $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+         fi
+         ;;
+       esac
+      else
+        ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+       ;;
+       *)
+         # For security reasons, it is highly recommended that you always
+         # use absolute paths for naming shared libraries, and exclude the
+         # DT_RUNPATH tag from executables and libraries.  But doing so
+         # requires that you compile everything twice, which is a pain.
+         if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+           hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+           archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         else
+           ld_shlibs=no
+         fi
+       ;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       # Also, AIX nm treats weak defined symbols like other global
+       # defined symbols, whereas GNU nm marks them as "W".
+       if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+         export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+         ;;
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='${wl}-f,'
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+          strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         :
+         else
+         # We have old collect2
+         hardcode_direct=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L=yes
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_libdir_separator=
+         fi
+         ;;
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+         fi
+       fi
+      fi
+
+      export_dynamic_flag_spec='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath_+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+         /^0/ {
+             s/^0  *\([^ ]*\) *$/\1/
+             p
+         }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_="/usr/lib:/lib"
+  fi
+
+fi
+
+  aix_libpath=$lt_cv_aix_libpath_
+fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag="-z nodefs"
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath_+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+         /^0/ {
+             s/^0  *\([^ ]*\) *$/\1/
+             p
+         }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_="/usr/lib:/lib"
+  fi
+
+fi
+
+  aix_libpath=$lt_cv_aix_libpath_
+fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag=' ${wl}-bernotok'
+         allow_undefined_flag=' ${wl}-berok'
+         if test "$with_gnu_ld" = yes; then
+           # We only use this code for GNU lds that support --whole-archive.
+           whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+         else
+           # Exported symbols can be pulled into shared objects from archives
+           whole_archive_flag_spec='$convenience'
+         fi
+         archive_cmds_need_lc=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      case $cc_basename in
+      cl*)
+       # Native MSVC
+       hardcode_libdir_flag_spec=' '
+       allow_undefined_flag=unsupported
+       always_export_symbols=yes
+       file_list_spec='@'
+       # Tell ltmain to make .lib files, not .a files.
+       libext=lib
+       # Tell ltmain to make .dll files, not .so files.
+       shrext_cmds=".dll"
+       # FIXME: Setting linknames here is a bad hack.
+       archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+       archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+           sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+         else
+           sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+         fi~
+         $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+         linknames='
+       # The linker will not automatically build a static lib if we build a DLL.
+       # _LT_TAGVAR(old_archive_from_new_cmds, )='true'
+       enable_shared_with_static_runtimes=yes
+       exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+       export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+       # Don't use ranlib
+       old_postinstall_cmds='chmod 644 $oldlib'
+       postlink_cmds='lt_outputfile="@OUTPUT@"~
+         lt_tool_outputfile="@TOOL_OUTPUT@"~
+         case $lt_outputfile in
+           *.exe|*.EXE) ;;
+           *)
+             lt_outputfile="$lt_outputfile.exe"
+             lt_tool_outputfile="$lt_tool_outputfile.exe"
+             ;;
+         esac~
+         if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+           $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+           $RM "$lt_outputfile.manifest";
+         fi'
+       ;;
+      *)
+       # Assume MSVC wrapper
+       hardcode_libdir_flag_spec=' '
+       allow_undefined_flag=unsupported
+       # Tell ltmain to make .lib files, not .a files.
+       libext=lib
+       # Tell ltmain to make .dll files, not .so files.
+       shrext_cmds=".dll"
+       # FIXME: Setting linknames here is a bad hack.
+       archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+       # The linker will automatically build a .lib file if we build a DLL.
+       old_archive_from_new_cmds='true'
+       # FIXME: Should let the user specify the lib program.
+       old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+       enable_shared_with_static_runtimes=yes
+       ;;
+      esac
+      ;;
+
+    darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+  else
+    whole_archive_flag_spec=''
+  fi
+  link_all_deplibs=yes
+  allow_undefined_flag="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs=no
+  fi
+
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2.*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+       hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+       hardcode_libdir_separator=:
+       hardcode_direct=yes
+       hardcode_direct_absolute=yes
+       export_dynamic_flag_spec='${wl}-E'
+       # hardcode_minus_L: Not really in the search PATH,
+       # but as the default location of the library.
+       hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*)
+         archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+
+         # Older versions of the 11.00 compiler do not understand -b yet
+         # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+         { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+$as_echo_n "checking if $CC understands -b... " >&6; }
+if ${lt_cv_prog_compiler__b+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler__b=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS -b"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler__b=yes
+       fi
+     else
+       lt_cv_prog_compiler__b=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+$as_echo "$lt_cv_prog_compiler__b" >&6; }
+
+if test x"$lt_cv_prog_compiler__b" = xyes; then
+    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
+
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+       hardcode_libdir_separator=:
+
+       case $host_cpu in
+       hppa*64*|ia64*)
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+         ;;
+       *)
+         hardcode_direct=yes
+         hardcode_direct_absolute=yes
+         export_dynamic_flag_spec='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       # Try to use the -exported_symbol ld option, if it does not
+       # work, assume that -exports_file does not work either and
+       # implicitly export all symbols.
+       # This should be the same for all languages, so no per-tag cache variable.
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if ${lt_cv_irix_exported_symbol+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  save_LDFLAGS="$LDFLAGS"
+          LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo (void) { return 0; }
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_irix_exported_symbol=yes
+else
+  lt_cv_irix_exported_symbol=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+           LDFLAGS="$save_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+       if test "$lt_cv_irix_exported_symbol" = yes; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+       fi
+      else
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+       hardcode_direct=yes
+       hardcode_shlibpath_var=no
+       hardcode_direct_absolute=yes
+       if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+         archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+         export_dynamic_flag_spec='${wl}-E'
+       else
+         case $host_os in
+          openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+            archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+            hardcode_libdir_flag_spec='-R$libdir'
+            ;;
+          *)
+            archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+            hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+            ;;
+         esac
+       fi
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+       $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+       case `$CC -V 2>&1` in
+       *"Compilers 5.0"*)
+         wlarc=''
+         archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+         ;;
+       *)
+         wlarc='${wl}'
+         archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+         ;;
+       esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine and reorder linker options,
+       # but understands `-z linker_flag'.  GCC discards it without `$wl',
+       # but is careful enough not to reorder.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       if test "$GCC" = yes; then
+         whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+       else
+         whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+       fi
+       ;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds='$CC -r -o $output$reload_objs'
+         hardcode_direct=no
+        ;;
+       motorola)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+       export_dynamic_flag_spec='${wl}-Blargedynsym'
+       ;;
+      esac
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  $RM conftest*
+       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+       if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+         soname=conftest
+         lib=conftest
+         libobjs=conftest.$ac_objext
+         deplibs=
+         wl=$lt_prog_compiler_wl
+         pic_flag=$lt_prog_compiler_pic
+         compiler_flags=-v
+         linker_flags=-v
+         verstring=
+         output_objdir=.
+         libname=conftest
+         lt_save_allow_undefined_flag=$allow_undefined_flag
+         allow_undefined_flag=
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+         then
+           lt_cv_archive_cmds_need_lc=no
+         else
+           lt_cv_archive_cmds_need_lc=yes
+         fi
+         allow_undefined_flag=$lt_save_allow_undefined_flag
+       else
+         cat conftest.err 1>&5
+       fi
+       $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+       lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
+
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
+
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
+
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
+
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux # correct to gnu/linux during the next big refactor
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+        LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+
+fi
+
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[      ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+       ;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+   test "$inherit_rpath" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+  if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+    ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if ${ac_cv_lib_dld_shl_load+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if ${ac_cv_lib_svld_dlopen+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if ${ac_cv_lib_dld_dld_link+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self_static+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+  # Report which library types will actually be built
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+
+NLOPT_SUFFIX=""
+
+# Check whether --with-cxx was given.
+if test "${with_cxx+set}" = set; then :
+  withval=$with_cxx; with_cxx=$withval
+else
+  with_cxx=no
+fi
+
+ if test "x$with_cxx" = xyes; then
+  WITH_CXX_TRUE=
+  WITH_CXX_FALSE='#'
+else
+  WITH_CXX_TRUE='#'
+  WITH_CXX_FALSE=
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+        CXXFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+
+
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
+
+      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+  if ${ac_cv_prog_CXXCPP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+else
+  _lt_caught_CXX_error=yes
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+reload_flag_CXX=$reload_flag
+reload_cmds_CXX=$reload_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_CFLAGS=$CFLAGS
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  CFLAGS=$CXXFLAGS
+  compiler=$CC
+  compiler_CXX=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+    else
+      lt_prog_compiler_no_builtin_flag_CXX=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+         $GREP 'no-whole-archive' > /dev/null; then
+          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          whole_archive_flag_spec_CXX=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+    ld_shlibs_CXX=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+      aix[4-9]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+           for ld_flag in $LDFLAGS; do
+             case $ld_flag in
+             *-brtl*)
+               aix_use_runtimelinking=yes
+               break
+               ;;
+             esac
+           done
+           ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        archive_cmds_CXX=''
+        hardcode_direct_CXX=yes
+        hardcode_direct_absolute_CXX=yes
+        hardcode_libdir_separator_CXX=':'
+        link_all_deplibs_CXX=yes
+        file_list_spec_CXX='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[012]|aix4.[012].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+            strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+           # We have reworked collect2
+           :
+         else
+           # We have old collect2
+           hardcode_direct_CXX=unsupported
+           # It fails to find uninstalled libraries when the uninstalled
+           # path is not listed in the libpath.  Setting hardcode_minus_L
+           # to unsupported forces relinking
+           hardcode_minus_L_CXX=yes
+           hardcode_libdir_flag_spec_CXX='-L$libdir'
+           hardcode_libdir_separator_CXX=
+         fi
+          esac
+          shared_flag='-shared'
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag="$shared_flag "'${wl}-G'
+         fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+         # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+         # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+          else
+           if test "$aix_use_runtimelinking" = yes; then
+             shared_flag='${wl}-G'
+           else
+             shared_flag='${wl}-bM:SRE'
+           fi
+          fi
+        fi
+
+        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+       # export.
+        always_export_symbols_CXX=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          allow_undefined_flag_CXX='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath__CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+         /^0/ {
+             s/^0  *\([^ ]*\) *$/\1/
+             p
+         }
+      }'
+  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+  fi
+
+fi
+
+  aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+           hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+           allow_undefined_flag_CXX="-z nodefs"
+           archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+           # Determine the default libpath from the value encoded in an
+           # empty executable.
+           if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath__CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+         /^0/ {
+             s/^0  *\([^ ]*\) *$/\1/
+             p
+         }
+      }'
+  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+  fi
+
+fi
+
+  aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+           hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+           # Warning - without using the other run time loading flags,
+           # -berok will link without error, but may produce a broken library.
+           no_undefined_flag_CXX=' ${wl}-bernotok'
+           allow_undefined_flag_CXX=' ${wl}-berok'
+           if test "$with_gnu_ld" = yes; then
+             # We only use this code for GNU lds that support --whole-archive.
+             whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           else
+             # Exported symbols can be pulled into shared objects from archives
+             whole_archive_flag_spec_CXX='$convenience'
+           fi
+           archive_cmds_need_lc_CXX=yes
+           # This is similar to how AIX traditionally builds its shared
+           # libraries.
+           archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+         allow_undefined_flag_CXX=unsupported
+         # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+         # support --undefined.  This deserves some investigation.  FIXME
+         archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       else
+         ld_shlibs_CXX=no
+       fi
+       ;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+         # FIXME: insert proper C++ library support
+         ld_shlibs_CXX=no
+         ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32* | cegcc*)
+       case $GXX,$cc_basename in
+       ,cl* | no,cl*)
+         # Native MSVC
+         # hardcode_libdir_flag_spec is actually meaningless, as there is
+         # no search path for DLLs.
+         hardcode_libdir_flag_spec_CXX=' '
+         allow_undefined_flag_CXX=unsupported
+         always_export_symbols_CXX=yes
+         file_list_spec_CXX='@'
+         # Tell ltmain to make .lib files, not .a files.
+         libext=lib
+         # Tell ltmain to make .dll files, not .so files.
+         shrext_cmds=".dll"
+         # FIXME: Setting linknames here is a bad hack.
+         archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+         archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+             $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+           else
+             $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+           fi~
+           $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+           linknames='
+         # The linker will not automatically build a static lib if we build a DLL.
+         # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
+         enable_shared_with_static_runtimes_CXX=yes
+         # Don't use ranlib
+         old_postinstall_cmds_CXX='chmod 644 $oldlib'
+         postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
+           lt_tool_outputfile="@TOOL_OUTPUT@"~
+           case $lt_outputfile in
+             *.exe|*.EXE) ;;
+             *)
+               lt_outputfile="$lt_outputfile.exe"
+               lt_tool_outputfile="$lt_tool_outputfile.exe"
+               ;;
+           esac~
+           func_to_tool_file "$lt_outputfile"~
+           if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+             $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+             $RM "$lt_outputfile.manifest";
+           fi'
+         ;;
+       *)
+         # g++
+         # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+         # as there is no search path for DLLs.
+         hardcode_libdir_flag_spec_CXX='-L$libdir'
+         export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+         allow_undefined_flag_CXX=unsupported
+         always_export_symbols_CXX=no
+         enable_shared_with_static_runtimes_CXX=yes
+
+         if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+           archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+           # If the export-symbols file already is a .def file (1st line
+           # is EXPORTS), use it as is; otherwise, prepend...
+           archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+             cp $export_symbols $output_objdir/$soname.def;
+           else
+             echo EXPORTS > $output_objdir/$soname.def;
+             cat $export_symbols >> $output_objdir/$soname.def;
+           fi~
+           $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+         else
+           ld_shlibs_CXX=no
+         fi
+         ;;
+       esac
+       ;;
+      darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc_CXX=no
+  hardcode_direct_CXX=no
+  hardcode_automatic_CXX=yes
+  hardcode_shlibpath_var_CXX=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+  else
+    whole_archive_flag_spec_CXX=''
+  fi
+  link_all_deplibs_CXX=yes
+  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+
+  else
+  ld_shlibs_CXX=no
+  fi
+
+       ;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          ghcx*)
+           # Green Hills C++ Compiler
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+        esac
+        ;;
+
+      freebsd2.*)
+        # C++ shared libraries reported to be fairly broken before
+       # switch to ELF
+        ld_shlibs_CXX=no
+        ;;
+
+      freebsd-elf*)
+        archive_cmds_need_lc_CXX=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        ld_shlibs_CXX=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      haiku*)
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        link_all_deplibs_CXX=yes
+        ;;
+
+      hpux9*)
+        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        export_dynamic_flag_spec_CXX='${wl}-E'
+        hardcode_direct_CXX=yes
+        hardcode_minus_L_CXX=yes # Not in the search PATH,
+                                            # but as the default
+                                            # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            ld_shlibs_CXX=no
+            ;;
+          aCC*)
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              ld_shlibs_CXX=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+         hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+         hardcode_libdir_separator_CXX=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+             export_dynamic_flag_spec_CXX='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct_CXX=no
+            hardcode_shlibpath_var_CXX=no
+            ;;
+          *)
+            hardcode_direct_CXX=yes
+            hardcode_direct_absolute_CXX=yes
+            hardcode_minus_L_CXX=yes # Not in the search PATH,
+                                                # but as the default
+                                                # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          aCC*)
+           case $host_cpu in
+             hppa*64*)
+               archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             ia64*)
+               archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             *)
+               archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+           esac
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test $with_gnu_ld = no; then
+               case $host_cpu in
+                 hppa*64*)
+                   archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 ia64*)
+                   archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 *)
+                   archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+               esac
+             fi
+           else
+             # FIXME: insert proper C++ library support
+             ld_shlibs_CXX=no
+           fi
+           ;;
+        esac
+        ;;
+
+      interix[3-9]*)
+       hardcode_direct_CXX=no
+       hardcode_shlibpath_var_CXX=no
+       hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+       export_dynamic_flag_spec_CXX='${wl}-E'
+       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+       # Instead, shared libraries are loaded at an image base (0x10000000 by
+       # default) and relocated if they conflict, which is a slow very memory
+       # consuming and fragmenting process.  To avoid this, we pick a random,
+       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+       archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       ;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+           # SGI C++
+           archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+           # Archives containing C++ object files must be created using
+           # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test "$with_gnu_ld" = no; then
+               archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+             else
+               archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+             fi
+           fi
+           link_all_deplibs_CXX=yes
+           ;;
+        esac
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        inherit_rpath_CXX=yes
+        ;;
+
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+           archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+           hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+           export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+           # Archives containing C++ object files must be created using
+           # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+           old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+           ;;
+         icpc* | ecpc* )
+           # Intel C++
+           with_gnu_ld=yes
+           # version 8.0 and above of icpc choke on multiply defined symbols
+           # if we add $predep_objects and $postdep_objects, however 7.1 and
+           # earlier do not add the objects themselves.
+           case `$CC -V 2>&1` in
+             *"Version 7."*)
+               archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+             *)  # Version 8.0 or newer
+               tmp_idyn=
+               case $host_cpu in
+                 ia64*) tmp_idyn=' -i_dynamic';;
+               esac
+               archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+           esac
+           archive_cmds_need_lc_CXX=no
+           hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+           export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+           whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+           case `$CC -V` in
+           *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
+             prelink_cmds_CXX='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+             old_archive_cmds_CXX='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+               $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+               $RANLIB $oldlib'
+             archive_cmds_CXX='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             archive_expsym_cmds_CXX='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           *) # Version 6 and above use weak symbols
+             archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           esac
+
+           hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+           export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+           whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+         cxx*)
+           # Compaq C++
+           archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+           runpath_var=LD_RUN_PATH
+           hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+           hardcode_libdir_separator_CXX=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+           ;;
+         xl* | mpixl* | bgxl*)
+           # IBM XL 8.0 on PPC, with GNU ld
+           hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+           export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+           archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           if test "x$supports_anon_versioning" = xyes; then
+             archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+               cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+               echo "local: *; };" >> $output_objdir/$libname.ver~
+               $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+           fi
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             no_undefined_flag_CXX=' -zdefs'
+             archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+             archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+             hardcode_libdir_flag_spec_CXX='-R$libdir'
+             whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+             compiler_needs_object_CXX=yes
+
+             # Not sure whether something based on
+             # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+             # would be better.
+             output_verbose_link_cmd='func_echo_all'
+
+             # Archives containing C++ object files must be created using
+             # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+             # necessary to make sure instantiated templates are included
+             # in the archive.
+             old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+       ld_shlibs_CXX=no
+       ;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+       ;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+         *)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+       esac
+       ;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+         archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+         wlarc=
+         hardcode_libdir_flag_spec_CXX='-R$libdir'
+         hardcode_direct_CXX=yes
+         hardcode_shlibpath_var_CXX=no
+       fi
+       # Workaround some broken pre-1.5 toolchains
+       output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+       ;;
+
+      *nto* | *qnx*)
+        ld_shlibs_CXX=yes
+       ;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+       ld_shlibs_CXX=no
+       ;;
+
+      openbsd*)
+       if test -f /usr/libexec/ld.so; then
+         hardcode_direct_CXX=yes
+         hardcode_shlibpath_var_CXX=no
+         hardcode_direct_absolute_CXX=yes
+         archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+         hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+         if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+           archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+           export_dynamic_flag_spec_CXX='${wl}-E'
+           whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+         fi
+         output_verbose_link_cmd=func_echo_all
+       else
+         ld_shlibs_CXX=no
+       fi
+       ;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+           hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+           hardcode_libdir_separator_CXX=:
+
+           # Archives containing C++ object files must be created using
+           # the KAI C++ compiler.
+           case $host in
+             osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+             *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+           esac
+           ;;
+          RCC*)
+           # Rational C++ 2.4.1
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          cxx*)
+           case $host in
+             osf3*)
+               allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+               archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+               ;;
+             *)
+               allow_undefined_flag_CXX=' -expect_unresolved \*'
+               archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+                 echo "-hidden">> $lib.exp~
+                 $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+                 $RM $lib.exp'
+               hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+               ;;
+           esac
+
+           hardcode_libdir_separator_CXX=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+         *)
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+             case $host in
+               osf3*)
+                 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+               *)
+                 archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+             esac
+
+             hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+             hardcode_libdir_separator_CXX=:
+
+             # Commands to make compiler produce verbose output that lists
+             # what "hidden" libraries, object files and flags are used when
+             # linking a shared library.
+             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+           else
+             # FIXME: insert proper C++ library support
+             ld_shlibs_CXX=no
+           fi
+           ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+           # Sun C++ 4.x
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          lcc*)
+           # Lucid
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+            archive_cmds_need_lc_CXX=yes
+           no_undefined_flag_CXX=' -zdefs'
+           archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+           archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+             $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+           hardcode_libdir_flag_spec_CXX='-R$libdir'
+           hardcode_shlibpath_var_CXX=no
+           case $host_os in
+             solaris2.[0-5] | solaris2.[0-5].*) ;;
+             *)
+               # The compiler driver will combine and reorder linker options,
+               # but understands `-z linker_flag'.
+               # Supported since Solaris 2.6 (maybe 2.5.1?)
+               whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+               ;;
+           esac
+           link_all_deplibs_CXX=yes
+
+           output_verbose_link_cmd='func_echo_all'
+
+           # Archives containing C++ object files must be created using
+           # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+           ;;
+          gcx*)
+           # Green Hills C++ Compiler
+           archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+           # The C++ compiler must be used to create the archive.
+           old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+           ;;
+          *)
+           # GNU C++ compiler with Solaris linker
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+             if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+               archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             else
+               # g++ 2.7 appears to require `-G' NOT `-shared' on this
+               # platform.
+               archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             fi
+
+             hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+             case $host_os in
+               solaris2.[0-5] | solaris2.[0-5].*) ;;
+               *)
+                 whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+                 ;;
+             esac
+           fi
+           ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_CXX='${wl}-z,text'
+      archive_cmds_need_lc_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+         archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+       # Note: We can NOT use -z defs as we might desire, because we do not
+       # link with -lc, and that would cause any symbols used from libc to
+       # always be unresolved, which means just about no library would
+       # ever link correctly.  If we're not using GNU ld we use -z text
+       # though, which does catch some bad symbols but isn't as heavy-handed
+       # as -z defs.
+       no_undefined_flag_CXX='${wl}-z,text'
+       allow_undefined_flag_CXX='${wl}-z,nodefs'
+       archive_cmds_need_lc_CXX=no
+       hardcode_shlibpath_var_CXX=no
+       hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+       hardcode_libdir_separator_CXX=':'
+       link_all_deplibs_CXX=yes
+       export_dynamic_flag_spec_CXX='${wl}-Bexport'
+       runpath_var='LD_RUN_PATH'
+
+       case $cc_basename in
+          CC*)
+           archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
+             '"$old_archive_cmds_CXX"
+           reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
+             '"$reload_cmds_CXX"
+           ;;
+         *)
+           archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           ;;
+       esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+           # NonStop-UX NCC 3.20
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           ld_shlibs_CXX=no
+           ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+    esac
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+    test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+    GCC_CXX="$GXX"
+    LD_CXX="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case ${prev}${p} in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+        prev=$p
+        continue
+       fi
+
+       # Expand the sysroot to ease extracting the directories later.
+       if test -z "$prev"; then
+         case $p in
+         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+         esac
+       fi
+       case $p in
+       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+       esac
+       if test "$pre_test_object_deps_done" = no; then
+        case ${prev} in
+        -L | -R)
+          # Internal compiler library paths should come after those
+          # provided the user.  The postdeps already come after the
+          # user supplied libs so there is no need to process them.
+          if test -z "$compiler_lib_search_path_CXX"; then
+            compiler_lib_search_path_CXX="${prev}${p}"
+          else
+            compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+          fi
+          ;;
+        # The "-l" case would never come before the object being
+        # linked, so don't bother handling this case.
+        esac
+       else
+        if test -z "$postdeps_CXX"; then
+          postdeps_CXX="${prev}${p}"
+        else
+          postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+        fi
+       fi
+       prev=
+       ;;
+
+    *.lto.$objext) ;; # Ignore GCC LTO objects
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+        pre_test_object_deps_done=yes
+        continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        if test -z "$predep_objects_CXX"; then
+          predep_objects_CXX="$p"
+        else
+          predep_objects_CXX="$predep_objects_CXX $p"
+        fi
+       else
+        if test -z "$postdep_objects_CXX"; then
+          postdep_objects_CXX="$p"
+        else
+          postdep_objects_CXX="$postdep_objects_CXX $p"
+        fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC* | sunCC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    lt_prog_compiler_wl_CXX='-Wl,'
+    lt_prog_compiler_static_CXX='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static_CXX='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_CXX='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_CXX='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      lt_prog_compiler_pic_CXX=
+      ;;
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static_CXX=
+      ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic_CXX=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       ;;
+      *)
+       lt_prog_compiler_pic_CXX='-fPIC'
+       ;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_CXX='-fPIC -shared'
+      ;;
+    *)
+      lt_prog_compiler_pic_CXX='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[4-9]*)
+       # All AIX code is PIC.
+       if test "$host_cpu" = ia64; then
+         # AIX 5 now supports IA64 processor
+         lt_prog_compiler_static_CXX='-Bstatic'
+       else
+         lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+       fi
+       ;;
+      chorus*)
+       case $cc_basename in
+       cxch68*)
+         # Green Hills C++ Compiler
+         # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+         ;;
+       esac
+       ;;
+      mingw* | cygwin* | os2* | pw32* | cegcc*)
+       # This hack is so that the source file can tell whether it is being
+       # built for inclusion in a dll (and should export symbols for example).
+       lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+       ;;
+      dgux*)
+       case $cc_basename in
+         ec++*)
+           lt_prog_compiler_pic_CXX='-KPIC'
+           ;;
+         ghcx*)
+           # Green Hills C++ Compiler
+           lt_prog_compiler_pic_CXX='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      freebsd* | dragonfly*)
+       # FreeBSD uses GNU C++
+       ;;
+      hpux9* | hpux10* | hpux11*)
+       case $cc_basename in
+         CC*)
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+           if test "$host_cpu" != ia64; then
+             lt_prog_compiler_pic_CXX='+Z'
+           fi
+           ;;
+         aCC*)
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+           case $host_cpu in
+           hppa*64*|ia64*)
+             # +Z the default
+             ;;
+           *)
+             lt_prog_compiler_pic_CXX='+Z'
+             ;;
+           esac
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      interix*)
+       # This is c89, which is MS Visual C++ (no shared libs)
+       # Anyone wants to do a port?
+       ;;
+      irix5* | irix6* | nonstopux*)
+       case $cc_basename in
+         CC*)
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_static_CXX='-non_shared'
+           # CC pic flag -KPIC is the default.
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+       case $cc_basename in
+         KCC*)
+           # KAI C++ Compiler
+           lt_prog_compiler_wl_CXX='--backend -Wl,'
+           lt_prog_compiler_pic_CXX='-fPIC'
+           ;;
+         ecpc* )
+           # old Intel C++ for x86_64 which still supported -KPIC.
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_pic_CXX='-KPIC'
+           lt_prog_compiler_static_CXX='-static'
+           ;;
+         icpc* )
+           # Intel C++, used to be incompatible with GCC.
+           # ICC 10 doesn't accept -KPIC any more.
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_pic_CXX='-fPIC'
+           lt_prog_compiler_static_CXX='-static'
+           ;;
+         pgCC* | pgcpp*)
+           # Portland Group C++ compiler
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_pic_CXX='-fpic'
+           lt_prog_compiler_static_CXX='-Bstatic'
+           ;;
+         cxx*)
+           # Compaq C++
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           lt_prog_compiler_pic_CXX=
+           lt_prog_compiler_static_CXX='-non_shared'
+           ;;
+         xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)
+           # IBM XL 8.0, 9.0 on PPC and BlueGene
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_pic_CXX='-qpic'
+           lt_prog_compiler_static_CXX='-qstaticlink'
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             lt_prog_compiler_pic_CXX='-KPIC'
+             lt_prog_compiler_static_CXX='-Bstatic'
+             lt_prog_compiler_wl_CXX='-Qoption ld '
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+      lynxos*)
+       ;;
+      m88k*)
+       ;;
+      mvs*)
+       case $cc_basename in
+         cxx*)
+           lt_prog_compiler_pic_CXX='-W c,exportall'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      netbsd*)
+       ;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        lt_prog_compiler_pic_CXX='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+       case $cc_basename in
+         KCC*)
+           lt_prog_compiler_wl_CXX='--backend -Wl,'
+           ;;
+         RCC*)
+           # Rational C++ 2.4.1
+           lt_prog_compiler_pic_CXX='-pic'
+           ;;
+         cxx*)
+           # Digital/Compaq C++
+           lt_prog_compiler_wl_CXX='-Wl,'
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           lt_prog_compiler_pic_CXX=
+           lt_prog_compiler_static_CXX='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      psos*)
+       ;;
+      solaris*)
+       case $cc_basename in
+         CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+           lt_prog_compiler_pic_CXX='-KPIC'
+           lt_prog_compiler_static_CXX='-Bstatic'
+           lt_prog_compiler_wl_CXX='-Qoption ld '
+           ;;
+         gcx*)
+           # Green Hills C++ Compiler
+           lt_prog_compiler_pic_CXX='-PIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sunos4*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.x
+           lt_prog_compiler_pic_CXX='-pic'
+           lt_prog_compiler_static_CXX='-Bstatic'
+           ;;
+         lcc*)
+           # Lucid
+           lt_prog_compiler_pic_CXX='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+       case $cc_basename in
+         CC*)
+           lt_prog_compiler_wl_CXX='-Wl,'
+           lt_prog_compiler_pic_CXX='-KPIC'
+           lt_prog_compiler_static_CXX='-Bstatic'
+           ;;
+       esac
+       ;;
+      tandem*)
+       case $cc_basename in
+         NCC*)
+           # NonStop-UX NCC 3.20
+           lt_prog_compiler_pic_CXX='-KPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      vxworks*)
+       ;;
+      *)
+       lt_prog_compiler_can_build_shared_CXX=no
+       ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_CXX=
+    ;;
+  *)
+    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
+lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_CXX=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+    case $lt_prog_compiler_pic_CXX in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+     esac
+else
+    lt_prog_compiler_pic_CXX=
+     lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  case $host_os in
+  aix[4-9]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    # Also, AIX nm treats weak defined symbols like other global defined
+    # symbols, whereas GNU nm marks them as "W".
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    export_symbols_cmds_CXX="$ltdll_cmds"
+    ;;
+  cygwin* | mingw* | cegcc*)
+    case $cc_basename in
+    cl*)
+      exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+      ;;
+    *)
+      export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+      ;;
+    esac
+    ;;
+  *)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+    ;;
+  esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_CXX=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_CXX in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  $RM conftest*
+       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+       if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+         soname=conftest
+         lib=conftest
+         libobjs=conftest.$ac_objext
+         deplibs=
+         wl=$lt_prog_compiler_wl_CXX
+         pic_flag=$lt_prog_compiler_pic_CXX
+         compiler_flags=-v
+         linker_flags=-v
+         verstring=
+         output_objdir=.
+         libname=conftest
+         lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+         allow_undefined_flag_CXX=
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+         then
+           lt_cv_archive_cmds_need_lc_CXX=no
+         else
+           lt_cv_archive_cmds_need_lc_CXX=yes
+         fi
+         allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+       else
+         cat conftest.err 1>&5
+       fi
+       $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
+      archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
+
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
+
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
+
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
+
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux # correct to gnu/linux during the next big refactor
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+        LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+
+fi
+
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[      ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+       ;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+   test -n "$runpath_var_CXX" ||
+   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_CXX" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+     test "$hardcode_minus_L_CXX" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_CXX=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_CXX=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_CXX=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+   test "$inherit_rpath_CXX" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+if test "x$with_cxx" = xyes; then
+
+$as_echo "#define WITH_CXX 1" >>confdefs.h
+
+   NLOPT_SUFFIX="_cxx"
+   CC=$CXX
+   CFLAGS=$CXXFLAGS
+fi
+
+
+
+# Check whether --with-mthreads was given.
+if test "${with_mthreads+set}" = set; then :
+  withval=$with_mthreads; with_mthrads=$withval
+else
+  with_mthreads=no
+fi
+
+if test "x$with_mthreads" = xyes; then
+   CFLAGS="$CFLAGS -mthreads"
+   CXXFLAGS="$CXXFLAGS -mthreads"
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if ${ac_cv_header_time+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_time=yes
+else
+  ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
+
+for ac_header in unistd.h getopt.h stdint.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if ${ac_cv_c_const+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this sort of thing.  */
+  typedef int charset[2];
+  const charset cs = { 0, 0 };
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this sort of thing.  */
+    char tx;
+    char *t = &tx;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; } bx;
+    struct s *b = &bx; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_const=yes
+else
+  ac_cv_c_const=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+$as_echo "#define const /**/" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if ${ac_cv_c_inline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+
+# Check whether --with-threadlocal was given.
+if test "${with_threadlocal+set}" = set; then :
+  withval=$with_threadlocal; with_ax_c_threadlocal=$withval
+else
+  with_ax_c_threadlocal=yes
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C thread-local keyword" >&5
+$as_echo_n "checking for C thread-local keyword... " >&6; }
+if ${ax_cv_c_threadlocal+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$with_ax_c_threadlocal" = xno; then
+   ax_cv_c_threadlocal=disabled
+ else
+   ax_cv_c_threadlocal=unsupported
+
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+   for ax_kw in __thread "__declspec(thread)"; do
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+static $ax_kw int x = 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_c_threadlocal=$ax_kw; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   done
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_threadlocal" >&5
+$as_echo "$ax_cv_c_threadlocal" >&6; }
+ ax_kw="$ax_cv_c_threadlocal"
+ if test "x$ax_kw" = xunsupported; then ax_kw=""; fi
+ if test "x$ax_kw" = xdisabled; then ax_kw=""; fi
+
+cat >>confdefs.h <<_ACEOF
+#define THREADLOCAL $ax_kw
+_ACEOF
+
+ if test "$ax_cv_c_threadlocal" = unsupported; then
+   :
+ else
+   :
+ fi
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5
+$as_echo_n "checking size of unsigned int... " >&6; }
+if ${ac_cv_sizeof_unsigned_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5
+$as_echo "$ac_cv_sizeof_unsigned_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int
+_ACEOF
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long" >&5
+$as_echo_n "checking size of unsigned long... " >&6; }
+if ${ac_cv_sizeof_unsigned_long+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long))" "ac_cv_sizeof_unsigned_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned long)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long" >&5
+$as_echo "$ac_cv_sizeof_unsigned_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_LONG $ac_cv_sizeof_unsigned_long
+_ACEOF
+
+
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default
+#ifdef HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+"
+if test "x$ac_cv_type_uint32_t" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5
+$as_echo_n "checking for sin in -lm... " >&6; }
+if ${ac_cv_lib_m_sin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sin ();
+int
+main ()
+{
+return sin ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_m_sin=yes
+else
+  ac_cv_lib_m_sin=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sin" >&5
+$as_echo "$ac_cv_lib_m_sin" >&6; }
+if test "x$ac_cv_lib_m_sin" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+fi
+
+for ac_func in BSDgettimeofday gettimeofday time qsort_r getpid
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettid syscall" >&5
+$as_echo_n "checking for gettid syscall... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int
+main ()
+{
+syscall(SYS_gettid);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ok=yes
+else
+  ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test "$ok" = "yes"; then
+
+$as_echo "#define HAVE_GETTID_SYSCALL 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ok}" >&5
+$as_echo "${ok}" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isnan" >&5
+$as_echo_n "checking for isnan... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+
+int
+main ()
+{
+if (!isnan(3.14159)) isnan(2.7183);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ok=yes
+else
+  ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test "$ok" = "yes"; then
+
+$as_echo "#define HAVE_ISNAN 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ok}" >&5
+$as_echo "${ok}" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf" >&5
+$as_echo_n "checking for isinf... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+
+int
+main ()
+{
+if (!isinf(3.14159)) isinf(2.7183);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ok=yes
+else
+  ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test "$ok" = "yes"; then
+
+$as_echo "#define HAVE_ISINF 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ok}" >&5
+$as_echo "${ok}" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for copysign" >&5
+$as_echo_n "checking for copysign... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+
+int
+main ()
+{
+double x = copysign(3.14159, -2.7183);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ok=yes
+else
+  ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test "$ok" = "yes"; then
+
+$as_echo "#define HAVE_COPYSIGN 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ok}" >&5
+$as_echo "${ok}" >&6; }
+
+
+
+# Check whether --with-guile was given.
+if test "${with_guile+set}" = set; then :
+  withval=$with_guile; with_guile=$withval
+else
+  with_guile=yes
+fi
+
+
+# Check whether --with-python was given.
+if test "${with_python+set}" = set; then :
+  withval=$with_python; with_python=$withval
+else
+  with_python=yes
+fi
+
+
+if test "$enable_shared" = no; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Python and Guile wrappers require --enable-shared; disabling" >&5
+$as_echo "$as_me: WARNING: Python and Guile wrappers require --enable-shared; disabling" >&2;}
+   GUILE_CONFIG=unknown
+   have_python=no
+else
+
+if test "x$with_guile" = xno; then
+   GUILE_CONFIG=unknown
+else
+
+
+# Extract the first word of "guile-config", so it can be a program name with args.
+set dummy guile-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_GUILE_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$GUILE_CONFIG"; then
+  ac_cv_prog_GUILE_CONFIG="$GUILE_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_GUILE_CONFIG="guile-config"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_prog_GUILE_CONFIG" && ac_cv_prog_GUILE_CONFIG="unknown"
+fi
+fi
+GUILE_CONFIG=$ac_cv_prog_GUILE_CONFIG
+if test -n "$GUILE_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_CONFIG" >&5
+$as_echo "$GUILE_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+if test "x$GUILE_CONFIG" = "xunknown"; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find guile-config, disabling Guile wrapper" >&5
+$as_echo "$as_me: WARNING: can't find guile-config, disabling Guile wrapper" >&2;}
+else
+   save_CPPFLAGS=$CPPFLAGS
+   save_LIBS=$LIBS
+   GUILE_CPPFLAGS=`$GUILE_CONFIG compile`
+   GUILE_LIBS=`$GUILE_CONFIG link`
+   CPPFLAGS="$CPPFLAGS $GUILE_CPPFLAGS"
+   LIBS="$GUILE_LIBS $LIBS"
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linking to guile works" >&5
+$as_echo_n "checking if linking to guile works... " >&6; }
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char scm_is_vector ();
+int
+main ()
+{
+return scm_is_vector ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: guile-config is broken" >&5
+$as_echo "$as_me: WARNING: guile-config is broken" >&2;}
+        GUILE_CONFIG="unknown"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+   CPPFLAGS=$save_CPPFLAGS
+   LIBS=$save_LIBS
+fi
+# Extract the first word of "guile", so it can be a program name with args.
+set dummy guile; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_GUILE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$GUILE"; then
+  ac_cv_prog_GUILE="$GUILE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_GUILE="guile"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_prog_GUILE" && ac_cv_prog_GUILE="unknown"
+fi
+fi
+GUILE=$ac_cv_prog_GUILE
+if test -n "$GUILE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE" >&5
+$as_echo "$GUILE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+if test "x$GUILE" = xunknown; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find guile, disabling Guile wrapper" >&5
+$as_echo "$as_me: WARNING: can't find guile, disabling Guile wrapper" >&2;}
+   GUILE_CONFIG=unknown
+elif test x"$GUILE_INSTALL_DIR" = "x"; then
+   for ac_prog in guile-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_GUILE_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$GUILE_CONFIG"; then
+  ac_cv_prog_GUILE_CONFIG="$GUILE_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_GUILE_CONFIG="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+GUILE_CONFIG=$ac_cv_prog_GUILE_CONFIG
+if test -n "$GUILE_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_CONFIG" >&5
+$as_echo "$GUILE_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GUILE_CONFIG" && break
+done
+test -n "$GUILE_CONFIG" || GUILE_CONFIG="echo"
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking guile prefix" >&5
+$as_echo_n "checking guile prefix... " >&6; }
+   GUILE_PREFIX=`$GUILE_CONFIG info prefix`
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_PREFIX" >&5
+$as_echo "$GUILE_PREFIX" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Guile installation directory" >&5
+$as_echo_n "checking for Guile installation directory... " >&6; }
+   GUILE_INSTALL_DIR=`guile -c '(display (%site-dir))'`
+   if test "$prefix" != "NONE"; then
+        # strip guile install path to honor prefix
+        GUILE_INSTALL_DIR=`echo "$GUILE_INSTALL_DIR" | sed "s|$GUILE_PREFIX|$prefix|g"`
+   fi
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_INSTALL_DIR" >&5
+$as_echo "$GUILE_INSTALL_DIR" >&6; }
+fi
+
+fi # with_guile
+
+if test "x$with_python" = xno; then
+  have_python=no
+else
+
+
+
+
+
+
+
+        # Find any Python interpreter.
+    if test -z "$PYTHON"; then
+      for ac_prog in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7  python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PYTHON+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PYTHON in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PYTHON=$ac_cv_path_PYTHON
+if test -n "$PYTHON"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
+$as_echo "$PYTHON" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PYTHON" && break
+done
+test -n "$PYTHON" || PYTHON=":"
+
+    fi
+    am_display_PYTHON=python
+
+
+  if test "$PYTHON" = :; then
+      have_python=no
+  else
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5
+$as_echo_n "checking for $am_display_PYTHON version... " >&6; }
+if ${am_cv_python_version+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
+$as_echo "$am_cv_python_version" >&6; }
+  PYTHON_VERSION=$am_cv_python_version
+
+
+
+  PYTHON_PREFIX='${prefix}'
+
+  PYTHON_EXEC_PREFIX='${exec_prefix}'
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5
+$as_echo_n "checking for $am_display_PYTHON platform... " >&6; }
+if ${am_cv_python_platform+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5
+$as_echo "$am_cv_python_platform" >&6; }
+  PYTHON_PLATFORM=$am_cv_python_platform
+
+
+  # Just factor out some code duplication.
+  am_python_setup_sysconfig="\
+import sys
+# Prefer sysconfig over distutils.sysconfig, for better compatibility
+# with python 3.x.  See automake bug#10227.
+try:
+    import sysconfig
+except ImportError:
+    can_use_sysconfig = 0
+else:
+    can_use_sysconfig = 1
+# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    from platform import python_implementation
+    if python_implementation() == 'CPython' and sys.version[:3] == '2.7':
+        can_use_sysconfig = 0
+except ImportError:
+    pass"
+
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5
+$as_echo_n "checking for $am_display_PYTHON script directory... " >&6; }
+if ${am_cv_python_pythondir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$prefix" = xNONE
+     then
+       am_py_prefix=$ac_default_prefix
+     else
+       am_py_prefix=$prefix
+     fi
+     am_cv_python_pythondir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+    sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+else:
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
+     case $am_cv_python_pythondir in
+     $am_py_prefix*)
+       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
+       ;;
+     *)
+       case $am_py_prefix in
+         /usr|/System*) ;;
+         *)
+         am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
+         ;;
+       esac
+       ;;
+     esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5
+$as_echo "$am_cv_python_pythondir" >&6; }
+  pythondir=$am_cv_python_pythondir
+
+
+
+  pkgpythondir=\${pythondir}/$PACKAGE
+
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5
+$as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; }
+if ${am_cv_python_pyexecdir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$exec_prefix" = xNONE
+     then
+       am_py_exec_prefix=$am_py_prefix
+     else
+       am_py_exec_prefix=$exec_prefix
+     fi
+     am_cv_python_pyexecdir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+    sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
+else:
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
+     case $am_cv_python_pyexecdir in
+     $am_py_exec_prefix*)
+       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
+       ;;
+     *)
+       case $am_py_exec_prefix in
+         /usr|/System*) ;;
+         *)
+          am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
+          ;;
+       esac
+       ;;
+     esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5
+$as_echo "$am_cv_python_pyexecdir" >&6; }
+  pyexecdir=$am_cv_python_pyexecdir
+
+
+
+  pkgpyexecdir=\${pyexecdir}/$PACKAGE
+
+
+    have_python=yes
+  fi
+
+
+if test $have_python = yes; then
+
+  for ac_prog in python$PYTHON_VERSION-config python-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PYTHON_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PYTHON_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PYTHON_CONFIG="$PYTHON_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="`dirname $PYTHON`:$PATH"
+for as_dir in $as_dummy
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PYTHON_CONFIG=$ac_cv_path_PYTHON_CONFIG
+if test -n "$PYTHON_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CONFIG" >&5
+$as_echo "$PYTHON_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PYTHON_CONFIG" && break
+done
+test -n "$PYTHON_CONFIG" || PYTHON_CONFIG="unknown"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python include flags" >&5
+$as_echo_n "checking for Python include flags... " >&6; }
+  if test "x$PYTHON_CONFIG" = "xunknown"; then
+      pinc=-I`echo "import distutils.sysconfig; print (distutils.sysconfig.get_python_inc())" | $PYTHON - 2>/dev/null`
+      test "x$pinc" = "x-I" && pinc=""
+  else
+      pinc=`$PYTHON_CONFIG --includes 2>/dev/null`
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${pinc:-unknown}" >&5
+$as_echo "${pinc:-unknown}" >&6; }
+  PYTHON_INCLUDES="$pinc"
+  save_CPPFLAGS=$CPPFLAGS
+  CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+  ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default"
+if test "x$ac_cv_header_Python_h" = xyes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: disabling Python wrappers" >&5
+$as_echo "$as_me: WARNING: disabling Python wrappers" >&2;}
+                                   have_python=no
+fi
+
+
+  if test $have_python = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Numpy include directory" >&5
+$as_echo_n "checking for Numpy include directory... " >&6; }
+    pinc=`echo "import numpy; print (numpy.get_include())" | $PYTHON - 2>/dev/null`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${pinc:-unknown}" >&5
+$as_echo "${pinc:-unknown}" >&6; }
+    test -n "$pinc" && PYTHON_INCLUDES="$PYTHON_INCLUDES -I$pinc"
+    CPPFLAGS="$save_CPPFLAGS $PYTHON_INCLUDES"
+    ac_fn_c_check_header_compile "$LINENO" "numpy/arrayobject.h" "ac_cv_header_numpy_arrayobject_h" "#include <Python.h>
+"
+if test "x$ac_cv_header_numpy_arrayobject_h" = xyes; then :
+
+else
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: disabling Python wrappers" >&5
+$as_echo "$as_me: WARNING: disabling Python wrappers" >&2;}
+      have_python=no
+fi
+
+
+  fi
+  CPPFLAGS=$save_CPPFLAGS
+fi
+
+fi # with_python
+
+fi # if enable_shared
+
+
+
+
+
+ if test x"$GUILE_CONFIG" != "xunknown"; then
+  WITH_GUILE_TRUE=
+  WITH_GUILE_FALSE='#'
+else
+  WITH_GUILE_TRUE='#'
+  WITH_GUILE_FALSE=
+fi
+
+ if test x"$have_python" = "xyes"; then
+  WITH_PYTHON_TRUE=
+  WITH_PYTHON_FALSE='#'
+else
+  WITH_PYTHON_TRUE='#'
+  WITH_PYTHON_FALSE=
+fi
+
+
+
+
+
+
+
+
+# Check whether --with-octave was given.
+if test "${with_octave+set}" = set; then :
+  withval=$with_octave; with_octave=$withval
+else
+  with_octave=yes
+fi
+
+
+for ac_prog in mkoctfile
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MKOCTFILE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MKOCTFILE"; then
+  ac_cv_prog_MKOCTFILE="$MKOCTFILE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MKOCTFILE="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MKOCTFILE=$ac_cv_prog_MKOCTFILE
+if test -n "$MKOCTFILE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5
+$as_echo "$MKOCTFILE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MKOCTFILE" && break
+done
+test -n "$MKOCTFILE" || MKOCTFILE="echo"
+
+
+if test x"$with_octave" = xno; then
+       OCT_INSTALL_DIR=""
+elif test "$MKOCTFILE" = "echo"; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find mkoctfile: won't be able to compile GNU Octave plugin" >&5
+$as_echo "$as_me: WARNING: can't find mkoctfile: won't be able to compile GNU Octave plugin" >&2;}
+       OCT_INSTALL_DIR=""
+elif test x"$OCT_INSTALL_DIR" = "x"; then
+       # try to find installation directory
+       for ac_prog in octave
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OCTAVE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OCTAVE"; then
+  ac_cv_prog_OCTAVE="$OCTAVE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OCTAVE="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OCTAVE=$ac_cv_prog_OCTAVE
+if test -n "$OCTAVE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE" >&5
+$as_echo "$OCTAVE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$OCTAVE" && break
+done
+test -n "$OCTAVE" || OCTAVE="echo"
+
+       for ac_prog in octave-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OCTAVE_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OCTAVE_CONFIG"; then
+  ac_cv_prog_OCTAVE_CONFIG="$OCTAVE_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OCTAVE_CONFIG="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OCTAVE_CONFIG=$ac_cv_prog_OCTAVE_CONFIG
+if test -n "$OCTAVE_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_CONFIG" >&5
+$as_echo "$OCTAVE_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$OCTAVE_CONFIG" && break
+done
+test -n "$OCTAVE_CONFIG" || OCTAVE_CONFIG="echo"
+
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking octave prefix" >&5
+$as_echo_n "checking octave prefix... " >&6; }
+       OCTAVE_PREFIX=`$OCTAVE_CONFIG --print PREFIX 2> /dev/null`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_PREFIX" >&5
+$as_echo "$OCTAVE_PREFIX" >&6; }
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking where octave plugins go" >&5
+$as_echo_n "checking where octave plugins go... " >&6; }
+       OCT_INSTALL_DIR=`$OCTAVE_CONFIG --oct-site-dir 2> /dev/null | grep '/'`
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`$OCTAVE_CONFIG --print OCTFILEDIR 2> /dev/null | grep '/'`
+       fi
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/oct/" | head -1`
+       fi
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/oct" | head -1`
+        fi
+       if test -n "$OCT_INSTALL_DIR"; then
+               if test "$prefix" != "NONE"; then
+                       # strip octave install path to honor prefix
+                       OCT_INSTALL_DIR=`echo "$OCT_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"`
+               fi
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCT_INSTALL_DIR" >&5
+$as_echo "$OCT_INSTALL_DIR" >&6; }
+       else
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5
+$as_echo "unknown" >&6; }
+               { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find where to install octave plugins: won't be able to compile octave plugin" >&5
+$as_echo "$as_me: WARNING: can't find where to install octave plugins: won't be able to compile octave plugin" >&2;}
+       fi
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking where octave scripts go" >&5
+$as_echo_n "checking where octave scripts go... " >&6; }
+       M_INSTALL_DIR=`$OCTAVE_CONFIG --m-site-dir 2> /dev/null | grep '/'`
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`$OCTAVE_CONFIG --print FCNFILEDIR 2> /dev/null | grep '/'`
+       fi
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/m" | head -1`
+       fi
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/m" | head -1`
+        fi
+       if test -n "$M_INSTALL_DIR"; then
+               if test "$prefix" != "NONE"; then
+                       # strip octave install path to honor prefix
+                       M_INSTALL_DIR=`echo "$M_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"`
+               fi
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: $M_INSTALL_DIR" >&5
+$as_echo "$M_INSTALL_DIR" >&6; }
+       else
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5
+$as_echo "unknown" >&6; }
+               { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find where to install octave scripts: won't be able to install octave plugin" >&5
+$as_echo "$as_me: WARNING: can't find where to install octave scripts: won't be able to install octave plugin" >&2;}
+               OCT_INSTALL_DIR=""
+       fi
+elif test x"$M_INSTALL_DIR" = "x"; then # user-specified OCT_INSTALL_DIR
+     M_INSTALL_DIR=$OCT_INSTALL_DIR
+fi
+
+if test x"$OCT_INSTALL_DIR" != "x"; then
+if test "$enable_shared" = no; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mkoctfile requires --enable-shared; won't compile Octave plugin" >&5
+$as_echo "$as_me: WARNING: mkoctfile requires --enable-shared; won't compile Octave plugin" >&2;}
+       OCT_INSTALL_DIR=""
+fi
+fi
+
+ if test x"$OCT_INSTALL_DIR" != "x"; then
+  WITH_OCTAVE_TRUE=
+  WITH_OCTAVE_FALSE='#'
+else
+  WITH_OCTAVE_TRUE='#'
+  WITH_OCTAVE_FALSE=
+fi
+
+
+
+
+
+
+
+# Check whether --with-matlab was given.
+if test "${with_matlab+set}" = set; then :
+  withval=$with_matlab; with_matlab=$withval
+else
+  with_matlab=yes
+fi
+
+
+
+
+for ac_prog in mex
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MEX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MEX"; then
+  ac_cv_prog_MEX="$MEX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MEX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MEX=$ac_cv_prog_MEX
+if test -n "$MEX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEX" >&5
+$as_echo "$MEX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MEX" && break
+done
+test -n "$MEX" || MEX="echo"
+
+if test x"$with_matlab" = xno; then
+     MEX_INSTALL_DIR=""
+elif test "$MEX" = "echo"; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find mex: won't be able to compile Matlab plugin" >&5
+$as_echo "$as_me: WARNING: can't find mex: won't be able to compile Matlab plugin" >&2;}
+     MEX_INSTALL_DIR=""
+else
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extension of compiled mex files" >&5
+$as_echo_n "checking for extension of compiled mex files... " >&6; }
+     rm -f conftest*
+     cat > conftest.c <<EOF
+#include <mex.h>
+void mexFunction(int nlhs, mxArray *plhs[],
+                 int nrhs, const mxArray *prhs[]) { }
+EOF
+     if $MEX conftest.c >&5 2>&5; then
+        MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEXSUFF" >&5
+$as_echo "$MEXSUFF" >&6; }
+       for ac_prog in matlab
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MATLAB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MATLAB"; then
+  ac_cv_prog_MATLAB="$MATLAB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MATLAB="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MATLAB=$ac_cv_prog_MATLAB
+if test -n "$MATLAB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MATLAB" >&5
+$as_echo "$MATLAB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MATLAB" && break
+done
+test -n "$MATLAB" || MATLAB="echo"
+
+     else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $MEX failed to compile a simple file; won't compile Matlab plugin" >&5
+$as_echo "$as_me: WARNING: $MEX failed to compile a simple file; won't compile Matlab plugin" >&2;}
+       MEX_INSTALL_DIR=""
+       MATLAB=echo
+     fi
+
+     if test x"$MATLAB" != xecho; then
+     if test "$enable_shared" = no; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mex requires --enable-shared; won't compile Matlab plugin" >&5
+$as_echo "$as_me: WARNING: mex requires --enable-shared; won't compile Matlab plugin" >&2;}
+       MEX_INSTALL_DIR=""
+       MATLAB=echo
+     fi
+     fi
+
+     if test x"$MATLAB" != xecho; then
+       # try to find installation directory
+       if test x"$MEX_INSTALL_DIR" = "x"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MATLAB mex installation dir" >&5
+$as_echo_n "checking for MATLAB mex installation dir... " >&6; }
+         MEX_INSTALL_DIR=`matlab -nodisplay -nodesktop -nojvm -r 'path;quit' | grep toolbox/local |sed 's,^[^/]*,,g' |sort |head -1`
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEX_INSTALL_DIR" >&5
+$as_echo "$MEX_INSTALL_DIR" >&6; }
+         if test x`basename "$MEX_INSTALL_DIR"` != xlocal; then
+            MEX_INSTALL_DIR=""
+         fi
+          if test x"$MEX_INSTALL_DIR" = "x"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find reasonable Matlab installation directory; Matlab plugins will not be compiled unless you manually specify MEX_INSTALL_DIR" >&5
+$as_echo "$as_me: WARNING: can't find reasonable Matlab installation directory; Matlab plugins will not be compiled unless you manually specify MEX_INSTALL_DIR" >&2;}
+          fi
+       fi
+     else
+       MEX_INSTALL_DIR=""
+     fi
+fi
+ if test x"$MEX_INSTALL_DIR" != "x"; then
+  WITH_MATLAB_TRUE=
+  WITH_MATLAB_FALSE='#'
+else
+  WITH_MATLAB_TRUE='#'
+  WITH_MATLAB_FALSE=
+fi
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working HUGE_VAL" >&5
+$as_echo_n "checking for working HUGE_VAL... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+int
+main ()
+{
+double x = -HUGE_VAL;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+#ifdef __GNUC__
+#undef HUGE_VAL
+#define HUGE_VAL __builtin_huge_val()
+#endif
+int
+main ()
+{
+double x = -HUGE_VAL;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: __builtin_huge_val()" >&5
+$as_echo "__builtin_huge_val()" >&6; }
+
+$as_echo "#define REPLACEMENT_HUGE_VAL __builtin_huge_val()" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5
+$as_echo "unknown" >&6; }
+as_fn_error $? "broken HUGE_VAL macro with this compiler, unknown workaround" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then :
+  enableval=$enable_debug; ok=$enableval
+else
+  ok=no
+fi
+
+if test "$ok" = "yes"; then
+
+$as_echo "#define DEBUG 1" >>confdefs.h
+
+fi
+
+if test "${enable_debug}" = "yes"; then
+        CFLAGS="-g"
+        CXXFLAGS="-g"
+        FFLAGS="-g"
+fi
+
+if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
+if test $ac_cv_c_compiler_gnu = yes; then
+   if test "$ac_test_CFLAGS" != "set"; then
+      CFLAGS="$CFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wbad-function-cast -Wwrite-strings -Wstrict-prototypes -Wredundant-decls -Wnested-externs -Wundef -Wconversion -Wmissing-prototypes -Wmissing-declarations"
+   fi
+   if test "$ac_test_CXXFLAGS" != "set"; then
+      CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
+   fi
+   if test "x$with_cxx" = xyes; then
+      CFLAGS=$CXXFLAGS
+   fi
+fi
+fi
+
+vers=`echo ${VERSION}.0.0 | cut -d. -f1`
+
+cat >>confdefs.h <<_ACEOF
+#define MAJOR_VERSION $vers
+_ACEOF
+
+vers=`echo ${VERSION}.0.0 | cut -d. -f2`
+
+cat >>confdefs.h <<_ACEOF
+#define MINOR_VERSION $vers
+_ACEOF
+
+vers=`echo ${VERSION}.0.0 | cut -d. -f3`
+
+cat >>confdefs.h <<_ACEOF
+#define BUGFIX_VERSION $vers
+_ACEOF
+
+
+
+ac_config_files="$ac_config_files Makefile nlopt.pc api/Makefile util/Makefile octave/Makefile direct/Makefile cdirect/Makefile stogo/Makefile praxis/Makefile luksan/Makefile crs/Makefile mlsl/Makefile mma/Makefile cobyla/Makefile newuoa/Makefile neldermead/Makefile auglag/Makefile bobyqa/Makefile isres/Makefile slsqp/Makefile esch/Makefile test/Makefile swig/Makefile swig/nlopt.scm"
+
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    if test "x$cache_file" != "x/dev/null"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+       cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+         mv -f confcache "$cache_file"$$ &&
+         mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+         mv -f confcache "$cache_file" ;;
+       esac
+      fi
+    fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+  as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error $? "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_CXX_TRUE}" && test -z "${WITH_CXX_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_CXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_GUILE_TRUE}" && test -z "${WITH_GUILE_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_GUILE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_PYTHON_TRUE}" && test -z "${WITH_PYTHON_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_PYTHON\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_OCTAVE_TRUE}" && test -z "${WITH_OCTAVE_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_OCTAVE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_MATLAB_TRUE}" && test -z "${WITH_MATLAB_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_MATLAB\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by nlopt $as_me 2.4.2, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <stevenj@alum.mit.edu>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+nlopt config.status 2.4.2
+configured by $0, generated by GNU Autoconf 2.69,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
+AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
+file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
+want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
+sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
+archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
+lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
+MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
+postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`'
+predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`'
+postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`'
+reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`'
+reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in AS \
+DLLTOOL \
+OBJDUMP \
+SHELL \
+ECHO \
+PATH_SEPARATOR \
+SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+deplibs_check_method \
+file_magic_cmd \
+file_magic_glob \
+want_nocaseglob \
+sharedlib_from_linklib_cmd \
+AR \
+AR_FLAGS \
+archiver_list_spec \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+nm_file_list_spec \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_pic \
+lt_prog_compiler_wl \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+MANIFEST_TOOL \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_separator \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+install_override_mode \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+reload_flag_CXX \
+compiler_CXX \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_static_CXX \
+lt_cv_prog_compiler_c_o_CXX \
+export_dynamic_flag_spec_CXX \
+whole_archive_flag_spec_CXX \
+compiler_needs_object_CXX \
+with_gnu_ld_CXX \
+allow_undefined_flag_CXX \
+no_undefined_flag_CXX \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_separator_CXX \
+exclude_expsyms_CXX \
+include_expsyms_CXX \
+file_list_spec_CXX \
+compiler_lib_search_dirs_CXX \
+predep_objects_CXX \
+postdep_objects_CXX \
+predeps_CXX \
+postdeps_CXX \
+compiler_lib_search_path_CXX; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postlink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+reload_cmds_CXX \
+old_archive_cmds_CXX \
+old_archive_from_new_cmds_CXX \
+old_archive_from_expsyms_cmds_CXX \
+archive_cmds_CXX \
+archive_expsym_cmds_CXX \
+module_cmds_CXX \
+module_expsym_cmds_CXX \
+export_symbols_cmds_CXX \
+prelink_cmds_CXX \
+postlink_cmds_CXX; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "nlopt.pc") CONFIG_FILES="$CONFIG_FILES nlopt.pc" ;;
+    "api/Makefile") CONFIG_FILES="$CONFIG_FILES api/Makefile" ;;
+    "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;;
+    "octave/Makefile") CONFIG_FILES="$CONFIG_FILES octave/Makefile" ;;
+    "direct/Makefile") CONFIG_FILES="$CONFIG_FILES direct/Makefile" ;;
+    "cdirect/Makefile") CONFIG_FILES="$CONFIG_FILES cdirect/Makefile" ;;
+    "stogo/Makefile") CONFIG_FILES="$CONFIG_FILES stogo/Makefile" ;;
+    "praxis/Makefile") CONFIG_FILES="$CONFIG_FILES praxis/Makefile" ;;
+    "luksan/Makefile") CONFIG_FILES="$CONFIG_FILES luksan/Makefile" ;;
+    "crs/Makefile") CONFIG_FILES="$CONFIG_FILES crs/Makefile" ;;
+    "mlsl/Makefile") CONFIG_FILES="$CONFIG_FILES mlsl/Makefile" ;;
+    "mma/Makefile") CONFIG_FILES="$CONFIG_FILES mma/Makefile" ;;
+    "cobyla/Makefile") CONFIG_FILES="$CONFIG_FILES cobyla/Makefile" ;;
+    "newuoa/Makefile") CONFIG_FILES="$CONFIG_FILES newuoa/Makefile" ;;
+    "neldermead/Makefile") CONFIG_FILES="$CONFIG_FILES neldermead/Makefile" ;;
+    "auglag/Makefile") CONFIG_FILES="$CONFIG_FILES auglag/Makefile" ;;
+    "bobyqa/Makefile") CONFIG_FILES="$CONFIG_FILES bobyqa/Makefile" ;;
+    "isres/Makefile") CONFIG_FILES="$CONFIG_FILES isres/Makefile" ;;
+    "slsqp/Makefile") CONFIG_FILES="$CONFIG_FILES slsqp/Makefile" ;;
+    "esch/Makefile") CONFIG_FILES="$CONFIG_FILES esch/Makefile" ;;
+    "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
+    "swig/Makefile") CONFIG_FILES="$CONFIG_FILES swig/Makefile" ;;
+    "swig/nlopt.scm") CONFIG_FILES="$CONFIG_FILES swig/nlopt.scm" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=[    ]*/{
+h
+s///
+s/^/:/
+s/[     ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[  ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
+  case $ac_file in
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Older Autoconf quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named 'Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running 'make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "$am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+    "libtool":C)
+
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Assembler program.
+AS=$lt_AS
+
+# DLL creation program.
+DLLTOOL=$lt_DLLTOOL
+
+# Object dumper program.
+OBJDUMP=$lt_OBJDUMP
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that protects backslashes.
+ECHO=$lt_ECHO
+
+# The PATH separator for the build system.
+PATH_SEPARATOR=$lt_PATH_SEPARATOR
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# convert \$build file names to \$host format.
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+
+# convert \$build files to toolchain format.
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method = "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# How to find potential files when deplibs_check_method = "file_magic".
+file_magic_glob=$lt_file_magic_glob
+
+# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
+want_nocaseglob=$lt_want_nocaseglob
+
+# Command to associate shared and link libraries.
+sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
+
+# The archiver.
+AR=$lt_AR
+
+# Flags to create an archive.
+AR_FLAGS=$lt_AR_FLAGS
+
+# How to feed a file listing to the archiver.
+archiver_list_spec=$lt_archiver_list_spec
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Whether to use a lock for old archive extraction.
+lock_old_archive_extraction=$lock_old_archive_extraction
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# Specify filename containing input files for \$NM.
+nm_file_list_spec=$lt_nm_file_list_spec
+
+# The root where to search for dependent libraries,and in which our libraries should be installed.
+lt_sysroot=$lt_sysroot
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Manifest tool.
+MANIFEST_TOOL=$lt_MANIFEST_TOOL
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Permission mode override for installation of shared libraries.
+install_override_mode=$lt_install_override_mode
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" \
+     || (rm -f "$cfgfile"; exit 1)
+
+  if test x"$xsi_shell" = xyes; then
+  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
+func_dirname ()\
+{\
+\    case ${1} in\
+\      */*) func_dirname_result="${1%/*}${2}" ;;\
+\      *  ) func_dirname_result="${3}" ;;\
+\    esac\
+} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_basename ()$/,/^} # func_basename /c\
+func_basename ()\
+{\
+\    func_basename_result="${1##*/}"\
+} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
+func_dirname_and_basename ()\
+{\
+\    case ${1} in\
+\      */*) func_dirname_result="${1%/*}${2}" ;;\
+\      *  ) func_dirname_result="${3}" ;;\
+\    esac\
+\    func_basename_result="${1##*/}"\
+} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
+func_stripname ()\
+{\
+\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
+\    # positional parameters, so assign one to ordinary parameter first.\
+\    func_stripname_result=${3}\
+\    func_stripname_result=${func_stripname_result#"${1}"}\
+\    func_stripname_result=${func_stripname_result%"${2}"}\
+} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
+func_split_long_opt ()\
+{\
+\    func_split_long_opt_name=${1%%=*}\
+\    func_split_long_opt_arg=${1#*=}\
+} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
+func_split_short_opt ()\
+{\
+\    func_split_short_opt_arg=${1#??}\
+\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
+} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
+func_lo2o ()\
+{\
+\    case ${1} in\
+\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
+\      *)    func_lo2o_result=${1} ;;\
+\    esac\
+} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_xform ()$/,/^} # func_xform /c\
+func_xform ()\
+{\
+    func_xform_result=${1%.*}.lo\
+} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_arith ()$/,/^} # func_arith /c\
+func_arith ()\
+{\
+    func_arith_result=$(( $* ))\
+} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_len ()$/,/^} # func_len /c\
+func_len ()\
+{\
+    func_len_result=${#1}\
+} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+fi
+
+if test x"$lt_shell_append" = xyes; then
+  sed -e '/^func_append ()$/,/^} # func_append /c\
+func_append ()\
+{\
+    eval "${1}+=\\${2}"\
+} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
+func_append_quoted ()\
+{\
+\    func_quote_for_eval "${2}"\
+\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
+} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  # Save a `func_append' function call where possible by direct use of '+='
+  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+else
+  # Save a `func_append' function call even when '+=' is not available
+  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
+$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
+fi
+
+
+   mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+
+    cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_CXX
+reload_cmds=$lt_reload_cmds_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..3b93080
--- /dev/null
@@ -0,0 +1,438 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(nlopt, 2.4.2, stevenj@alum.mit.edu)
+AC_CONFIG_SRCDIR(api/nlopt.h)
+SHARED_VERSION_INFO="8:2:8" # CURRENT:REVISION:AGE
+
+AM_INIT_AUTOMAKE(1.7)
+AM_CONFIG_HEADER(config.h)
+AC_CONFIG_MACRO_DIR([m4])
+AM_MAINTAINER_MODE
+AC_SUBST(SHARED_VERSION_INFO)
+AC_DISABLE_SHARED dnl shared libraries are a PITA, disable by default
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CC_STDC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+
+NLOPT_SUFFIX=""
+AC_ARG_WITH(cxx,
+       [AC_HELP_STRING([--with-cxx], [include C++-based routines])],
+        with_cxx=$withval,with_cxx=no)
+AM_CONDITIONAL(WITH_CXX, test "x$with_cxx" = xyes)
+AC_PROG_CXX
+if test "x$with_cxx" = xyes; then
+   AC_DEFINE([WITH_CXX], 1, [Define if compiled including C++-based routines])
+   NLOPT_SUFFIX="_cxx"
+   CC=$CXX
+   CFLAGS=$CXXFLAGS
+fi
+AC_SUBST(NLOPT_SUFFIX)
+
+AC_ARG_WITH(mthreads,
+        [AC_HELP_STRING([--with-mthreads], [use -mthreads compiler flag])],
+        with_mthrads=$withval,with_mthreads=no)
+if test "x$with_mthreads" = xyes; then
+   CFLAGS="$CFLAGS -mthreads"
+   CXXFLAGS="$CXXFLAGS -mthreads"
+fi
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDC
+AC_HEADER_TIME
+AC_CHECK_HEADERS([unistd.h getopt.h stdint.h])
+AC_C_CONST
+AC_C_INLINE
+AX_C_THREADLOCAL
+
+dnl find 32-bit unsigned integer type for random-number generator
+AC_CHECK_SIZEOF(unsigned int)
+AC_CHECK_SIZEOF(unsigned long)
+AC_CHECK_TYPES(uint32_t, [], [], [$ac_includes_default
+#ifdef HAVE_STDINT_H
+#  include <stdint.h>
+#endif])
+
+dnl Checks for libraries and functions
+AC_CHECK_LIB(m, sin)
+AC_CHECK_FUNCS([BSDgettimeofday gettimeofday time qsort_r getpid])
+
+AC_MSG_CHECKING([for gettid syscall])
+AC_TRY_LINK([#include <unistd.h>
+#include <sys/syscall.h>
+], [syscall(SYS_gettid);], [ok=yes], [ok=no])
+if test "$ok" = "yes"; then
+       AC_DEFINE(HAVE_GETTID_SYSCALL,1,[Define if syscall(SYS_gettid) available.])
+fi
+AC_MSG_RESULT(${ok})
+
+AC_MSG_CHECKING([for isnan])
+AC_TRY_LINK([#include <math.h>
+], [if (!isnan(3.14159)) isnan(2.7183);], ok=yes, ok=no)
+if test "$ok" = "yes"; then
+       AC_DEFINE(HAVE_ISNAN,1,[Define if the isnan() function/macro is available.])
+fi
+AC_MSG_RESULT(${ok})
+
+AC_MSG_CHECKING([for isinf])
+AC_TRY_LINK([#include <math.h>
+], [if (!isinf(3.14159)) isinf(2.7183);], ok=yes, ok=no)
+if test "$ok" = "yes"; then
+       AC_DEFINE(HAVE_ISINF,1,[Define if the isinf() function/macro is available.])
+fi
+AC_MSG_RESULT(${ok})
+
+AC_MSG_CHECKING([for copysign])
+AC_TRY_LINK([#include <math.h>
+], [double x = copysign(3.14159, -2.7183);], ok=yes, ok=no)
+if test "$ok" = "yes"; then
+       AC_DEFINE(HAVE_COPYSIGN,1,[Define if the copysign function/macro is available.])
+fi
+AC_MSG_RESULT(${ok})
+
+dnl -----------------------------------------------------------------------
+dnl SWIG wrappers
+
+AC_ARG_WITH(guile,
+       [AC_HELP_STRING([--without-guile], [don't compile Guile plugin])],
+        with_guile=$withval,with_guile=yes)
+AC_ARG_WITH(python,
+       [AC_HELP_STRING([--without-python], [don't compile Python plugin])],
+        with_python=$withval,with_python=yes)
+
+if test "$enable_shared" = no; then
+   AC_MSG_WARN([Python and Guile wrappers require --enable-shared; disabling])
+   GUILE_CONFIG=unknown
+   have_python=no
+else
+
+if test "x$with_guile" = xno; then
+   GUILE_CONFIG=unknown
+else
+
+dnl Guile:
+AC_ARG_VAR(GUILE_INSTALL_DIR, [where to install Guile plug-ins])
+AC_CHECK_PROG(GUILE_CONFIG, guile-config, guile-config, unknown)
+if test "x$GUILE_CONFIG" = "xunknown"; then
+   AC_MSG_WARN([can't find guile-config, disabling Guile wrapper])
+else
+   save_CPPFLAGS=$CPPFLAGS
+   save_LIBS=$LIBS
+   GUILE_CPPFLAGS=`$GUILE_CONFIG compile`
+   GUILE_LIBS=`$GUILE_CONFIG link`
+   CPPFLAGS="$CPPFLAGS $GUILE_CPPFLAGS"
+   LIBS="$GUILE_LIBS $LIBS"
+   AC_MSG_CHECKING([if linking to guile works])
+   AC_TRY_LINK_FUNC(scm_is_vector, [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
+        AC_MSG_WARN(guile-config is broken, disabling Guile wrapper)
+        GUILE_CONFIG="unknown"])
+   CPPFLAGS=$save_CPPFLAGS
+   LIBS=$save_LIBS
+fi
+AC_CHECK_PROG(GUILE, guile, guile, unknown)
+if test "x$GUILE" = xunknown; then
+   AC_MSG_WARN([can't find guile, disabling Guile wrapper])
+   GUILE_CONFIG=unknown
+elif test x"$GUILE_INSTALL_DIR" = "x"; then
+   AC_CHECK_PROGS(GUILE_CONFIG, guile-config, echo)
+   AC_MSG_CHECKING(guile prefix)
+   GUILE_PREFIX=`$GUILE_CONFIG info prefix`
+   AC_MSG_RESULT($GUILE_PREFIX)
+   AC_MSG_CHECKING([for Guile installation directory])
+   GUILE_INSTALL_DIR=`guile -c '(display (%site-dir))'`
+   if test "$prefix" != "NONE"; then
+        # strip guile install path to honor prefix
+        GUILE_INSTALL_DIR=`echo "$GUILE_INSTALL_DIR" | sed "s|$GUILE_PREFIX|$prefix|g"`
+   fi
+
+   AC_MSG_RESULT([$GUILE_INSTALL_DIR])
+fi
+
+fi # with_guile
+
+if test "x$with_python" = xno; then
+  have_python=no
+else
+
+dnl Python:
+AM_PATH_PYTHON([],[have_python=yes],[have_python=no])
+if test $have_python = yes; then
+  AC_ARG_VAR([PYTHON_CONFIG], [python-config program])
+  AC_PATH_PROGS([PYTHON_CONFIG], [python$PYTHON_VERSION-config python-config],
+                [unknown], [`dirname $PYTHON`:$PATH])
+  AC_MSG_CHECKING([for Python include flags])
+  if test "x$PYTHON_CONFIG" = "xunknown"; then
+      pinc=-I`echo "import distutils.sysconfig; print (distutils.sysconfig.get_python_inc())" | $PYTHON - 2>/dev/null`
+      test "x$pinc" = "x-I" && pinc=""
+  else
+      pinc=`$PYTHON_CONFIG --includes 2>/dev/null`
+  fi
+  AC_MSG_RESULT([${pinc:-unknown}])
+  PYTHON_INCLUDES="$pinc"
+  save_CPPFLAGS=$CPPFLAGS
+  CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+  AC_CHECK_HEADER([Python.h], [], [AC_MSG_WARN([disabling Python wrappers]) 
+                                   have_python=no])
+  if test $have_python = yes; then
+    AC_MSG_CHECKING([for Numpy include directory])
+    pinc=`echo "import numpy; print (numpy.get_include())" | $PYTHON - 2>/dev/null`
+    AC_MSG_RESULT([${pinc:-unknown}])
+    test -n "$pinc" && PYTHON_INCLUDES="$PYTHON_INCLUDES -I$pinc"
+    CPPFLAGS="$save_CPPFLAGS $PYTHON_INCLUDES"
+    AC_CHECK_HEADER([numpy/arrayobject.h],[],[
+      AC_MSG_WARN([disabling Python wrappers])
+      have_python=no],[#include <Python.h>])
+  fi
+  CPPFLAGS=$save_CPPFLAGS
+fi
+
+fi # with_python
+
+fi # if enable_shared
+
+AC_SUBST(GUILE_INSTALL_DIR)
+AC_SUBST(GUILE_CPPFLAGS)
+AC_SUBST(GUILE_LIBS)
+AC_SUBST(PYTHON_INCLUDES)
+AM_CONDITIONAL(WITH_GUILE, test x"$GUILE_CONFIG" != "xunknown")
+AM_CONDITIONAL(WITH_PYTHON, test x"$have_python" = "xyes")
+
+dnl -----------------------------------------------------------------------
+dnl Compiling Octave plug-in
+
+AC_ARG_VAR(OCT_INSTALL_DIR, [where to install GNU Octave .oct plug-ins])
+AC_ARG_VAR(M_INSTALL_DIR, [where to install GNU Octave .m plug-ins])
+AC_ARG_VAR(MKOCTFILE, [name of mkoctfile program to compile Octave plug-ins])
+
+AC_ARG_WITH(octave,
+       [AC_HELP_STRING([--without-octave], [don't compile Octave plugin])],
+        with_octave=$withval,with_octave=yes)
+
+AC_CHECK_PROGS(MKOCTFILE, mkoctfile, echo)
+
+if test x"$with_octave" = xno; then
+       OCT_INSTALL_DIR=""
+elif test "$MKOCTFILE" = "echo"; then
+       AC_MSG_WARN([can't find mkoctfile: won't be able to compile GNU Octave plugin])
+       OCT_INSTALL_DIR=""
+elif test x"$OCT_INSTALL_DIR" = "x"; then
+       # try to find installation directory
+       AC_CHECK_PROGS(OCTAVE, octave, echo)
+       AC_CHECK_PROGS(OCTAVE_CONFIG, octave-config, echo)
+       
+       AC_MSG_CHECKING(octave prefix)
+       OCTAVE_PREFIX=`$OCTAVE_CONFIG --print PREFIX 2> /dev/null`
+       AC_MSG_RESULT($OCTAVE_PREFIX)
+       
+       AC_MSG_CHECKING(where octave plugins go)
+       OCT_INSTALL_DIR=`$OCTAVE_CONFIG --oct-site-dir 2> /dev/null | grep '/'`
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`$OCTAVE_CONFIG --print OCTFILEDIR 2> /dev/null | grep '/'`
+       fi
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/oct/" | head -1`
+       fi
+       if test -z "$OCT_INSTALL_DIR"; then
+               OCT_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/oct" | head -1`
+        fi
+       if test -n "$OCT_INSTALL_DIR"; then
+               if test "$prefix" != "NONE"; then
+                       # strip octave install path to honor prefix
+                       OCT_INSTALL_DIR=`echo "$OCT_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"`
+               fi
+               AC_MSG_RESULT($OCT_INSTALL_DIR)
+       else
+               AC_MSG_RESULT(unknown)
+               AC_MSG_WARN([can't find where to install octave plugins: won't be able to compile octave plugin])
+       fi
+
+       AC_MSG_CHECKING(where octave scripts go)
+       M_INSTALL_DIR=`$OCTAVE_CONFIG --m-site-dir 2> /dev/null | grep '/'`
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`$OCTAVE_CONFIG --print FCNFILEDIR 2> /dev/null | grep '/'`
+       fi
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`echo "path" | $OCTAVE -q 2> /dev/null | grep "/m" | head -1`
+       fi
+       if test -z "$M_INSTALL_DIR"; then
+               M_INSTALL_DIR=`echo "DEFAULT_LOADPATH" | $OCTAVE -q 2> /dev/null | tr ':' '\n' | grep "site/m" | head -1`
+        fi
+       if test -n "$M_INSTALL_DIR"; then
+               if test "$prefix" != "NONE"; then
+                       # strip octave install path to honor prefix
+                       M_INSTALL_DIR=`echo "$M_INSTALL_DIR" | sed "s|$OCTAVE_PREFIX|$prefix|g"`
+               fi
+               AC_MSG_RESULT($M_INSTALL_DIR)
+       else
+               AC_MSG_RESULT(unknown)
+               AC_MSG_WARN([can't find where to install octave scripts: won't be able to install octave plugin])
+               OCT_INSTALL_DIR=""
+       fi
+elif test x"$M_INSTALL_DIR" = "x"; then # user-specified OCT_INSTALL_DIR
+     M_INSTALL_DIR=$OCT_INSTALL_DIR
+fi
+
+if test x"$OCT_INSTALL_DIR" != "x"; then
+if test "$enable_shared" = no; then
+        AC_MSG_WARN([mkoctfile requires --enable-shared; won't compile Octave plugin])
+       OCT_INSTALL_DIR=""
+fi
+fi
+
+AM_CONDITIONAL(WITH_OCTAVE, test x"$OCT_INSTALL_DIR" != "x")
+AC_SUBST(OCT_INSTALL_DIR)
+AC_SUBST(M_INSTALL_DIR)
+AC_SUBST(MKOCTFILE)
+
+dnl -----------------------------------------------------------------------
+dnl Compiling Matlab plug-in
+
+AC_ARG_WITH(matlab,
+       [AC_HELP_STRING([--without-matlab], [don't compile Matlab plugin])],
+        with_matlab=$withval,with_matlab=yes)
+
+AC_ARG_VAR(MEX_INSTALL_DIR, [where to install Matlab .mex plug-ins])
+AC_ARG_VAR(MEX, [name of mex program to compile Matlab plug-ins])
+AC_CHECK_PROGS(MEX, mex, echo)
+if test x"$with_matlab" = xno; then
+     MEX_INSTALL_DIR=""
+elif test "$MEX" = "echo"; then
+     AC_MSG_WARN([can't find mex: won't be able to compile Matlab plugin])
+     MEX_INSTALL_DIR=""
+else
+     AC_MSG_CHECKING([for extension of compiled mex files])
+     rm -f conftest*
+     cat > conftest.c <<EOF
+#include <mex.h>
+void mexFunction(int nlhs, mxArray *plhs[[]],
+                 int nrhs, const mxArray *prhs[[]]) { }
+EOF
+     if $MEX conftest.c >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+        MEXSUFF=`ls conftest.m* | head -1 | cut -d'.' -f2`
+       AC_MSG_RESULT($MEXSUFF)
+       AC_CHECK_PROGS(MATLAB, matlab, echo)
+     else
+        AC_MSG_WARN([$MEX failed to compile a simple file; won't compile Matlab plugin])
+       MEX_INSTALL_DIR=""
+       MATLAB=echo
+     fi
+
+     if test x"$MATLAB" != xecho; then
+     if test "$enable_shared" = no; then
+       AC_MSG_RESULT(no)
+        AC_MSG_WARN([mex requires --enable-shared; won't compile Matlab plugin])
+       MEX_INSTALL_DIR=""
+       MATLAB=echo
+     fi
+     fi
+
+     if test x"$MATLAB" != xecho; then
+       # try to find installation directory
+       if test x"$MEX_INSTALL_DIR" = "x"; then
+          AC_MSG_CHECKING(for MATLAB mex installation dir)
+         MEX_INSTALL_DIR=`matlab -nodisplay -nodesktop -nojvm -r 'path;quit' | grep toolbox/local |sed 's,^[[^/]]*,,g' |sort |head -1`
+         AC_MSG_RESULT($MEX_INSTALL_DIR)
+         if test x`basename "$MEX_INSTALL_DIR"` != xlocal; then
+            MEX_INSTALL_DIR=""
+         fi
+          if test x"$MEX_INSTALL_DIR" = "x"; then
+            AC_MSG_WARN([can't find reasonable Matlab installation directory; Matlab plugins will not be compiled unless you manually specify MEX_INSTALL_DIR])
+          fi
+       fi
+     else
+       MEX_INSTALL_DIR=""
+     fi
+fi
+AM_CONDITIONAL(WITH_MATLAB, test x"$MEX_INSTALL_DIR" != "x")
+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
+
+AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile with extra runtime checks for debugging])], ok=$enableval, ok=no)
+if test "$ok" = "yes"; then
+       AC_DEFINE(DEBUG,1,[Define to enable extra debugging code.])
+fi
+
+dnl override CFLAGS selection when debugging
+if test "${enable_debug}" = "yes"; then
+        CFLAGS="-g"
+        CXXFLAGS="-g"
+        FFLAGS="-g"
+fi
+
+dnl add gcc warnings, in debug/maintainer mode only
+if test "$enable_debug" = yes || test "$USE_MAINTAINER_MODE" = yes; then
+if test $ac_cv_prog_gcc = yes; then
+   if test "$ac_test_CFLAGS" != "set"; then
+      CFLAGS="$CFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wbad-function-cast -Wwrite-strings -Wstrict-prototypes -Wredundant-decls -Wnested-externs -Wundef -Wconversion -Wmissing-prototypes -Wmissing-declarations"
+   fi
+   if test "$ac_test_CXXFLAGS" != "set"; then
+      CXXFLAGS="$CXXFLAGS -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion"
+   fi
+   if test "x$with_cxx" = xyes; then
+      CFLAGS=$CXXFLAGS
+   fi
+fi
+fi
+
+vers=`echo ${VERSION}.0.0 | cut -d. -f1`
+AC_DEFINE_UNQUOTED(MAJOR_VERSION, $vers, [Major version number.])
+vers=`echo ${VERSION}.0.0 | cut -d. -f2`
+AC_DEFINE_UNQUOTED(MINOR_VERSION, $vers, [Minor version number.])
+vers=`echo ${VERSION}.0.0 | cut -d. -f3`
+AC_DEFINE_UNQUOTED(BUGFIX_VERSION, $vers, [Bugfix version number.])
+
+dnl -----------------------------------------------------------------------
+
+AC_CONFIG_FILES([
+   Makefile
+   nlopt.pc
+   api/Makefile
+   util/Makefile
+   octave/Makefile
+   direct/Makefile
+   cdirect/Makefile
+   stogo/Makefile
+   praxis/Makefile
+   luksan/Makefile
+   crs/Makefile
+   mlsl/Makefile
+   mma/Makefile
+   cobyla/Makefile
+   newuoa/Makefile
+   neldermead/Makefile
+   auglag/Makefile
+   bobyqa/Makefile
+   isres/Makefile
+   slsqp/Makefile
+   esch/Makefile
+   test/Makefile
+   swig/Makefile
+   swig/nlopt.scm
+])
+
+AC_OUTPUT
diff --git a/crs/Makefile.am b/crs/Makefile.am
new file mode 100644 (file)
index 0000000..14ff7cb
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libcrs.la
+libcrs_la_SOURCES = crs.c crs.h
+
+EXTRA_DIST = README
diff --git a/crs/Makefile.in b/crs/Makefile.in
new file mode 100644 (file)
index 0000000..f8266ee
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = crs
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcrs_la_LIBADD =
+am_libcrs_la_OBJECTS = crs.lo
+libcrs_la_OBJECTS = $(am_libcrs_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libcrs_la_SOURCES)
+DIST_SOURCES = $(libcrs_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libcrs.la
+libcrs_la_SOURCES = crs.c crs.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu crs/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu crs/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libcrs.la: $(libcrs_la_OBJECTS) $(libcrs_la_DEPENDENCIES) $(EXTRA_libcrs_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libcrs_la_OBJECTS) $(libcrs_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/crs/README b/crs/README
new file mode 100644 (file)
index 0000000..beaad8b
--- /dev/null
@@ -0,0 +1,19 @@
+This is my implementation of the "controlled random search" (CRS2) algorithm
+with the "local mutation" modification, as defined by:
+
+       P. Kaelo and M. M. Ali, "Some variants of the controlled random
+       search algorithm for global optimization," J. Optim. Theory Appl.
+       130 (2), 253-264 (2006).
+
+The original CRS2 algorithm was described by:
+
+       W. L. Price, "A controlled random search procedure for global
+       optimization," in Towards Global Optimization 2, p. 71-84
+       edited by L. C. W. Dixon and G. P. Szego (North-Holland Press,
+       Amsterdam, 1978).
+
+It is under the same MIT license as the rest of my code in NLopt (see
+../COPYRIGHT).
+
+Steven G. Johnson
+September 2007
diff --git a/crs/crs.c b/crs/crs.c
new file mode 100644 (file)
index 0000000..d6eb5e2
--- /dev/null
+++ b/crs/crs.c
@@ -0,0 +1,270 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "crs.h"
+#include "redblack.h"
+
+/* Controlled Random Search 2 (CRS2) with "local mutation", as defined
+   by:
+       P. Kaelo and M. M. Ali, "Some variants of the controlled random
+       search algorithm for global optimization," J. Optim. Theory Appl.
+       130 (2), 253-264 (2006).
+*/
+
+typedef struct {
+     int n; /* # dimensions */
+     const double *lb, *ub;
+     nlopt_stopping *stop; /* stopping criteria */
+     nlopt_func f; void *f_data;
+
+     int N; /* # points in population */
+     double *ps; /* population array N x (n+1) of tuples [f(x), x] */
+     double *p; /* single point array (length n+1), for temp use */
+     rb_tree t; /* red-black tree of population, sorted by f(x) */
+     nlopt_sobol s; /* sobol data for LDS point generation, or NULL
+                      to use pseudo-random numbers */
+} crs_data;
+
+/* sort order in red-black tree: keys [f(x), x] are sorted by f(x) */
+static int crs_compare(double *k1, double *k2)
+{
+     if (*k1 < *k2) return -1;
+     if (*k1 > *k2) return +1;
+     return k1 - k2; /* tie-breaker */
+}
+
+/* set x to a random trial value, as defined by CRS:
+     x = 2G - x_n, 
+   where x_0 ... x_n are distinct points in the population
+   with x_0 the current best point and the other points are random,
+   and G is the centroid of x_0...x_{n-1} */
+static void random_trial(crs_data *d, double *x, rb_node *best)
+{
+     int n = d->n, n1 = n+1, i, k, i0, jn;
+     double *ps = d->ps, *xi;
+
+     /* initialize x to x_0 = best point */
+     memcpy(x, best->k + 1, sizeof(double) * n);
+     i0 = (best->k - ps) / n1;
+
+     jn = nlopt_iurand(n); /* which of remaining n points is "x_n",
+                             i.e. which to reflect through ...
+                             this is necessary since we generate
+                             the remaining points in order, so
+                             just picking the last point would not
+                             be very random */
+
+     /* use "method A" from
+       
+           Jeffrey Scott Vitter, "An efficient algorithm for
+          sequential random sampling," ACM Trans. Math. Soft. 13 (1),
+          58--67 (1987).  
+
+        to randomly pick n distinct points out of the remaining N-1 (not 
+        including i0!).  (The same as "method S" in Knuth vol. 2.)
+        This method requires O(N) time, which is fine in our case
+        (there are better methods if n << N). */
+     {
+         int Nleft = d->N - 1, nleft = n;
+         int Nfree = Nleft - nleft;
+         i = 0; i += i == i0;
+         while (nleft > 1) {
+              double q = ((double) Nfree) / Nleft;
+              double v = nlopt_urand(0., 1.);
+              while (q > v) {
+                   ++i; i += i == i0;
+                   --Nfree; --Nleft;
+                   q = (q * Nfree) / Nleft;
+              }
+              xi = ps + n1 * i + 1;
+              if (jn-- == 0) /* point to reflect through */
+                   for (k = 0; k < n; ++k) x[k] -= xi[k] * (0.5*n);
+              else /* point to include in centroid */
+                   for (k = 0; k < n; ++k) x[k] += xi[k];
+              ++i; i += i == i0;
+              --Nleft; --nleft;
+         }
+         i += nlopt_iurand(Nleft); i += i == i0;
+         xi = ps + n1 * i + 1;
+         if (jn-- == 0) /* point to reflect through */
+              for (k = 0; k < n; ++k) x[k] -= xi[k] * (0.5*n);
+         else /* point to include in centroid */
+              for (k = 0; k < n; ++k) x[k] += xi[k];
+     }
+     for (k = 0; k < n; ++k) {
+         x[k] *= 2.0 / n; /* renormalize */
+         if (x[k] > d->ub[k]) x[k] = d->ub[k];
+         else if (x[k] < d->lb[k]) x[k] = d->lb[k];
+     }
+}
+
+#define NUM_MUTATION 1 /* # "local mutation" steps to try if trial fails */
+
+static nlopt_result crs_trial(crs_data *d)
+{
+     rb_node *best = rb_tree_min(&d->t);
+     rb_node *worst = rb_tree_max(&d->t);
+     int mutation = NUM_MUTATION;
+     int i, n = d->n;
+     random_trial(d, d->p + 1, best);
+     do {
+         d->p[0] = d->f(n, d->p + 1, NULL, d->f_data);
+         d->stop->nevals++;
+         if (nlopt_stop_forced(d->stop)) return NLOPT_FORCED_STOP;
+         if (d->p[0] < worst->k[0]) break;
+         if (nlopt_stop_evals(d->stop)) return NLOPT_MAXEVAL_REACHED;
+         if (nlopt_stop_time(d->stop)) return NLOPT_MAXTIME_REACHED;
+         if (mutation) {
+              for (i = 0; i < n; ++i) {
+                   double w = nlopt_urand(0.,1.);
+                   d->p[1+i] = best->k[1+i] * (1 + w) - w * d->p[1+i];
+                   if (d->p[1+i] > d->ub[i]) d->p[1+i] = d->ub[i];
+                   else if (d->p[1+i] < d->lb[i]) d->p[1+i] = d->lb[i];
+              }
+              mutation--;
+         }
+         else {
+              random_trial(d, d->p + 1, best);
+              mutation = NUM_MUTATION;
+         }
+     } while (1);
+     memcpy(worst->k, d->p, sizeof(double) * (n+1));
+     rb_tree_resort(&d->t, worst);
+     return NLOPT_SUCCESS;
+}
+
+static void crs_destroy(crs_data *d)
+{
+     nlopt_sobol_destroy(d->s);
+     rb_tree_destroy(&d->t);
+     free(d->ps);
+}
+
+static nlopt_result crs_init(crs_data *d, int n, const double *x,
+                            const double *lb, const double *ub,
+                            nlopt_stopping *stop, nlopt_func f, void *f_data,
+                            int population, int lds)
+{
+     int i;
+
+     if (!population) {
+         /* TODO: how should we set the default population size? 
+            the Kaelo and Ali paper suggests 10*(n+1), but should
+            we add more random points if maxeval is large, or... ? */
+         d->N = 10 * (n + 1); /* heuristic initial population size */
+     }
+     else
+         d->N = population;
+     if (d->N < n + 1) /* population must be big enough for a simplex */
+         return NLOPT_INVALID_ARGS;
+
+     d->n = n;
+     d->stop = stop;
+     d->f = f; d->f_data = f_data;
+     d->ub = ub; d->lb = lb;
+     d->ps = (double *) malloc(sizeof(double) * (n + 1) * (d->N + 1));
+     if (!d->ps) return NLOPT_OUT_OF_MEMORY;
+     d->p = d->ps + d->N * (n+1);
+     rb_tree_init(&d->t, crs_compare);
+
+     /* we can either use pseudorandom points, as in the original CRS
+       algorithm, or use a low-discrepancy Sobol' sequence ... I tried
+       the latter, however, and it doesn't seem to help, probably
+       because we are only generating a small number of random points
+       to start with */
+     d->s = lds ? nlopt_sobol_create((unsigned) n) : NULL;
+     nlopt_sobol_skip(d->s, (unsigned) d->N, d->ps + 1);
+
+     /* generate initial points randomly, plus starting guess x */
+     memcpy(d->ps + 1, x, sizeof(double) * n);
+     d->ps[0] = f(n, x, NULL, f_data);
+     stop->nevals++;
+     if (!rb_tree_insert(&d->t, d->ps)) return NLOPT_OUT_OF_MEMORY;
+     if (d->ps[0] < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+     if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+     if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+     for (i = 1; i < d->N; ++i) {
+         double *k = d->ps + i*(n+1);
+         if (d->s) 
+              nlopt_sobol_next(d->s, k + 1, lb, ub);
+         else {
+              int j;
+              for (j = 0; j < n; ++j) 
+                   k[1 + j] = nlopt_urand(lb[j], ub[j]);
+         }
+         k[0] = f(n, k + 1, NULL, f_data);
+         stop->nevals++;
+         if (!rb_tree_insert(&d->t, k)) return NLOPT_OUT_OF_MEMORY;
+         if (k[0] < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+         if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+         if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;        
+     }
+
+     return NLOPT_SUCCESS;;
+}
+
+nlopt_result crs_minimize(int n, nlopt_func f, void *f_data,
+                         const double *lb, const double *ub, /* bounds */
+                         double *x, /* in: initial guess, out: minimizer */
+                         double *minf,
+                         nlopt_stopping *stop,
+                         int population, /* initial population (0=default) */
+                         int lds) /* random or low-discrepancy seq. (lds) */
+{
+     nlopt_result ret;
+     crs_data d;
+     rb_node *best;
+
+     ret = crs_init(&d, n, x, lb, ub, stop, f, f_data, population, lds);
+     if (ret < 0) return ret;
+     
+     best = rb_tree_min(&d.t);
+     *minf = best->k[0];
+     memcpy(x, best->k + 1, sizeof(double) * n);
+
+     while (ret == NLOPT_SUCCESS) {
+         if (NLOPT_SUCCESS == (ret = crs_trial(&d))) {
+              best = rb_tree_min(&d.t);
+              if (best->k[0] < *minf) {
+                   if (best->k[0] < stop->minf_max)
+                        ret = NLOPT_MINF_MAX_REACHED;
+                   else if (nlopt_stop_f(stop, best->k[0], *minf))
+                        ret = NLOPT_FTOL_REACHED;
+                   else if (nlopt_stop_x(stop, best->k + 1, x))
+                        ret = NLOPT_XTOL_REACHED;
+                   *minf = best->k[0];
+                   memcpy(x, best->k + 1, sizeof(double) * n);
+              }
+              if (ret != NLOPT_SUCCESS) {
+                   if (nlopt_stop_evals(stop)) 
+                        ret = NLOPT_MAXEVAL_REACHED;
+                   else if (nlopt_stop_time(stop)) 
+                        ret = NLOPT_MAXTIME_REACHED;
+              }
+         }
+     }
+     crs_destroy(&d);
+     return ret;
+}
diff --git a/crs/crs.h b/crs/crs.h
new file mode 100644 (file)
index 0000000..f3e5b5a
--- /dev/null
+++ b/crs/crs.h
@@ -0,0 +1,47 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef CRS_H
+#define CRS_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result crs_minimize(int n, nlopt_func f, void *f_data,
+                         const double *lb, const double *ub, /* bounds */
+                         double *x, /* in: initial guess, out: minimizer */
+                         double *minf,
+                         nlopt_stopping *stop,
+                         int population, /* initial population (0=default) */
+                         int random); /* random or low-discrepancy seq. */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/depcomp b/depcomp
new file mode 100755 (executable)
index 0000000..4ebd5b3
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,791 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2013-05-30.07; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+    exit 1;
+    ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by 'PROGRAMS ARGS'.
+  object      Object file output by 'PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputting dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+# Get the directory component of the given path, and save it in the
+# global variables '$dir'.  Note that this directory component will
+# be either empty or ending with a '/' character.  This is deliberate.
+set_dir_from ()
+{
+  case $1 in
+    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
+      *) dir=;;
+  esac
+}
+
+# Get the suffix-stripped basename of the given path, and save it the
+# global variable '$base'.
+set_base_from ()
+{
+  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
+}
+
+# If no dependency file was actually created by the compiler invocation,
+# we still have to create a dummy depfile, to avoid errors with the
+# Makefile "include basename.Plo" scheme.
+make_dummy_depfile ()
+{
+  echo "#dummy" > "$depfile"
+}
+
+# Factor out some common post-processing of the generated depfile.
+# Requires the auxiliary global variable '$tmpdepfile' to be set.
+aix_post_process_depfile ()
+{
+  # If the compiler actually managed to produce a dependency file,
+  # post-process it.
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form 'foo.o: dependency.h'.
+    # Do two passes, one to just change these to
+    #   $object: dependency.h
+    # and one to simply output
+    #   dependency.h:
+    # which is needed to avoid the deleted-header problem.
+    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
+      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
+    } > "$depfile"
+    rm -f "$tmpdepfile"
+  else
+    make_dummy_depfile
+  fi
+}
+
+# A tabulation character.
+tab='  '
+# A newline character.
+nl='
+'
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Avoid interferences from the environment.
+gccflag= dashmflag=
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+  # This is just like dashmstdout with a different argument.
+  dashmflag=-xM
+  depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+  # This is just like msvisualcpp but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvisualcpp
+fi
+
+if test "$depmode" = msvc7msys; then
+  # This is just like msvc7 but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvc7
+fi
+
+if test "$depmode" = xlc; then
+  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
+  gccflag=-qmakedep=gcc,-MF
+  depmode=gcc
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## (see the conditional assignment to $gccflag above).
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).  Also, it might not be
+##   supported by the other compilers which use the 'gcc' depmode.
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  # The second -e expression handles DOS-style file names with drive
+  # letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the "deleted header file" problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+## Some versions of gcc put a space before the ':'.  On the theory
+## that the space means something, we add a space to the output as
+## well.  hp depmode also adds that space, but also prefixes the VPATH
+## to the object.  Take care to not repeat it in the output.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like '#:fec' to the end of the
+    # dependency line.
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
+      | tr "$nl" ' ' >> "$depfile"
+    echo >> "$depfile"
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+      >> "$depfile"
+  else
+    make_dummy_depfile
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+xlc)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts '$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  set_dir_from "$object"
+  set_base_from "$object"
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  aix_post_process_depfile
+  ;;
+
+tcc)
+  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
+  # FIXME: That version still under development at the moment of writing.
+  #        Make that this statement remains true also for stable, released
+  #        versions.
+  # It will wrap lines (doesn't matter whether long or short) with a
+  # trailing '\', as in:
+  #
+  #   foo.o : \
+  #    foo.c \
+  #    foo.h \
+  #
+  # It will put a trailing '\' even on the last line, and will use leading
+  # spaces rather than leading tabs (at least since its commit 0394caf7
+  # "Emit spaces for -MD").
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
+  # We have to change lines of the first kind to '$object: \'.
+  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
+  # And for each line of the second kind, we have to emit a 'dep.h:'
+  # dummy dependency, to avoid the deleted-header problem.
+  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file.  A plain '-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+  # Portland's C compiler understands '-MD'.
+  # Will always output deps to 'file.d' where file is the root name of the
+  # source file under compilation, even if file resides in a subdirectory.
+  # The object file name does not affect the name of the '.d' file.
+  # pgcc 10.2 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using '\' :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+  set_dir_from "$object"
+  # Use the source, not the object, to determine the base name, since
+  # that's sadly what pgcc will do too.
+  set_base_from "$source"
+  tmpdepfile=$base.d
+
+  # For projects that build the same source file twice into different object
+  # files, the pgcc approach of using the *source* file root name can cause
+  # problems in parallel builds.  Use a locking strategy to avoid stomping on
+  # the same $tmpdepfile.
+  lockdir=$base.d-lock
+  trap "
+    echo '$0: caught signal, cleaning up...' >&2
+    rmdir '$lockdir'
+    exit 1
+  " 1 2 13 15
+  numtries=100
+  i=$numtries
+  while test $i -gt 0; do
+    # mkdir is a portable test-and-set.
+    if mkdir "$lockdir" 2>/dev/null; then
+      # This process acquired the lock.
+      "$@" -MD
+      stat=$?
+      # Release the lock.
+      rmdir "$lockdir"
+      break
+    else
+      # If the lock is being held by a different process, wait
+      # until the winning process is done or we timeout.
+      while test -d "$lockdir" && test $i -gt 0; do
+        sleep 1
+        i=`expr $i - 1`
+      done
+    fi
+    i=`expr $i - 1`
+  done
+  trap - 1 2 13 15
+  if test $i -le 0; then
+    echo "$0: failed to acquire lock after $numtries attempts" >&2
+    echo "$0: check lockdir '$lockdir'" >&2
+    exit 1
+  fi
+
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
+    | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  set_dir_from  "$object"
+  set_base_from "$object"
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -ne 0; then
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add 'dependent.h:' lines.
+    sed -ne '2,${
+               s/^ *//
+               s/ \\*$//
+               s/$/:/
+               p
+             }' "$tmpdepfile" >> "$depfile"
+  else
+    make_dummy_depfile
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+  # The Tru64 compiler uses -MD to generate dependencies as a side
+  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
+  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+  # dependencies in 'foo.d' instead, so we check for that too.
+  # Subdirectories are respected.
+  set_dir_from  "$object"
+  set_base_from "$object"
+
+  if test "$libtool" = yes; then
+    # Libtool generates 2 separate objects for the 2 libraries.  These
+    # two compilations output dependencies in $dir.libs/$base.o.d and
+    # in $dir$base.o.d.  We have to check for both files, because
+    # one of the two compilations can be disabled.  We should prefer
+    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+    # automatically cleaned when .libs/ is deleted, while ignoring
+    # the former would cause a distcleancheck panic.
+    tmpdepfile1=$dir$base.o.d          # libtool 1.5
+    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
+    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
+    "$@" -Wc,-MD
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    tmpdepfile3=$dir$base.d
+    "$@" -MD
+  fi
+
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  # Same post-processing that is required for AIX mode.
+  aix_post_process_depfile
+  ;;
+
+msvc7)
+  if test "$libtool" = yes; then
+    showIncludes=-Wc,-showIncludes
+  else
+    showIncludes=-showIncludes
+  fi
+  "$@" $showIncludes > "$tmpdepfile"
+  stat=$?
+  grep -v '^Note: including file: ' "$tmpdepfile"
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  # The first sed program below extracts the file names and escapes
+  # backslashes for cygpath.  The second sed program outputs the file
+  # name when reading, but also accumulates all include files in the
+  # hold buffer in order to output them again at the end.  This only
+  # works with sed implementations that can handle large buffers.
+  sed < "$tmpdepfile" -n '
+/^Note: including file:  *\(.*\)/ {
+  s//\1/
+  s/\\/\\\\/g
+  p
+}' | $cygpath_u | sort -u | sed -n '
+s/ /\\ /g
+s/\(.*\)/'"$tab"'\1 \\/p
+s/.\(.*\) \\/\1:/
+H
+$ {
+  s/.*/'"$tab"'/
+  G
+  p
+}' >> "$depfile"
+  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
+  rm -f "$tmpdepfile"
+  ;;
+
+msvc7msys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove '-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for ':'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
+  "$@" $dashmflag |
+    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this sed invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  # makedepend may prepend the VPATH from the source file name to the object.
+  # No need to regex-escape $object, excess matching of '.' is harmless.
+  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process the last invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed '1,2d' "$tmpdepfile" \
+    | tr ' ' "$nl" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove '-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E \
+    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+    | sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+        set fnord "$@"
+        shift
+        shift
+        ;;
+    *)
+        set fnord "$@" "$arg"
+        shift
+        shift
+        ;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+  echo "$tab" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/direct/AUTHORS b/direct/AUTHORS
new file mode 100644 (file)
index 0000000..b676a64
--- /dev/null
@@ -0,0 +1,2 @@
+C conversion: Steven G. Johnson (stevenj@alum.mit.edu)
+Original Fortran code: Joerg.M.Gablonsky (jmgablon@mailandnews.com)
diff --git a/direct/COPYING b/direct/COPYING
new file mode 100644 (file)
index 0000000..4b4a9c3
--- /dev/null
@@ -0,0 +1,28 @@
+This code is based on the DIRECT 2.0.4 Fortran code by Gablonsky et al. at
+       http://www4.ncsu.edu/~ctk/SOFTWARE/DIRECTv204.tar.gz
+The C version was initially converted via f2c and then cleaned up and
+reorganized by Steven G. Johnson (stevenj@alum.mit.edu), August 2007.
+
+******** Copyright and license for the original Fortran DIRECT code ********
+Copyright (c) 1999, 2000, 2001 North Carolina State University
+
+This program is distributed under the MIT License (see
+http://www.opensource.org/licenses/mit-license.php):
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/direct/DIRect.c b/direct/DIRect.c
new file mode 100644 (file)
index 0000000..f0a7c1a
--- /dev/null
@@ -0,0 +1,770 @@
+/* DIRect-transp.f -- translated by f2c (version 20050501).
+   
+   f2c output hand-cleaned by SGJ (August 2007). 
+*/
+
+#include <math.h>
+#include "direct-internal.h"
+
+/* Common Block Declarations */
+
+/* Table of constant values */
+
+/* +-----------------------------------------------------------------------+ */
+/* | Program       : Direct.f                                              | */
+/* | Last modified : 07-16-2001                                            | */
+/* | Written by    : Joerg Gablonsky (jmgablon@unity.ncsu.edu)             | */
+/* |                 North Carolina State University                       | */
+/* |                 Dept. of Mathematics                                  | */
+/* | DIRECT is a method to solve problems of the form:                     | */
+/* |              min f: Q --> R,                                          | */
+/* | where f is the function to be minimized and Q is an n-dimensional     | */
+/* | hyperrectangle given by the the following equation:                   | */
+/* |                                                                       | */
+/* |       Q={ x : l(i) <= x(i) <= u(i), i = 1,...,n }.                    | */
+/* | Note: This version of DIRECT can also handle hidden constraints. By   | */
+/* |       this we mean that the function may not be defined over the whole| */
+/* |       hyperrectangle Q, but only over a subset, which is not given    | */
+/* |       analytically.                                                   | */
+/* |                                                                       | */
+/* | We now give a brief outline of the algorithm:                         | */
+/* |                                                                       | */
+/* |   The algorithm starts with mapping the hyperrectangle Q to the       | */
+/* |   n-dimensional unit hypercube. DIRECT then samples the function at   | */
+/* |   the center of this hypercube and at 2n more points, 2 in each       | */
+/* |   coordinate direction. Uisng these function values, DIRECT then      | */
+/* |   divides the domain into hyperrectangles, each having exactly one of | */
+/* |   the sampling points as its center. In each iteration, DIRECT chooses| */
+/* |   some of the existing hyperrectangles to be further divided.         | */
+/* |   We provide two different strategies of how to decide which          | */
+/* |   hyperrectangles DIRECT divides and several different convergence    | */
+/* |   criteria.                                                           | */
+/* |                                                                       | */
+/* |   DIRECT was designed to solve problems where the function f is       | */
+/* |   Lipschitz continues. However, DIRECT has proven to be effective on  | */
+/* |   more complex problems than these.                                   | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_direct_(fp fcn, doublereal *x, integer *n, doublereal *eps, doublereal epsabs, integer *maxf, integer *maxt, double starttime, double maxtime, int *force_stop, doublereal *minf, doublereal *l, 
+       doublereal *u, integer *algmethod, integer *ierror, FILE *logfile, 
+       doublereal *fglobal, doublereal *fglper, doublereal *volper, 
+       doublereal *sigmaper, void *fcn_data)
+{
+    /* System generated locals */
+    integer i__1, i__2;
+    doublereal d__1;
+
+    /* changed by SGJ to be dynamically allocated ... would be
+       even better to use realloc, below, to grow these as needed */
+    integer MAXFUNC = *maxf <= 0 ? 101000 : (*maxf + 1000 + *maxf / 2);
+    integer MAXDEEP = *maxt <= 0 ? MAXFUNC/5: *maxt + 1000;
+    const integer MAXDIV = 5000;
+
+    /* Local variables */
+    integer increase;
+    doublereal *c__ = 0        /* was [90000][64] */, *f = 0   /* 
+           was [90000][2] */;
+    integer i__, j, *s = 0     /* was [3000][2] */, t;
+    doublereal *w = 0;
+    doublereal divfactor;
+    integer ifeasiblef, iepschange, actmaxdeep;
+    integer actdeep_div__, iinfesiblef;
+    integer pos1, newtosample;
+    integer ifree, help;
+    doublereal *oldl = 0, fmax;
+    integer maxi;
+    doublereal kmax, *oldu = 0;
+    integer oops, *list2 = 0   /* was [64][2] */, cheat;
+    doublereal delta;
+    integer mdeep, *point = 0, start;
+    integer *anchor = 0, *length = 0   /* was [90000][64] */, *arrayi = 0;
+    doublereal *levels = 0, *thirds = 0;
+    integer writed;
+    doublereal epsfix;
+    integer oldpos, minpos, maxpos, tstart, actdeep, ifreeold, oldmaxf;
+    integer numfunc, version;
+    integer jones;
+
+    /* FIXME: change sizes dynamically? */
+#define MY_ALLOC(p, t, n) p = (t *) malloc(sizeof(t) * (n)); \
+                          if (!(p)) { *ierror = -100; goto cleanup; }
+
+    /* Note that I've transposed c__, length, and f relative to the 
+       original Fortran code.  e.g. length was length(maxfunc,n) 
+       in Fortran [ or actually length(maxfunc, maxdims), but by
+       using malloc I can just allocate n ], corresponding to
+       length[n][maxfunc] in C, but I've changed the code to access
+       it as length[maxfunc][n].  That is, the maxfunc direction
+       is the discontiguous one.  This makes it easier to resize
+       dynamically (by adding contiguous rows) using realloc, without
+       having to move data around manually. */
+    MY_ALLOC(c__, doublereal, MAXFUNC * (*n));
+    MY_ALLOC(length, integer, MAXFUNC * (*n));
+    MY_ALLOC(f, doublereal, MAXFUNC * 2);
+    MY_ALLOC(point, integer, MAXFUNC);
+    if (*maxf <= 0) *maxf = MAXFUNC - 1000;
+
+    MY_ALLOC(s, integer, MAXDIV * 2);
+
+    MY_ALLOC(anchor, integer, MAXDEEP + 2);
+    MY_ALLOC(levels, doublereal, MAXDEEP + 1);
+    MY_ALLOC(thirds, doublereal, MAXDEEP + 1);    
+    if (*maxt <= 0) *maxt = MAXDEEP;
+
+    MY_ALLOC(w, doublereal, (*n));
+    MY_ALLOC(oldl, doublereal, (*n));
+    MY_ALLOC(oldu, doublereal, (*n));
+    MY_ALLOC(list2, integer, (*n) * 2);
+    MY_ALLOC(arrayi, integer, (*n));
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE Direct                                                  | */
+/* | On entry                                                              | */
+/* |     fcn -- The argument containing the name of the user-supplied      | */
+/* |            SUBROUTINE that returns values for the function to be      | */
+/* |            minimized.                                                 | */
+/* |       n -- The dimension of the problem.                              | */
+/* |     eps -- Exceeding value. If eps > 0, we use the same epsilon for   | */
+/* |            all iterations. If eps < 0, we use the update formula from | */
+/* |            Jones:                                                     | */
+/* |               eps = max(1.D-4*abs(minf),epsfix),                      | */
+/* |            where epsfix = abs(eps), the absolute value of eps which is| */
+/* |            passed to the function.                                    | */
+/* |    maxf -- The maximum number of function evaluations.                | */
+/* |    maxT -- The maximum number of iterations.                          | */
+/* |            Direct stops when either the maximum number of iterations  | */
+/* |            is reached or more than maxf function-evalutions were made.| */
+/* |       l -- The lower bounds of the hyperbox.                          | */
+/* |       u -- The upper bounds of the hyperbox.                          | */
+/* |algmethod-- Choose the method, that is either use the original method  | */
+/* |            as described by Jones et.al. (0) or use our modification(1)| */
+/* | logfile -- File-Handle for the logfile. DIRECT expects this file to be| */
+/* |            opened and closed by the user outside of DIRECT. We moved  | */
+/* |            this to the outside so the user can add extra informations | */
+/* |            to this file before and after the call to DIRECT.          | */
+/* | fglobal -- Function value of the global optimum. If this value is not | */
+/* |            known (that is, we solve a real problem, not a testproblem)| */
+/* |            set this value to -1.D100 and fglper (see below) to 0.D0.  | */
+/* |  fglper -- Terminate the optimization when the percent error          | */
+/* |                100(f_min - fglobal)/max(1,abs(fglobal)) < fglper.     | */
+/* |  volper -- Terminate the optimization when the volume of the          | */
+/* |            hyperrectangle S with f(c(S)) = minf is less then volper   | */
+/* |            percent of the volume of the original hyperrectangle.      | */
+/* |sigmaper -- Terminate the optimization when the measure of the         | */
+/* |            hyperrectangle S with f(c(S)) = minf is less then sigmaper.| */
+/* |                                                                       | */
+/* | User data that is passed through without being changed:               | */
+/* |  fcn_data - opaque pointer to any user data                           | */
+/* |                                                                       | */
+/* | On return                                                             | */
+/* |                                                                       | */
+/* |       x -- The final point obtained in the optimization process.      | */
+/* |            X should be a good approximation to the global minimum     | */
+/* |            for the function within the hyper-box.                     | */
+/* |                                                                       | */
+/* |    minf -- The value of the function at x.                            | */
+/* |  Ierror -- Error flag. If Ierror is lower 0, an error has occured. The| */
+/* |            values of Ierror mean                                      | */
+/* |            Fatal errors :                                             | */
+/* |             -1   u(i) <= l(i) for some i.                             | */
+/* |             -2   maxf is too large.                                   | */
+/* |             -3   Initialization in DIRpreprc failed.                  | */
+/* |             -4   Error in DIRSamplepoints, that is there was an error | */
+/* |                  in the creation of the sample points.                | */
+/* |             -5   Error in DIRSamplef, that is an error occured while  | */
+/* |                  the function was sampled.                            | */
+/* |             -6   Error in DIRDoubleInsert, that is an error occured   | */
+/* |                  DIRECT tried to add all hyperrectangles with the same| */
+/* |                  size and function value at the center. Either        | */
+/* |                  increase maxdiv or use our modification (Jones = 1). | */
+/* |            Termination values :                                       | */
+/* |              1   Number of function evaluations done is larger then   | */
+/* |                  maxf.                                                | */
+/* |              2   Number of iterations is equal to maxT.               | */
+/* |              3   The best function value found is within fglper of    | */
+/* |                  the (known) global optimum, that is                  | */
+/* |                   100(minf - fglobal/max(1,|fglobal|))  < fglper.     | */
+/* |                  Note that this termination signal only occurs when   | */
+/* |                  the global optimal value is known, that is, a test   | */
+/* |                  function is optimized.                               | */
+/* |              4   The volume of the hyperrectangle with minf at its    | */
+/* |                  center is less than volper percent of the volume of  | */
+/* |                  the original hyperrectangle.                         | */
+/* |              5   The measure of the hyperrectangle with minf at its   | */
+/* |                  center is less than sigmaper.                        | */
+/* |                                                                       | */
+/* | SUBROUTINEs used :                                                    | */
+/* |                                                                       | */
+/* | DIRheader, DIRInitSpecific, DIRInitList, DIRpreprc, DIRInit, DIRChoose| */
+/* | DIRDoubleInsert, DIRGet_I, DIRSamplepoints, DIRSamplef, DIRDivide     | */
+/* | DIRInsertList, DIRreplaceInf, DIRWritehistbox, DIRsummary, Findareas  | */
+/* |                                                                       | */
+/* | Functions used :                                                      | */
+/* |                                                                       | */
+/* | DIRgetMaxdeep, DIRgetlevel                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Parameters                                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | The maximum of function evaluations allowed.                          | */
+/* | The maximum dept of the algorithm.                                    | */
+/* | The maximum number of divisions allowed.                              | */
+/* | The maximal dimension of the problem.                                 | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Global Variables.                                                     | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | EXTERNAL Variables.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | User Variables.                                                       | */
+/* | These can be used to pass user defined data to the function to be     | */
+/* | optimized.                                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Place to define, if needed, some application-specific variables.      | */
+/* | Note: You should try to use the arrays defined above for this.        | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | End of application - specific variables !                             | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Internal variables :                                                  | */
+/* |       f -- values of functions.                                       | */
+/* |divfactor-- Factor used for termination with known global minimum.     | */
+/* |  anchor -- anchors of lists with deepness i, -1 is anchor for list of | */
+/* |            NaN - values.                                              | */
+/* |       S -- List of potentially optimal points.                        | */
+/* |   point -- lists                                                      | */
+/* |    ifree -- first free position                                        | */
+/* |       c -- midpoints of arrays                                        | */
+/* |  thirds -- Precalculated values of 1/3^i.                             | */
+/* |  levels -- Length of intervals.                                       | */
+/* |  length -- Length of intervall (index)                                | */
+/* |       t -- actual iteration                                           | */
+/* |       j -- loop-variable                                              | */
+/* | actdeep -- the actual minimal interval-length index                   | */
+/* |  Minpos -- position of the actual minimum                             | */
+/* |    file -- The filehandle for a datafile.                             | */
+/* |  maxpos -- The number of intervalls, which are truncated.             | */
+/* |    help -- A help variable.                                           | */
+/* | numfunc -- The actual number of function evaluations.                 | */
+/* |   file2 -- The filehandle for an other datafile.                      | */
+/* |  ArrayI -- Array with the indexes of the sides with maximum length.   | */
+/* |    maxi -- Number of directions with maximal side length.             | */
+/* |    oops -- Flag which shows if anything went wrong in the             | */
+/* |            initialisation.                                            | */
+/* |   cheat -- Obsolete. If equal 1, we don't allow Ktilde > kmax.        | */
+/* |  writed -- If writed=1, store final division to plot with Matlab.     | */
+/* |   List2 -- List of indicies of intervalls, which are to be truncated. | */
+/* |       i -- Another loop-variable.                                     | */
+/* |actmaxdeep-- The actual maximum (minimum) of possible Interval length. | */
+/* |  oldpos -- The old index of the minimum. Used to print only, if there | */
+/* |            is a new minimum found.                                    | */
+/* |  tstart -- The start of the outer loop.                               | */
+/* |   start -- The postion of the starting point in the inner loop.       | */
+/* | Newtosample -- The total number of points to sample in the inner loop.| */
+/* |       w -- Array used to divide the intervalls                        | */
+/* |    kmax -- Obsolete. If cheat = 1, Ktilde was not allowed to be larger| */
+/* |            than kmax. If Ktilde > kmax, we set ktilde = kmax.         | */
+/* |   delta -- The distance to new points from center of old hyperrec.    | */
+/* |    pos1 -- Help variable used as an index.                            | */
+/* | version -- Store the version number of DIRECT.                        | */
+/* | oldmaxf -- Store the original function budget.                        | */
+/* |increase -- Flag used to keep track if function budget was increased   | */
+/* |            because no feasible point was found.                       | */
+/* | ifreeold -- Keep track which index was free before. Used with          | */
+/* |            SUBROUTINE DIRReplaceInf.                                  | */
+/* |actdeep_div-- Keep track of the current depths for divisions.          | */
+/* |    oldl -- Array used to store the original bounds of the domain.     | */
+/* |    oldu -- Array used to store the original bounds of the domain.     | */
+/* |  epsfix -- If eps < 0, we use Jones update formula. epsfix stores the | */
+/* |            absolute value of epsilon.                                 | */
+/* |iepschange-- flag iepschange to store if epsilon stays fixed or is     | */
+/* |             changed.                                                  | */
+/* |DIRgetMaxdeep-- Function to calculate the level of a hyperrectangle.   | */
+/* |DIRgetlevel-- Function to calculate the level and stage of a hyperrec. | */
+/* |    fmax -- Keep track of the maximum value of the function found.     | */
+/* |Ifeasiblef-- Keep track if a feasible point has  been found so far.    | */
+/* |             Ifeasiblef = 0 means a feasible point has been found,     | */
+/* |             Ifeasiblef = 1 no feasible point has been found.          | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 09/25/00 Version counter.                                          | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 09/24/00 Add another actdeep to keep track of the current depths   | */
+/* |             for divisions.                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* |JG 01/13/01 Added epsfix for epsilon update. If eps < 0, we use Jones  | */
+/* |            update formula. epsfix stores the absolute value of epsilon| */
+/* |            then. Also added flag iepschange to store if epsilon stays | */
+/* |            fixed or is changed.                                       | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 fmax is used to keep track of the maximum value found.    | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Ifeasiblef is used to keep track if a feasible point has  | */
+/* |             been found so far. Ifeasiblef = 0 means a feasible point  | */
+/* |             has been found, Ifeasiblef = 1 if not.                    | */
+/* | JG 03/09/01 IInfeasible is used to keep track if an infeasible point  | */
+/* |             has been found. IInfeasible > 0 means a infeasible point  | */
+/* |             has been found, IInfeasible = 0 if not.                   | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* |                            Start of code.                             | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+
+    /* Function Body */
+    writed = 0;
+    jones = *algmethod;
+/* +-----------------------------------------------------------------------+ */
+/* | Save the upper and lower bounds.                                      | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       oldu[i__ - 1] = u[i__];
+       oldl[i__ - 1] = l[i__];
+/* L150: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Set version.                                                          | */
+/* +-----------------------------------------------------------------------+ */
+    version = 204;
+/* +-----------------------------------------------------------------------+ */
+/* | Set parameters.                                                       | */
+/* |    If cheat > 0, we do not allow \tilde{K} to be larger than kmax, and| */
+/* |    set \tilde{K} to set value if necessary. Not used anymore.         | */
+/* +-----------------------------------------------------------------------+ */
+    cheat = 0;
+    kmax = 1e10;
+    mdeep = MAXDEEP;
+/* +-----------------------------------------------------------------------+ */
+/* | Write the header of the logfile.                                      | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirheader_(logfile, &version, &x[1], n, eps, maxf, maxt, &l[1], &u[1], 
+           algmethod, &MAXFUNC, &MAXDEEP, fglobal, fglper, ierror, &epsfix, &
+                     iepschange, volper, sigmaper);
+/* +-----------------------------------------------------------------------+ */
+/* | If an error has occured while writing the header (we do some checking | */
+/* | of variables there), return to the main program.                      | */
+/* +-----------------------------------------------------------------------+ */
+    if (*ierror < 0) {
+       goto cleanup;
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | If the known global minimum is equal 0, we cannot divide by it.       | */
+/* | Therefore we set it to 1. If not, we set the divisionfactor to the    | */
+/* | absolute value of the global minimum.                                 | */
+/* +-----------------------------------------------------------------------+ */
+    if (*fglobal == 0.) {
+       divfactor = 1.;
+    } else {
+       divfactor = fabs(*fglobal);
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Save the budget given by the user. The variable maxf will be changed  | */
+/* | if in the beginning no feasible points are found.                     | */
+/* +-----------------------------------------------------------------------+ */
+    oldmaxf = *maxf;
+    increase = 0;
+/* +-----------------------------------------------------------------------+ */
+/* | Initialiase the lists.                                                | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirinitlist_(anchor, &ifree, point, f, &MAXFUNC, &MAXDEEP);
+/* +-----------------------------------------------------------------------+ */
+/* | Call the routine to initialise the mapping of x from the n-dimensional| */
+/* | unit cube to the hypercube given by u and l. If an error occured,     | */
+/* | give out a error message and return to the main program with the error| */
+/* | flag set.                                                             | */
+/* | JG 07/16/01 Changed call to remove unused data.                       | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirpreprc_(&u[1], &l[1], n, &l[1], &u[1], &oops);
+    if (oops > 0) {
+       if (logfile)
+            fprintf(logfile,"WARNING: Initialization in DIRpreprc failed.\n");
+       *ierror = -3;
+       goto cleanup;
+    }
+    tstart = 2;
+/* +-----------------------------------------------------------------------+ */
+/* | Initialise the algorithm DIRECT.                                      | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Added variable to keep track of the maximum value found.              | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirinit_(f, fcn, c__, length, &actdeep, point, anchor, &ifree,
+           logfile, arrayi, &maxi, list2, w, &x[1], &l[1], &u[1], 
+           minf, &minpos, thirds, levels, &MAXFUNC, &MAXDEEP, n, n, &
+           fmax, &ifeasiblef, &iinfesiblef, ierror, fcn_data, jones,
+                   starttime, maxtime, force_stop);
+/* +-----------------------------------------------------------------------+ */
+/* | Added error checking.                                                 | */
+/* +-----------------------------------------------------------------------+ */
+    if (*ierror < 0) {
+       if (*ierror == -4) {
+           if (logfile)
+                fprintf(logfile, "WARNING: Error occured in routine DIRsamplepoints.\n");
+           goto cleanup;
+       }
+       if (*ierror == -5) {
+           if (logfile)
+                fprintf(logfile, "WARNING: Error occured in routine DIRsamplef..\n");
+           goto cleanup;
+       }
+       if (*ierror == -102) goto L100;
+    }
+    else if (*ierror == DIRECT_MAXTIME_EXCEEDED) goto L100;
+    numfunc = maxi + 1 + maxi;
+    actmaxdeep = 1;
+    oldpos = 0;
+    tstart = 2;
+/* +-----------------------------------------------------------------------+ */
+/* | If no feasible point has been found, give out the iteration, the      | */
+/* | number of function evaluations and a warning. Otherwise, give out     | */
+/* | the iteration, the number of function evaluations done and minf.      | */
+/* +-----------------------------------------------------------------------+ */
+    if (ifeasiblef > 0) {
+        if (logfile)
+             fprintf(logfile, "No feasible point found in %d iterations "
+                     "and %d function evaluations.\n", tstart-1, numfunc);
+    } else {
+        if (logfile)
+             fprintf(logfile, "%d, %d, %g, %g\n", 
+                     tstart-1, numfunc, *minf, fmax);
+    }
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Main loop!                                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *maxt;
+    for (t = tstart; t <= i__1; ++t) {
+/* +-----------------------------------------------------------------------+ */
+/* | Choose the sample points. The indices of the sample points are stored | */
+/* | in the list S.                                                        | */
+/* +-----------------------------------------------------------------------+ */
+       actdeep = actmaxdeep;
+       direct_dirchoose_(anchor, s, &MAXDEEP, f, minf, *eps, epsabs, levels, &maxpos, length, 
+               &MAXFUNC, &MAXDEEP, &MAXDIV, n, logfile, &cheat, &
+               kmax, &ifeasiblef, jones);
+/* +-----------------------------------------------------------------------+ */
+/* | Add other hyperrectangles to S, which have the same level and the same| */
+/* | function value at the center as the ones found above (that are stored | */
+/* | in S). This is only done if we use the original DIRECT algorithm.     | */
+/* | JG 07/16/01 Added Errorflag.                                          | */
+/* +-----------------------------------------------------------------------+ */
+       if (*algmethod == 0) {
+            direct_dirdoubleinsert_(anchor, s, &maxpos, point, f, &MAXDEEP, &MAXFUNC,
+                    &MAXDIV, ierror);
+           if (*ierror == -6) {
+               if (logfile)
+                    fprintf(logfile,
+"WARNING: Capacity of array S in DIRDoubleInsert reached. Increase maxdiv.\n"
+"This means that there are a lot of hyperrectangles with the same function\n"
+"value at the center. We suggest to use our modification instead (Jones = 1)\n"
+                         );
+               goto cleanup;
+           }
+       }
+       oldpos = minpos;
+/* +-----------------------------------------------------------------------+ */
+/* | Initialise the number of sample points in this outer loop.            | */
+/* +-----------------------------------------------------------------------+ */
+       newtosample = 0;
+       i__2 = maxpos;
+       for (j = 1; j <= i__2; ++j) {
+           actdeep = s[j + MAXDIV-1];
+/* +-----------------------------------------------------------------------+ */
+/* | If the actual index is a point to sample, do it.                      | */
+/* +-----------------------------------------------------------------------+ */
+           if (s[j - 1] > 0) {
+/* +-----------------------------------------------------------------------+ */
+/* | JG 09/24/00 Calculate the value delta used for sampling points.       | */
+/* +-----------------------------------------------------------------------+ */
+               actdeep_div__ = direct_dirgetmaxdeep_(&s[j - 1], length, &MAXFUNC, 
+                       n);
+               delta = thirds[actdeep_div__ + 1];
+               actdeep = s[j + MAXDIV-1];
+/* +-----------------------------------------------------------------------+ */
+/* | If the current dept of division is only one under the maximal allowed | */
+/* | dept, stop the computation.                                           | */
+/* +-----------------------------------------------------------------------+ */
+               if (actdeep + 1 >= mdeep) {
+                   if (logfile)
+                        fprintf(logfile, "WARNING: Maximum number of levels reached. Increase maxdeep.\n");
+                   *ierror = -6;
+                   goto L100;
+               }
+               actmaxdeep = MAX(actdeep,actmaxdeep);
+               help = s[j - 1];
+               if (! (anchor[actdeep + 1] == help)) {
+                   pos1 = anchor[actdeep + 1];
+                   while(! (point[pos1 - 1] == help)) {
+                       pos1 = point[pos1 - 1];
+                   }
+                   point[pos1 - 1] = point[help - 1];
+               } else {
+                   anchor[actdeep + 1] = point[help - 1];
+               }
+               if (actdeep < 0) {
+                   actdeep = (integer) f[(help << 1) - 2];
+               }
+/* +-----------------------------------------------------------------------+ */
+/* | Get the Directions in which to decrease the intervall-length.         | */
+/* +-----------------------------------------------------------------------+ */
+               direct_dirget_i__(length, &help, arrayi, &maxi, n, &MAXFUNC);
+/* +-----------------------------------------------------------------------+ */
+/* | Sample the function. To do this, we first calculate the points where  | */
+/* | we need to sample the function. After checking for errors, we then do | */
+/* | the actual evaluation of the function, again followed by checking for | */
+/* | errors.                                                               | */
+/* +-----------------------------------------------------------------------+ */
+               direct_dirsamplepoints_(c__, arrayi, &delta, &help, &start, length, 
+                       logfile, f, &ifree, &maxi, point, &x[
+                       1], &l[1], minf, &minpos, &u[1], n, &MAXFUNC, &
+                       MAXDEEP, &oops);
+               if (oops > 0) {
+                   if (logfile)
+                        fprintf(logfile, "WARNING: Error occured in routine DIRsamplepoints.\n");
+                   *ierror = -4;
+                   goto cleanup;
+               }
+               newtosample += maxi;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+               direct_dirsamplef_(c__, arrayi, &delta, &help, &start, length,
+                           logfile, f, &ifree, &maxi, point, fcn, &x[
+                       1], &l[1], minf, &minpos, &u[1], n, &MAXFUNC, &
+                       MAXDEEP, &oops, &fmax, &ifeasiblef, &iinfesiblef, 
+                                  fcn_data, force_stop);
+               if (force_stop && *force_stop) {
+                    *ierror = -102;
+                    goto L100;
+               }
+               if (nlopt_stop_time_(starttime, maxtime)) {
+                    *ierror = DIRECT_MAXTIME_EXCEEDED;
+                    goto L100;
+               }
+               if (oops > 0) {
+                   if (logfile)
+                        fprintf(logfile, "WARNING: Error occured in routine DIRsamplef.\n");
+                   *ierror = -5;
+                   goto cleanup;
+               }
+/* +-----------------------------------------------------------------------+ */
+/* | Divide the intervalls.                                                | */
+/* +-----------------------------------------------------------------------+ */
+               direct_dirdivide_(&start, &actdeep_div__, length, point, arrayi, &
+                       help, list2, w, &maxi, f, &MAXFUNC, &MAXDEEP, n);
+/* +-----------------------------------------------------------------------+ */
+/* | Insert the new intervalls into the list (sorted).                     | */
+/* +-----------------------------------------------------------------------+ */
+               direct_dirinsertlist_(&start, anchor, point, f, &maxi, length, &
+                       MAXFUNC, &MAXDEEP, n, &help, jones);
+/* +-----------------------------------------------------------------------+ */
+/* | Increase the number of function evaluations.                          | */
+/* +-----------------------------------------------------------------------+ */
+               numfunc = numfunc + maxi + maxi;
+           }
+/* +-----------------------------------------------------------------------+ */
+/* | End of main loop.                                                     | */
+/* +-----------------------------------------------------------------------+ */
+/* L20: */
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If there is a new minimum, show the actual iteration, the number of   | */
+/* | function evaluations, the minimum value of f (so far) and the position| */
+/* | in the array.                                                         | */
+/* +-----------------------------------------------------------------------+ */
+       if (oldpos < minpos) {
+           if (logfile)
+                fprintf(logfile, "%d, %d, %g, %g\n",
+                        t, numfunc, *minf, fmax);
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If no feasible point has been found, give out the iteration, the      | */
+/* | number of function evaluations and a warning.                         | */
+/* +-----------------------------------------------------------------------+ */
+       if (ifeasiblef > 0) {
+           if (logfile)
+                fprintf(logfile, "No feasible point found in %d iterations "
+                        "and %d function evaluations\n", t, numfunc);
+       }
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* |                       Termination Checks                              | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Calculate the index for the hyperrectangle at which       | */
+/* |             minf is assumed. We then calculate the volume of this     | */
+/* |             hyperrectangle and store it in delta. This delta can be   | */
+/* |             used to stop DIRECT once the volume is below a certain    | */
+/* |             percentage of the original volume. Since the original     | */
+/* |             is 1 (scaled), we can stop once delta is below a certain  | */
+/* |             percentage, given by volper.                              | */
+/* +-----------------------------------------------------------------------+ */
+       *ierror = jones;
+       jones = 0;
+       actdeep_div__ = direct_dirgetlevel_(&minpos, length, &MAXFUNC, n, jones);
+       jones = *ierror;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Use precalculated values to calculate volume.             | */
+/* +-----------------------------------------------------------------------+ */
+       delta = thirds[actdeep_div__] * 100;
+       if (delta <= *volper) {
+           *ierror = 4;
+           if (logfile)
+                fprintf(logfile, "DIRECT stopped: Volume of S_min is "
+                        "%g%% < %g%% of the original volume.\n",
+                        delta, *volper);
+           goto L100;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/23/01 Calculate the measure for the hyperrectangle at which     | */
+/* |             minf is assumed. If this measure is smaller then sigmaper,| */
+/* |             we stop DIRECT.                                           | */
+/* +-----------------------------------------------------------------------+ */
+       actdeep_div__ = direct_dirgetlevel_(&minpos, length, &MAXFUNC, n, jones);
+       delta = levels[actdeep_div__];
+       if (delta <= *sigmaper) {
+           *ierror = 5;
+           if (logfile)
+                fprintf(logfile, "DIRECT stopped: Measure of S_min "
+                        "= %g < %g.\n", delta, *sigmaper);
+           goto L100;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If the best found function value is within fglper of the (known)      | */
+/* | global minimum value, terminate. This only makes sense if this optimal| */
+/* | value is known, that is, in test problems.                            | */
+/* +-----------------------------------------------------------------------+ */
+       if ((*minf - *fglobal) * 100 / divfactor <= *fglper) {
+           *ierror = 3;
+           if (logfile)
+                fprintf(logfile, "DIRECT stopped: minf within fglper of global minimum.\n");
+           goto L100;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Find out if there are infeasible points which are near feasible ones. | */
+/* | If this is the case, replace the function value at the center of the  | */
+/* | hyper rectangle by the lowest function value of a nearby function.    | */
+/* | If no infeasible points exist (IInfesiblef = 0), skip this.           | */
+/* +-----------------------------------------------------------------------+ */
+       if (iinfesiblef > 0) {
+            direct_dirreplaceinf_(&ifree, &ifreeold, f, c__, thirds, length, anchor, 
+                   point, &u[1], &l[1], &MAXFUNC, &MAXDEEP, n, n, 
+                   logfile, &fmax, jones);
+       }
+       ifreeold = ifree;
+/* +-----------------------------------------------------------------------+ */
+/* | If iepschange = 1, we use the epsilon change formula from Jones.      | */
+/* +-----------------------------------------------------------------------+ */
+       if (iepschange == 1) {
+/* Computing MAX */
+           d__1 = fabs(*minf) * 1e-4;
+           *eps = MAX(d__1,epsfix);
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If no feasible point has been found yet, set the maximum number of    | */
+/* | function evaluations to the number of evaluations already done plus   | */
+/* | the budget given by the user.                                         | */
+/* | If the budget has already be increased, increase it again. If a       | */
+/* | feasible point has been found, remark that and reset flag. No further | */
+/* | increase is needed.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+       if (increase == 1) {
+           *maxf = numfunc + oldmaxf;
+           if (ifeasiblef == 0) {
+               if (logfile)
+                    fprintf(logfile, "DIRECT found a feasible point.  The "
+                            "adjusted budget is now set to %d.\n", *maxf);
+               increase = 0;
+           }
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Check if the number of function evaluations done is larger than the   | */
+/* | allocated budget. If this is the case, check if a feasible point was  | */
+/* | found. If this is a case, terminate. If no feasible point was found,  | */
+/* | increase the budget and set flag increase.                            | */
+/* +-----------------------------------------------------------------------+ */
+       if (numfunc > *maxf) {
+           if (ifeasiblef == 0) {
+               *ierror = 1;
+               if (logfile)
+                    fprintf(logfile, "DIRECT stopped: numfunc >= maxf.\n");
+               goto L100;
+           } else {
+               increase = 1;
+               if (logfile)
+                     fprintf(logfile, 
+"DIRECT could not find a feasible point after %d function evaluations.\n"
+"DIRECT continues until a feasible point is found.\n", numfunc);
+               *maxf = numfunc + oldmaxf;
+           }
+       }
+/* L10: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | End of main loop.                                                     | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | The algorithm stopped after maxT iterations.                          | */
+/* +-----------------------------------------------------------------------+ */
+    *ierror = 2;
+    if (logfile)
+        fprintf(logfile, "DIRECT stopped: maxT iterations.\n");
+
+L100:
+/* +-----------------------------------------------------------------------+ */
+/* | Store the position of the minimum in x.                               | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       x[i__] = c__[i__ + minpos * i__1 - i__1-1] * l[i__] + l[i__] * u[i__];
+       u[i__] = oldu[i__ - 1];
+       l[i__] = oldl[i__ - 1];
+/* L50: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Store the number of function evaluations in maxf.                     | */
+/* +-----------------------------------------------------------------------+ */
+    *maxf = numfunc;
+/* +-----------------------------------------------------------------------+ */
+/* | Give out a summary of the run.                                        | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirsummary_(logfile, &x[1], &l[1], &u[1], n, minf, fglobal, &numfunc, 
+           ierror);
+/* +-----------------------------------------------------------------------+ */
+/* | Format statements.                                                    | */
+/* +-----------------------------------------------------------------------+ */
+
+ cleanup:
+#define MY_FREE(p) if (p) free(p)
+    MY_FREE(c__);
+    MY_FREE(f);
+    MY_FREE(s);
+    MY_FREE(w);
+    MY_FREE(oldl);
+    MY_FREE(oldu);
+    MY_FREE(list2);
+    MY_FREE(point);
+    MY_FREE(anchor);
+    MY_FREE(length);
+    MY_FREE(arrayi);
+    MY_FREE(levels);
+    MY_FREE(thirds);
+} /* direct_ */
+
diff --git a/direct/DIRparallel.c b/direct/DIRparallel.c
new file mode 100644 (file)
index 0000000..88fb902
--- /dev/null
@@ -0,0 +1,381 @@
+/* DIRparallel.f -- translated by f2c (version 20050501).
+
+   f2c output hand-cleaned by SGJ (August 2007).
+*/
+
+#include "direct-internal.h"
+
+/* Table of constant values */
+
+static integer c__0 = 0;
+static integer c_n1 = -1;
+
+/* +-----------------------------------------------------------------------+ */
+/* | Program       : Direct.f (subfile DIRseriell.f)                       | */
+/* | Last modified : 02-22-01                                              | */
+/* | Written by    : Joerg Gablonsky                                       | */
+/* | Subroutines, which differ depending on the serial or parallel version.| */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Parallel Direct. This routine replaces the normal main routine DIRect.| */
+/* | In it, we find out if this pe is the master or slave. If it is the    | */
+/* | master, it calls the serial DIRect main routine. The only routine that| */
+/* | has to change for parallel Direct is DIRSamplef, where the actual     | */
+/* | sampling of the function is done. If we are on the slave, wait for    | */
+/* | either the coordinates of a point to sample the function or the       | */
+/* | termination signal.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ int direct_pardirect_(fp fcn, doublereal *x, integer *n, 
+       doublereal *eps, integer *maxf, integer *maxt, doublereal *minf, 
+       doublereal *l, doublereal *u, integer *algmethod, integer *ierror, 
+       FILE *logfile, doublereal *fglobal, doublereal *fglper, doublereal 
+       *volper, doublereal *sigmaper, void *fcn_data)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__, k;
+    integer tid;
+    integer flag__;
+    doublereal fval;
+    integer tids[360], kret;
+    integer mytid;
+    doublereal fscale;
+    integer nprocs;
+
+/* +-----------------------------------------------------------------------+ */
+/* | Parameters                                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | The maximum of function evaluations allowed.                          | */
+/* | The maximum dept of the algorithm.                                    | */
+/* | The maximum number of divisions allowed.                              | */
+/* | The maximal dimension of the problem.                                 | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Global Variables.                                                     | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | External Variables.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | User Variables.                                                       | */
+/* | These can be used to pass user defined data to the function to be     | */
+/* | optimized.                                                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Parallel programming variables                                        | */
+/* +-----------------------------------------------------------------------+ */
+/*       maxprocs should be >= the number of processes used for DIRECT */
+/* +-----------------------------------------------------------------------+ */
+/* | End of parallel programming variables                                 | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Internal variables                                                    | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 02/28/01 Begin of parallel additions                               | */
+/* | DETERMINE MASTER PROCESSOR. GET TIDS OF ALL PROCESSORS.               | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+
+    /* Function Body */
+    getmytidif_(&mytid);
+    getnprocsif_(&nprocs);
+    gettidif_(&c__0, tids);
+/* +-----------------------------------------------------------------------+ */
+/* | If I am the master get the other tids and start running DIRECT.       | */
+/* | Otherwise, branch off to do function evaluations.                     | */
+/* +-----------------------------------------------------------------------+ */
+    if (mytid == tids[0]) {
+       i__1 = nprocs - 1;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           gettidif_(&i__, &tids[i__]);
+/* L46: */
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Call Direct main routine. This routine calls DIRSamplef for the       | */
+/* | function evaluations, which are then done in parallel.                | */
+/* +-----------------------------------------------------------------------+ */
+       direct_direct_(fcn, &x[1], n, eps, maxf, maxt, minf, &l[1], &u[1], 
+               algmethod, ierror, logfile, fglobal, fglper, volper, sigmaper,
+               fcn_data);
+/* +-----------------------------------------------------------------------+ */
+/* | Send exit message to rest of pe's.                                    | */
+/* +-----------------------------------------------------------------------+ */
+       flag__ = 0;
+       i__1 = nprocs;
+       for (tid = 2; tid <= i__1; ++tid) {
+           mastersendif_(&tids[tid - 1], &tids[tid - 1], n, &flag__, &flag__,
+                    &x[1], &u[1], &l[1], &x[1]);
+/* L200: */
+       }
+    } else {
+/* +-----------------------------------------------------------------------+ */
+/* | This is what the slaves do!!                                          | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* |   Receive the first point from the master processor.                  | */
+/* +-----------------------------------------------------------------------+ */
+       slaverecvif_(tids, &c_n1, n, &flag__, &k, &fscale, &u[1], &l[1], &x[1]
+               );
+/* +-----------------------------------------------------------------------+ */
+/* | Repeat until master signals to stop.                                  | */
+/* +-----------------------------------------------------------------------+ */
+       while(flag__ > 0) {
+/* +-----------------------------------------------------------------------+ */
+/* | Evaluate f(x).                                                        | */
+/* +-----------------------------------------------------------------------+ */
+            direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &fval, &kret, &
+                     fcn_data);
+/* +-----------------------------------------------------------------------+ */
+/* | Send result and wait for next point / message with signal to stop.    | */
+/* +-----------------------------------------------------------------------+ */
+           slavesendif_(tids, &mytid, &k, &mytid, &fval, &kret);
+           slaverecvif_(tids, &c_n1, n, &flag__, &k, &fscale, &u[1], &l[1], &
+                   x[1]);
+       }
+    }
+    return 0;
+} /* pardirect_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* | Subroutine for sampling. This sampling is done in parallel, the master| */
+/* | prozessor is also evaluating the function sometimes.                  | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal 
+       *delta, integer *sample, integer *new__, integer *length, 
+       FILE *logfile, doublereal *f, integer *free, integer *maxi, 
+       integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
+       minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc, 
+       integer *maxdeep, integer *oops, doublereal *fmax, integer *
+       ifeasiblef, integer *iinfesiblef, void *fcn_data)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, c_dim1, c_offset, f_dim1, f_offset, 
+           i__1;
+    doublereal d__1;
+
+    /* Local variables */
+    integer i__, j, k, helppoint, tid, pos;
+    integer flag__, tids[360], kret, npts;
+    doublereal fhelp;
+    integer oldpos, nprocs, datarec;
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 fcn must be declared external.                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Removed fcn.                                              | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* |             Added variable to keep track if feasible point was found. | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Variables to pass user defined data to the function to be optimized.  | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Parallel programming variables.                                       | */
+/* +-----------------------------------------------------------------------+ */
+/* JG 09/05/00 Increase this if more processors are used. */
+/* +-----------------------------------------------------------------------+ */
+/* | Find out the id's of all processors.                                  | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+    --arrayi;
+    --point;
+    f_dim1 = *maxfunc;
+    f_offset = 1 + f_dim1;
+    f -= f_offset;
+    length_dim1 = *maxfunc;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    c_dim1 = *maxfunc;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+
+    /* Function Body */
+    getnprocsif_(&nprocs);
+    i__1 = nprocs - 1;
+    for (i__ = 0; i__ <= i__1; ++i__) {
+       gettidif_(&i__, &tids[i__]);
+/* L46: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Set the pointer to the first function to be evaluated,                | */
+/* | store this position also in helppoint.                                | */
+/* +-----------------------------------------------------------------------+ */
+    pos = *new__;
+    helppoint = pos;
+/* +-----------------------------------------------------------------------+ */
+/* | Iterate over all points, where the function should be                 | */
+/* | evaluated.                                                            | */
+/* +-----------------------------------------------------------------------+ */
+    flag__ = 1;
+    npts = *maxi + *maxi;
+    k = 1;
+    while(k <= npts && k < nprocs) {
+/* +-----------------------------------------------------------------------+ */
+/* | tid is the id of the prozessor the next points is send to.            | */
+/* +-----------------------------------------------------------------------+ */
+       tid = k + 1;
+/* +-----------------------------------------------------------------------+ */
+/* | Copy the position into the helparray x.                               | */
+/* +-----------------------------------------------------------------------+ */
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           x[i__] = c__[pos + i__ * c_dim1];
+/* L60: */
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Send the point.                                                       | */
+/* +-----------------------------------------------------------------------+ */
+       mastersendif_(&tids[tid - 1], &tids[tid - 1], n, &flag__, &pos, &x[1],
+                &u[1], &l[1], &x[1]);
+       ++k;
+       pos = point[pos];
+/* +-----------------------------------------------------------------------+ */
+/* | Get the next point.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* |  Get data until it is all received.                                   | */
+/* +-----------------------------------------------------------------------+ */
+    datarec = 0;
+    while(datarec < npts) {
+       if ((doublereal) datarec / (doublereal) nprocs - datarec / nprocs < 
+               1e-5 && k <= npts) {
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               x[i__] = c__[pos + i__ * c_dim1];
+/* L165: */
+           }
+           direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &fhelp, &kret,
+                     fcn_data);
+           oldpos = pos;
+           f[oldpos + f_dim1] = fhelp;
+           ++datarec;
+/* +-----------------------------------------------------------------------+ */
+/* | Remember if an infeasible point has been found.                       | */
+/* +-----------------------------------------------------------------------+ */
+           *iinfesiblef = MAX(*iinfesiblef,kret);
+           if (kret == 0) {
+/* +-----------------------------------------------------------------------+ */
+/* | if the function evaluation was O.K., set the flag in                  | */
+/* | f(pos,2).                                                             | */
+/* +-----------------------------------------------------------------------+ */
+               f[oldpos + (f_dim1 << 1)] = 0.;
+               *ifeasiblef = 0;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+/* Computing MAX */
+               d__1 = f[pos + f_dim1];
+               *fmax = MAX(d__1,*fmax);
+           }
+/* +-----------------------------------------------------------------------+ */
+/* | Remember if an infeasible point has been found.                       | */
+/* +-----------------------------------------------------------------------+ */
+           *iinfesiblef = MAX(*iinfesiblef,kret);
+           if (kret == 1) {
+/* +-----------------------------------------------------------------------+ */
+/* | If the function could not be evaluated at the given point,            | */
+/* | set flag to mark this (f(pos,2) and store the maximum                 | */
+/* | box-sidelength in f(pos,1).                                           | */
+/* +-----------------------------------------------------------------------+ */
+               f[oldpos + (f_dim1 << 1)] = 2.;
+               f[oldpos + f_dim1] = *fmax;
+           }
+/* +-----------------------------------------------------------------------+ */
+/* | If the function could not be evaluated due to a failure in            | */
+/* | the setup, mark this.                                                 | */
+/* +-----------------------------------------------------------------------+ */
+           if (kret == -1) {
+               f[oldpos + (f_dim1 << 1)] = -1.;
+           }
+           ++k;
+           pos = point[pos];
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Recover where to store the value.                                     | */
+/* +-----------------------------------------------------------------------+ */
+       masterrecvif_(&c_n1, &c_n1, &oldpos, &tid, &fhelp, &kret);
+       f[oldpos + f_dim1] = fhelp;
+       ++datarec;
+/* +-----------------------------------------------------------------------+ */
+/* | Remember if an infeasible point has been found.                       | */
+/* +-----------------------------------------------------------------------+ */
+       *iinfesiblef = MAX(*iinfesiblef,kret);
+       if (kret == 0) {
+/* +-----------------------------------------------------------------------+ */
+/* | if the function evaluation was O.K., set the flag in                  | */
+/* | f(pos,2).                                                             | */
+/* +-----------------------------------------------------------------------+ */
+           f[oldpos + (f_dim1 << 1)] = 0.;
+           *ifeasiblef = 0;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+/* Computing MAX */
+           d__1 = f[oldpos + f_dim1];
+           *fmax = MAX(d__1,*fmax);
+       }
+       if (kret == 1) {
+/* +-----------------------------------------------------------------------+ */
+/* | If the function could not be evaluated at the given point,            | */
+/* | set flag to mark this (f(pos,2) and store the maximum                 | */
+/* | box-sidelength in f(pos,1).                                           | */
+/* +-----------------------------------------------------------------------+ */
+           f[oldpos + (f_dim1 << 1)] = 2.;
+           f[oldpos + f_dim1] = *fmax;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If the function could not be evaluated due to a failure in            | */
+/* | the setup, mark this.                                                 | */
+/* +-----------------------------------------------------------------------+ */
+       if (kret == -1) {
+           f[oldpos + (f_dim1 << 1)] = -1.;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* |         Send data until it is all sent.                               | */
+/* +-----------------------------------------------------------------------+ */
+       if (k <= npts) {
+/* +-----------------------------------------------------------------------+ */
+/* | Copy the position into the helparray x.                               | */
+/* +-----------------------------------------------------------------------+ */
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               x[i__] = c__[pos + i__ * c_dim1];
+/* L160: */
+           }
+           mastersendif_(&tid, &tid, n, &flag__, &pos, &x[1], &u[1], &l[1], &
+                   x[1]);
+           ++k;
+           pos = point[pos];
+       }
+    }
+    pos = helppoint;
+/* +-----------------------------------------------------------------------+ */
+/* | Iterate over all evaluated points and see, if the minimal             | */
+/* | value of the function has changed. If this has happend,               | */
+/* | store the minimal value and its position in the array.                | */
+/* | Attention: Only valied values are checked!!                           | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *maxi + *maxi;
+    for (j = 1; j <= i__1; ++j) {
+       if (f[pos + f_dim1] < *minf && f[pos + (f_dim1 << 1)] == 0.) {
+           *minf = f[pos + f_dim1];
+           *minpos = pos;
+       }
+       pos = point[pos];
+/* L50: */
+    }
+} /* dirsamplef_ */
diff --git a/direct/DIRserial.c b/direct/DIRserial.c
new file mode 100644 (file)
index 0000000..03dd91d
--- /dev/null
@@ -0,0 +1,147 @@
+/* DIRserial-transp.f -- translated by f2c (version 20050501).
+
+   f2c output hand-cleaned by SGJ (August 2007).
+*/
+
+#include "direct-internal.h"
+
+/* +-----------------------------------------------------------------------+ */
+/* | Program       : Direct.f (subfile DIRserial.f)                        | */
+/* | Last modified : 04-12-2001                                            | */
+/* | Written by    : Joerg Gablonsky                                       | */
+/* | SUBROUTINEs, which differ depENDing on the serial or parallel version.| */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | SUBROUTINE for sampling.                                              | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal 
+       *delta, integer *sample, integer *new__, integer *length, 
+       FILE *logfile, doublereal *f, integer *free, integer *maxi, 
+       integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
+       minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc, 
+       const integer *maxdeep, integer *oops, doublereal *fmax, integer *
+       ifeasiblef, integer *iinfesiblef, void *fcn_data, int *force_stop)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, c_dim1, c_offset, i__1, i__2;
+    doublereal d__1;
+
+    /* Local variables */
+    integer i__, j, helppoint, pos, kret;
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 fcn must be declared external.                            | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Removed fcn.                                              | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* |             Added variable to keep track IF feasible point was found. | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Variables to pass user defined data to the function to be optimized.  | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Set the pointer to the first function to be evaluated,                | */
+/* | store this position also in helppoint.                                | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+    --arrayi;
+    --point;
+    f -= 3;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    c_dim1 = *n;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+
+    /* Function Body */
+    pos = *new__;
+    helppoint = pos;
+/* +-----------------------------------------------------------------------+ */
+/* | Iterate over all points, where the function should be                 | */
+/* | evaluated.                                                            | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *maxi + *maxi;
+    for (j = 1; j <= i__1; ++j) {
+/* +-----------------------------------------------------------------------+ */
+/* | Copy the position into the helparrayy x.                              | */
+/* +-----------------------------------------------------------------------+ */
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           x[i__] = c__[i__ + pos * c_dim1];
+/* L60: */
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Call the function.                                                    | */
+/* +-----------------------------------------------------------------------+ */
+       if (force_stop && *force_stop)  /* skip eval after forced stop */
+            f[(pos << 1) + 1] = *fmax;
+       else
+            direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1], 
+                             &kret, fcn_data);
+       if (force_stop && *force_stop)
+            kret = -1; /* mark as invalid point */
+/* +-----------------------------------------------------------------------+ */
+/* | Remember IF an infeasible point has been found.                       | */
+/* +-----------------------------------------------------------------------+ */
+       *iinfesiblef = MAX(*iinfesiblef,kret);
+       if (kret == 0) {
+/* +-----------------------------------------------------------------------+ */
+/* | IF the function evaluation was O.K., set the flag in                  | */
+/* | f(2,pos). Also mark that a feasible point has been found.             | */
+/* +-----------------------------------------------------------------------+ */
+           f[(pos << 1) + 2] = 0.;
+           *ifeasiblef = 0;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+/* Computing MAX */
+           d__1 = f[(pos << 1) + 1];
+           *fmax = MAX(d__1,*fmax);
+       }
+       if (kret >= 1) {
+/* +-----------------------------------------------------------------------+ */
+/* |  IF the function could not be evaluated at the given point,            | */
+/* | set flag to mark this (f(2,pos) and store the maximum                 | */
+/* | box-sidelength in f(1,pos).                                           | */
+/* +-----------------------------------------------------------------------+ */
+           f[(pos << 1) + 2] = 2.;
+           f[(pos << 1) + 1] = *fmax;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* |  IF the function could not be evaluated due to a failure in            | */
+/* | the setup, mark this.                                                 | */
+/* +-----------------------------------------------------------------------+ */
+       if (kret == -1) {
+           f[(pos << 1) + 2] = -1.;
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | Set the position to the next point, at which the function             | */
+/* | should e evaluated.                                                   | */
+/* +-----------------------------------------------------------------------+ */
+       pos = point[pos];
+/* L40: */
+    }
+    pos = helppoint;
+/* +-----------------------------------------------------------------------+ */
+/* | Iterate over all evaluated points and see, IF the minimal             | */
+/* | value of the function has changed.  IF this has happEND,               | */
+/* | store the minimal value and its position in the array.                | */
+/* | Attention: Only valid values are checked!!                           | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *maxi + *maxi;
+    for (j = 1; j <= i__1; ++j) {
+       if (f[(pos << 1) + 1] < *minf && f[(pos << 1) + 2] == 0.) {
+           *minf = f[(pos << 1) + 1];
+           *minpos = pos;
+       }
+       pos = point[pos];
+/* L50: */
+    }
+} /* dirsamplef_ */
diff --git a/direct/DIRsubrout.c b/direct/DIRsubrout.c
new file mode 100644 (file)
index 0000000..7414961
--- /dev/null
@@ -0,0 +1,1582 @@
+/* DIRsubrout.f -- translated by f2c (version 20050501).
+
+   f2c output hand-cleaned by SGJ (August 2007).
+*/
+
+#include <math.h>
+#include "direct-internal.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c__32 = 32;
+static integer c__0 = 0;
+
+/* +-----------------------------------------------------------------------+ */
+/* | INTEGER Function DIRGetlevel                                          | */
+/* | Returns the level of the hyperrectangle. Depending on the value of the| */
+/* | global variable JONES. IF JONES equals 0, the level is given by       | */
+/* |               kN + p, where the rectangle has p sides with a length of| */
+/* |             1/3^(k+1), and N-p sides with a length of 1/3^k.          | */
+/* | If JONES equals 1, the level is the power of 1/3 of the length of the | */
+/* | longest side hyperrectangle.                                          | */
+/* |                                                                       | */
+/* | On Return :                                                           | */
+/* |    the maximal length                                                 | */
+/* |                                                                       | */
+/* | pos     -- the position of the midpoint in the array length           | */
+/* | length  -- the array with the dimensions                              | */
+/* | maxfunc -- the leading dimension of length                            | */
+/* | n    -- the dimension of the problem                                  | */
+/* |                                                                       | */
+/* +-----------------------------------------------------------------------+ */
+integer direct_dirgetlevel_(integer *pos, integer *length, integer *maxfunc, integer 
+       *n, integer jones)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, ret_val, i__1;
+
+    /* Local variables */
+    integer i__, k, p, help;
+
+/* JG 09/15/00 Added variable JONES (see above) */
+    /* Parameter adjustments */
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    if (jones == 0) {
+       help = length[*pos * length_dim1 + 1];
+       k = help;
+       p = 1;
+       i__1 = *n;
+       for (i__ = 2; i__ <= i__1; ++i__) {
+           if (length[i__ + *pos * length_dim1] < k) {
+               k = length[i__ + *pos * length_dim1];
+           }
+           if (length[i__ + *pos * length_dim1] == help) {
+               ++p;
+           }
+/* L100: */
+       }
+       if (k == help) {
+           ret_val = k * *n + *n - p;
+       } else {
+           ret_val = k * *n + p;
+       }
+    } else {
+       help = length[*pos * length_dim1 + 1];
+       i__1 = *n;
+       for (i__ = 2; i__ <= i__1; ++i__) {
+           if (length[i__ + *pos * length_dim1] < help) {
+               help = length[i__ + *pos * length_dim1];
+           }
+/* L10: */
+       }
+       ret_val = help;
+    }
+    return ret_val;
+} /* dirgetlevel_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* | Program       : Direct.f (subfile DIRsubrout.f)                       | */
+/* | Last modified : 07-16-2001                                            | */
+/* | Written by    : Joerg Gablonsky                                       | */
+/* | Subroutines used by the algorithm DIRECT.                             | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRChoose                                               | */
+/* |    Decide, which is the next sampling point.                          | */
+/* |    Changed 09/25/00 JG                                                | */
+/* |         Added maxdiv to call and changed S to size maxdiv.            | */
+/* |    Changed 01/22/01 JG                                                | */
+/* |         Added Ifeasiblef to call to keep track if a feasible point has| */
+/* |         been found.                                                   | */
+/* |    Changed 07/16/01 JG                                                | */
+/* |         Changed if statement to prevent run-time errors.              |                                  
+                 | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirchoose_(integer *anchor, integer *s, integer *actdeep,
+        doublereal *f, doublereal *minf, doublereal epsrel, doublereal epsabs, doublereal *thirds,
+        integer *maxpos, integer *length, integer *maxfunc, const integer *maxdeep,
+        const integer *maxdiv, integer *n, FILE *logfile,
+       integer *cheat, doublereal *kmax, integer *ifeasiblef, integer jones)
+{
+    /* System generated locals */
+    integer s_dim1, s_offset, length_dim1, length_offset, i__1;
+
+    /* Local variables */
+    integer i__, j, k;
+    doublereal helplower;
+    integer i___, j___;
+    doublereal helpgreater;
+    integer novaluedeep = 0;
+    doublereal help2;
+    integer novalue;
+
+    /* Parameter adjustments */
+    f -= 3;
+    ++anchor;
+    s_dim1 = *maxdiv;
+    s_offset = 1 + s_dim1;
+    s -= s_offset;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    helplower = HUGE_VAL;
+    helpgreater = 0.;
+    k = 1;
+    if (*ifeasiblef >= 1) {
+       i__1 = *actdeep;
+       for (j = 0; j <= i__1; ++j) {
+           if (anchor[j] > 0) {
+               s[k + s_dim1] = anchor[j];
+               s[k + (s_dim1 << 1)] = direct_dirgetlevel_(&s[k + s_dim1], &length[
+                       length_offset], maxfunc, n, jones);
+               goto L12;
+           }
+/* L1001: */
+       }
+L12:
+       ++k;
+       *maxpos = 1;
+       return;
+    } else {
+       i__1 = *actdeep;
+       for (j = 0; j <= i__1; ++j) {
+           if (anchor[j] > 0) {
+               s[k + s_dim1] = anchor[j];
+               s[k + (s_dim1 << 1)] = direct_dirgetlevel_(&s[k + s_dim1], &length[
+                       length_offset], maxfunc, n, jones);
+               ++k;
+           }
+/* L10: */
+       }
+    }
+    novalue = 0;
+    if (anchor[-1] > 0) {
+       novalue = anchor[-1];
+       novaluedeep = direct_dirgetlevel_(&novalue, &length[length_offset], maxfunc, 
+               n, jones);
+    }
+    *maxpos = k - 1;
+    i__1 = *maxdeep;
+    for (j = k - 1; j <= i__1; ++j) {
+       s[k + s_dim1] = 0;
+/* L11: */
+    }
+    for (j = *maxpos; j >= 1; --j) {
+       helplower = HUGE_VAL;
+       helpgreater = 0.;
+       j___ = s[j + s_dim1];
+       i__1 = j - 1;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           i___ = s[i__ + s_dim1];
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Changed IF statement into two to prevent run-time errors  | */
+/* |             which could occur if the compiler checks the second       | */
+/* |             expression in an .AND. statement although the first       | */
+/* |             statement is already not true.                            | */
+/* +-----------------------------------------------------------------------+ */
+           if (i___ > 0 && ! (i__ == j)) {
+               if (f[(i___ << 1) + 2] <= 1.) {
+                   help2 = thirds[s[i__ + (s_dim1 << 1)]] - thirds[s[j + (
+                           s_dim1 << 1)]];
+                   help2 = (f[(i___ << 1) + 1] - f[(j___ << 1) + 1]) / help2;
+                   if (help2 <= 0.) {
+                        if (logfile)
+                             fprintf(logfile, "thirds > 0, help2 <= 0\n");
+                       goto L60;
+                   }
+                   if (help2 < helplower) {
+                        if (logfile)
+                             fprintf(logfile, "helplower = %g\n", help2);
+                       helplower = help2;
+                   }
+               }
+           }
+/* L30: */
+       }
+       i__1 = *maxpos;
+       for (i__ = j + 1; i__ <= i__1; ++i__) {
+           i___ = s[i__ + s_dim1];
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Changed IF statement into two to prevent run-time errors  | */
+/* |             which could occur if the compiler checks the second       | */
+/* |             expression in an .AND. statement although the first       | */
+/* |             statement is already not true.                            | */
+/* +-----------------------------------------------------------------------+ */
+           if (i___ > 0 && ! (i__ == j)) {
+               if (f[(i___ << 1) + 2] <= 1.) {
+                   help2 = thirds[s[i__ + (s_dim1 << 1)]] - thirds[s[j + (
+                           s_dim1 << 1)]];
+                   help2 = (f[(i___ << 1) + 1] - f[(j___ << 1) + 1]) / help2;
+                   if (help2 <= 0.) {
+                       if (logfile)
+                            fprintf(logfile, "thirds < 0, help2 <= 0\n");
+                       goto L60;
+                   }
+                   if (help2 > helpgreater) {
+                       if (logfile)
+                              fprintf(logfile, "helpgreater = %g\n", help2);
+                       helpgreater = help2;
+                   }
+               }
+           }
+/* L31: */
+       }
+       if (helpgreater <= helplower) {
+           if (*cheat == 1 && helplower > *kmax) {
+               helplower = *kmax;
+           }
+           if (f[(j___ << 1) + 1] - helplower * thirds[s[j + (s_dim1 << 1)]] >
+                    MIN(*minf - epsrel * fabs(*minf), 
+                        *minf - epsabs)) {
+               if (logfile)
+                    fprintf(logfile, "> minf - epslminfl\n");
+               goto L60;
+           }
+       } else {
+           if (logfile)
+                fprintf(logfile, "helpgreater > helplower: %g  %g  %g\n",
+                        helpgreater, helplower, helpgreater - helplower);
+           goto L60;
+       }
+       goto L40;
+L60:
+       s[j + s_dim1] = 0;
+L40:
+       ;
+    }
+    if (novalue > 0) {
+       ++(*maxpos);
+       s[*maxpos + s_dim1] = novalue;
+       s[*maxpos + (s_dim1 << 1)] = novaluedeep;
+    }
+} /* dirchoose_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRDoubleInsert                                         | */
+/* |      Routine to make sure that if there are several potential optimal | */
+/* |      hyperrectangles of the same level (i.e. hyperrectangles that have| */
+/* |      the same level and the same function value at the center), all of| */
+/* |      them are divided. This is the way as originally described in     | */
+/* |      Jones et.al.                                                     | */
+/* | JG 07/16/01 Added errorflag to calling sequence. We check if more     | */
+/* |             we reach the capacity of the array S. If this happens, we | */
+/* |             return to the main program with an error.                 | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirdoubleinsert_(integer *anchor, integer *s, integer *
+       maxpos, integer *point, doublereal *f, const integer *maxdeep, integer *
+       maxfunc, const integer *maxdiv, integer *ierror)
+{
+    /* System generated locals */
+    integer s_dim1, s_offset, i__1;
+
+    /* Local variables */
+    integer i__, oldmaxpos, pos, help, iflag, actdeep;
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Added flag to prevent run time-errors on some systems.    | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    ++anchor;
+    f -= 3;
+    --point;
+    s_dim1 = *maxdiv;
+    s_offset = 1 + s_dim1;
+    s -= s_offset;
+
+    /* Function Body */
+    oldmaxpos = *maxpos;
+    i__1 = oldmaxpos;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (s[i__ + s_dim1] > 0) {
+           actdeep = s[i__ + (s_dim1 << 1)];
+           help = anchor[actdeep];
+           pos = point[help];
+           iflag = 0;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Added flag to prevent run time-errors on some systems. On | */
+/* |             some systems the second conditions in an AND statement is | */
+/* |             evaluated even if the first one is already not true.      | */
+/* +-----------------------------------------------------------------------+ */
+           while(pos > 0 && iflag == 0) {
+               if (f[(pos << 1) + 1] - f[(help << 1) + 1] <= 1e-13) {
+                   if (*maxpos < *maxdiv) {
+                       ++(*maxpos);
+                       s[*maxpos + s_dim1] = pos;
+                       s[*maxpos + (s_dim1 << 1)] = actdeep;
+                       pos = point[pos];
+                   } else {
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Maximum number of elements possible in S has been reached!| */
+/* +-----------------------------------------------------------------------+ */
+                       *ierror = -6;
+                       return;
+                   }
+               } else {
+                   iflag = 1;
+               }
+           }
+       }
+/* L10: */
+    }
+} /* dirdoubleinsert_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* | INTEGER Function GetmaxDeep                                           | */
+/* | function to get the maximal length (1/length) of the n-dimensional    | */
+/* | rectangle with midpoint pos.                                          | */
+/* |                                                                       | */
+/* | On Return :                                                           | */
+/* |    the maximal length                                                 | */
+/* |                                                                       | */
+/* | pos     -- the position of the midpoint in the array length           | */
+/* | length  -- the array with the dimensions                              | */
+/* | maxfunc -- the leading dimension of length                            | */
+/* | n    -- the dimension of the problem                                  | */
+/* |                                                                       | */
+/* +-----------------------------------------------------------------------+ */
+integer direct_dirgetmaxdeep_(integer *pos, integer *length, integer *maxfunc, 
+       integer *n)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, i__1, i__2, i__3;
+
+    /* Local variables */
+    integer i__, help;
+
+    /* Parameter adjustments */
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    help = length[*pos * length_dim1 + 1];
+    i__1 = *n;
+    for (i__ = 2; i__ <= i__1; ++i__) {
+/* Computing MIN */
+       i__2 = help, i__3 = length[i__ + *pos * length_dim1];
+       help = MIN(i__2,i__3);
+/* L10: */
+    }
+    return help;
+} /* dirgetmaxdeep_ */
+
+static integer isinbox_(doublereal *x, doublereal *a, doublereal *b, integer *n, 
+       integer *lmaxdim)
+{
+    /* System generated locals */
+    integer ret_val, i__1;
+
+    /* Local variables */
+    integer outofbox, i__;
+
+    /* Parameter adjustments */
+    --b;
+    --a;
+    --x;
+
+    /* Function Body */
+    outofbox = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (a[i__] > x[i__] || b[i__] < x[i__]) {
+           outofbox = 0;
+           goto L1010;
+       }
+/* L1000: */
+    }
+L1010:
+    ret_val = outofbox;
+    return ret_val;
+} /* isinbox_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG Added 09/25/00                                                     | */
+/* |                                                                       | */
+/* |                       SUBROUTINE DIRResortlist                        | */
+/* |                                                                       | */
+/* | Resort the list so that the infeasible point is in the list with the  | */
+/* | replaced value.                                                       | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ static void dirresortlist_(integer *replace, integer *anchor, 
+       doublereal *f, integer *point, integer *length, integer *n, integer *
+       maxfunc, integer *maxdim, const integer *maxdeep, FILE *logfile,
+                                           integer jones)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, i__1;
+
+    /* Local variables */
+    integer i__, l, pos;
+    integer start;
+
+/* +-----------------------------------------------------------------------+ */
+/* | Get the length of the hyper rectangle with infeasible mid point and   | */
+/* | Index of the corresponding list.                                      | */
+/* +-----------------------------------------------------------------------+ */
+/* JG 09/25/00 Replaced with DIRgetlevel */
+/*      l = DIRgetmaxDeep(replace,length,maxfunc,n) */
+    /* Parameter adjustments */
+    --point;
+    f -= 3;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    ++anchor;
+
+    /* Function Body */
+    l = direct_dirgetlevel_(replace, &length[length_offset], maxfunc, n, jones);
+    start = anchor[l];
+/* +-----------------------------------------------------------------------+ */
+/* | If the hyper rectangle with infeasibel midpoint is already the start  | */
+/* | of the list, give out message, nothing to do.                         | */
+/* +-----------------------------------------------------------------------+ */
+    if (*replace == start) {
+/*         write(logfile,*) 'No resorting of list necessarry, since new ', */
+/*     + 'point is already anchor of list .',l */
+    } else {
+/* +-----------------------------------------------------------------------+ */
+/* | Take the hyper rectangle with infeasible midpoint out of the list.    | */
+/* +-----------------------------------------------------------------------+ */
+       pos = start;
+       i__1 = *maxfunc;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (point[pos] == *replace) {
+               point[pos] = point[*replace];
+               goto L20;
+           } else {
+               pos = point[pos];
+           }
+           if (pos == 0) {
+               if (logfile)
+                    fprintf(logfile, "Error in DIRREsortlist: "
+                            "We went through the whole list\n"
+                            "and could not find the point to replace!!\n");
+               goto L20;
+           }
+/* L10: */
+       }
+/* +-----------------------------------------------------------------------+ */
+/* | If the anchor of the list has a higher value than the value of a      | */
+/* | nearby point, put the infeasible point at the beginning of the list.  | */
+/* +-----------------------------------------------------------------------+ */
+L20:
+       if (f[(start << 1) + 1] > f[(*replace << 1) + 1]) {
+           anchor[l] = *replace;
+           point[*replace] = start;
+/*            write(logfile,*) 'Point is replacing current anchor for ' */
+/*     +             , 'this list ',l,replace,start */
+       } else {
+/* +-----------------------------------------------------------------------+ */
+/* | Insert the point into the list according to its (replaced) function   | */
+/* | value.                                                                | */
+/* +-----------------------------------------------------------------------+ */
+           pos = start;
+           i__1 = *maxfunc;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+/* +-----------------------------------------------------------------------+ */
+/* | The point has to be added at the end of the list.                     | */
+/* +-----------------------------------------------------------------------+ */
+               if (point[pos] == 0) {
+                   point[*replace] = point[pos];
+                   point[pos] = *replace;
+/*                  write(logfile,*) 'Point is added at the end of the ' */
+/*     +             , 'list ',l, replace */
+                   goto L40;
+               } else {
+                   if (f[(point[pos] << 1) + 1] > f[(*replace << 1) + 1]) {
+                       point[*replace] = point[pos];
+                       point[pos] = *replace;
+/*                     write(logfile,*) 'There are points with a higher ' */
+/*     +               ,'f-value in the list ',l,replace, pos */
+                       goto L40;
+                   }
+                   pos = point[pos];
+               }
+/* L30: */
+           }
+L40:
+           pos = pos;
+       }
+    }
+} /* dirresortlist_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG Added 09/25/00                                                     | */
+/* |                       SUBROUTINE DIRreplaceInf                        | */
+/* |                                                                       | */
+/* | Find out if there are infeasible points which are near feasible ones. | */
+/* | If this is the case, replace the function value at the center of the  | */
+/* | hyper rectangle by the lowest function value of a nearby function.    | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirreplaceinf_(integer *free, integer *freeold, 
+       doublereal *f, doublereal *c__, doublereal *thirds, integer *length, 
+       integer *anchor, integer *point, doublereal *c1, doublereal *c2, 
+       integer *maxfunc, const integer *maxdeep, integer *maxdim, integer *n, 
+       FILE *logfile, doublereal *fmax, integer jones)
+{
+    /* System generated locals */
+    integer c_dim1, c_offset, length_dim1, length_offset, i__1, i__2, i__3;
+    doublereal d__1, d__2;
+
+    /* Local variables */
+    doublereal a[32], b[32];
+    integer i__, j, k, l;
+    doublereal x[32], sidelength;
+    integer help;
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --point;
+    f -= 3;
+    ++anchor;
+    length_dim1 = *maxdim;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    c_dim1 = *maxdim;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+    --c2;
+    --c1;
+
+    /* Function Body */
+    i__1 = *free - 1;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (f[(i__ << 1) + 2] > 0.) {
+/* +-----------------------------------------------------------------------+ */
+/* | Get the maximum side length of the hyper rectangle and then set the   | */
+/* | new side length to this lengths times the growth factor.              | */
+/* +-----------------------------------------------------------------------+ */
+           help = direct_dirgetmaxdeep_(&i__, &length[length_offset], maxfunc, n);
+           sidelength = thirds[help] * 2.;
+/* +-----------------------------------------------------------------------+ */
+/* | Set the Center and the upper and lower bounds of the rectangles.      | */
+/* +-----------------------------------------------------------------------+ */
+           i__2 = *n;
+           for (j = 1; j <= i__2; ++j) {
+               sidelength = thirds[length[i__ + j * length_dim1]];
+               a[j - 1] = c__[j + i__ * c_dim1] - sidelength;
+               b[j - 1] = c__[j + i__ * c_dim1] + sidelength;
+/* L20: */
+           }
+/* +-----------------------------------------------------------------------+ */
+/* | The function value is reset to 'Inf', since it may have been changed  | */
+/* | in an earlier iteration and now the feasible point which was close    | */
+/* | is not close anymore (since the hyper rectangle surrounding the       | */
+/* | current point may have shrunk).                                       | */
+/* +-----------------------------------------------------------------------+ */
+           f[(i__ << 1) + 1] = HUGE_VAL;
+           f[(i__ << 1) + 2] = 2.;
+/* +-----------------------------------------------------------------------+ */
+/* | Check if any feasible point is near this infeasible point.            | */
+/* +-----------------------------------------------------------------------+ */
+           i__2 = *free - 1;
+           for (k = 1; k <= i__2; ++k) {
+/* +-----------------------------------------------------------------------+ */
+/* | If the point k is feasible, check if it is near.                      | */
+/* +-----------------------------------------------------------------------+ */
+               if (f[(k << 1) + 2] == 0.) {
+/* +-----------------------------------------------------------------------+ */
+/* | Copy the coordinates of the point k into x.                           | */
+/* +-----------------------------------------------------------------------+ */
+                   i__3 = *n;
+                   for (l = 1; l <= i__3; ++l) {
+                       x[l - 1] = c__[l + k * c_dim1];
+/* L40: */
+                   }
+/* +-----------------------------------------------------------------------+ */
+/* | Check if the point k is near the infeasible point, if so, replace the | */
+/* | value at */
+/* +-----------------------------------------------------------------------+ */
+                   if (isinbox_(x, a, b, n, &c__32) == 1) {
+/* Computing MIN */
+                        d__1 = f[(i__ << 1) + 1], d__2 = f[(k << 1) + 1];
+                        f[(i__ << 1) + 1] = MIN(d__1,d__2);
+                        f[(i__ << 1) + 2] = 1.; 
+                   }
+               }
+/* L30: */
+           }
+           if (f[(i__ << 1) + 2] == 1.) {
+               f[(i__ << 1) + 1] += (d__1 = f[(i__ << 1) + 1], fabs(d__1)) *
+                       1e-6f;
+               i__2 = *n;
+               for (l = 1; l <= i__2; ++l) {
+                   x[l - 1] = c__[l + i__ * c_dim1] * c1[l] + c__[l + i__ *
+                           c_dim1] * c2[l];
+/* L200: */
+               }
+               dirresortlist_(&i__, &anchor[-1], &f[3], &point[1], 
+                              &length[length_offset], n, 
+                              maxfunc, maxdim, maxdeep, logfile, jones);
+           } else {
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01                                                           | */
+/* | Replaced fixed value for infeasible points with maximum value found,  | */
+/* | increased by 1.                                                       | */
+/* +-----------------------------------------------------------------------+ */
+               if (! (*fmax == f[(i__ << 1) + 1])) {
+/* Computing MAX */
+                   d__1 = *fmax + 1., d__2 = f[(i__ << 1) + 1];
+                   f[(i__ << 1) + 1] = MAX(d__1,d__2);
+               }
+           }
+       }
+/* L10: */
+    }
+/* L1000: */
+} /* dirreplaceinf_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRInsert                                               | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ static void dirinsert_(integer *start, integer *ins, integer *point, 
+       doublereal *f, integer *maxfunc)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__, help;
+
+/* JG 09/17/00 Rewrote this routine. */
+/*      DO 10,i = 1,maxfunc */
+/*        IF (f(ins,1) .LT. f(point(start),1)) THEN */
+/*          help = point(start) */
+/*          point(start) = ins */
+/*          point(ins) = help */
+/*          GOTO 20 */
+/*        END IF */
+/*        IF (point(start) .EQ. 0) THEN */
+/*           point(start) = ins */
+/*           point(ins) = 0 */
+/*           GOTO 20 */
+/*        END IF */
+/*        start = point(start) */
+/* 10    CONTINUE */
+/* 20    END */
+    /* Parameter adjustments */
+    f -= 3;
+    --point;
+
+    /* Function Body */
+    i__1 = *maxfunc;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (point[*start] == 0) {
+           point[*start] = *ins;
+           point[*ins] = 0;
+           return;
+       } else if (f[(*ins << 1) + 1] < f[(point[*start] << 1) + 1]) {
+            help = point[*start];
+            point[*start] = *ins;
+            point[*ins] = help;
+            return;
+       }
+       *start = point[*start];
+/* L10: */
+    }
+} /* dirinsert_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRInsertList                                           | */
+/* |    Changed 02-24-2000                                                 | */
+/* |      Got rid of the distinction between feasible and infeasible points| */
+/* |      I could do this since infeasible points get set to a high        | */
+/* |      function value, which may be replaced by a function value of a   | */
+/* |      nearby function at the end of the main loop.                     | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirinsertlist_(integer *new__, integer *anchor, integer *
+       point, doublereal *f, integer *maxi, integer *length, integer *
+       maxfunc, const integer *maxdeep, integer *n, integer *samp,
+                                           integer jones)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, i__1;
+
+    /* Local variables */
+    integer j;
+    integer pos;
+    integer pos1, pos2, deep;
+
+/* JG 09/24/00 Changed this to Getlevel */
+    /* Parameter adjustments */
+    f -= 3;
+    --point;
+    ++anchor;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    i__1 = *maxi;
+    for (j = 1; j <= i__1; ++j) {
+       pos1 = *new__;
+       pos2 = point[pos1];
+       *new__ = point[pos2];
+/* JG 09/24/00 Changed this to Getlevel */
+/*        deep = DIRGetMaxdeep(pos1,length,maxfunc,n) */
+       deep = direct_dirgetlevel_(&pos1, &length[length_offset], maxfunc, n, jones);
+       if (anchor[deep] == 0) {
+           if (f[(pos2 << 1) + 1] < f[(pos1 << 1) + 1]) {
+               anchor[deep] = pos2;
+               point[pos2] = pos1;
+               point[pos1] = 0;
+           } else {
+               anchor[deep] = pos1;
+               point[pos2] = 0;
+           }
+       } else {
+           pos = anchor[deep];
+           if (f[(pos2 << 1) + 1] < f[(pos1 << 1) + 1]) {
+               if (f[(pos2 << 1) + 1] < f[(pos << 1) + 1]) {
+                   anchor[deep] = pos2;
+/* JG 08/30/00 Fixed bug. Sorting was not correct when */
+/*      f(1,pos2) < f(1,pos1) < f(1,pos) */
+                   if (f[(pos1 << 1) + 1] < f[(pos << 1) + 1]) {
+                       point[pos2] = pos1;
+                       point[pos1] = pos;
+                   } else {
+                       point[pos2] = pos;
+                       dirinsert_(&pos, &pos1, &point[1], &f[3], maxfunc);
+                   }
+               } else {
+                   dirinsert_(&pos, &pos2, &point[1], &f[3], maxfunc);
+                   dirinsert_(&pos, &pos1, &point[1], &f[3], maxfunc);
+               }
+           } else {
+               if (f[(pos1 << 1) + 1] < f[(pos << 1) + 1]) {
+/* JG 08/30/00 Fixed bug. Sorting was not correct when */
+/*      f(pos1,1) < f(pos2,1) < f(pos,1) */
+                   anchor[deep] = pos1;
+                   if (f[(pos << 1) + 1] < f[(pos2 << 1) + 1]) {
+                       point[pos1] = pos;
+                       dirinsert_(&pos, &pos2, &point[1], &f[3], maxfunc);
+                   } else {
+                       point[pos1] = pos2;
+                       point[pos2] = pos;
+                   }
+               } else {
+                   dirinsert_(&pos, &pos1, &point[1], &f[3], maxfunc);
+                   dirinsert_(&pos, &pos2, &point[1], &f[3], maxfunc);
+               }
+           }
+       }
+/* L10: */
+    }
+/* JG 09/24/00 Changed this to Getlevel */
+/*      deep = DIRGetMaxdeep(samp,length,maxfunc,n) */
+    deep = direct_dirgetlevel_(samp, &length[length_offset], maxfunc, n, jones);
+    pos = anchor[deep];
+    if (f[(*samp << 1) + 1] < f[(pos << 1) + 1]) {
+       anchor[deep] = *samp;
+       point[*samp] = pos;
+    } else {
+       dirinsert_(&pos, samp, &point[1], &f[3], maxfunc);
+    }
+} /* dirinsertlist_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRInsertList2  (Old way to do it.)                     | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ static void dirinsertlist_2__(integer *start, integer *j, integer *k,
+        integer *list2, doublereal *w, integer *maxi, integer *n)
+{
+    /* System generated locals */
+    integer list2_dim1, list2_offset, i__1;
+
+    /* Local variables */
+    integer i__, pos;
+
+    /* Parameter adjustments */
+    --w;
+    list2_dim1 = *n;
+    list2_offset = 1 + list2_dim1;
+    list2 -= list2_offset;
+
+    /* Function Body */
+    pos = *start;
+    if (*start == 0) {
+       list2[*j + list2_dim1] = 0;
+       *start = *j;
+       goto L50;
+    }
+    if (w[*start] > w[*j]) {
+       list2[*j + list2_dim1] = *start;
+       *start = *j;
+    } else {
+       i__1 = *maxi;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (list2[pos + list2_dim1] == 0) {
+               list2[*j + list2_dim1] = 0;
+               list2[pos + list2_dim1] = *j;
+               goto L50;
+           } else {
+               if (w[*j] < w[list2[pos + list2_dim1]]) {
+                   list2[*j + list2_dim1] = list2[pos + list2_dim1];
+                   list2[pos + list2_dim1] = *j;
+                   goto L50;
+               }
+           }
+           pos = list2[pos + list2_dim1];
+/* L10: */
+       }
+    }
+L50:
+    list2[*j + (list2_dim1 << 1)] = *k;
+} /* dirinsertlist_2__ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRSearchmin                                            | */
+/* |    Search for the minimum in the list.                                ! */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ static void dirsearchmin_(integer *start, integer *list2, integer *
+       pos, integer *k, integer *n)
+{
+    /* System generated locals */
+    integer list2_dim1, list2_offset;
+
+    /* Parameter adjustments */
+    list2_dim1 = *n;
+    list2_offset = 1 + list2_dim1;
+    list2 -= list2_offset;
+
+    /* Function Body */
+    *k = *start;
+    *pos = list2[*start + (list2_dim1 << 1)];
+    *start = list2[*start + list2_dim1];
+} /* dirsearchmin_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRSamplepoints                                         | */
+/* |    Subroutine to sample the new points.                               | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirsamplepoints_(doublereal *c__, integer *arrayi, 
+       doublereal *delta, integer *sample, integer *start, integer *length, 
+       FILE *logfile, doublereal *f, integer *free, 
+       integer *maxi, integer *point, doublereal *x, doublereal *l,
+        doublereal *minf, integer *minpos, doublereal *u, integer *n, 
+       integer *maxfunc, const integer *maxdeep, integer *oops)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, c_dim1, c_offset, i__1, i__2;
+
+    /* Local variables */
+    integer j, k, pos;
+
+
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+    --arrayi;
+    --point;
+    f -= 3;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    c_dim1 = *n;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+
+    /* Function Body */
+    *oops = 0;
+    pos = *free;
+    *start = *free;
+    i__1 = *maxi + *maxi;
+    for (k = 1; k <= i__1; ++k) {
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           length[j + *free * length_dim1] = length[j + *sample *
+                   length_dim1];
+           c__[j + *free * c_dim1] = c__[j + *sample * c_dim1];
+/* L20: */
+       }
+       pos = *free;
+       *free = point[*free];
+       if (*free == 0) {
+            if (logfile)
+                 fprintf(logfile, "Error, no more free positions! "
+                         "Increase maxfunc!\n");
+           *oops = 1;
+           return;
+       }
+/* L10: */
+    }
+    point[pos] = 0;
+    pos = *start;
+    i__1 = *maxi;
+    for (j = 1; j <= i__1; ++j) {
+       c__[arrayi[j] + pos * c_dim1] = c__[arrayi[j] + *sample * c_dim1] + *
+               delta;
+       pos = point[pos];
+       c__[arrayi[j] + pos * c_dim1] = c__[arrayi[j] + *sample * c_dim1] - *
+               delta;
+       pos = point[pos];
+/* L30: */
+    }
+    ASRT(pos <= 0);
+} /* dirsamplepoints_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRDivide                                               | */
+/* |    Subroutine to divide the hyper rectangles according to the rules.  | */
+/* |    Changed 02-24-2000                                                 | */
+/* |      Replaced if statement by min (line 367)                          | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirdivide_(integer *new__, integer *currentlength, 
+       integer *length, integer *point, integer *arrayi, integer *sample, 
+       integer *list2, doublereal *w, integer *maxi, doublereal *f, integer *
+       maxfunc, const integer *maxdeep, integer *n)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, list2_dim1, list2_offset, i__1, i__2;
+    doublereal d__1, d__2;
+
+    /* Local variables */
+    integer i__, j, k, pos, pos2;
+    integer start;
+
+
+    /* Parameter adjustments */
+    f -= 3;
+    --point;
+    --w;
+    list2_dim1 = *n;
+    list2_offset = 1 + list2_dim1;
+    list2 -= list2_offset;
+    --arrayi;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    start = 0;
+    pos = *new__;
+    i__1 = *maxi;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       j = arrayi[i__];
+       w[j] = f[(pos << 1) + 1];
+       k = pos;
+       pos = point[pos];
+/* Computing MIN */
+       d__1 = f[(pos << 1) + 1], d__2 = w[j];
+       w[j] = MIN(d__1,d__2);
+       pos = point[pos];
+       dirinsertlist_2__(&start, &j, &k, &list2[list2_offset], &w[1], maxi, 
+               n);
+/* L10: */
+    }
+    ASRT(pos <= 0);
+    i__1 = *maxi;
+    for (j = 1; j <= i__1; ++j) {
+       dirsearchmin_(&start, &list2[list2_offset], &pos, &k, n);
+       pos2 = start;
+       length[k + *sample * length_dim1] = *currentlength + 1; 
+       i__2 = *maxi - j + 1;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           length[k + pos * length_dim1] = *currentlength + 1; 
+           pos = point[pos];
+           length[k + pos * length_dim1] = *currentlength + 1;
+/* JG 07/10/01 pos2 = 0 at the end of the 30-loop. Since we end */
+/*             the loop now, we do not need to reassign pos and pos2. */
+           if (pos2 > 0) {
+               pos = list2[pos2 + (list2_dim1 << 1)];
+               pos2 = list2[pos2 + list2_dim1];
+           }
+/* L30: */
+       }
+/* L20: */
+    }
+} /* dirdivide_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |                                                                       | */
+/* |                       SUBROUTINE DIRINFCN                             | */
+/* |                                                                       | */
+/* | Subroutine DIRinfcn unscales the variable x for use in the            | */
+/* | user-supplied function evaluation subroutine fcn. After fcn returns   | */
+/* | to DIRinfcn, DIRinfcn then rescales x for use by DIRECT.              | */
+/* |                                                                       | */
+/* | On entry                                                              | */
+/* |                                                                       | */
+/* |        fcn -- The argument containing the name of the user-supplied   | */
+/* |               subroutine that returns values for the function to be   | */
+/* |               minimized.                                              | */
+/* |                                                                       | */
+/* |          x -- A double-precision vector of length n. The point at     | */
+/* |               which the derivative is to be evaluated.                | */
+/* |                                                                       | */
+/* |        xs1 -- A double-precision vector of length n. Used for         | */
+/* |               scaling and unscaling the vector x by DIRinfcn.         | */
+/* |                                                                       | */
+/* |        xs2 -- A double-precision vector of length n. Used for         | */
+/* |               scaling and unscaling the vector x by DIRinfcn.         | */
+/* |                                                                       | */
+/* |          n -- An integer. The dimension of the problem.               | */
+/* |       kret -- An Integer. If kret =  1, the point is infeasible,      | */
+/* |                              kret = -1, bad problem set up,           | */
+/* |                              kret =  0, feasible.                     | */
+/* |                                                                       | */
+/* | On return                                                             | */
+/* |                                                                       | */
+/* |          f -- A double-precision scalar.                              | */
+/* |                                                                       | */
+/* | Subroutines and Functions                                             | */
+/* |                                                                       | */
+/* | The subroutine whose name is passed through the argument fcn.         | */
+/* |                                                                       | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirinfcn_(fp fcn, doublereal *x, doublereal *c1, 
+       doublereal *c2, integer *n, doublereal *f, integer *flag__, 
+                                      void *fcn_data)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__;
+
+/* +-----------------------------------------------------------------------+ */
+/* | Variables to pass user defined data to the function to be optimized.  | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | Unscale the variable x.                                               | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --c2;
+    --c1;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       x[i__] = (x[i__] + c2[i__]) * c1[i__];
+/* L20: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Call the function-evaluation subroutine fcn.                          | */
+/* +-----------------------------------------------------------------------+ */
+    *flag__ = 0;
+    *f = fcn(*n, &x[1], flag__, fcn_data);
+/* +-----------------------------------------------------------------------+ */
+/* | Rescale the variable x.                                               | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       x[i__] = x[i__] / c1[i__] - c2[i__];
+/* L30: */
+    }
+} /* dirinfcn_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRGet_I                                                | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirget_i__(integer *length, integer *pos, integer *
+       arrayi, integer *maxi, integer *n, integer *maxfunc)
+{
+    /* System generated locals */
+    integer length_dim1, length_offset, i__1;
+
+    /* Local variables */
+    integer i__, j, help;
+
+    /* Parameter adjustments */
+    --arrayi;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+
+    /* Function Body */
+    j = 1;
+    help = length[*pos * length_dim1 + 1];
+    i__1 = *n;
+    for (i__ = 2; i__ <= i__1; ++i__) {
+       if (length[i__ + *pos * length_dim1] < help) {
+           help = length[i__ + *pos * length_dim1];
+       }
+/* L10: */
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (length[i__ + *pos * length_dim1] == help) {
+           arrayi[j] = i__;
+           ++j;
+       }
+/* L20: */
+    }
+    *maxi = j - 1;
+} /* dirget_i__ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRInit                                                 | */
+/* |    Initialise all needed variables and do the first run of the        | */
+/* |    algorithm.                                                         | */
+/* |    Changed 02/24/2000                                                 | */
+/* |       Changed fcn Double precision to fcn external!                   | */
+/* |    Changed 09/15/2000                                                 | */
+/* |       Added distinction between Jones way to characterize rectangles  | */
+/* |       and our way. Common variable JONES controls which way we use.   | */
+/* |          JONES = 0    Jones way (Distance from midpoint to corner)    | */
+/* |          JONES = 1    Our way (Length of longest side)                | */
+/* |    Changed 09/24/00                                                   | */
+/* |       Added array levels. Levels contain the values to characterize   | */
+/* |       the hyperrectangles.                                            | */
+/* |    Changed 01/22/01                                                   | */
+/* |       Added variable fmax to keep track of maximum value found.       | */
+/* |       Added variable Ifeasiblef to keep track if feasibel point has   | */
+/* |       been found.                                                     | */
+/* |    Changed 01/23/01                                                   | */
+/* |       Added variable Ierror to keep track of errors.                  | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirinit_(doublereal *f, fp fcn, doublereal *c__, 
+       integer *length, integer *actdeep, integer *point, integer *anchor, 
+       integer *free, FILE *logfile, integer *arrayi, 
+       integer *maxi, integer *list2, doublereal *w, doublereal *x, 
+       doublereal *l, doublereal *u, doublereal *minf, integer *minpos, 
+       doublereal *thirds, doublereal *levels, integer *maxfunc, const integer *
+       maxdeep, integer *n, integer *maxor, doublereal *fmax, integer *
+       ifeasiblef, integer *iinfeasible, integer *ierror, void *fcndata,
+       integer jones, double starttime, double maxtime, int *force_stop)
+{
+    /* System generated locals */
+    integer c_dim1, c_offset, length_dim1, length_offset, list2_dim1, 
+           list2_offset, i__1, i__2;
+
+    /* Local variables */
+    integer i__, j;
+    integer new__, help, oops;
+    doublereal help2, delta;
+    doublereal costmin;
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* +-----------------------------------------------------------------------+ */
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable Ifeasiblef to keep track if feasibel point | */
+/* |             has been found.                                           | */
+/* | JG 01/23/01 Added variable Ierror to keep track of errors.            | */
+/* | JG 03/09/01 Added IInfeasible to keep track if an infeasible point has| */
+/* |             been found.                                               | */
+/* +-----------------------------------------------------------------------+ */
+/* JG 09/15/00 Added variable JONES (see above) */
+/* +-----------------------------------------------------------------------+ */
+/* | Variables to pass user defined data to the function to be optimized.  | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --point;
+    f -= 3;
+    ++anchor;
+    --u;
+    --l;
+    --x;
+    --w;
+    list2_dim1 = *maxor;
+    list2_offset = 1 + list2_dim1;
+    list2 -= list2_offset;
+    --arrayi;
+    length_dim1 = *n;
+    length_offset = 1 + length_dim1;
+    length -= length_offset;
+    c_dim1 = *maxor;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+
+    /* Function Body */
+    *minf = HUGE_VAL;
+    costmin = *minf;
+/* JG 09/15/00 If Jones way of characterising rectangles is used, */
+/*             initialise thirds to reflect this. */
+    if (jones == 0) {
+       i__1 = *n - 1;
+       for (j = 0; j <= i__1; ++j) {
+           w[j + 1] = sqrt(*n - j + j / 9.) * .5;
+/* L5: */
+       }
+       help2 = 1.;
+       i__1 = *maxdeep / *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           i__2 = *n - 1;
+           for (j = 0; j <= i__2; ++j) {
+               levels[(i__ - 1) * *n + j] = w[j + 1] / help2;
+/* L8: */
+           }
+           help2 *= 3.;
+/* L10: */
+       }
+    } else {
+/* JG 09/15/00 Initialiase levels to contain 1/j */
+       help2 = 3.;
+       i__1 = *maxdeep;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           levels[i__] = 1. / help2;
+           help2 *= 3.;
+/* L11: */
+       }
+       levels[0] = 1.;
+    }
+    help2 = 3.;
+    i__1 = *maxdeep;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       thirds[i__] = 1. / help2;
+       help2 *= 3.;
+/* L21: */
+    }
+    thirds[0] = 1.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       c__[i__ + c_dim1] = .5;
+       x[i__] = .5;
+       length[i__ + length_dim1] = 0;
+/* L20: */
+    }
+    direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[3], &help, fcndata);
+    if (force_stop && *force_stop) {
+        *ierror = -102;
+        return;
+    }
+    f[4] = (doublereal) help;
+    *iinfeasible = help;
+    *fmax = f[3];
+/* 09/25/00 Added this */
+/*      if (f(1,1) .ge. 1.E+6) then */
+    if (f[4] > 0.) {
+       f[3] = HUGE_VAL;
+       *fmax = f[3];
+       *ifeasiblef = 1;
+    } else {
+       *ifeasiblef = 0;
+    }
+/* JG 09/25/00 Remove IF */
+    *minf = f[3];
+    costmin = f[3];
+    *minpos = 1;
+    *actdeep = 2;
+    point[1] = 0;
+    *free = 2;
+    delta = thirds[1];
+    if (nlopt_stop_time_(starttime, maxtime)) {
+        *ierror = DIRECT_MAXTIME_EXCEEDED;
+        return;
+    }
+    direct_dirget_i__(&length[length_offset], &c__1, &arrayi[1], maxi, n, maxfunc);
+    new__ = *free;
+    direct_dirsamplepoints_(&c__[c_offset], &arrayi[1], &delta, &c__1, &new__, &
+           length[length_offset], logfile, &f[3], free, maxi, &
+           point[1], &x[1], &l[1], minf, minpos, &u[1], n, 
+           maxfunc, maxdeep, &oops);
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/23/01 Added error checking.                                     | */
+/* +-----------------------------------------------------------------------+ */
+    if (oops > 0) {
+       *ierror = -4;
+       return;
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/22/01 Added variable to keep track of the maximum value found.  | */
+/* |             Added variable to keep track if feasible point was found. | */
+/* +-----------------------------------------------------------------------+ */
+    direct_dirsamplef_(&c__[c_offset], &arrayi[1], &delta, &c__1, &new__, &length[
+           length_offset], logfile, &f[3], free, maxi, &point[
+           1], fcn, &x[1], &l[1], minf, minpos, &u[1], n, maxfunc, 
+           maxdeep, &oops, fmax, ifeasiblef, iinfeasible, fcndata,
+           force_stop);
+    if (force_stop && *force_stop) {
+        *ierror = -102;
+        return;
+    }
+    if (nlopt_stop_time_(starttime, maxtime)) {
+        *ierror = DIRECT_MAXTIME_EXCEEDED;
+        return;
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/23/01 Added error checking.                                     | */
+/* +-----------------------------------------------------------------------+ */
+    if (oops > 0) {
+       *ierror = -5;
+       return;
+    }
+    direct_dirdivide_(&new__, &c__0, &length[length_offset], &point[1], &arrayi[1], &
+           c__1, &list2[list2_offset], &w[1], maxi, &f[3], maxfunc, 
+           maxdeep, n);
+    direct_dirinsertlist_(&new__, &anchor[-1], &point[1], &f[3], maxi, &
+           length[length_offset], maxfunc, maxdeep, n, &c__1, jones);
+} /* dirinit_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |    SUBROUTINE DIRInitList                                             | */
+/* |    Initialise the list.                                               | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirinitlist_(integer *anchor, integer *free, integer *
+       point, doublereal *f, integer *maxfunc, const integer *maxdeep)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__;
+
+/*   f -- values of functions. */
+/*   anchor -- anchors of lists with deep i */
+/*   point -- lists */
+/*   free  -- first free position */
+    /* Parameter adjustments */
+    f -= 3;
+    --point;
+    ++anchor;
+
+    /* Function Body */
+    i__1 = *maxdeep;
+    for (i__ = -1; i__ <= i__1; ++i__) {
+       anchor[i__] = 0;
+/* L10: */
+    }
+    i__1 = *maxfunc;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       f[(i__ << 1) + 1] = 0.;
+       f[(i__ << 1) + 2] = 0.;
+       point[i__] = i__ + 1;
+/*       point(i) = 0 */
+/* L20: */
+    }
+    point[*maxfunc] = 0;
+    *free = 1;
+} /* dirinitlist_ */
+
+/* +-----------------------------------------------------------------------+ */
+/* |                                                                       | */
+/* |                       SUBROUTINE DIRPREPRC                            | */
+/* |                                                                       | */
+/* | Subroutine DIRpreprc uses an afine mapping to map the hyper-box given | */
+/* | by the constraints on the variable x onto the n-dimensional unit cube.| */
+/* | This mapping is done using the following equation:                    | */
+/* |                                                                       | */
+/* |               x(i)=x(i)/(u(i)-l(i))-l(i)/(u(i)-l(i)).                 | */
+/* |                                                                       | */
+/* | DIRpreprc checks if the bounds l and u are well-defined. That is, if  | */
+/* |                                                                       | */
+/* |               l(i) < u(i) forevery i.                                 | */
+/* |                                                                       | */
+/* | On entry                                                              | */
+/* |                                                                       | */
+/* |          u -- A double-precision vector of length n. The vector       | */
+/* |               containing the upper bounds for the n independent       | */
+/* |               variables.                                              | */
+/* |                                                                       | */
+/* |          l -- A double-precision vector of length n. The vector       | */
+/* |               containing the lower bounds for the n independent       | */
+/* |               variables.                                              | */
+/* |                                                                       | */
+/* |          n -- An integer. The dimension of the problem.               | */
+/* |                                                                       | */
+/* | On return                                                             | */
+/* |                                                                       | */
+/* |        xs1 -- A double-precision vector of length n, used for scaling | */
+/* |               and unscaling the vector x.                             | */
+/* |                                                                       | */
+/* |        xs2 -- A double-precision vector of length n, used for scaling | */
+/* |               and unscaling the vector x.                             | */
+/* |                                                                       | */
+/* |                                                                       | */
+/* |       oops -- An integer. If an upper bound is less than a lower      | */
+/* |               bound or if the initial point is not in the             | */
+/* |               hyper-box oops is set to 1 and iffco terminates.        | */
+/* |                                                                       | */
+/* +-----------------------------------------------------------------------+ */
+/* Subroutine */ void direct_dirpreprc_(doublereal *u, doublereal *l, integer *n, 
+       doublereal *xs1, doublereal *xs2, integer *oops)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__;
+    doublereal help;
+
+    /* Parameter adjustments */
+    --xs2;
+    --xs1;
+    --l;
+    --u;
+
+    /* Function Body */
+    *oops = 0;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* +-----------------------------------------------------------------------+ */
+/* | Check if the hyper-box is well-defined.                               | */
+/* +-----------------------------------------------------------------------+ */
+       if (u[i__] <= l[i__]) {
+           *oops = 1;
+           return;
+       }
+/* L20: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | Scale the initial iterate so that it is in the unit cube.             | */
+/* +-----------------------------------------------------------------------+ */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       help = u[i__] - l[i__];
+       xs2[i__] = l[i__] / help;
+       xs1[i__] = help;
+/* L50: */
+    }
+} /* dirpreprc_ */
+
+/* Subroutine */ void direct_dirheader_(FILE *logfile, integer *version, 
+       doublereal *x, integer *n, doublereal *eps, integer *maxf, integer *
+       maxt, doublereal *l, doublereal *u, integer *algmethod, integer *
+       maxfunc, const integer *maxdeep, doublereal *fglobal, doublereal *fglper, 
+       integer *ierror, doublereal *epsfix, integer *iepschange, doublereal *
+       volper, doublereal *sigmaper)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer imainver, i__, numerrors, isubsubver, ihelp, isubver;
+
+
+/* +-----------------------------------------------------------------------+ */
+/* | Variables to pass user defined data to the function to be optimized.  | */
+/* +-----------------------------------------------------------------------+ */
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+
+    /* Function Body */
+    if (logfile)
+        fprintf(logfile, "------------------- Log file ------------------\n");
+
+    numerrors = 0;
+    *ierror = 0;
+    imainver = *version / 100;
+    ihelp = *version - imainver * 100;
+    isubver = ihelp / 10;
+    ihelp -= isubver * 10;
+    isubsubver = ihelp;
+/* +-----------------------------------------------------------------------+ */
+/* | JG 01/13/01 Added check for epsilon. If epsilon is smaller 0, we use  | */
+/* |             the update formula from Jones. We then set the flag       | */
+/* |             iepschange to 1, and store the absolute value of eps in   | */
+/* |             epsfix. epsilon is then changed after each iteration.     | */
+/* +-----------------------------------------------------------------------+ */
+    if (*eps < 0.) {
+       *iepschange = 1;
+       *epsfix = -(*eps);
+       *eps = -(*eps);
+    } else {
+       *iepschange = 0;
+       *epsfix = 1e100;
+    }
+
+/* +-----------------------------------------------------------------------+ */
+/* | JG 07/16/01 Removed printout of contents in cdata(1).                 | */
+/* +-----------------------------------------------------------------------+ */
+/*      write(logfile,*) cdata(1) */
+
+    if (logfile) {
+        fprintf(logfile, "DIRECT Version %d.%d.%d\n"
+                " Problem dimension n: %d\n"
+                " Eps value: %e\n"
+                " Maximum number of f-evaluations (maxf): %d\n"
+                " Maximum number of iterations (MaxT): %d\n"
+                " Value of f_global: %e\n"
+                " Global percentage wanted: %e\n"
+                " Volume percentage wanted: %e\n"
+                " Measure percentage wanted: %e\n",
+                imainver, isubver, isubsubver, *n, *eps, *maxf, *maxt,
+                *fglobal, *fglper, *volper, *sigmaper);
+        fprintf(logfile, *iepschange == 1 
+                ? "Epsilon is changed using the Jones formula.\n" 
+                : "Epsilon is constant.\n");
+        fprintf(logfile, *algmethod == 0
+                ? "Jones original DIRECT algorithm is used.\n"
+                : "Our modification of the DIRECT algorithm is used.\n");
+    }
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (u[i__] <= l[i__]) {
+           *ierror = -1;
+           if (logfile)
+                fprintf(logfile, "WARNING: bounds on variable x%d: "
+                        "%g <= xi <= %g\n", i__, l[i__], u[i__]);
+           ++numerrors;
+       } else {
+           if (logfile)
+                fprintf(logfile, "Bounds on variable x%d: "
+                        "%g <= xi <= %g\n", i__, l[i__], u[i__]);
+       }
+/* L1010: */
+    }
+/* +-----------------------------------------------------------------------+ */
+/* | If there are to many function evaluations or to many iteration, note  | */
+/* | this and set the error flag accordingly. Note: If more than one error | */
+/* | occurred, we give out an extra message.                               | */
+/* +-----------------------------------------------------------------------+ */
+    if (*maxf + 20 > *maxfunc) {
+       if (logfile)
+            fprintf(logfile,
+"WARNING: The maximum number of function evaluations (%d) is higher than\n"
+"         the constant maxfunc (%d).  Increase maxfunc in subroutine DIRECT\n"
+"         or decrease the maximum number of function evaluations.\n",
+                    *maxf, *maxfunc);
+       ++numerrors;
+       *ierror = -2;
+    }
+    if (*ierror < 0) {
+       if (logfile) fprintf(logfile, "----------------------------------\n");
+       if (numerrors == 1) {
+            if (logfile) 
+                 fprintf(logfile, "WARNING: One error in the input!\n");
+       } else {
+            if (logfile) 
+                 fprintf(logfile, "WARNING: %d errors in the input!\n",
+                         numerrors);
+       }
+    }
+    if (logfile) fprintf(logfile, "----------------------------------\n");
+    if (*ierror >= 0) {
+        if (logfile)
+             fprintf(logfile, "Iteration # of f-eval. minf\n");
+    }
+/* L10005: */
+} /* dirheader_ */
+
+/* Subroutine */ void direct_dirsummary_(FILE *logfile, doublereal *x, doublereal *
+       l, doublereal *u, integer *n, doublereal *minf, doublereal *fglobal, 
+       integer *numfunc, integer *ierror)
+{
+    /* Local variables */
+    integer i__;
+
+    /* Parameter adjustments */
+    --u;
+    --l;
+    --x;
+
+    /* Function Body */
+    if (logfile) {
+        fprintf(logfile, "-----------------------Summary------------------\n"
+                "Final function value: %g\n"
+                "Number of function evaluations: %d\n", *minf, *numfunc);
+        if (*fglobal > -1e99)
+             fprintf(logfile, "Final function value is within %g%% of global optimum\n", 100*(*minf - *fglobal) / MAX(1.0, fabs(*fglobal)));
+        fprintf(logfile, "Index, final solution, x(i)-l(i), u(i)-x(i)\n");
+        for (i__ = 1; i__ <= *n; ++i__)
+             fprintf(logfile, "%d, %g, %g, %g\n", i__, x[i__], 
+                     x[i__]-l[i__], u[i__] - x[i__]);
+        fprintf(logfile, "-----------------------------------------------\n");
+             
+    }
+} /* dirsummary_ */
diff --git a/direct/Makefile.am b/direct/Makefile.am
new file mode 100644 (file)
index 0000000..161dded
--- /dev/null
@@ -0,0 +1,7 @@
+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
+
+EXTRA_DIST = README AUTHORS COPYING DIRparallel.c tstc.c userguide.pdf
diff --git a/direct/Makefile.in b/direct/Makefile.in
new file mode 100644 (file)
index 0000000..35dbf21
--- /dev/null
@@ -0,0 +1,612 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = direct
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp AUTHORS COPYING README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdirect_la_LIBADD =
+am_libdirect_la_OBJECTS = DIRect.lo direct_wrap.lo DIRserial.lo \
+       DIRsubrout.lo
+libdirect_la_OBJECTS = $(am_libdirect_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libdirect_la_SOURCES)
+DIST_SOURCES = $(libdirect_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+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
+
+EXTRA_DIST = README AUTHORS COPYING DIRparallel.c tstc.c userguide.pdf
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu direct/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu direct/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libdirect.la: $(libdirect_la_OBJECTS) $(libdirect_la_DEPENDENCIES) $(EXTRA_libdirect_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libdirect_la_OBJECTS) $(libdirect_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DIRect.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DIRserial.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DIRsubrout.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_wrap.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/direct/README b/direct/README
new file mode 100644 (file)
index 0000000..785fb03
--- /dev/null
@@ -0,0 +1,37 @@
+The DIRECT algorithm (DIviding RECTangles) is a derivative-free global
+optimization algorithm invented by Jones et al.:
+
+       D. R. Jones, C. D. Perttunen, and B. E. Stuckmann,
+       "Lipschitzian optimization without the lipschitz constant,"
+       J. Optimization Theory and Applications, vol. 79, p. 157 (1993).
+
+This is a deterministic-search algorithm based on systematic division
+of the search domain into smaller and smaller hyperrectangles.
+
+The implementation is based on the 1998-2001 Fortran version by
+J. M. Gablonsky at North Carolina State University, converted to C by
+Steven G. Johnson.  The Fortran source was downloaded from:
+
+       http://www4.ncsu.edu/~ctk/SOFTWARE/DIRECTv204.tar.gz
+
+Gablonsky et al implemented a modified version of the original DIRECT
+algorithm, as described in:
+
+       J. M. Gablonsky and C. T. Kelley, "A locally-biased form
+       of the DIRECT algorithm," J. Global Optimization 21 (1),
+       p. 27-37 (2001).
+
+Both the original Jones algorithm (NLOPT_GLOBAL_DIRECT) and the
+Gablonsky modified version (NLOPT_GLOBAL_DIRECT_L) are implemented
+and available from the NLopt interface.  The Gablonsky version
+makes the algorithm "more biased towards local search" so that it
+is more efficient for functions without too many local minima.
+
+Also, Gablonsky et al. extended the algorithm to handle "hidden
+constraints", i.e. arbitrary nonlinear constraints.  In NLopt, a
+hidden constraint is represented by returning NaN (or Inf, or
+HUGE_VAL) from the objective function at any points violating the
+constraint.
+
+Further information on the DIRECT algorithm and Gablonsky's
+implementation can be found in the included userguide.pdf file.
diff --git a/direct/direct-internal.h b/direct/direct-internal.h
new file mode 100644 (file)
index 0000000..fb4b274
--- /dev/null
@@ -0,0 +1,122 @@
+#ifndef DIRECT_INTERNAL_H
+#define DIRECT_INTERNAL_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "direct.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef int integer;
+typedef double doublereal;
+typedef direct_objective_func fp;
+
+#define ASRT(c) if (!(c)) { fprintf(stderr, "DIRECT assertion failure at " __FILE__ ":%d -- " #c "\n", __LINE__); exit(EXIT_FAILURE); }
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+/* DIRsubrout.c */
+
+extern void direct_dirheader_(
+     FILE *logfile, integer *version,
+     doublereal *x, integer *n, doublereal *eps, integer *maxf, integer *
+     maxt, doublereal *l, doublereal *u, integer *algmethod, integer *
+     maxfunc, const integer *maxdeep, doublereal *fglobal, doublereal *fglper,
+     integer *ierror, doublereal *epsfix, integer *iepschange, doublereal *
+     volper, doublereal *sigmaper);
+extern void direct_dirinit_(
+     doublereal *f, fp fcn, doublereal *c__,
+     integer *length, integer *actdeep, integer *point, integer *anchor,
+     integer *free, FILE *logfile, integer *arrayi,
+     integer *maxi, integer *list2, doublereal *w, doublereal *x,
+     doublereal *l, doublereal *u, doublereal *minf, integer *minpos,
+     doublereal *thirds, doublereal *levels, integer *maxfunc, const integer *
+     maxdeep, integer *n, integer *maxor, doublereal *fmax, integer *
+     ifeasiblef, integer *iinfeasible, integer *ierror, void *fcndata,
+     integer jones, double starttime, double maxtime, int *force_stop);
+extern void direct_dirinitlist_(
+     integer *anchor, integer *free, integer *
+     point, doublereal *f, integer *maxfunc, const integer *maxdeep);
+extern void direct_dirpreprc_(doublereal *u, doublereal *l, integer *n, 
+                             doublereal *xs1, doublereal *xs2, integer *oops);
+extern void direct_dirchoose_(
+     integer *anchor, integer *s, integer *actdeep,
+     doublereal *f, doublereal *minf, doublereal epsrel, doublereal epsabs, doublereal *thirds,
+     integer *maxpos, integer *length, integer *maxfunc, const integer *maxdeep,
+     const integer *maxdiv, integer *n, FILE *logfile,
+     integer *cheat, doublereal *kmax, integer *ifeasiblef, integer jones);
+extern void direct_dirdoubleinsert_(
+     integer *anchor, integer *s, integer *maxpos, integer *point, 
+     doublereal *f, const integer *maxdeep, integer *maxfunc, 
+     const integer *maxdiv, integer *ierror);
+extern integer direct_dirgetmaxdeep_(integer *pos, integer *length, integer *maxfunc,
+                             integer *n);
+extern void direct_dirget_i__(
+     integer *length, integer *pos, integer *arrayi, integer *maxi, 
+     integer *n, integer *maxfunc);
+extern void direct_dirsamplepoints_(
+     doublereal *c__, integer *arrayi, 
+     doublereal *delta, integer *sample, integer *start, integer *length, 
+     FILE *logfile, doublereal *f, integer *free, 
+     integer *maxi, integer *point, doublereal *x, doublereal *l,
+     doublereal *minf, integer *minpos, doublereal *u, integer *n, 
+     integer *maxfunc, const integer *maxdeep, integer *oops);
+extern void direct_dirdivide_(
+     integer *new__, integer *currentlength, 
+     integer *length, integer *point, integer *arrayi, integer *sample, 
+     integer *list2, doublereal *w, integer *maxi, doublereal *f, 
+     integer *maxfunc, const integer *maxdeep, integer *n);
+extern void direct_dirinsertlist_(
+     integer *new__, integer *anchor, integer *point, doublereal *f, 
+     integer *maxi, integer *length, integer *maxfunc, 
+     const integer *maxdeep, integer *n, integer *samp, integer jones);
+extern void direct_dirreplaceinf_(
+     integer *free, integer *freeold, 
+     doublereal *f, doublereal *c__, doublereal *thirds, integer *length, 
+     integer *anchor, integer *point, doublereal *c1, doublereal *c2, 
+     integer *maxfunc, const integer *maxdeep, integer *maxdim, integer *n, 
+     FILE *logfile, doublereal *fmax, integer jones);
+extern void direct_dirsummary_(
+     FILE *logfile, doublereal *x, doublereal *l, doublereal *u, 
+     integer *n, doublereal *minf, doublereal *fglobal, 
+     integer *numfunc, integer *ierror);
+extern integer direct_dirgetlevel_(
+     integer *pos, integer *length, 
+     integer *maxfunc, integer *n, integer jones);
+extern void direct_dirinfcn_(
+     fp fcn, doublereal *x, doublereal *c1, 
+     doublereal *c2, integer *n, doublereal *f, integer *flag__, 
+     void *fcn_data);
+
+/* DIRserial.c / DIRparallel.c */
+extern void direct_dirsamplef_(
+     doublereal *c__, integer *arrayi, doublereal 
+     *delta, integer *sample, integer *new__, integer *length, 
+     FILE *logfile, doublereal *f, integer *free, integer *maxi, 
+     integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
+     minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc, 
+     const integer *maxdeep, integer *oops, doublereal *fmax, integer *
+     ifeasiblef, integer *iinfesiblef, void *fcn_data, int *force_stop);
+
+/* DIRect.c */
+extern void direct_direct_(
+     fp fcn, doublereal *x, integer *n, doublereal *eps, doublereal epsabs,
+     integer *maxf, integer *maxt, 
+     double starttime, double maxtime, 
+     int *force_stop, doublereal *minf, doublereal *l, 
+     doublereal *u, integer *algmethod, integer *ierror, FILE *logfile, 
+     doublereal *fglobal, doublereal *fglper, doublereal *volper, 
+     doublereal *sigmaper, void *fcn_data);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* DIRECT_INTERNAL_H */
diff --git a/direct/direct.h b/direct/direct.h
new file mode 100644 (file)
index 0000000..2b100b2
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef DIRECT_H
+#define DIRECT_H
+
+#include <math.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef double (*direct_objective_func)(int n, const double *x,
+                                       int *undefined_flag, 
+                                       void *data);
+
+typedef enum {
+     DIRECT_ORIGINAL, DIRECT_GABLONSKY
+} direct_algorithm;
+
+typedef enum {
+     DIRECT_INVALID_BOUNDS = -1,
+     DIRECT_MAXFEVAL_TOOBIG = -2,
+     DIRECT_INIT_FAILED = -3,
+     DIRECT_SAMPLEPOINTS_FAILED = -4,
+     DIRECT_SAMPLE_FAILED = -5,
+     DIRECT_MAXFEVAL_EXCEEDED = 1,
+     DIRECT_MAXITER_EXCEEDED = 2,
+     DIRECT_GLOBAL_FOUND = 3,
+     DIRECT_VOLTOL = 4,
+     DIRECT_SIGMATOL = 5,
+     DIRECT_MAXTIME_EXCEEDED = 6,
+
+     DIRECT_OUT_OF_MEMORY = -100,
+     DIRECT_INVALID_ARGS = -101,
+     DIRECT_FORCED_STOP = -102
+} direct_return_code;
+
+#define DIRECT_UNKNOWN_FGLOBAL (-HUGE_VAL)
+#define DIRECT_UNKNOWN_FGLOBAL_RELTOL (0.0)
+
+extern direct_return_code direct_optimize(
+     direct_objective_func f, void *f_data,
+     int dimension,
+     const double *lower_bounds, const double *upper_bounds,
+
+     double *x, double *minf, 
+
+     int max_feval, int max_iter, 
+     double start, double maxtime,
+     double magic_eps, double magic_eps_abs,
+     double volume_reltol, double sigma_reltol,
+     int *force_stop,
+
+     double fglobal,
+     double fglobal_reltol,
+
+     FILE *logfile,
+     direct_algorithm algorithm);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* DIRECT_H */
diff --git a/direct/direct_wrap.c b/direct/direct_wrap.c
new file mode 100644 (file)
index 0000000..98d7c28
--- /dev/null
@@ -0,0 +1,104 @@
+/* C-style API for DIRECT functions.  SGJ (August 2007). */
+
+#include "direct-internal.h"
+
+/* Perform global minimization using (Gablonsky implementation of) DIRECT
+   algorithm.   Arguments:
+
+   f, f_data: the objective function and any user data
+       -- the objective function f(n, x, undefined_flag, data) takes 4 args:
+              int n: the dimension, same as dimension arg. to direct_optimize
+              const double *x: array x[n] of point to evaluate
+             int *undefined_flag: set to 1 on return if x violates constraints
+                                  or don't touch otherwise
+              void *data: same as f_data passed to direct_optimize
+          return value = value of f(x)
+
+   dimension: the number of minimization variable dimensions
+   lower_bounds, upper_bounds: arrays of length dimension of variable bounds
+
+   x: an array of length dimension, set to optimum variables upon return
+   minf: on return, set to minimum f value
+
+   magic_eps, magic_eps_abs: Jones' "magic" epsilon parameter, and
+                             also an absolute version of the same
+                            (not multipled by minf).  Jones suggests
+                            setting this to 1e-4, but 0 also works...
+
+   max_feval, max_iter: maximum number of function evaluations & DIRECT iters
+   volume_reltol: relative tolerance on hypercube volume (0 if none)
+   sigma_reltol: relative tolerance on hypercube "measure" (??) (0 if none)
+
+   fglobal: the global minimum of f, if known ahead of time
+       -- this is mainly for benchmarking, in most cases it
+          is not known and you should pass DIRECT_UNKNOWN_FGLOBAL
+   fglobal_reltol: relative tolerance on how close we should find fglobal
+       -- ignored if fglobal is DIRECT_UNKNOWN_FGLOBAL
+
+   logfile: an output file to write diagnostic info to (NULL for no I/O)
+
+   algorithm: whether to use the original DIRECT algorithm (DIRECT_ORIGINAL)
+              or Gablonsky's "improved" version (DIRECT_GABLONSKY)
+*/
+direct_return_code direct_optimize(
+     direct_objective_func f, void *f_data,
+     int dimension,
+     const double *lower_bounds, const double *upper_bounds,
+
+     double *x, double *minf, 
+
+     int max_feval, int max_iter,
+     double start, double maxtime,
+     double magic_eps, double magic_eps_abs,
+     double volume_reltol, double sigma_reltol,
+     int *force_stop,
+
+     double fglobal,
+     double fglobal_reltol,
+
+     FILE *logfile,
+     direct_algorithm algorithm)
+{
+     integer algmethod = algorithm == DIRECT_GABLONSKY;
+     integer ierror;
+     doublereal *l, *u;
+     int i;
+
+     /* convert to percentages: */
+     volume_reltol *= 100;
+     sigma_reltol *= 100;
+     fglobal_reltol *= 100;
+
+     /* make sure these are ignored if <= 0 */
+     if (volume_reltol <= 0) volume_reltol = -1;
+     if (sigma_reltol <= 0) sigma_reltol = -1;
+
+     if (fglobal == DIRECT_UNKNOWN_FGLOBAL)
+         fglobal_reltol = DIRECT_UNKNOWN_FGLOBAL_RELTOL;
+
+     if (dimension < 1) return DIRECT_INVALID_ARGS;
+
+     l = (doublereal *) malloc(sizeof(doublereal) * dimension * 2);
+     if (!l) return DIRECT_OUT_OF_MEMORY;
+     u = l + dimension;
+     for (i = 0; i < dimension; ++i) {
+         l[i] = lower_bounds[i];
+         u[i] = upper_bounds[i];
+     }
+     
+     direct_direct_(f, x, &dimension, &magic_eps, magic_eps_abs,
+                   &max_feval, &max_iter, 
+                   start, maxtime, force_stop,
+                   minf,
+                   l, u,
+                   &algmethod,
+                   &ierror,
+                   logfile,
+                   &fglobal, &fglobal_reltol,
+                   &volume_reltol, &sigma_reltol,
+                   f_data);
+
+     free(l);
+
+     return (direct_return_code) ierror;
+}
diff --git a/direct/tstc.c b/direct/tstc.c
new file mode 100644 (file)
index 0000000..6d441cd
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "direct.h"
+
+/* has two global minima at (0.09,-0.71) and (-0.09,0.71), plus
+   4 additional local minima */
+static int cnt=0;
+double tst_obj(int n, const double *xy, int *undefined_flag, void *unused)
+{
+  double x, y, f;
+  x = xy[0];
+  y = xy[1];
+  f = ((x*x)*(4-2.1*(x*x)+((x*x)*(x*x))/3) + x*y + (y*y)*(-4+4*(y*y)));
+  printf("feval:, %d, %g, %g, %g\n", ++cnt, x,y, f);
+  return f;
+}
+
+int main(int argc, char **argv)
+{
+  int n = 2;
+  double x[2], l[2], u[2];
+  long int maxits = 0;
+  int info;
+  double minf;
+  int force_stop = 0;
+
+  maxits = argc < 2 ? 100 : atoi(argv[1]);
+
+  l[0] = -3; l[1] = -3;
+  u[0] = 3; u[1] = 3;
+
+  info = direct_optimize(tst_obj, NULL, n, l, u, x, &minf,
+                        maxits, 500,
+                        0, 0, 0, 0, 
+                         0.0, -1.0,
+                         &force_stop, 
+                         DIRECT_UNKNOWN_FGLOBAL, 0,
+                        stdout, DIRECT_GABLONSKY);
+
+  printf("min f = %g at (%g,%g) after %d evals, return value %d\n",
+        minf, x[0], x[1], cnt, info);
+
+  return EXIT_SUCCESS;
+}
diff --git a/esch/COPYRIGHT b/esch/COPYRIGHT
new file mode 100644 (file)
index 0000000..e00ee0d
--- /dev/null
@@ -0,0 +1,22 @@
+/* Copyright (c) 2008-2013 Carlos Henrique da Silva Santos
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
diff --git a/esch/Makefile.am b/esch/Makefile.am
new file mode 100644 (file)
index 0000000..377c00f
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libesch.la
+libesch_la_SOURCES = esch.c esch.h 
+
+EXTRA_DIST = README COPYRIGHT
diff --git a/esch/Makefile.in b/esch/Makefile.in
new file mode 100644 (file)
index 0000000..a90489a
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = esch
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libesch_la_LIBADD =
+am_libesch_la_OBJECTS = esch.lo
+libesch_la_OBJECTS = $(am_libesch_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libesch_la_SOURCES)
+DIST_SOURCES = $(libesch_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libesch.la
+libesch_la_SOURCES = esch.c esch.h 
+EXTRA_DIST = README COPYRIGHT
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu esch/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu esch/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libesch.la: $(libesch_la_OBJECTS) $(libesch_la_DEPENDENCIES) $(EXTRA_libesch_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libesch_la_OBJECTS) $(libesch_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esch.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/esch/README b/esch/README
new file mode 100644 (file)
index 0000000..8ea4ec6
--- /dev/null
@@ -0,0 +1,27 @@
+This is Carlos Henrique da Silva Santos's implementation of
+a modified version of the Evolutionary Algorithm described in
+the following paper and Ph.D. thesis:
+
+    C. H. da Silva Santos, M. S. Gonçalves, and H. E. Hernandez-Figueroa,
+    "Designing Novel Photonic Devices by Bio-Inspired Computing,"
+    IEEE Photonics Technology Letters 22(15), pp. 1177-1179 (2010).
+
+    C. H. da Silva Santos, "Parallel and Bio-Inspired Computing
+    Applied to Analyze Microwave and Photonic Metamaterial Strucutures,"
+    University of Campinas, (2010)
+    http://www.bibliotecadigital.unicamp.br/document/?code=000767537&opt=4&lg=en_US
+
+The algorithms are adapted from ideas described in:
+
+    H.-G. Beyer and H.-P. Schwefel. Evolution Strategies: A Comprehensive Introduction. Journal Natural Computing, 1(1):3–52, 2002.
+
+    Ingo Rechenberg (1971): Evolutionsstrategie â€“ Optimierung technischer Systeme nach Prinzipien der biologischen Evolution (PhD thesis). Reprinted by Fromman-Holzboog (1973).
+
+It is distributed under the "MIT license" given in the attached
+COPYRIGHT file (similar to the rest of NLopt), and was
+supportedfinancially by the São Paulo Science Foundation (FAPESP -
+Fundação de Amparo Ã  Pesquisa do Estado de São Paulo) under the grant
+2012/14553-9.
+
+Carlos Henrique da Silva Santos
+January 2013
diff --git a/esch/esch.c b/esch/esch.c
new file mode 100644 (file)
index 0000000..e2c01d7
--- /dev/null
@@ -0,0 +1,259 @@
+/* Copyright (c) 2008-2013 Carlos Henrique da Silva Santos
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "esch.h"
+
+// ---------------------------------------------------------------------------
+// Cauchy random number distribution
+static double randcauchy(const double params[7]) {
+     /* double min, double max, double mi, double t, double band */
+     double na_unif, cauchy_mit, limit_inf, limit_sup;
+     double valor;
+     double min = params[1], max = params[2], mi = params[3],
+         t = params[4], band = params[5];
+     limit_inf = mi - (band*0.5);
+     limit_sup = mi + (band*0.5);
+     do {
+         na_unif = nlopt_urand(0,1); // ran2(0,1);
+         cauchy_mit = t*tan((na_unif-0.5)*3.14159265358979323846) + mi;
+     } while ( (cauchy_mit<limit_inf) || (cauchy_mit>limit_sup) );   
+     
+     if (cauchy_mit < 0)
+         cauchy_mit = -cauchy_mit;
+     else
+         cauchy_mit = cauchy_mit + (band*0.5);
+     valor  = cauchy_mit/band;
+     valor = min+(max-min)*valor;   
+     return valor;  
+}
+
+// ---------------------------------------------------------------------------
+
+// main Individual representation type
+typedef struct IndividualStructure {
+     double * parameters;
+     double fitness;
+} Individual; 
+
+static int CompareIndividuals(void *unused, const void *a_, const void *b_) {
+     // (void) unused;
+     const Individual *a = (const Individual *) a_;
+     const Individual *b = (const Individual *) b_;
+     return a->fitness < b->fitness ? -1 : (a->fitness > b->fitness ? +1 : 0);
+}
+
+nlopt_result chevolutionarystrategy( 
+     unsigned nparameters, /* Number of input parameters */
+     nlopt_func f,     /* Recursive Objective Funtion Call */
+     void * data_f,    /* Data to Objective Function */
+     const double* lb,                 /* Lower bound values */
+     const double* ub,                 /* Upper bound values */
+     double* x,                                /*in: initial guess, out: minimizer */
+     double* minf,
+     nlopt_stopping* stop,             /* nlopt stop condition */
+     unsigned np,                      /* Number of Parents */ 
+     unsigned no) {                    /* Number of Offsprings */
+
+     // variables from nlopt
+     nlopt_result ret = NLOPT_SUCCESS;
+     double vetor[8];
+     unsigned  i, id, item;
+     int  parent1, parent2;
+     unsigned crosspoint;  // crossover parameteres
+     int  contmutation, totalmutation; // mutation parameters
+     int  idoffmutation, paramoffmutation;     // mutation parameters
+     Individual * esparents;                   // Parents population
+     Individual * esoffsprings;                // Offsprings population
+     Individual * estotal;// copy containing Parents and Offsprings pops
+     /* It is interesting to maintain the parents and offsprings
+      * populations stablished and sorted; when the final iterations
+      * is achieved, they are ranked and updated. */
+
+     // -------------------------------
+     // controling the population size
+     // -------------------------------
+     if (!np) np = 40;
+     if (!no) no = 60;     
+     if ((np < 1)||(no<1)) return NLOPT_INVALID_ARGS;
+     esparents    = (Individual*) malloc(sizeof(Individual) * np);
+     esoffsprings = (Individual*) malloc(sizeof(Individual) * no);
+     estotal    = (Individual*) malloc(sizeof(Individual) * (np+no));
+     if ((!esparents)||(!esoffsprings)||(!estotal)) { 
+         free(esparents); free(esoffsprings); free(estotal); 
+         return NLOPT_OUT_OF_MEMORY;
+     }
+     for (id=0; id < np; id++) esparents[id].parameters = NULL;
+     for (id=0; id < no; id++) esoffsprings[id].parameters = NULL;
+     // From here the population is initialized 
+     /* we don't handle unbounded search regions;
+       this check is unnecessary since it is performed in nlopt_optimize.
+       for (j = 0; j < nparameters; ++j) 
+         if (nlopt_isinf(low[j]) || nlopt_isinf(up[j]))
+           return NLOPT_INVALID_ARGS;
+     */
+     // main vector of parameters to randcauchy
+     vetor[0] = 4; // ignored
+     vetor[3] = 0;
+     vetor[4] = 1;
+     vetor[5] = 10;
+     vetor[6] = 1;     
+     vetor[7] = 0; // ignored
+     // ------------------------------------
+     // Initializing parents population
+     // ------------------------------------
+     for (id=0; id < np; id++) {
+         esparents[id].parameters = 
+              (double*) malloc(sizeof(double) * nparameters);
+         if (!esparents[id].parameters) {
+              ret = NLOPT_OUT_OF_MEMORY;
+              goto done;
+         }
+         for (item=0; item<nparameters; item++) {
+              vetor[1] = lb[item];     
+              vetor[2] = ub[item];
+              vetor[7]=vetor[7]+1;
+              esparents[id].parameters[item] = randcauchy(vetor);
+         }
+     }
+     memcpy(esparents[0].parameters, x, nparameters * sizeof(double));
+
+     // ------------------------------------
+     // Initializing offsprings population
+     // ------------------------------------
+     for (id=0; id < no; id++) {
+         esoffsprings[id].parameters = 
+              (double*) malloc(sizeof(double) * nparameters);
+         if (!esoffsprings[id].parameters) {
+              ret = NLOPT_OUT_OF_MEMORY;
+              goto done;
+         }
+         for (item=0; item<nparameters; item++) {
+              vetor[1] = lb[item];     
+              vetor[2] = ub[item];
+              vetor[7]=vetor[7]+1;
+              esoffsprings[id].parameters[item] = randcauchy(vetor);
+         }
+     }
+     // ------------------------------------
+     // Parents fitness evaluation  
+     // ------------------------------------
+     for (id=0; id < np; id++) { 
+         esparents[id].fitness = 
+              f(nparameters, esparents[id].parameters, NULL, data_f);
+         estotal[id].fitness = esparents[id].fitness;
+         stop->nevals++;
+         if (*minf > esparents[id].fitness) {
+              *minf = esparents[id].fitness;
+              memcpy(x, esparents[id].parameters, 
+                     nparameters * sizeof(double));
+         }
+         if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+         else if (*minf < stop->minf_max) ret = NLOPT_MINF_MAX_REACHED;
+         else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+         else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+         if (ret != NLOPT_SUCCESS) goto done;
+     }
+     // ------------------------------------
+     // Main Loop - Generations
+     // ------------------------------------
+     while (1) {
+         // ------------------------------------
+         // Crossover 
+         // ------------------------------------
+         for (id=0; id < no; id++)
+         {
+              parent1  = nlopt_iurand((int) np);
+              parent2  = nlopt_iurand((int) np);
+              crosspoint = (unsigned) nlopt_iurand((int) nparameters);
+              for (item=0; item < crosspoint; item++)
+                   esoffsprings[id].parameters[item] 
+                        = esparents[parent1].parameters[item]; 
+              for (item=crosspoint; item < nparameters; item++)
+                   esoffsprings[id].parameters[item] 
+                        = esparents[parent2].parameters[item]; 
+         }
+         // ------------------------------------
+         // Gaussian Mutation 
+         // ------------------------------------
+         totalmutation = (int) ((no * nparameters) / 10);
+         if (totalmutation < 1) totalmutation = 1;
+         for (contmutation=0; contmutation < totalmutation;
+              contmutation++) {
+              idoffmutation = nlopt_iurand((int) no);
+              paramoffmutation = nlopt_iurand((int) nparameters);
+              vetor[1] = lb[paramoffmutation]; 
+              vetor[2] = ub[paramoffmutation];
+              vetor[7] = vetor[7]+contmutation;
+              esoffsprings[idoffmutation].parameters[paramoffmutation] 
+                   = randcauchy(vetor);
+         }
+         // ------------------------------------
+         // Offsprings fitness evaluation 
+         // ------------------------------------
+         for (id=0; id < no; id++){ 
+              //esoffsprings[id].fitness = (double)fitness(esoffsprings[id].parameters, nparameters,fittype);
+              esoffsprings[id].fitness = f(nparameters, esoffsprings[id].parameters, NULL, data_f);
+              estotal[id+np].fitness = esoffsprings[id].fitness;
+              stop->nevals++;
+              if (*minf > esoffsprings[id].fitness) {
+                   *minf = esoffsprings[id].fitness;
+                   memcpy(x, esoffsprings[id].parameters, 
+                          nparameters * sizeof(double));
+              }
+              if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+              else if (*minf < stop->minf_max) 
+                   ret = NLOPT_MINF_MAX_REACHED;
+              else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+              else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+              if (ret != NLOPT_SUCCESS) goto done;
+         }
+         // ------------------------------------
+         // Individual selection
+         // ------------------------------------
+         // all the individuals are copied to one vector to easily identify best solutions             
+         for (i=0; i < np; i++)
+              estotal[i] = esparents[i];
+         for (i=0; i < no; i++)
+              estotal[np+i] = esoffsprings[i];
+         // Sorting
+         nlopt_qsort_r(estotal, no+np, sizeof(Individual), NULL,
+                       CompareIndividuals);
+         // copy after sorting:
+         for (i=0; i < no+np; i++) {
+              if (i<np)
+                   esparents[i] = estotal[i];
+              else
+                   esoffsprings[i-np] = estotal[i];
+         }
+     } // generations loop
+     
+done:
+     for (id=0; id < np; id++) free(esparents[id].parameters);
+     for (id=0; id < no; id++) free(esoffsprings[id].parameters);
+     
+     if (esparents)    free(esparents);
+     if (esoffsprings)         free(esoffsprings);
+     if (estotal)              free(estotal);
+     return ret;
+}
diff --git a/esch/esch.h b/esch/esch.h
new file mode 100644 (file)
index 0000000..8732e31
--- /dev/null
@@ -0,0 +1,49 @@
+/* Copyright (c) 2008-2013 Carlos Henrique da Silva Santos\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * a copy of this software and associated documentation files (the\r
+ * "Software"), to deal in the Software without restriction, including\r
+ * without limitation the rights to use, copy, modify, merge, publish,\r
+ * distribute, sublicense, and/or sell copies of the Software, and to\r
+ * permit persons to whom the Software is furnished to do so, subject to\r
+ * the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \r
+ */\r
+\r
+#ifndef ES_POP_H\r
+#define ES_POP_H 1\r
+\r
+#include "nlopt-util.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C"\r
+{\r
+#endif /* __cplusplus */\r
+\r
+nlopt_result chevolutionarystrategy(\r
+     unsigned, /* Number of input parameters */\r
+     nlopt_func, /* Recursive Objective Funtion Call */\r
+     void *,   /* Data to Objective Function */\r
+     const double*,                            /* Lower bound values */\r
+     const double*,                            /* Upper bound values */\r
+     double*,                          /* in: initial guess, out: minimizer */\r
+     double*,\r
+     nlopt_stopping*,          /* nlopt stop condition */\r
+     unsigned,                         /* Number of Parents */ \r
+     unsigned);                        /* Number of Offsprings */\r
+\r
+#ifdef __cplusplus\r
+}  /* extern "C" */\r
+#endif /* __cplusplus */\r
+\r
+#endif /* ES_POP_H */\r
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..377bb86
--- /dev/null
@@ -0,0 +1,527 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2011-11-20.07; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# 'make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""       $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+       shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+       case $mode in
+         *' '* | *'    '* | *'
+'*       | *'*'* | *'?'* | *'['*)
+           echo "$0: invalid mode: $mode" >&2
+           exit 1;;
+       esac
+       shift;;
+
+    -o) chowncmd="$chownprog $2"
+       shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+       # Protect names problematic for 'test' and other utilities.
+       case $dst_arg in
+         -* | [=\(\)!]) dst_arg=./$dst_arg;;
+       esac
+       shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)        shift
+       break;;
+
+    -*)        echo "$0: invalid option: $1" >&2
+       exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+    # Protect names problematic for 'test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call 'install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  do_exit='(exit $ret); exit $ret'
+  trap "ret=129; $do_exit" 1
+  trap "ret=130; $do_exit" 2
+  trap "ret=141; $do_exit" 13
+  trap "ret=143; $do_exit" 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names problematic for 'test' and other utilities.
+  case $src in
+    -* | [=\(\)!]) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+    dst=$dst_arg
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dst_arg: Is a directory" >&2
+       exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+       (dirname "$dst") 2>/dev/null ||
+       expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+            X"$dst" : 'X\(//\)[^/]' \| \
+            X"$dst" : 'X\(//\)$' \| \
+            X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+       echo X"$dst" |
+           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)[^/].*/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\).*/{
+                  s//\1/
+                  q
+                }
+                s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+       # Create intermediate dirs using mode 755 as modified by the umask.
+       # This is like FreeBSD 'install' as of 1997-10-28.
+       umask=`umask`
+       case $stripcmd.$umask in
+         # Optimize common cases.
+         *[2367][2367]) mkdir_umask=$umask;;
+         .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+         *[0-7])
+           mkdir_umask=`expr $umask + 22 \
+             - $umask % 100 % 40 + $umask % 20 \
+             - $umask % 10 % 4 + $umask % 2
+           `;;
+         *) mkdir_umask=$umask,go-w;;
+       esac
+
+       # With -d, create the new directory with the user-specified mode.
+       # Otherwise, rely on $mkdir_umask.
+       if test -n "$dir_arg"; then
+         mkdir_mode=-m$mode
+       else
+         mkdir_mode=
+       fi
+
+       posix_mkdir=false
+       case $umask in
+         *[123567][0-7][0-7])
+           # POSIX mkdir -p sets u+wx bits regardless of umask, which
+           # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+           ;;
+         *)
+           tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+           trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+           if (umask $mkdir_umask &&
+               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+           then
+             if test -z "$dir_arg" || {
+                  # Check for POSIX incompatibilities with -m.
+                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                  # other-writable bit of parent directory when it shouldn't.
+                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                  case $ls_ld_tmpdir in
+                    d????-?r-*) different_mode=700;;
+                    d????-?--*) different_mode=755;;
+                    *) false;;
+                  esac &&
+                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                  }
+                }
+             then posix_mkdir=:
+             fi
+             rmdir "$tmpdir/d" "$tmpdir"
+           else
+             # Remove any dirs left behind by ancient mkdir implementations.
+             rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+           fi
+           trap '' 0;;
+       esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+       umask $mkdir_umask &&
+       $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+       /*) prefix='/';;
+       [-=\(\)!]*) prefix='./';;
+       *)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+       test X"$d" = X && continue
+
+       prefix=$prefix$d
+       if test -d "$prefix"; then
+         prefixes=
+       else
+         if $posix_mkdir; then
+           (umask=$mkdir_umask &&
+            $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+           # Don't fail if two instances are running concurrently.
+           test -d "$prefix" || exit 1
+         else
+           case $prefix in
+             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+             *) qprefix=$prefix;;
+           esac
+           prefixes="$prefixes '$qprefix'"
+         fi
+       fi
+       prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+       # Don't fail if two instances are running concurrently.
+       (umask $mkdir_umask &&
+        eval "\$doit_exec \$mkdirprog $prefixes") ||
+         test -d "$dstdir" || exit 1
+       obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"    2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+       # Now remove or move aside any old file at destination location.
+       # We try this two ways since rm can't unlink itself on some
+       # systems and the destination file might be busy for other
+       # reasons.  In this case, the final cleanup might fail but the new
+       # file should still install successfully.
+       {
+         test ! -f "$dst" ||
+         $doit $rmcmd -f "$dst" 2>/dev/null ||
+         { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+           { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+         } ||
+         { echo "$0: cannot unlink or rename $dst" >&2
+           (exit 1); exit 1
+         }
+       } &&
+
+       # Now rename the file to the real destination.
+       $doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/isres/Makefile.am b/isres/Makefile.am
new file mode 100644 (file)
index 0000000..d819248
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libisres.la
+libisres_la_SOURCES = isres.c isres.h
+
+EXTRA_DIST = README
diff --git a/isres/Makefile.in b/isres/Makefile.in
new file mode 100644 (file)
index 0000000..a12d782
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = isres
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libisres_la_LIBADD =
+am_libisres_la_OBJECTS = isres.lo
+libisres_la_OBJECTS = $(am_libisres_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libisres_la_SOURCES)
+DIST_SOURCES = $(libisres_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libisres.la
+libisres_la_SOURCES = isres.c isres.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu isres/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu isres/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libisres.la: $(libisres_la_OBJECTS) $(libisres_la_DEPENDENCIES) $(EXTRA_libisres_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libisres_la_OBJECTS) $(libisres_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isres.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/isres/README b/isres/README
new file mode 100644 (file)
index 0000000..c396213
--- /dev/null
@@ -0,0 +1,23 @@
+This is my implementation of the "Improved Stochastic Ranking
+Evolution Strategy" (ISRES) algorithm for nonlinearly-constrained
+global optimization, based on the method described in:
+
+   Thomas Philip Runarsson and Xin Yao, "Search biases in constrained
+   evolutionary optimization," IEEE Trans. on Systems, Man, and Cybernetics
+   Part C: Applications and Reviews, vol. 35 (no. 2), pp. 233-243 (2005).
+
+It is a refinement of an earlier method described in:
+
+   Thomas P. Runarsson and Xin Yao, "Stochastic ranking for constrained
+   evolutionary optimization," IEEE Trans. Evolutionary Computation,
+   vol. 4 (no. 3), pp. 284-294 (2000).
+
+This is an independent implementation by S. G. Johnson (2009) based
+on the papers above.  Runarsson also has his own Matlab implemention
+available from his web page: http://www3.hi.is/~tpr
+
+It is under the same MIT license as the rest of my code in NLopt (see
+../COPYRIGHT).
+
+Steven G. Johnson
+November 2009
diff --git a/isres/isres.c b/isres/isres.c
new file mode 100644 (file)
index 0000000..02b6f3c
--- /dev/null
@@ -0,0 +1,283 @@
+/* Copyright (c) 2010 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#include "isres.h"
+
+/* Improved Stochastic Ranking Evolution Strategy (ISRES) algorithm
+   for nonlinearly-constrained global optimization, based on
+   the method described in:
+
+   Thomas Philip Runarsson and Xin Yao, "Search biases in constrained
+   evolutionary optimization," IEEE Trans. on Systems, Man, and Cybernetics
+   Part C: Applications and Reviews, vol. 35 (no. 2), pp. 233-243 (2005).
+
+   It is a refinement of an earlier method described in:
+
+   Thomas P. Runarsson and Xin Yao, "Stochastic ranking for constrained
+   evolutionary optimization," IEEE Trans. Evolutionary Computation,
+   vol. 4 (no. 3), pp. 284-294 (2000).
+
+   This is an independent implementation by S. G. Johnson (2009) based
+   on the papers above.  Runarsson also has his own Matlab implemention
+   available from his web page: http://www3.hi.is/~tpr
+*/
+
+static int key_compare(void *keys_, const void *a_, const void *b_)
+{
+     const double *keys = (const double *) keys_;
+     const int *a = (const int *) a_;
+     const int *b = (const int *) b_;
+     return keys[*a] < keys[*b] ? -1 : (keys[*a] > keys[*b] ? +1 : 0);
+}
+
+static unsigned imax2(unsigned a, unsigned b) { return (a > b ? a : b); }
+
+nlopt_result isres_minimize(int n, nlopt_func f, void *f_data,
+                           int m, nlopt_constraint *fc, /* fc <= 0 */
+                           int p, nlopt_constraint *h, /* h == 0 */
+                           const double *lb, const double *ub, /* bounds */
+                           double *x, /* in: initial guess, out: minimizer */
+                           double *minf,
+                           nlopt_stopping *stop,
+                           int population) /* pop. size (= 0 for default) */
+{
+     const double ALPHA = 0.2; /* smoothing factor from paper */
+     const double GAMMA = 0.85; /* step-reduction factor from paper */
+     const double PHI = 1.0; /* expected rate of convergence, from paper */
+     const double PF = 0.45; /* fitness probability, from paper */
+     const double SURVIVOR = 1.0/7.0; /* survivor fraction, from paper */
+     int survivors;
+     nlopt_result ret = NLOPT_SUCCESS;
+     double *sigmas = 0, *xs; /* population-by-n arrays (row-major) */
+     double *fval; /* population array of function vals */
+     double *penalty; /* population array of penalty vals */
+     double *x0;
+     int *irank = 0;
+     int k, i, j, c;
+     int mp = m + p;
+     double minf_penalty = HUGE_VAL, minf_gpenalty = HUGE_VAL;
+     double taup, tau;
+     double *results = 0; /* scratch space for mconstraint results */
+     unsigned ires;
+
+     *minf = HUGE_VAL;
+
+     if (!population) population = 20 * (n + 1);
+     if (population < 1) return NLOPT_INVALID_ARGS;
+     survivors = ceil(population * SURVIVOR);
+
+     taup = PHI / sqrt(2*n);
+     tau = PHI / sqrt(2*sqrt(n));
+
+     /* we don't handle unbounded search regions */
+     for (j = 0; j < n; ++j) if (nlopt_isinf(lb[j]) || nlopt_isinf(ub[j]))
+                                 return NLOPT_INVALID_ARGS;
+
+     ires = imax2(nlopt_max_constraint_dim(m, fc),
+                 nlopt_max_constraint_dim(p, h));
+     results = (double *) malloc(ires * sizeof(double));
+     if (ires > 0 && !results) return NLOPT_OUT_OF_MEMORY;
+
+     sigmas = (double*) malloc(sizeof(double) * (population*n*2
+                                                + population
+                                                + population
+                                                + n));
+     if (!sigmas) { free(results); return NLOPT_OUT_OF_MEMORY; }
+     xs = sigmas + population*n;
+     fval = xs + population*n;
+     penalty = fval + population;
+     x0 = penalty + population;
+
+     irank = (int*) malloc(sizeof(int) * population);
+     if (!irank) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+
+     for (k = 0; k < population; ++k) {
+         for (j = 0; j < n; ++j) {
+              sigmas[k*n+j] = (ub[j] - lb[j]) / sqrt(n);
+              xs[k*n+j] = nlopt_urand(lb[j], ub[j]);
+         }
+     }
+     memcpy(xs, x, sizeof(double) * n); /* use input x for xs_0 */
+
+     while (1) { /* each loop body = one generation */
+         int all_feasible = 1;
+
+         /* evaluate f and constraint violations for whole population */
+         for (k = 0; k < population; ++k) {
+              int feasible = 1;
+              double gpenalty;
+              stop->nevals++;
+              fval[k] = f(n, xs + k*n, NULL, f_data);
+              if (nlopt_stop_forced(stop)) { 
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              penalty[k] = 0;
+              for (c = 0; c < m; ++c) { /* inequality constraints */
+                   nlopt_eval_constraint(results, NULL,
+                                         fc + c, n, xs + k*n);
+                   if (nlopt_stop_forced(stop)) { 
+                        ret = NLOPT_FORCED_STOP; goto done; }
+                   for (ires = 0; ires < fc[c].m; ++ires) {
+                        double gval = results[ires];
+                        if (gval > fc[c].tol[ires]) feasible = 0;
+                        if (gval < 0) gval = 0;
+                        penalty[k] += gval*gval;
+                   }
+              }
+              gpenalty = penalty[k];
+              for (c = m; c < mp; ++c) { /* equality constraints */
+                   nlopt_eval_constraint(results, NULL,
+                                         h + (c-m), n, xs + k*n);
+                   if (nlopt_stop_forced(stop)) { 
+                        ret = NLOPT_FORCED_STOP; goto done; }
+                   for (ires = 0; ires < h[c-m].m; ++ires) {
+                        double hval = results[ires];
+                        if (fabs(hval) > h[c-m].tol[ires]) feasible = 0;
+                        penalty[k] += hval*hval;
+                   }
+              }
+              if (penalty[k] > 0) all_feasible = 0;
+
+              /* convergence criteria (FIXME: improve?) */
+
+              /* FIXME: with equality constraints, how do
+                 we decide which solution is the "best" so far?
+                 ... need some total order on the solutions? */
+
+              if ((penalty[k] <= minf_penalty || feasible)
+                  && (fval[k] <= *minf || minf_gpenalty > 0)
+                  && ((feasible ? 0 : penalty[k]) != minf_penalty
+                      || fval[k] != *minf)) {
+                   if (fval[k] < stop->minf_max && feasible) 
+                        ret = NLOPT_MINF_MAX_REACHED;
+                   else if (!nlopt_isinf(*minf)) {
+                        if (nlopt_stop_f(stop, fval[k], *minf)
+                            && nlopt_stop_f(stop, feasible ? 0 : penalty[k], 
+                                            minf_penalty))
+                             ret = NLOPT_FTOL_REACHED;
+                        else if (nlopt_stop_x(stop, xs+k*n, x))
+                             ret = NLOPT_XTOL_REACHED;
+                   }
+                   memcpy(x, xs+k*n, sizeof(double)*n);
+                   *minf = fval[k];
+                   minf_penalty = feasible ? 0 : penalty[k];
+                   minf_gpenalty = feasible ? 0 : gpenalty;
+                   if (ret != NLOPT_SUCCESS) goto done;
+              }
+
+              if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+              else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+              else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+              if (ret != NLOPT_SUCCESS) goto done;
+         }
+
+         /* "selection" step: rank the population */
+         for (k = 0; k < population; ++k) irank[k] = k;
+         if (all_feasible) /* special case: rank by objective function */
+              nlopt_qsort_r(irank, population, sizeof(int), fval,key_compare);
+         else {
+              /* Runarsson & Yao's stochastic ranking of the population */
+              for (i = 0; i < population; ++i) {
+                   int swapped = 0;
+                   for (j = 0; j < population-1; ++j) {
+                        double u = nlopt_urand(0,1);
+                        if (u < PF || (penalty[irank[j]] == 0
+                                       && penalty[irank[j+1]] == 0)) {
+                             if (fval[irank[j]] > fval[irank[j+1]]) {
+                                  int irankj = irank[j];
+                                  irank[j] = irank[j+1];
+                                  irank[j+1] = irankj;
+                                  swapped = 1;
+                             }
+                        }
+                        else if (penalty[irank[j]] > penalty[irank[j+1]]) {
+                             int irankj = irank[j];
+                             irank[j] = irank[j+1];
+                             irank[j+1] = irankj;
+                             swapped = 1;
+                        }
+                   }
+                   if (!swapped) break;
+              }
+         }
+
+         /* evolve the population:
+            differential evolution for the best survivors,
+            and standard mutation of the best survivors for the rest: */
+         for (k = survivors; k < population; ++k) { /* standard mutation */
+              double taup_rand = taup * nlopt_nrand(0,1);
+              int rk = irank[k], ri;
+              i = k % survivors;
+              ri = irank[i];
+              for (j = 0; j < n; ++j) {
+                   double sigmamax = (ub[j] - lb[j]) / sqrt(n);
+                   sigmas[rk*n+j] = sigmas[ri*n+j] 
+                        * exp(taup_rand + tau*nlopt_nrand(0,1));
+                   if (sigmas[rk*n+j] > sigmamax)
+                        sigmas[rk*n+j] = sigmamax;
+                   do {
+                        xs[rk*n+j] = xs[ri*n+j] 
+                             + sigmas[rk*n+j] * nlopt_nrand(0,1);
+                   } while (xs[rk*n+j] < lb[j] || xs[rk*n+j] > ub[j]);
+                   sigmas[rk*n+j] = sigmas[ri*n+j] + ALPHA*(sigmas[rk*n+j]
+                                                          - sigmas[ri*n+j]);
+              }
+         }
+         memcpy(x0, xs, n * sizeof(double));
+         for (k = 0; k < survivors; ++k) { /* differential variation */
+              double taup_rand = taup * nlopt_nrand(0,1);
+              int rk = irank[k];
+              for (j = 0; j < n; ++j) {
+                   double xi = xs[rk*n+j];
+                   if (k+1 < survivors)
+                        xs[rk*n+j] += GAMMA * (x0[j] - xs[(k+1)*n+j]);
+                   if (k+1 == survivors
+                       || xs[rk*n+j] < lb[j] || xs[rk*n+j] > ub[j]) {
+                        /* standard mutation for last survivor and
+                           for any survivor components that are now
+                           outside the bounds */
+                        double sigmamax = (ub[j] - lb[j]) / sqrt(n);
+                        double sigi = sigmas[rk*n+j];
+                        sigmas[rk*n+j] *= exp(taup_rand 
+                                              + tau*nlopt_nrand(0,1));
+                        if (sigmas[rk*n+j] > sigmamax)
+                             sigmas[rk*n+j] = sigmamax;
+                        do {
+                             xs[rk*n+j] = xi 
+                                  + sigmas[rk*n+j] * nlopt_nrand(0,1);
+                        } while (xs[rk*n+j] < lb[j] || xs[rk*n+j] > ub[j]);
+                        sigmas[rk*n+j] = sigi 
+                             + ALPHA * (sigmas[rk*n+j] - sigi);
+                   }
+              }
+         }
+     }
+
+done:
+     if (irank) free(irank);
+     if (sigmas) free(sigmas);
+     if (results) free(results);
+     return ret;
+}
diff --git a/isres/isres.h b/isres/isres.h
new file mode 100644 (file)
index 0000000..7ef7f41
--- /dev/null
@@ -0,0 +1,48 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef ISRES_H
+#define ISRES_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result isres_minimize(int n, nlopt_func f, void *f_data,
+                           int m, nlopt_constraint *fc, /* fc <= 0  */
+                           int p, nlopt_constraint *h, /* h == 0 */
+                           const double *lb, const double *ub, /* bounds */
+                           double *x, /* in: initial guess, out: minimizer */
+                           double *minf,
+                           nlopt_stopping *stop,
+                           int population); /* init. population */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100644 (file)
index 0000000..63ae69d
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,9655 @@
+
+# libtool (GNU libtool) 2.4.2
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
+# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#       --config             show all configuration variables
+#       --debug              enable verbose shell tracing
+#   -n, --dry-run            display commands without modifying any files
+#       --features           display basic configuration information and exit
+#       --mode=MODE          use operation mode MODE
+#       --preserve-dup-deps  don't remove duplicate dependency libraries
+#       --quiet, --silent    don't print informational messages
+#       --no-quiet, --no-silent
+#                            print informational messages (default)
+#       --no-warn            don't display warning messages
+#       --tag=TAG            use configuration variables from tag TAG
+#   -v, --verbose            print more informational messages than default
+#       --no-verbose         don't print the extra informational messages
+#       --version            print version information
+#   -h, --help, --help-all   print short, long, or detailed help message
+#
+# MODE must be one of the following:
+#
+#         clean              remove files from the build directory
+#         compile            compile a source file into a libtool object
+#         execute            automatically set library path, then run a program
+#         finish             complete the installation of libtool libraries
+#         install            install libraries or executables
+#         link               create a library or an executable
+#         uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.  When passed as first option,
+# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#         host-triplet:        $host
+#         shell:               $SHELL
+#         compiler:            $LTCC
+#         compiler flags:              $LTCFLAGS
+#         linker:              $LD (gnu? $with_gnu_ld)
+#         $progname:   (GNU libtool) 2.4.2
+#         automake:    $automake_version
+#         autoconf:    $autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+# General help using GNU software: <http://www.gnu.org/gethelp/>.
+
+PROGRAM=libtool
+PACKAGE=libtool
+VERSION=2.4.2
+TIMESTAMP=""
+package_revision=1.3337
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# NLS nuisances: We save the old values to restore during execute mode.
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+         export $lt_var
+         lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+         lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+       fi"
+done
+LC_ALL=C
+LANGUAGE=C
+export LANGUAGE LC_ALL
+
+$lt_unset CDPATH
+
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+
+
+: ${CP="cp -f"}
+test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77     # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS="  $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+    if test "X$func_dirname_result" = "X${1}"; then
+      func_dirname_result="${3}"
+    else
+      func_dirname_result="$func_dirname_result${2}"
+    fi
+} # func_dirname may be replaced by extended shell implementation
+
+
+# func_basename file
+func_basename ()
+{
+    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+} # func_basename may be replaced by extended shell implementation
+
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+    # Extract subdirectory from the argument.
+    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
+    if test "X$func_dirname_result" = "X${1}"; then
+      func_dirname_result="${3}"
+    else
+      func_dirname_result="$func_dirname_result${2}"
+    fi
+    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
+} # func_dirname_and_basename may be replaced by extended shell implementation
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+    case ${2} in
+      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+    esac
+} # func_stripname may be replaced by extended shell implementation
+
+
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar='s,^/\([^/]*\).*$,\1,'
+pathcdr='s,^/[^/]*,,'
+removedotparts=':dotsl
+               s@/\./@/@g
+               t dotsl
+               s,/\.$,/,'
+collapseslashes='s@/\{1,\}@/@g'
+finalslash='s,/*$,/,'
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+#             value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+  # Start from root dir and reassemble the path.
+  func_normal_abspath_result=
+  func_normal_abspath_tpath=$1
+  func_normal_abspath_altnamespace=
+  case $func_normal_abspath_tpath in
+    "")
+      # Empty path, that just means $cwd.
+      func_stripname '' '/' "`pwd`"
+      func_normal_abspath_result=$func_stripname_result
+      return
+    ;;
+    # The next three entries are used to spot a run of precisely
+    # two leading slashes without using negated character classes;
+    # we take advantage of case's first-match behaviour.
+    ///*)
+      # Unusual form of absolute path, do nothing.
+    ;;
+    //*)
+      # Not necessarily an ordinary path; POSIX reserves leading '//'
+      # and for example Cygwin uses it to access remote file shares
+      # over CIFS/SMB, so we conserve a leading double slash if found.
+      func_normal_abspath_altnamespace=/
+    ;;
+    /*)
+      # Absolute path, do nothing.
+    ;;
+    *)
+      # Relative path, prepend $cwd.
+      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+    ;;
+  esac
+  # Cancel out all the simple stuff to save iterations.  We also want
+  # the path to end with a slash for ease of parsing, so make sure
+  # there is one (and only one) here.
+  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+  while :; do
+    # Processed it all yet?
+    if test "$func_normal_abspath_tpath" = / ; then
+      # If we ascended to the root using ".." the result may be empty now.
+      if test -z "$func_normal_abspath_result" ; then
+        func_normal_abspath_result=/
+      fi
+      break
+    fi
+    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcar"`
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcdr"`
+    # Figure out what to do with it
+    case $func_normal_abspath_tcomponent in
+      "")
+        # Trailing empty path component, ignore it.
+      ;;
+      ..)
+        # Parent dir; strip last assembled component from result.
+        func_dirname "$func_normal_abspath_result"
+        func_normal_abspath_result=$func_dirname_result
+      ;;
+      *)
+        # Actual path component, append it.
+        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+      ;;
+    esac
+  done
+  # Restore leading double-slash if one was found on entry.
+  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+#             value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+  func_relative_path_result=
+  func_normal_abspath "$1"
+  func_relative_path_tlibdir=$func_normal_abspath_result
+  func_normal_abspath "$2"
+  func_relative_path_tbindir=$func_normal_abspath_result
+
+  # Ascend the tree starting from libdir
+  while :; do
+    # check if we have found a prefix of bindir
+    case $func_relative_path_tbindir in
+      $func_relative_path_tlibdir)
+        # found an exact match
+        func_relative_path_tcancelled=
+        break
+        ;;
+      $func_relative_path_tlibdir*)
+        # found a matching prefix
+        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+        func_relative_path_tcancelled=$func_stripname_result
+        if test -z "$func_relative_path_result"; then
+          func_relative_path_result=.
+        fi
+        break
+        ;;
+      *)
+        func_dirname $func_relative_path_tlibdir
+        func_relative_path_tlibdir=${func_dirname_result}
+        if test "x$func_relative_path_tlibdir" = x ; then
+          # Have to descend all the way to the root!
+          func_relative_path_result=../$func_relative_path_result
+          func_relative_path_tcancelled=$func_relative_path_tbindir
+          break
+        fi
+        func_relative_path_result=../$func_relative_path_result
+        ;;
+    esac
+  done
+
+  # Now calculate path; take care to avoid doubling-up slashes.
+  func_stripname '' '/' "$func_relative_path_result"
+  func_relative_path_result=$func_stripname_result
+  func_stripname '/' '/' "$func_relative_path_tcancelled"
+  if test "x$func_stripname_result" != x ; then
+    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+  fi
+
+  # Normalisation. If bindir is libdir, return empty string,
+  # else relative path ending with a slash; either way, target
+  # file name can be directly appended.
+  if test ! -z "$func_relative_path_result"; then
+    func_stripname './' '' "$func_relative_path_result/"
+    func_relative_path_result=$func_stripname_result
+  fi
+}
+
+# The name of this program:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=${PATH_SEPARATOR-:}
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+
+# Sed substitution that converts a w32 file name or path
+# which contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+       # list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+       IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "$my_tmpdir"
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+       func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+       my_arg=`$ECHO "$1" | $SED \
+           -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+       eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+           $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+       eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+# func_tr_sh
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+  case $1 in
+  [0-9]* | *[!a-zA-Z0-9_]*)
+    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
+    ;;
+  * )
+    func_tr_sh_result=$1
+    ;;
+  esac
+}
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $opt_debug
+
+    $SED -n '/(C)/!b go
+       :more
+       /\./!{
+         N
+         s/\n# / /
+         b more
+       }
+       :go
+       /^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+       s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $opt_debug
+
+    $SED -n '/^# Usage:/,/^#  *.*--help/ {
+        s/^# //
+       s/^# *$//
+       s/\$progname/'$progname'/
+       p
+    }' < "$progpath"
+    echo
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help [NOEXIT]
+# Echo long help message to standard output and exit,
+# unless 'noexit' is passed as argument.
+func_help ()
+{
+    $opt_debug
+
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+       :print
+        s/^# //
+       s/^# *$//
+       s*\$progname*'$progname'*
+       s*\$host*'"$host"'*
+       s*\$SHELL*'"$SHELL"'*
+       s*\$LTCC*'"$LTCC"'*
+       s*\$LTCFLAGS*'"$LTCFLAGS"'*
+       s*\$LD*'"$LD"'*
+       s/\$with_gnu_ld/'"$with_gnu_ld"'/
+       s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
+       s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
+       p
+       d
+     }
+     /^# .* home page:/b print
+     /^# General help using/b print
+     ' < "$progpath"
+    ret=$?
+    if test -z "$1"; then
+      exit $ret
+    fi
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    $opt_debug
+
+    func_error "missing argument for $1."
+    exit_cmd=exit
+}
+
+
+# func_split_short_opt shortopt
+# Set func_split_short_opt_name and func_split_short_opt_arg shell
+# variables after splitting SHORTOPT after the 2nd character.
+func_split_short_opt ()
+{
+    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
+    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+
+    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
+    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
+} # func_split_short_opt may be replaced by extended shell implementation
+
+
+# func_split_long_opt longopt
+# Set func_split_long_opt_name and func_split_long_opt_arg shell
+# variables after splitting LONGOPT at the `=' sign.
+func_split_long_opt ()
+{
+    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
+    my_sed_long_arg='1s/^--[^=]*=//'
+
+    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
+    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
+} # func_split_long_opt may be replaced by extended shell implementation
+
+exit_cmd=:
+
+
+
+
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+nonopt=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+    eval "${1}=\$${1}\${2}"
+} # func_append may be replaced by extended shell implementation
+
+# func_append_quoted var value
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+func_append_quoted ()
+{
+    func_quote_for_eval "${2}"
+    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
+} # func_append_quoted may be replaced by extended shell implementation
+
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+    func_arith_result=`expr "${@}"`
+} # func_arith may be replaced by extended shell implementation
+
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
+} # func_len may be replaced by extended shell implementation
+
+
+# func_lo2o object
+func_lo2o ()
+{
+    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
+} # func_lo2o may be replaced by extended shell implementation
+
+
+# func_xform libobj-or-source
+func_xform ()
+{
+    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
+} # func_xform may be replaced by extended shell implementation
+
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      echo "enable shared libraries"
+    else
+      echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      echo "enable static libraries"
+    else
+      echo "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+       taglist="$taglist $tagname"
+
+       # Evaluate the configuration.  Be careful to quote the path
+       # and the sed script, to avoid splitting on whitespace, but
+       # also don't use non-portable quotes within backquotes within
+       # quotes we have to do it in 2 steps:
+       extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+       eval "$extractedcf"
+      else
+       func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+# Shorthand for --mode=foo, only valid as the first argument
+case $1 in
+clean|clea|cle|cl)
+  shift; set dummy --mode clean ${1+"$@"}; shift
+  ;;
+compile|compil|compi|comp|com|co|c)
+  shift; set dummy --mode compile ${1+"$@"}; shift
+  ;;
+execute|execut|execu|exec|exe|ex|e)
+  shift; set dummy --mode execute ${1+"$@"}; shift
+  ;;
+finish|finis|fini|fin|fi|f)
+  shift; set dummy --mode finish ${1+"$@"}; shift
+  ;;
+install|instal|insta|inst|ins|in|i)
+  shift; set dummy --mode install ${1+"$@"}; shift
+  ;;
+link|lin|li|l)
+  shift; set dummy --mode link ${1+"$@"}; shift
+  ;;
+uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+  shift; set dummy --mode uninstall ${1+"$@"}; shift
+  ;;
+esac
+
+
+
+# Option defaults:
+opt_debug=:
+opt_dry_run=false
+opt_config=false
+opt_preserve_dup_deps=false
+opt_features=false
+opt_finish=false
+opt_help=false
+opt_help_all=false
+opt_silent=:
+opt_warning=:
+opt_verbose=:
+opt_silent=false
+opt_verbose=false
+
+
+# Parse options once, thoroughly.  This comes as soon as possible in the
+# script to make things like `--version' happen as quickly as we can.
+{
+  # this just eases exit handling
+  while test $# -gt 0; do
+    opt="$1"
+    shift
+    case $opt in
+      --debug|-x)      opt_debug='set -x'
+                       func_echo "enabling shell trace mode"
+                       $opt_debug
+                       ;;
+      --dry-run|--dryrun|-n)
+                       opt_dry_run=:
+                       ;;
+      --config)
+                       opt_config=:
+func_config
+                       ;;
+      --dlopen|-dlopen)
+                       optarg="$1"
+                       opt_dlopen="${opt_dlopen+$opt_dlopen
+}$optarg"
+                       shift
+                       ;;
+      --preserve-dup-deps)
+                       opt_preserve_dup_deps=:
+                       ;;
+      --features)
+                       opt_features=:
+func_features
+                       ;;
+      --finish)
+                       opt_finish=:
+set dummy --mode finish ${1+"$@"}; shift
+                       ;;
+      --help)
+                       opt_help=:
+                       ;;
+      --help-all)
+                       opt_help_all=:
+opt_help=': help-all'
+                       ;;
+      --mode)
+                       test $# = 0 && func_missing_arg $opt && break
+                       optarg="$1"
+                       opt_mode="$optarg"
+case $optarg in
+  # Valid mode arguments:
+  clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+  # Catch anything else as an error
+  *) func_error "invalid argument for $opt"
+     exit_cmd=exit
+     break
+     ;;
+esac
+                       shift
+                       ;;
+      --no-silent|--no-quiet)
+                       opt_silent=false
+func_append preserve_args " $opt"
+                       ;;
+      --no-warning|--no-warn)
+                       opt_warning=false
+func_append preserve_args " $opt"
+                       ;;
+      --no-verbose)
+                       opt_verbose=false
+func_append preserve_args " $opt"
+                       ;;
+      --silent|--quiet)
+                       opt_silent=:
+func_append preserve_args " $opt"
+        opt_verbose=false
+                       ;;
+      --verbose|-v)
+                       opt_verbose=:
+func_append preserve_args " $opt"
+opt_silent=false
+                       ;;
+      --tag)
+                       test $# = 0 && func_missing_arg $opt && break
+                       optarg="$1"
+                       opt_tag="$optarg"
+func_append preserve_args " $opt $optarg"
+func_enable_tag "$optarg"
+                       shift
+                       ;;
+
+      -\?|-h)          func_usage                              ;;
+      --help)          func_help                               ;;
+      --version)       func_version                            ;;
+
+      # Separate optargs to long options:
+      --*=*)
+                       func_split_long_opt "$opt"
+                       set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
+                       shift
+                       ;;
+
+      # Separate non-argument short options:
+      -\?*|-h*|-n*|-v*)
+                       func_split_short_opt "$opt"
+                       set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
+                       shift
+                       ;;
+
+      --)              break                                   ;;
+      -*)              func_fatal_help "unrecognized option \`$opt'" ;;
+      *)               set dummy "$opt" ${1+"$@"};     shift; break  ;;
+    esac
+  done
+
+  # Validate options:
+
+  # save first non-option argument
+  if test "$#" -gt 0; then
+    nonopt="$opt"
+    shift
+  fi
+
+  # preserve --debug
+  test "$opt_debug" = : || func_append preserve_args " --debug"
+
+  case $host in
+    *cygwin* | *mingw* | *pw32* | *cegcc*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+      ;;
+  esac
+
+  $opt_help || {
+    # Sanity checks first:
+    func_check_version_match
+
+    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+      func_fatal_configuration "not configured to build any kind of library"
+    fi
+
+    # Darwin sucks
+    eval std_shrext=\"$shrext_cmds\"
+
+    # Only execute mode is allowed to have -dlopen flags.
+    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
+      func_error "unrecognized option \`-dlopen'"
+      $ECHO "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Change the help message to a mode-specific one.
+    generic_help="$help"
+    help="Try \`$progname --help --mode=$opt_mode' for more information."
+  }
+
+
+  # Bail if the options were screwed
+  $exit_cmd $EXIT_FAILURE
+}
+
+
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    test -f "$1" &&
+      $SED -e 4q "$1" 2>/dev/null \
+        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+       for lalib_p_l in 1 2 3 4
+       do
+           read lalib_p_line
+           case "$lalib_p_line" in
+               \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+           esac
+       done
+       exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_dirname_and_basename "$1" "" "."
+    func_stripname '' '.exe' "$func_basename_result"
+    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)        . "$1" ;;
+    *)         . "./$1" ;;
+    esac
+}
+
+
+# func_resolve_sysroot PATH
+# Replace a leading = in PATH with a sysroot.  Store the result into
+# func_resolve_sysroot_result
+func_resolve_sysroot ()
+{
+  func_resolve_sysroot_result=$1
+  case $func_resolve_sysroot_result in
+  =*)
+    func_stripname '=' '' "$func_resolve_sysroot_result"
+    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
+    ;;
+  esac
+}
+
+# func_replace_sysroot PATH
+# If PATH begins with the sysroot, replace it with = and
+# store the result into func_replace_sysroot_result.
+func_replace_sysroot ()
+{
+  case "$lt_sysroot:$1" in
+  ?*:"$lt_sysroot"*)
+    func_stripname "$lt_sysroot" '' "$1"
+    func_replace_sysroot_result="=$func_stripname_result"
+    ;;
+  *)
+    # Including no sysroot.
+    func_replace_sysroot_result=$1
+    ;;
+  esac
+}
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+       func_append_quoted CC_quoted "$arg"
+      done
+      CC_expanded=`func_echo_all $CC`
+      CC_quoted_expanded=`func_echo_all $CC_quoted`
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+       for z in $available_tags; do
+         if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+           # Evaluate the configuration.
+           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+           CC_quoted=
+           for arg in $CC; do
+             # Double-quote args containing other shell metacharacters.
+             func_append_quoted CC_quoted "$arg"
+           done
+           CC_expanded=`func_echo_all $CC`
+           CC_quoted_expanded=`func_echo_all $CC_quoted`
+           case "$@ " in
+           " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+           " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
+             # The compiler in the base compile command matches
+             # the one in the tagged configuration.
+             # Assume this is the tagged configuration we want.
+             tagname=$z
+             break
+             ;;
+           esac
+         fi
+       done
+       # If $tagname still isn't set, then no tagged configuration
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+         func_echo "unable to infer tagged configuration"
+         func_fatal_error "specify a tag with \`--tag'"
+#      else
+#        func_verbose "using $tagname tagged configuration"
+       fi
+       ;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+
+##################################################
+# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
+##################################################
+
+# func_convert_core_file_wine_to_w32 ARG
+# Helper function used by file name conversion functions when $build is *nix,
+# and $host is mingw, cygwin, or some other w32 environment. Relies on a
+# correctly configured wine environment available, with the winepath program
+# in $build's $PATH.
+#
+# ARG is the $build file name to be converted to w32 format.
+# Result is available in $func_convert_core_file_wine_to_w32_result, and will
+# be empty on error (or when ARG is empty)
+func_convert_core_file_wine_to_w32 ()
+{
+  $opt_debug
+  func_convert_core_file_wine_to_w32_result="$1"
+  if test -n "$1"; then
+    # Unfortunately, winepath does not exit with a non-zero error code, so we
+    # are forced to check the contents of stdout. On the other hand, if the
+    # command is not found, the shell will set an exit code of 127 and print
+    # *an error message* to stdout. So we must check for both error code of
+    # zero AND non-empty stdout, which explains the odd construction:
+    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
+    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
+        $SED -e "$lt_sed_naive_backslashify"`
+    else
+      func_convert_core_file_wine_to_w32_result=
+    fi
+  fi
+}
+# end: func_convert_core_file_wine_to_w32
+
+
+# func_convert_core_path_wine_to_w32 ARG
+# Helper function used by path conversion functions when $build is *nix, and
+# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
+# configured wine environment available, with the winepath program in $build's
+# $PATH. Assumes ARG has no leading or trailing path separator characters.
+#
+# ARG is path to be converted from $build format to win32.
+# Result is available in $func_convert_core_path_wine_to_w32_result.
+# Unconvertible file (directory) names in ARG are skipped; if no directory names
+# are convertible, then the result may be empty.
+func_convert_core_path_wine_to_w32 ()
+{
+  $opt_debug
+  # unfortunately, winepath doesn't convert paths, only file names
+  func_convert_core_path_wine_to_w32_result=""
+  if test -n "$1"; then
+    oldIFS=$IFS
+    IFS=:
+    for func_convert_core_path_wine_to_w32_f in $1; do
+      IFS=$oldIFS
+      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
+      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+        if test -z "$func_convert_core_path_wine_to_w32_result"; then
+          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+        else
+          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
+        fi
+      fi
+    done
+    IFS=$oldIFS
+  fi
+}
+# end: func_convert_core_path_wine_to_w32
+
+
+# func_cygpath ARGS...
+# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
+# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
+# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
+# (2), returns the Cygwin file name or path in func_cygpath_result (input
+# file name or path is assumed to be in w32 format, as previously converted
+# from $build's *nix or MSYS format). In case (3), returns the w32 file name
+# or path in func_cygpath_result (input file name or path is assumed to be in
+# Cygwin format). Returns an empty string on error.
+#
+# ARGS are passed to cygpath, with the last one being the file name or path to
+# be converted.
+#
+# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
+# environment variable; do not put it in $PATH.
+func_cygpath ()
+{
+  $opt_debug
+  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
+    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
+    if test "$?" -ne 0; then
+      # on failure, ensure result is empty
+      func_cygpath_result=
+    fi
+  else
+    func_cygpath_result=
+    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+  fi
+}
+#end: func_cygpath
+
+
+# func_convert_core_msys_to_w32 ARG
+# Convert file name or path ARG from MSYS format to w32 format.  Return
+# result in func_convert_core_msys_to_w32_result.
+func_convert_core_msys_to_w32 ()
+{
+  $opt_debug
+  # awkward: cmd appends spaces to result
+  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
+    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+}
+#end: func_convert_core_msys_to_w32
+
+
+# func_convert_file_check ARG1 ARG2
+# Verify that ARG1 (a file name in $build format) was converted to $host
+# format in ARG2. Otherwise, emit an error message, but continue (resetting
+# func_to_host_file_result to ARG1).
+func_convert_file_check ()
+{
+  $opt_debug
+  if test -z "$2" && test -n "$1" ; then
+    func_error "Could not determine host file name corresponding to"
+    func_error "  \`$1'"
+    func_error "Continuing, but uninstalled executables may not work."
+    # Fallback:
+    func_to_host_file_result="$1"
+  fi
+}
+# end func_convert_file_check
+
+
+# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
+# Verify that FROM_PATH (a path in $build format) was converted to $host
+# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
+# func_to_host_file_result to a simplistic fallback value (see below).
+func_convert_path_check ()
+{
+  $opt_debug
+  if test -z "$4" && test -n "$3"; then
+    func_error "Could not determine the host path corresponding to"
+    func_error "  \`$3'"
+    func_error "Continuing, but uninstalled executables may not work."
+    # Fallback.  This is a deliberately simplistic "conversion" and
+    # should not be "improved".  See libtool.info.
+    if test "x$1" != "x$2"; then
+      lt_replace_pathsep_chars="s|$1|$2|g"
+      func_to_host_path_result=`echo "$3" |
+        $SED -e "$lt_replace_pathsep_chars"`
+    else
+      func_to_host_path_result="$3"
+    fi
+  fi
+}
+# end func_convert_path_check
+
+
+# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
+# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
+# and appending REPL if ORIG matches BACKPAT.
+func_convert_path_front_back_pathsep ()
+{
+  $opt_debug
+  case $4 in
+  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+    ;;
+  esac
+  case $4 in
+  $2 ) func_append func_to_host_path_result "$3"
+    ;;
+  esac
+}
+# end func_convert_path_front_back_pathsep
+
+
+##################################################
+# $build to $host FILE NAME CONVERSION FUNCTIONS #
+##################################################
+# invoked via `$to_host_file_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# Result will be available in $func_to_host_file_result.
+
+
+# func_to_host_file ARG
+# Converts the file name ARG from $build format to $host format. Return result
+# in func_to_host_file_result.
+func_to_host_file ()
+{
+  $opt_debug
+  $to_host_file_cmd "$1"
+}
+# end func_to_host_file
+
+
+# func_to_tool_file ARG LAZY
+# converts the file name ARG from $build format to toolchain format. Return
+# result in func_to_tool_file_result.  If the conversion in use is listed
+# in (the comma separated) LAZY, no conversion takes place.
+func_to_tool_file ()
+{
+  $opt_debug
+  case ,$2, in
+    *,"$to_tool_file_cmd",*)
+      func_to_tool_file_result=$1
+      ;;
+    *)
+      $to_tool_file_cmd "$1"
+      func_to_tool_file_result=$func_to_host_file_result
+      ;;
+  esac
+}
+# end func_to_tool_file
+
+
+# func_convert_file_noop ARG
+# Copy ARG to func_to_host_file_result.
+func_convert_file_noop ()
+{
+  func_to_host_file_result="$1"
+}
+# end func_convert_file_noop
+
+
+# func_convert_file_msys_to_w32 ARG
+# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper.  Returns result in
+# func_to_host_file_result.
+func_convert_file_msys_to_w32 ()
+{
+  $opt_debug
+  func_to_host_file_result="$1"
+  if test -n "$1"; then
+    func_convert_core_msys_to_w32 "$1"
+    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+  fi
+  func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_w32
+
+
+# func_convert_file_cygwin_to_w32 ARG
+# Convert file name ARG from Cygwin to w32 format.  Returns result in
+# func_to_host_file_result.
+func_convert_file_cygwin_to_w32 ()
+{
+  $opt_debug
+  func_to_host_file_result="$1"
+  if test -n "$1"; then
+    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
+    # LT_CYGPATH in this case.
+    func_to_host_file_result=`cygpath -m "$1"`
+  fi
+  func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_cygwin_to_w32
+
+
+# func_convert_file_nix_to_w32 ARG
+# Convert file name ARG from *nix to w32 format.  Requires a wine environment
+# and a working winepath. Returns result in func_to_host_file_result.
+func_convert_file_nix_to_w32 ()
+{
+  $opt_debug
+  func_to_host_file_result="$1"
+  if test -n "$1"; then
+    func_convert_core_file_wine_to_w32 "$1"
+    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+  fi
+  func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_w32
+
+
+# func_convert_file_msys_to_cygwin ARG
+# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_file_msys_to_cygwin ()
+{
+  $opt_debug
+  func_to_host_file_result="$1"
+  if test -n "$1"; then
+    func_convert_core_msys_to_w32 "$1"
+    func_cygpath -u "$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result="$func_cygpath_result"
+  fi
+  func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_cygwin
+
+
+# func_convert_file_nix_to_cygwin ARG
+# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
+# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
+# in func_to_host_file_result.
+func_convert_file_nix_to_cygwin ()
+{
+  $opt_debug
+  func_to_host_file_result="$1"
+  if test -n "$1"; then
+    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
+    func_convert_core_file_wine_to_w32 "$1"
+    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result="$func_cygpath_result"
+  fi
+  func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_cygwin
+
+
+#############################################
+# $build to $host PATH CONVERSION FUNCTIONS #
+#############################################
+# invoked via `$to_host_path_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# The result will be available in $func_to_host_path_result.
+#
+# Path separators are also converted from $build format to $host format.  If
+# ARG begins or ends with a path separator character, it is preserved (but
+# converted to $host format) on output.
+#
+# All path conversion functions are named using the following convention:
+#   file name conversion function    : func_convert_file_X_to_Y ()
+#   path conversion function         : func_convert_path_X_to_Y ()
+# where, for any given $build/$host combination the 'X_to_Y' value is the
+# same.  If conversion functions are added for new $build/$host combinations,
+# the two new functions must follow this pattern, or func_init_to_host_path_cmd
+# will break.
+
+
+# func_init_to_host_path_cmd
+# Ensures that function "pointer" variable $to_host_path_cmd is set to the
+# appropriate value, based on the value of $to_host_file_cmd.
+to_host_path_cmd=
+func_init_to_host_path_cmd ()
+{
+  $opt_debug
+  if test -z "$to_host_path_cmd"; then
+    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
+    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+  fi
+}
+
+
+# func_to_host_path ARG
+# Converts the path ARG from $build format to $host format. Return result
+# in func_to_host_path_result.
+func_to_host_path ()
+{
+  $opt_debug
+  func_init_to_host_path_cmd
+  $to_host_path_cmd "$1"
+}
+# end func_to_host_path
+
+
+# func_convert_path_noop ARG
+# Copy ARG to func_to_host_path_result.
+func_convert_path_noop ()
+{
+  func_to_host_path_result="$1"
+}
+# end func_convert_path_noop
+
+
+# func_convert_path_msys_to_w32 ARG
+# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper.  Returns result in
+# func_to_host_path_result.
+func_convert_path_msys_to_w32 ()
+{
+  $opt_debug
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # Remove leading and trailing path separator characters from ARG.  MSYS
+    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
+    # and winepath ignores them completely.
+    func_stripname : : "$1"
+    func_to_host_path_tmp1=$func_stripname_result
+    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_convert_path_check : ";" \
+      "$func_to_host_path_tmp1" "$func_to_host_path_result"
+    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_convert_path_msys_to_w32
+
+
+# func_convert_path_cygwin_to_w32 ARG
+# Convert path ARG from Cygwin to w32 format.  Returns result in
+# func_to_host_file_result.
+func_convert_path_cygwin_to_w32 ()
+{
+  $opt_debug
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # See func_convert_path_msys_to_w32:
+    func_stripname : : "$1"
+    func_to_host_path_tmp1=$func_stripname_result
+    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
+    func_convert_path_check : ";" \
+      "$func_to_host_path_tmp1" "$func_to_host_path_result"
+    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_convert_path_cygwin_to_w32
+
+
+# func_convert_path_nix_to_w32 ARG
+# Convert path ARG from *nix to w32 format.  Requires a wine environment and
+# a working winepath.  Returns result in func_to_host_file_result.
+func_convert_path_nix_to_w32 ()
+{
+  $opt_debug
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # See func_convert_path_msys_to_w32:
+    func_stripname : : "$1"
+    func_to_host_path_tmp1=$func_stripname_result
+    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_convert_path_check : ";" \
+      "$func_to_host_path_tmp1" "$func_to_host_path_result"
+    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_convert_path_nix_to_w32
+
+
+# func_convert_path_msys_to_cygwin ARG
+# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_path_msys_to_cygwin ()
+{
+  $opt_debug
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # See func_convert_path_msys_to_w32:
+    func_stripname : : "$1"
+    func_to_host_path_tmp1=$func_stripname_result
+    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result="$func_cygpath_result"
+    func_convert_path_check : : \
+      "$func_to_host_path_tmp1" "$func_to_host_path_result"
+    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+  fi
+}
+# end func_convert_path_msys_to_cygwin
+
+
+# func_convert_path_nix_to_cygwin ARG
+# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
+# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
+# func_to_host_file_result.
+func_convert_path_nix_to_cygwin ()
+{
+  $opt_debug
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # Remove leading and trailing path separator characters from
+    # ARG. msys behavior is inconsistent here, cygpath turns them
+    # into '.;' and ';.', and winepath ignores them completely.
+    func_stripname : : "$1"
+    func_to_host_path_tmp1=$func_stripname_result
+    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result="$func_cygpath_result"
+    func_convert_path_check : : \
+      "$func_to_host_path_tmp1" "$func_to_host_path_result"
+    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+  fi
+}
+# end func_convert_path_nix_to_cygwin
+
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+       # do not "continue".  Instead, add this to base_compile
+       lastarg="$arg"
+       arg_mode=normal
+       ;;
+
+      target )
+       libobj="$arg"
+       arg_mode=normal
+       continue
+       ;;
+
+      normal )
+       # Accept any command-line options.
+       case $arg in
+       -o)
+         test -n "$libobj" && \
+           func_fatal_error "you cannot specify \`-o' more than once"
+         arg_mode=target
+         continue
+         ;;
+
+       -pie | -fpie | -fPIE)
+          func_append pie_flag " $arg"
+         continue
+         ;;
+
+       -shared | -static | -prefer-pic | -prefer-non-pic)
+         func_append later " $arg"
+         continue
+         ;;
+
+       -no-suppress)
+         suppress_opt=no
+         continue
+         ;;
+
+       -Xcompiler)
+         arg_mode=arg  #  the next one goes into the "base_compile" arg list
+         continue      #  The current "srcfile" will either be retained or
+         ;;            #  replaced later.  I would guess that would be a bug.
+
+       -Wc,*)
+         func_stripname '-Wc,' '' "$arg"
+         args=$func_stripname_result
+         lastarg=
+         save_ifs="$IFS"; IFS=','
+         for arg in $args; do
+           IFS="$save_ifs"
+           func_append_quoted lastarg "$arg"
+         done
+         IFS="$save_ifs"
+         func_stripname ' ' '' "$lastarg"
+         lastarg=$func_stripname_result
+
+         # Add the arguments to base_compile.
+         func_append base_compile " $lastarg"
+         continue
+         ;;
+
+       *)
+         # Accept the current argument as the source file.
+         # The previous "srcfile" becomes the current argument.
+         #
+         lastarg="$srcfile"
+         srcfile="$arg"
+         ;;
+       esac  #  case $arg
+       ;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_append_quoted base_compile "$lastarg"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+       func_basename "$srcfile"
+       libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+       test "$build_libtool_libs" != yes && \
+         func_fatal_configuration "can not build a shared library"
+       build_old_libs=no
+       continue
+       ;;
+
+      -static)
+       build_libtool_libs=no
+       build_old_libs=yes
+       continue
+       ;;
+
+      -prefer-pic)
+       pic_mode=yes
+       continue
+       ;;
+
+      -prefer-non-pic)
+       pic_mode=no
+       continue
+       ;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'   &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2* | cegcc*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+       func_echo "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+      func_append removelist " $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    func_append removelist " $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
+    srcfile=$func_to_tool_file_result
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+       command="$base_compile $qsrcfile $pic_flag"
+      else
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+       # Place PIC objects in $objdir
+       func_append command " -o $lobj"
+      fi
+
+      func_show_eval_locale "$command" \
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+       func_show_eval '$MV "$output_obj" "$lobj"' \
+         'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+       suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+       # Don't build PIC code
+       command="$base_compile $qsrcfile$pie_flag"
+      else
+       command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+       func_append command " -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      func_append command "$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+       func_show_eval '$MV "$output_obj" "$obj"' \
+         'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+       removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $opt_mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to build PIC objects only
+  -prefer-non-pic   try to build non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+  -Wc,FLAG          pass FLAG directly to the compiler
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -bindir BINDIR    specify path to binaries directory (for systems where
+                    libraries must be found in the PATH setting at runtime)
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+  -Wc,FLAG
+  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
+  -Wl,FLAG
+  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
+  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$opt_mode'"
+        ;;
+    esac
+
+    echo
+    $ECHO "Try \`$progname --help' for more information about other modes."
+}
+
+# Now that we've collected a possible --mode arg, show help if necessary
+if $opt_help; then
+  if test "$opt_help" = :; then
+    func_mode_help
+  else
+    {
+      func_help noexit
+      for opt_mode in compile link execute install finish uninstall clean; do
+       func_mode_help
+      done
+    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    {
+      func_help noexit
+      for opt_mode in compile link execute install finish uninstall clean; do
+       echo
+       func_mode_help
+      done
+    } |
+    sed '1d
+      /^When reporting/,/^Report/{
+       H
+       d
+      }
+      $x
+      /information about other modes/d
+      /more detailed .*MODE/d
+      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
+  fi
+  exit $?
+fi
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $opt_dlopen; do
+      test -f "$file" \
+       || func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+       func_resolve_sysroot "$file"
+       file=$func_resolve_sysroot_result
+
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$file" \
+         || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+       func_source "$file"
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && \
+           func_warning "\`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       func_dirname "$file" "" "."
+       dir="$func_dirname_result"
+
+       if test -f "$dir/$objdir/$dlname"; then
+         func_append dir "/$objdir"
+       else
+         if test ! -f "$dir/$dlname"; then
+           func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+         fi
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       func_dirname "$file" "" "."
+       dir="$func_dirname_result"
+       ;;
+
+      *)
+       func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+       continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -* | *.la | *.lo ) ;;
+      *)
+       # Do a test to see if this is really a libtool program.
+       if func_ltwrapper_script_p "$file"; then
+         func_source "$file"
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       elif func_ltwrapper_executable_p "$file"; then
+         func_ltwrapper_scriptname "$file"
+         func_source "$func_ltwrapper_scriptname_result"
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+       ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_append_quoted args "$file"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+       # Export the shlibpath_var.
+       eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+       eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+             else
+               $lt_unset $lt_var
+             fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+       eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+       echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libs=
+    libdirs=
+    admincmds=
+
+    for opt in "$nonopt" ${1+"$@"}
+    do
+      if test -d "$opt"; then
+       func_append libdirs " $opt"
+
+      elif test -f "$opt"; then
+       if func_lalib_unsafe_p "$opt"; then
+         func_append libs " $opt"
+       else
+         func_warning "\`$opt' is not a valid libtool archive"
+       fi
+
+      else
+       func_fatal_error "invalid argument \`$opt'"
+      fi
+    done
+
+    if test -n "$libs"; then
+      if test -n "$lt_sysroot"; then
+        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
+        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
+      else
+        sysroot_cmd=
+      fi
+
+      # Remove sysroot references
+      if $opt_dry_run; then
+        for lib in $libs; do
+          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+        done
+      else
+        tmpdir=`func_mktempdir`
+        for lib in $libs; do
+         sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+           > $tmpdir/tmp-la
+         mv -f $tmpdir/tmp-la $lib
+       done
+        ${RM}r "$tmpdir"
+      fi
+    fi
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for libdir in $libdirs; do
+       if test -n "$finish_cmds"; then
+         # Do each command in the finish commands.
+         func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+       fi
+       if test -n "$finish_eval"; then
+         # Do the single finish_eval.
+         eval cmds=\"$finish_eval\"
+         $opt_dry_run || eval "$cmds" || func_append admincmds "
+       $cmds"
+       fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      echo "----------------------------------------------------------------------"
+      echo "Libraries have been installed in:"
+      for libdir in $libdirs; do
+       $ECHO "   $libdir"
+      done
+      echo
+      echo "If you ever happen to want to link against installed libraries"
+      echo "in a given directory, LIBDIR, you must either use libtool, and"
+      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "flag during linking and do at least one of the following:"
+      if test -n "$shlibpath_var"; then
+       echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+       echo "     during execution"
+      fi
+      if test -n "$runpath_var"; then
+       echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+       echo "     during linking"
+      fi
+      if test -n "$hardcode_libdir_flag_spec"; then
+       libdir=LIBDIR
+       eval flag=\"$hardcode_libdir_flag_spec\"
+
+       $ECHO "   - use the \`$flag' linker flag"
+      fi
+      if test -n "$admincmds"; then
+       $ECHO "   - have your system administrator run these commands:$admincmds"
+      fi
+      if test -f /etc/ld.so.conf; then
+       echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+      fi
+      echo
+
+      echo "See any operating system documentation about shared libraries for"
+      case $host in
+       solaris2.[6789]|solaris2.1[0-9])
+         echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+         echo "pages."
+         ;;
+       *)
+         echo "more information, such as the ld(1) and ld.so(8) manual pages."
+         ;;
+      esac
+      echo "----------------------------------------------------------------------"
+    fi
+    exit $EXIT_SUCCESS
+}
+
+test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       case $nonopt in *shtool*) :;; *) false;; esac; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    func_append install_prog "$func_quote_for_eval_result"
+    install_shared_prog=$install_prog
+    case " $install_prog " in
+      *[\\\ /]cp\ *) install_cp=: ;;
+      *) install_cp=false ;;
+    esac
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    no_mode=:
+    for arg
+    do
+      arg2=
+      if test -n "$dest"; then
+       func_append files " $dest"
+       dest=$arg
+       continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+       if $install_cp; then :; else
+         prev=$arg
+       fi
+       ;;
+      -g | -m | -o)
+       prev=$arg
+       ;;
+      -s)
+       stripme=" -s"
+       continue
+       ;;
+      -*)
+       ;;
+      *)
+       # If the previous option needed an argument, then skip it.
+       if test -n "$prev"; then
+         if test "x$prev" = x-m && test -n "$install_override_mode"; then
+           arg2=$install_override_mode
+           no_mode=false
+         fi
+         prev=
+       else
+         dest=$arg
+         continue
+       fi
+       ;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      func_append install_prog " $func_quote_for_eval_result"
+      if test -n "$arg2"; then
+       func_quote_for_eval "$arg2"
+      fi
+      func_append install_shared_prog " $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -n "$install_override_mode" && $no_mode; then
+      if $install_cp; then :; else
+       func_quote_for_eval "$install_override_mode"
+       func_append install_shared_prog " -m $func_quote_for_eval_result"
+      fi
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+       func_fatal_help "no file or destination specified"
+      else
+       func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+       func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+       case $file in
+       *.lo) ;;
+       *)
+         func_fatal_help "\`$destdir' must be an absolute directory name"
+         ;;
+       esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+       # Do the static libraries later.
+       func_append staticlibs " $file"
+       ;;
+
+      *.la)
+       func_resolve_sysroot "$file"
+       file=$func_resolve_sysroot_result
+
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$file" \
+         || func_fatal_help "\`$file' is not a valid libtool archive"
+
+       library_names=
+       old_library=
+       relink_command=
+       func_source "$file"
+
+       # Add the libdir to current_libdirs if it is the destination.
+       if test "X$destdir" = "X$libdir"; then
+         case "$current_libdirs " in
+         *" $libdir "*) ;;
+         *) func_append current_libdirs " $libdir" ;;
+         esac
+       else
+         # Note the libdir as a future libdir.
+         case "$future_libdirs " in
+         *" $libdir "*) ;;
+         *) func_append future_libdirs " $libdir" ;;
+         esac
+       fi
+
+       func_dirname "$file" "/" ""
+       dir="$func_dirname_result"
+       func_append dir "$objdir"
+
+       if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+         test "$inst_prefix_dir" = "$destdir" && \
+           func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+         fi
+
+         func_warning "relinking \`$file'"
+         func_show_eval "$relink_command" \
+           'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+       fi
+
+       # See the names of the shared library.
+       set dummy $library_names; shift
+       if test -n "$1"; then
+         realname="$1"
+         shift
+
+         srcname="$realname"
+         test -n "$relink_command" && srcname="$realname"T
+
+         # Install the shared library and build the symlinks.
+         func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
+             'exit $?'
+         tstripme="$stripme"
+         case $host_os in
+         cygwin* | mingw* | pw32* | cegcc*)
+           case $realname in
+           *.dll.a)
+             tstripme=""
+             ;;
+           esac
+           ;;
+         esac
+         if test -n "$tstripme" && test -n "$striplib"; then
+           func_show_eval "$striplib $destdir/$realname" 'exit $?'
+         fi
+
+         if test "$#" -gt 0; then
+           # Delete the old symlinks, and create new ones.
+           # Try `ln -sf' first, because the `ln' binary might depend on
+           # the symlink we replace!  Solaris /bin/ln does not understand -f,
+           # so we also need to try rm && ln -s.
+           for linkname
+           do
+             test "$linkname" != "$realname" \
+               && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+           done
+         fi
+
+         # Do each command in the postinstall commands.
+         lib="$destdir/$realname"
+         func_execute_cmds "$postinstall_cmds" 'exit $?'
+       fi
+
+       # Install the pseudo-library for information purposes.
+       func_basename "$file"
+       name="$func_basename_result"
+       instname="$dir/$name"i
+       func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+       # Maybe install the static library, too.
+       test -n "$old_library" && func_append staticlibs " $dir/$old_library"
+       ;;
+
+      *.lo)
+       # Install (i.e. copy) a libtool object.
+
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         func_basename "$file"
+         destfile="$func_basename_result"
+         destfile="$destdir/$destfile"
+       fi
+
+       # Deduce the name of the destination old-style object file.
+       case $destfile in
+       *.lo)
+         func_lo2o "$destfile"
+         staticdest=$func_lo2o_result
+         ;;
+       *.$objext)
+         staticdest="$destfile"
+         destfile=
+         ;;
+       *)
+         func_fatal_help "cannot copy a libtool object to \`$destfile'"
+         ;;
+       esac
+
+       # Install the libtool object if requested.
+       test -n "$destfile" && \
+         func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+       # Install the old object if enabled.
+       if test "$build_old_libs" = yes; then
+         # Deduce the name of the old-style object file.
+         func_lo2o "$file"
+         staticobj=$func_lo2o_result
+         func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+       fi
+       exit $EXIT_SUCCESS
+       ;;
+
+      *)
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         func_basename "$file"
+         destfile="$func_basename_result"
+         destfile="$destdir/$destfile"
+       fi
+
+       # If the file is missing, and there is a .exe on the end, strip it
+       # because it is most likely a libtool script we actually want to
+       # install
+       stripped_ext=""
+       case $file in
+         *.exe)
+           if test ! -f "$file"; then
+             func_stripname '' '.exe' "$file"
+             file=$func_stripname_result
+             stripped_ext=".exe"
+           fi
+           ;;
+       esac
+
+       # Do a test to see if this is really a libtool program.
+       case $host in
+       *cygwin* | *mingw*)
+           if func_ltwrapper_executable_p "$file"; then
+             func_ltwrapper_scriptname "$file"
+             wrapper=$func_ltwrapper_scriptname_result
+           else
+             func_stripname '' '.exe' "$file"
+             wrapper=$func_stripname_result
+           fi
+           ;;
+       *)
+           wrapper=$file
+           ;;
+       esac
+       if func_ltwrapper_script_p "$wrapper"; then
+         notinst_deplibs=
+         relink_command=
+
+         func_source "$wrapper"
+
+         # Check the variables that should have been set.
+         test -z "$generated_by_libtool_version" && \
+           func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+         finalize=yes
+         for lib in $notinst_deplibs; do
+           # Check to see that each library is installed.
+           libdir=
+           if test -f "$lib"; then
+             func_source "$lib"
+           fi
+           libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+           if test -n "$libdir" && test ! -f "$libfile"; then
+             func_warning "\`$lib' has not been installed in \`$libdir'"
+             finalize=no
+           fi
+         done
+
+         relink_command=
+         func_source "$wrapper"
+
+         outputname=
+         if test "$fast_install" = no && test -n "$relink_command"; then
+           $opt_dry_run || {
+             if test "$finalize" = yes; then
+               tmpdir=`func_mktempdir`
+               func_basename "$file$stripped_ext"
+               file="$func_basename_result"
+               outputname="$tmpdir/$file"
+               # Replace the output file specification.
+               relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
+
+               $opt_silent || {
+                 func_quote_for_expand "$relink_command"
+                 eval "func_echo $func_quote_for_expand_result"
+               }
+               if eval "$relink_command"; then :
+                 else
+                 func_error "error: relink \`$file' with the above command before installing it"
+                 $opt_dry_run || ${RM}r "$tmpdir"
+                 continue
+               fi
+               file="$outputname"
+             else
+               func_warning "cannot relink \`$file'"
+             fi
+           }
+         else
+           # Install the binary that we compiled earlier.
+           file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
+         fi
+       fi
+
+       # remove .exe since cygwin /usr/bin/install will append another
+       # one anyway
+       case $install_prog,$host in
+       */usr/bin/install*,*cygwin*)
+         case $file:$destfile in
+         *.exe:*.exe)
+           # this is ok
+           ;;
+         *.exe:*)
+           destfile=$destfile.exe
+           ;;
+         *:*.exe)
+           func_stripname '' '.exe' "$destfile"
+           destfile=$func_stripname_result
+           ;;
+         esac
+         ;;
+       esac
+       func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+       $opt_dry_run || if test -n "$outputname"; then
+         ${RM}r "$tmpdir"
+       fi
+       ;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+      tool_oldlib=$func_to_tool_file_result
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+       func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$opt_mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+       my_dlsyms="${my_outputname}S.c"
+      else
+       func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+       # Discover the nlist of each of the dlfiles.
+       nlist="$output_objdir/${my_outputname}.nm"
+
+       func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+       # Parse the name list into a source file.
+       func_verbose "creating $output_objdir/$my_dlsyms"
+
+       $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#endif
+
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+       if test "$dlself" = yes; then
+         func_verbose "generating symbol list for \`$output'"
+
+         $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+         # Add our own program objects to the symbol list.
+         progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+         for progfile in $progfiles; do
+           func_to_tool_file "$progfile" func_convert_file_msys_to_w32
+           func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+           $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
+         done
+
+         if test -n "$exclude_expsyms"; then
+           $opt_dry_run || {
+             eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+           }
+         fi
+
+         if test -n "$export_symbols_regex"; then
+           $opt_dry_run || {
+             eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+           }
+         fi
+
+         # Prepare the list of exported symbols
+         if test -z "$export_symbols"; then
+           export_symbols="$output_objdir/$outputname.exp"
+           $opt_dry_run || {
+             $RM $export_symbols
+             eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+             case $host in
+             *cygwin* | *mingw* | *cegcc* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+               ;;
+             esac
+           }
+         else
+           $opt_dry_run || {
+             eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+             eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+             case $host in
+               *cygwin* | *mingw* | *cegcc* )
+                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                 ;;
+             esac
+           }
+         fi
+       fi
+
+       for dlprefile in $dlprefiles; do
+         func_verbose "extracting global C symbols from \`$dlprefile'"
+         func_basename "$dlprefile"
+         name="$func_basename_result"
+          case $host in
+           *cygwin* | *mingw* | *cegcc* )
+             # if an import library, we need to obtain dlname
+             if func_win32_import_lib_p "$dlprefile"; then
+               func_tr_sh "$dlprefile"
+               eval "curr_lafile=\$libfile_$func_tr_sh_result"
+               dlprefile_dlbasename=""
+               if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
+                 # Use subshell, to avoid clobbering current variable values
+                 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
+                 if test -n "$dlprefile_dlname" ; then
+                   func_basename "$dlprefile_dlname"
+                   dlprefile_dlbasename="$func_basename_result"
+                 else
+                   # no lafile. user explicitly requested -dlpreopen <import library>.
+                   $sharedlib_from_linklib_cmd "$dlprefile"
+                   dlprefile_dlbasename=$sharedlib_from_linklib_result
+                 fi
+               fi
+               $opt_dry_run || {
+                 if test -n "$dlprefile_dlbasename" ; then
+                   eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
+                 else
+                   func_warning "Could not compute DLL name from $name"
+                   eval '$ECHO ": $name " >> "$nlist"'
+                 fi
+                 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+                 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
+                   $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
+               }
+             else # not an import lib
+               $opt_dry_run || {
+                 eval '$ECHO ": $name " >> "$nlist"'
+                 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+                 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+               }
+             fi
+           ;;
+           *)
+             $opt_dry_run || {
+               eval '$ECHO ": $name " >> "$nlist"'
+               func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+               eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+             }
+           ;;
+          esac
+       done
+
+       $opt_dry_run || {
+         # Make sure we have at least an empty file.
+         test -f "$nlist" || : > "$nlist"
+
+         if test -n "$exclude_expsyms"; then
+           $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+           $MV "$nlist"T "$nlist"
+         fi
+
+         # Try sorting and uniquifying the output.
+         if $GREP -v "^: " < "$nlist" |
+             if sort -k 3 </dev/null >/dev/null 2>&1; then
+               sort -k 3
+             else
+               sort +2
+             fi |
+             uniq > "$nlist"S; then
+           :
+         else
+           $GREP -v "^: " < "$nlist" > "$nlist"S
+         fi
+
+         if test -f "$nlist"S; then
+           eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+         else
+           echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
+         fi
+
+         echo >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+extern LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+         case $need_lib_prefix in
+         no)
+           eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+           ;;
+         *)
+           eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+           ;;
+         esac
+         echo >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+       } # !$opt_dry_run
+
+       pic_flag_for_symtable=
+       case "$compile_command " in
+       *" -static "*) ;;
+       *)
+         case $host in
+         # compiling the symbol table file with pic_flag works around
+         # a FreeBSD bug that causes programs to crash when -lm is
+         # linked before any other PIC object.  But we must not use
+         # pic_flag when linking with -static.  The problem exists in
+         # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+         *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+           pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+         *-*-hpux*)
+           pic_flag_for_symtable=" $pic_flag"  ;;
+         *)
+           if test "X$my_pic_p" != Xno; then
+             pic_flag_for_symtable=" $pic_flag"
+           fi
+           ;;
+         esac
+         ;;
+       esac
+       symtab_cflags=
+       for arg in $LTCFLAGS; do
+         case $arg in
+         -pie | -fpie | -fPIE) ;;
+         *) func_append symtab_cflags " $arg" ;;
+         esac
+       done
+
+       # Now compile the dynamic symbol file.
+       func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+       # Clean up the generated files.
+       func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+       # Transform the symbol file into the correct name.
+       symfileobj="$output_objdir/${my_outputname}S.$objext"
+       case $host in
+       *cygwin* | *mingw* | *cegcc* )
+         if test -f "$output_objdir/$my_outputname.def"; then
+           compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+           finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+         else
+           compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+           finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         fi
+         ;;
+       *)
+         compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         ;;
+       esac
+       ;;
+      *)
+       func_fatal_error "unknown suffix for \`$my_dlsyms'"
+       ;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+# Despite the name, also deal with 64 bit binaries.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
+      func_to_tool_file "$1" func_convert_file_msys_to_w32
+      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+       $SED -n -e '
+           1,100{
+               / I /{
+                   s,.*,import,
+                   p
+                   q
+               }
+           }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+# func_cygming_dll_for_implib ARG
+#
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+# Invoked by eval'ing the libtool variable
+#    $sharedlib_from_linklib_cmd
+# Result is available in the variable
+#    $sharedlib_from_linklib_result
+func_cygming_dll_for_implib ()
+{
+  $opt_debug
+  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
+}
+
+# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
+#
+# The is the core of a fallback implementation of a
+# platform-specific function to extract the name of the
+# DLL associated with the specified import library LIBNAME.
+#
+# SECTION_NAME is either .idata$6 or .idata$7, depending
+# on the platform and compiler that created the implib.
+#
+# Echos the name of the DLL associated with the
+# specified import library.
+func_cygming_dll_for_implib_fallback_core ()
+{
+  $opt_debug
+  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
+  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
+    $SED '/^Contents of section '"$match_literal"':/{
+      # Place marker at beginning of archive member dllname section
+      s/.*/====MARK====/
+      p
+      d
+    }
+    # These lines can sometimes be longer than 43 characters, but
+    # are always uninteresting
+    /:[         ]*file format pe[i]\{,1\}-/d
+    /^In archive [^:]*:/d
+    # Ensure marker is printed
+    /^====MARK====/p
+    # Remove all lines with less than 43 characters
+    /^.\{43\}/!d
+    # From remaining lines, remove first 43 characters
+    s/^.\{43\}//' |
+    $SED -n '
+      # Join marker and all lines until next marker into a single line
+      /^====MARK====/ b para
+      H
+      $ b para
+      b
+      :para
+      x
+      s/\n//g
+      # Remove the marker
+      s/^====MARK====//
+      # Remove trailing dots and whitespace
+      s/[\. \t]*$//
+      # Print
+      /./p' |
+    # we now have a list, one entry per line, of the stringified
+    # contents of the appropriate section of all members of the
+    # archive which possess that section. Heuristic: eliminate
+    # all those which have a first or second character that is
+    # a '.' (that is, objdump's representation of an unprintable
+    # character.) This should work for all archives with less than
+    # 0x302f exports -- but will fail for DLLs whose name actually
+    # begins with a literal '.' or a single character followed by
+    # a '.'.
+    #
+    # Of those that remain, print the first one.
+    $SED -e '/^\./d;/^.\./d;q'
+}
+
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $opt_debug
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $opt_debug
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
+# func_cygming_dll_for_implib_fallback ARG
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+#
+# This fallback implementation is for use when $DLLTOOL
+# does not support the --identify-strict option.
+# Invoked by eval'ing the libtool variable
+#    $sharedlib_from_linklib_cmd
+# Result is available in the variable
+#    $sharedlib_from_linklib_result
+func_cygming_dll_for_implib_fallback ()
+{
+  $opt_debug
+  if func_cygming_gnu_implib_p "$1" ; then
+    # binutils import library
+    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
+  elif func_cygming_ms_implib_p "$1" ; then
+    # ms-generated import library
+    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
+  else
+    # unknown
+    sharedlib_from_linklib_result=""
+  fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    if test "$lock_old_archive_extraction" = yes; then
+      lockfile=$f_ex_an_ar_oldlib.lock
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+       func_echo "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    fi
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
+                  'stat=$?; rm -f "$lockfile"; exit $stat'
+    if test "$lock_old_archive_extraction" = yes; then
+      $opt_dry_run || rm -f "$lockfile"
+    fi
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+       *) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+       *" $my_xlib_u "*)
+         func_arith $extracted_serial + 1
+         extracted_serial=$func_arith_result
+         my_xlib_u=lt$extracted_serial-$my_xlib ;;
+       *) break ;;
+       esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+       func_verbose "Extracting $my_xabs"
+       # Do not bother doing anything if just a dry run
+       $opt_dry_run || {
+         darwin_orig_dir=`pwd`
+         cd $my_xdir || exit $?
+         darwin_archive=$my_xabs
+         darwin_curdir=`pwd`
+         darwin_base_archive=`basename "$darwin_archive"`
+         darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+         if test -n "$darwin_arches"; then
+           darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+           darwin_arch=
+           func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+           for darwin_arch in  $darwin_arches ; do
+             func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+             cd "$darwin_curdir"
+             $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+           done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+           darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+           darwin_file=
+           darwin_files=
+           for darwin_file in $darwin_filelist; do
+             darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
+             $LIPO -create -output "$darwin_file" $darwin_files
+           done # $darwin_filelist
+           $RM -rf unfat-$$
+           cd "$darwin_orig_dir"
+         else
+           cd $darwin_orig_dir
+           func_extract_an_archive "$my_xdir" "$my_xabs"
+         fi # $darwin_arches
+       } # !$opt_dry_run
+       ;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+       ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+       func_emit_wrapper_arg1=${1-no}
+
+       $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    file=\"\$0\""
+
+    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
+    $ECHO "\
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+    ECHO=\"$qECHO\"
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string "--lt-"
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=\$0
+  shift
+  for lt_opt
+  do
+    case \"\$lt_opt\" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
+        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
+        cat \"\$lt_dump_D/\$lt_dump_F\"
+        exit 0
+      ;;
+    --lt-*)
+        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+
+  # Print the debug banner immediately:
+  if test -n \"\$lt_option_debug\"; then
+    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+  fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+  case $host in
+  # Backslashes separate directories on plain windows
+  *-*-mingw | *-*-os2* | *-cegcc*)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        func_lt_dump_args \${1+\"\$@\"} 1>&2
+      fi
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+    ;;
+
+  *)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        func_lt_dump_args \${1+\"\$@\"} 1>&2
+      fi
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+    ;;
+  esac
+  $ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  case \" \$* \" in
+  *\\ --lt-*)
+    for lt_wr_arg
+    do
+      case \$lt_wr_arg in
+      --lt-*) ;;
+      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
+      esac
+      shift
+    done ;;
+  esac
+  func_exec_program_core \${1+\"\$@\"}
+}
+
+  # Parse options
+  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
+  done
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+       if test "$fast_install" = yes; then
+         $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+         $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+       $ECHO \"\$relink_command_output\" >&2
+       $RM \"\$progdir/\$file\"
+       exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+       else
+         $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+       fi
+
+       $ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+       # fixup the dll searchpath if we need to.
+       #
+       # Fix the DLL searchpath if we need to.  Do this before prepending
+       # to shlibpath, because on Windows, both are PATH and uninstalled
+       # libraries must come first.
+       if test -n "$dllsearchpath"; then
+         $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+       fi
+
+       # Export our shlibpath_var if we have one.
+       if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+         $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+       fi
+
+       $ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+      func_exec_program \${1+\"\$@\"}
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+       cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+*/
+EOF
+           cat <<"EOF"
+#ifdef _MSC_VER
+# define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* declarations of non-ANSI functions */
+#if defined(__MINGW32__)
+# ifdef __STRICT_ANSI__
+int _putenv (const char *);
+# endif
+#elif defined(__CYGWIN__)
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+/* #elif defined (other platforms) ... */
+#endif
+
+/* portability defines, excluding path handling macros */
+#if defined(_MSC_VER)
+# define setmode _setmode
+# define stat    _stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+# define S_IXUSR _S_IEXEC
+# ifndef _INTPTR_T_DEFINED
+#  define _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#elif defined(__MINGW32__)
+# define setmode _setmode
+# define stat    _stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+#elif defined(__CYGWIN__)
+# define HAVE_SETENV
+# define FOPEN_WB "wb"
+/* #elif defined (other platforms) ... */
+#endif
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+/* path handling portability macros */
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+       (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#if defined(LT_DEBUGWRAPPER)
+static int lt_debug = 1;
+#else
+static int lt_debug = 0;
+#endif
+
+const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_debugprintf (const char *file, int line, const char *fmt, ...);
+void lt_fatal (const char *file, int line, const char *message, ...);
+static const char *nonnull (const char *s);
+static const char *nonempty (const char *s);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+char **prepare_spawn (char **argv);
+void lt_dump_script (FILE *f);
+EOF
+
+           cat <<EOF
+volatile const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+           if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+              func_to_host_path "$temp_rpath"
+             cat <<EOF
+const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
+EOF
+           else
+             cat <<"EOF"
+const char * LIB_PATH_VALUE   = "";
+EOF
+           fi
+
+           if test -n "$dllsearchpath"; then
+              func_to_host_path "$dllsearchpath:"
+             cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
+EOF
+           else
+             cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE   = "";
+EOF
+           fi
+
+           if test "$fast_install" = yes; then
+             cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+           else
+             cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+           fi
+
+
+           cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX         "--lt-"
+
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
+static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int  newargc;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *actual_cwrapper_name;
+  char *target_name;
+  char *lt_argv_zero;
+  intptr_t rval = 127;
+
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  newargz = XMALLOC (char *, argc + 1);
+
+  /* very simple arg parsing; don't want to rely on getopt
+   * also, copy all non cwrapper options to newargz, except
+   * argz[0], which is handled differently
+   */
+  newargc=0;
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+       {
+EOF
+           case "$host" in
+             *mingw* | *cygwin* )
+               # make stdout use "unix" line endings
+               echo "          setmode(1,_O_BINARY);"
+               ;;
+             esac
+
+           cat <<"EOF"
+         lt_dump_script (stdout);
+         return 0;
+       }
+      if (strcmp (argv[i], debug_opt) == 0)
+       {
+          lt_debug = 1;
+          continue;
+       }
+      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+        {
+          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+             namespace, but it is not one of the ones we know about and
+             have already dealt with, above (inluding dump-script), then
+             report an error. Otherwise, targets might begin to believe
+             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+             namespace. The first time any user complains about this, we'll
+             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+             or a configure.ac-settable value.
+           */
+          lt_fatal (__FILE__, __LINE__,
+                   "unrecognized %s option: '%s'",
+                    ltwrapper_option_prefix, argv[i]);
+        }
+      /* otherwise ... */
+      newargz[++newargc] = xstrdup (argv[i]);
+    }
+  newargz[++newargc] = NULL;
+
+EOF
+           cat <<EOF
+  /* The GNU banner must be the first non-error debug message */
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+EOF
+           cat <<"EOF"
+  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
+  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
+
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
+  lt_debugprintf (__FILE__, __LINE__,
+                  "(main) found exe (before symlink chase) at: %s\n",
+                 tmp_pathspec);
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  lt_debugprintf (__FILE__, __LINE__,
+                  "(main) found exe (after symlink chase) at: %s\n",
+                 actual_cwrapper_path);
+  XFREE (tmp_pathspec);
+
+  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+  /* wrapper name transforms */
+  strendzap (actual_cwrapper_name, ".exe");
+  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+  XFREE (actual_cwrapper_name);
+  actual_cwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  /* target_name transforms -- use actual target program name; might have lt- prefix */
+  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+  strendzap (target_name, ".exe");
+  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+  XFREE (target_name);
+  target_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(main) libtool target name: %s\n",
+                 target_name);
+EOF
+
+           cat <<EOF
+  newargz[0] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+                   strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+  strcpy (newargz[0], actual_cwrapper_path);
+  strcat (newargz[0], "$objdir");
+  strcat (newargz[0], "/");
+EOF
+
+           cat <<"EOF"
+  /* stop here, and copy so we don't have to do this twice */
+  tmp_pathspec = xstrdup (newargz[0]);
+
+  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+  strcat (newargz[0], actual_cwrapper_name);
+
+  /* DO want the lt- prefix here if it exists, so use target_name */
+  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+  XFREE (tmp_pathspec);
+  tmp_pathspec = NULL;
+EOF
+
+           case $host_os in
+             mingw*)
+           cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[0], '\\')) != NULL)
+      {
+       *p = '/';
+      }
+    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+      {
+       *p = '/';
+      }
+  }
+EOF
+           ;;
+           esac
+
+           cat <<"EOF"
+  XFREE (target_name);
+  XFREE (actual_cwrapper_path);
+  XFREE (actual_cwrapper_name);
+
+  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
+  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
+     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
+     because on Windows, both *_VARNAMEs are PATH but uninstalled
+     libraries must come first. */
+  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+
+  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
+                 nonnull (lt_argv_zero));
+  for (i = 0; i < newargc; i++)
+    {
+      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
+                     i, nonnull (newargz[i]));
+    }
+
+EOF
+
+           case $host_os in
+             mingw*)
+               cat <<"EOF"
+  /* execv doesn't actually work on mingw as expected on unix */
+  newargz = prepare_spawn (newargz);
+  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      lt_debugprintf (__FILE__, __LINE__,
+                     "(main) failed to launch target \"%s\": %s\n",
+                     lt_argv_zero, nonnull (strerror (errno)));
+      return 127;
+    }
+  return rval;
+EOF
+               ;;
+             *)
+               cat <<"EOF"
+  execv (lt_argv_zero, newargz);
+  return rval; /* =127, but avoids unused variable warning */
+EOF
+               ;;
+           esac
+
+           cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal (__FILE__, __LINE__, "memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+                         string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
+                  nonempty (path));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
+                  nonempty (path));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
+                  nonempty (wrapper));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+       return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+       {
+         concat_name = xstrdup (wrapper);
+         if (check_executable (concat_name))
+           return concat_name;
+         XFREE (concat_name);
+       }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+       has_slash = 1;
+       break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+       {
+         for (p = path; *p; p = p_next)
+           {
+             const char *q;
+             size_t p_len;
+             for (q = p; *q; q++)
+               if (IS_PATH_SEPARATOR (*q))
+                 break;
+             p_len = q - p;
+             p_next = (*q == '\0' ? q : q + 1);
+             if (p_len == 0)
+               {
+                 /* empty path: current directory */
+                 if (getcwd (tmp, LT_PATHMAX) == NULL)
+                   lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+                              nonnull (strerror (errno)));
+                 tmp_len = strlen (tmp);
+                 concat_name =
+                   XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+                 memcpy (concat_name, tmp, tmp_len);
+                 concat_name[tmp_len] = '/';
+                 strcpy (concat_name + tmp_len + 1, wrapper);
+               }
+             else
+               {
+                 concat_name =
+                   XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+                 memcpy (concat_name, p, p_len);
+                 concat_name[p_len] = '/';
+                 strcpy (concat_name + p_len + 1, wrapper);
+               }
+             if (check_executable (concat_name))
+               return concat_name;
+             XFREE (concat_name);
+           }
+       }
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+              nonnull (strerror (errno)));
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      lt_debugprintf (__FILE__, __LINE__,
+                     "checking path component for symlinks: %s\n",
+                     tmp_pathspec);
+      if (lstat (tmp_pathspec, &s) == 0)
+       {
+         if (S_ISLNK (s.st_mode) != 0)
+           {
+             has_symlinks = 1;
+             break;
+           }
+
+         /* search backwards for last DIR_SEPARATOR */
+         p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+         while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+           p--;
+         if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+           {
+             /* no more DIR_SEPARATORS left */
+             break;
+           }
+         *p = '\0';
+       }
+      else
+       {
+         lt_fatal (__FILE__, __LINE__,
+                   "error accessing file \"%s\": %s",
+                   tmp_pathspec, nonnull (strerror (errno)));
+       }
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal (__FILE__, __LINE__,
+               "could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+       *str = '\0';
+    }
+  return str;
+}
+
+void
+lt_debugprintf (const char *file, int line, const char *fmt, ...)
+{
+  va_list args;
+  if (lt_debug)
+    {
+      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
+      va_start (args, fmt);
+      (void) vfprintf (stderr, fmt, args);
+      va_end (args);
+    }
+}
+
+static void
+lt_error_core (int exit_status, const char *file,
+              int line, const char *mode,
+              const char *message, va_list ap)
+{
+  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *file, int line, const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
+  va_end (ap);
+}
+
+static const char *
+nonnull (const char *s)
+{
+  return s ? s : "(null)";
+}
+
+static const char *
+nonempty (const char *s)
+{
+  return (s && !*s) ? "(empty)" : nonnull (s);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_setenv) setting '%s' to '%s'\n",
+                  nonnull (name), nonnull (value));
+  {
+#ifdef HAVE_SETENV
+    /* always make a copy, for consistency with !HAVE_SETENV */
+    char *str = xstrdup (value);
+    setenv (name, str, 1);
+#else
+    int len = strlen (name) + 1 + strlen (value) + 1;
+    char *str = XMALLOC (char, len);
+    sprintf (str, "%s=%s", name, value);
+    if (putenv (str) != EXIT_SUCCESS)
+      {
+        XFREE (str);
+      }
+#endif
+  }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+  char *new_value;
+  if (orig_value && *orig_value)
+    {
+      int orig_value_len = strlen (orig_value);
+      int add_len = strlen (add);
+      new_value = XMALLOC (char, add_len + orig_value_len + 1);
+      if (to_end)
+        {
+          strcpy (new_value, orig_value);
+          strcpy (new_value + orig_value_len, add);
+        }
+      else
+        {
+          strcpy (new_value, add);
+          strcpy (new_value + add_len, orig_value);
+        }
+    }
+  else
+    {
+      new_value = xstrdup (add);
+    }
+  return new_value;
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+                  nonnull (name), nonnull (value));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      /* some systems can't cope with a ':'-terminated path #' */
+      int len = strlen (new_value);
+      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+        {
+          new_value[len-1] = '\0';
+        }
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+                  nonnull (name), nonnull (value));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+EOF
+           case $host_os in
+             mingw*)
+               cat <<"EOF"
+
+/* Prepares an argument vector before calling spawn().
+   Note that spawn() does not by itself call the command interpreter
+     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
+      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+         GetVersionEx(&v);
+         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
+      }) ? "cmd.exe" : "command.com").
+   Instead it simply concatenates the arguments, separated by ' ', and calls
+   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
+   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
+   special way:
+   - Space and tab are interpreted as delimiters. They are not treated as
+     delimiters if they are surrounded by double quotes: "...".
+   - Unescaped double quotes are removed from the input. Their only effect is
+     that within double quotes, space and tab are treated like normal
+     characters.
+   - Backslashes not followed by double quotes are not special.
+   - But 2*n+1 backslashes followed by a double quote become
+     n backslashes followed by a double quote (n >= 0):
+       \" -> "
+       \\\" -> \"
+       \\\\\" -> \\"
+ */
+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+char **
+prepare_spawn (char **argv)
+{
+  size_t argc;
+  char **new_argv;
+  size_t i;
+
+  /* Count number of arguments.  */
+  for (argc = 0; argv[argc] != NULL; argc++)
+    ;
+
+  /* Allocate new argument vector.  */
+  new_argv = XMALLOC (char *, argc + 1);
+
+  /* Put quoted arguments into the new argument vector.  */
+  for (i = 0; i < argc; i++)
+    {
+      const char *string = argv[i];
+
+      if (string[0] == '\0')
+       new_argv[i] = xstrdup ("\"\"");
+      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+       {
+         int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+         size_t length;
+         unsigned int backslashes;
+         const char *s;
+         char *quoted_string;
+         char *p;
+
+         length = 0;
+         backslashes = 0;
+         if (quote_around)
+           length++;
+         for (s = string; *s != '\0'; s++)
+           {
+             char c = *s;
+             if (c == '"')
+               length += backslashes + 1;
+             length++;
+             if (c == '\\')
+               backslashes++;
+             else
+               backslashes = 0;
+           }
+         if (quote_around)
+           length += backslashes + 1;
+
+         quoted_string = XMALLOC (char, length + 1);
+
+         p = quoted_string;
+         backslashes = 0;
+         if (quote_around)
+           *p++ = '"';
+         for (s = string; *s != '\0'; s++)
+           {
+             char c = *s;
+             if (c == '"')
+               {
+                 unsigned int j;
+                 for (j = backslashes + 1; j > 0; j--)
+                   *p++ = '\\';
+               }
+             *p++ = c;
+             if (c == '\\')
+               backslashes++;
+             else
+               backslashes = 0;
+           }
+         if (quote_around)
+           {
+             unsigned int j;
+             for (j = backslashes; j > 0; j--)
+               *p++ = '\\';
+             *p++ = '"';
+           }
+         *p = '\0';
+
+         new_argv[i] = quoted_string;
+       }
+      else
+       new_argv[i] = (char *) string;
+    }
+  new_argv[argc] = NULL;
+
+  return new_argv;
+}
+EOF
+               ;;
+           esac
+
+            cat <<"EOF"
+void lt_dump_script (FILE* f)
+{
+EOF
+           func_emit_wrapper yes |
+             $SED -n -e '
+s/^\(.\{79\}\)\(..*\)/\1\
+\2/
+h
+s/\([\\"]\)/\\\1/g
+s/$/\\n/
+s/\([^\n]*\).*/  fputs ("\1", f);/p
+g
+D'
+            cat <<"EOF"
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_win32_import_lib_p ARG
+# True if ARG is an import lib, as indicated by $file_magic_cmd
+func_win32_import_lib_p ()
+{
+    $opt_debug
+    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
+    *import*) : ;;
+    *) false ;;
+    esac
+}
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    bindir=
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+       test "$build_libtool_libs" != yes && \
+         func_fatal_configuration "can not build a shared library"
+       build_old_libs=no
+       break
+       ;;
+      -all-static | -static | -static-libtool-libs)
+       case $arg in
+       -all-static)
+         if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+           func_warning "complete static linking is impossible in this configuration"
+         fi
+         if test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+         ;;
+       -static)
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=built
+         ;;
+       -static-libtool-libs)
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+         ;;
+       esac
+       build_libtool_libs=no
+       build_old_libs=yes
+       break
+       ;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+       case $prev in
+       output)
+         func_append compile_command " @OUTPUT@"
+         func_append finalize_command " @OUTPUT@"
+         ;;
+       esac
+
+       case $prev in
+       bindir)
+         bindir="$arg"
+         prev=
+         continue
+         ;;
+       dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           func_append compile_command " @SYMFILE@"
+           func_append finalize_command " @SYMFILE@"
+           preload=yes
+         fi
+         case $arg in
+         *.la | *.lo) ;;  # We handle these cases below.
+         force)
+           if test "$dlself" = no; then
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         self)
+           if test "$prev" = dlprefiles; then
+             dlself=yes
+           elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+             dlself=yes
+           else
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         *)
+           if test "$prev" = dlfiles; then
+             func_append dlfiles " $arg"
+           else
+             func_append dlprefiles " $arg"
+           fi
+           prev=
+           continue
+           ;;
+         esac
+         ;;
+       expsyms)
+         export_symbols="$arg"
+         test -f "$arg" \
+           || func_fatal_error "symbol file \`$arg' does not exist"
+         prev=
+         continue
+         ;;
+       expsyms_regex)
+         export_symbols_regex="$arg"
+         prev=
+         continue
+         ;;
+       framework)
+         case $host in
+           *-*-darwin*)
+             case "$deplibs " in
+               *" $qarg.ltframework "*) ;;
+               *) func_append deplibs " $qarg.ltframework" # this is fixed later
+                  ;;
+             esac
+             ;;
+         esac
+         prev=
+         continue
+         ;;
+       inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
+       objectlist)
+         if test -f "$arg"; then
+           save_arg=$arg
+           moreargs=
+           for fil in `cat "$save_arg"`
+           do
+#            func_append moreargs " $fil"
+             arg=$fil
+             # A libtool-controlled object.
+
+             # Check to see that this really is a libtool object.
+             if func_lalib_unsafe_p "$arg"; then
+               pic_object=
+               non_pic_object=
+
+               # Read the .lo file
+               func_source "$arg"
+
+               if test -z "$pic_object" ||
+                  test -z "$non_pic_object" ||
+                  test "$pic_object" = none &&
+                  test "$non_pic_object" = none; then
+                 func_fatal_error "cannot find name of object for \`$arg'"
+               fi
+
+               # Extract subdirectory from the argument.
+               func_dirname "$arg" "/" ""
+               xdir="$func_dirname_result"
+
+               if test "$pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 pic_object="$xdir$pic_object"
+
+                 if test "$prev" = dlfiles; then
+                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+                     func_append dlfiles " $pic_object"
+                     prev=
+                     continue
+                   else
+                     # If libtool objects are unsupported, then we need to preload.
+                     prev=dlprefiles
+                   fi
+                 fi
+
+                 # CHECK ME:  I think I busted this.  -Ossama
+                 if test "$prev" = dlprefiles; then
+                   # Preload the old-style object.
+                   func_append dlprefiles " $pic_object"
+                   prev=
+                 fi
+
+                 # A PIC object.
+                 func_append libobjs " $pic_object"
+                 arg="$pic_object"
+               fi
+
+               # Non-PIC object.
+               if test "$non_pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 non_pic_object="$xdir$non_pic_object"
+
+                 # A standard non-PIC object
+                 func_append non_pic_objects " $non_pic_object"
+                 if test -z "$pic_object" || test "$pic_object" = none ; then
+                   arg="$non_pic_object"
+                 fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 func_append non_pic_objects " $non_pic_object"
+               fi
+             else
+               # Only an error if not doing a dry-run.
+               if $opt_dry_run; then
+                 # Extract subdirectory from the argument.
+                 func_dirname "$arg" "/" ""
+                 xdir="$func_dirname_result"
+
+                 func_lo2o "$arg"
+                 pic_object=$xdir$objdir/$func_lo2o_result
+                 non_pic_object=$xdir$func_lo2o_result
+                 func_append libobjs " $pic_object"
+                 func_append non_pic_objects " $non_pic_object"
+               else
+                 func_fatal_error "\`$arg' is not a valid libtool object"
+               fi
+             fi
+           done
+         else
+           func_fatal_error "link input file \`$arg' does not exist"
+         fi
+         arg=$save_arg
+         prev=
+         continue
+         ;;
+       precious_regex)
+         precious_files_regex="$arg"
+         prev=
+         continue
+         ;;
+       release)
+         release="-$arg"
+         prev=
+         continue
+         ;;
+       rpath | xrpath)
+         # We need an absolute path.
+         case $arg in
+         [\\/]* | [A-Za-z]:[\\/]*) ;;
+         *)
+           func_fatal_error "only absolute run-paths are allowed"
+           ;;
+         esac
+         if test "$prev" = rpath; then
+           case "$rpath " in
+           *" $arg "*) ;;
+           *) func_append rpath " $arg" ;;
+           esac
+         else
+           case "$xrpath " in
+           *" $arg "*) ;;
+           *) func_append xrpath " $arg" ;;
+           esac
+         fi
+         prev=
+         continue
+         ;;
+       shrext)
+         shrext_cmds="$arg"
+         prev=
+         continue
+         ;;
+       weak)
+         func_append weak_libs " $arg"
+         prev=
+         continue
+         ;;
+       xcclinker)
+         func_append linker_flags " $qarg"
+         func_append compiler_flags " $qarg"
+         prev=
+         func_append compile_command " $qarg"
+         func_append finalize_command " $qarg"
+         continue
+         ;;
+       xcompiler)
+         func_append compiler_flags " $qarg"
+         prev=
+         func_append compile_command " $qarg"
+         func_append finalize_command " $qarg"
+         continue
+         ;;
+       xlinker)
+         func_append linker_flags " $qarg"
+         func_append compiler_flags " $wl$qarg"
+         prev=
+         func_append compile_command " $wl$qarg"
+         func_append finalize_command " $wl$qarg"
+         continue
+         ;;
+       *)
+         eval "$prev=\"\$arg\""
+         prev=
+         continue
+         ;;
+       esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+       if test -n "$link_static_flag"; then
+         # See comment for -static flag below, for more details.
+         func_append compile_command " $link_static_flag"
+         func_append finalize_command " $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -allow-undefined)
+       # FIXME: remove this flag sometime in the future.
+       func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+       ;;
+
+      -avoid-version)
+       avoid_version=yes
+       continue
+       ;;
+
+      -bindir)
+       prev=bindir
+       continue
+       ;;
+
+      -dlopen)
+       prev=dlfiles
+       continue
+       ;;
+
+      -dlpreopen)
+       prev=dlprefiles
+       continue
+       ;;
+
+      -export-dynamic)
+       export_dynamic=yes
+       continue
+       ;;
+
+      -export-symbols | -export-symbols-regex)
+       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+         func_fatal_error "more than one -exported-symbols argument is not allowed"
+       fi
+       if test "X$arg" = "X-export-symbols"; then
+         prev=expsyms
+       else
+         prev=expsyms_regex
+       fi
+       continue
+       ;;
+
+      -framework)
+       prev=framework
+       continue
+       ;;
+
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+       case $with_gcc/$host in
+       no/*-*-irix* | /*-*-irix*)
+         func_append compile_command " $arg"
+         func_append finalize_command " $arg"
+         ;;
+       esac
+       continue
+       ;;
+
+      -L*)
+       func_stripname "-L" '' "$arg"
+       if test -z "$func_stripname_result"; then
+         if test "$#" -gt 0; then
+           func_fatal_error "require no space between \`-L' and \`$1'"
+         else
+           func_fatal_error "need path for \`-L' option"
+         fi
+       fi
+       func_resolve_sysroot "$func_stripname_result"
+       dir=$func_resolve_sysroot_result
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         absdir=`cd "$dir" && pwd`
+         test -z "$absdir" && \
+           func_fatal_error "cannot determine absolute directory name of \`$dir'"
+         dir="$absdir"
+         ;;
+       esac
+       case "$deplibs " in
+       *" -L$dir "* | *" $arg "*)
+         # Will only happen for absolute or sysroot arguments
+         ;;
+       *)
+         # Preserve sysroot, but never include relative directories
+         case $dir in
+           [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
+           *) func_append deplibs " -L$dir" ;;
+         esac
+         func_append lib_search_path " $dir"
+         ;;
+       esac
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+         testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$dir:"*) ;;
+         ::) dllsearchpath=$dir;;
+         *) func_append dllsearchpath ":$dir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         ::) dllsearchpath=$testbindir;;
+         *) func_append dllsearchpath ":$testbindir";;
+         esac
+         ;;
+       esac
+       continue
+       ;;
+
+      -l*)
+       if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
+           # These systems don't actually have a C or math library (as such)
+           continue
+           ;;
+         *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C and math libraries are in the System framework
+           func_append deplibs " System.ltframework"
+           continue
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           test "X$arg" = "X-lc" && continue
+           ;;
+         esac
+       elif test "X$arg" = "X-lc_r"; then
+        case $host in
+        *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+          # Do not include libc_r directly, use -pthread flag.
+          continue
+          ;;
+        esac
+       fi
+       func_append deplibs " $arg"
+       continue
+       ;;
+
+      -module)
+       module=yes
+       continue
+       ;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot|--sysroot)
+       func_append compiler_flags " $arg"
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+       prev=xcompiler
+       continue
+       ;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+       func_append compiler_flags " $arg"
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+       case "$new_inherited_linker_flags " in
+           *" $arg "*) ;;
+           * ) func_append new_inherited_linker_flags " $arg" ;;
+       esac
+       continue
+       ;;
+
+      -multi_module)
+       single_module="${wl}-multi_module"
+       continue
+       ;;
+
+      -no-fast-install)
+       fast_install=no
+       continue
+       ;;
+
+      -no-install)
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+         # The PATH hackery in wrapper scripts is required on Windows
+         # and Darwin in order for the loader to find any dlls it needs.
+         func_warning "\`-no-install' is ignored for $host"
+         func_warning "assuming \`-no-fast-install' instead"
+         fast_install=no
+         ;;
+       *) no_install=yes ;;
+       esac
+       continue
+       ;;
+
+      -no-undefined)
+       allow_undefined=no
+       continue
+       ;;
+
+      -objectlist)
+       prev=objectlist
+       continue
+       ;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+       prev=precious_regex
+       continue
+       ;;
+
+      -release)
+       prev=release
+       continue
+       ;;
+
+      -rpath)
+       prev=rpath
+       continue
+       ;;
+
+      -R)
+       prev=xrpath
+       continue
+       ;;
+
+      -R*)
+       func_stripname '-R' '' "$arg"
+       dir=$func_stripname_result
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       =*)
+         func_stripname '=' '' "$dir"
+         dir=$lt_sysroot$func_stripname_result
+         ;;
+       *)
+         func_fatal_error "only absolute run-paths are allowed"
+         ;;
+       esac
+       case "$xrpath " in
+       *" $dir "*) ;;
+       *) func_append xrpath " $dir" ;;
+       esac
+       continue
+       ;;
+
+      -shared)
+       # The effects of -shared are defined in a previous loop.
+       continue
+       ;;
+
+      -shrext)
+       prev=shrext
+       continue
+       ;;
+
+      -static | -static-libtool-libs)
+       # The effects of -static are defined in a previous loop.
+       # We used to do the same as -all-static on platforms that
+       # didn't have a PIC flag, but the assumption that the effects
+       # would be equivalent was wrong.  It would break on at least
+       # Digital Unix and AIX.
+       continue
+       ;;
+
+      -thread-safe)
+       thread_safe=yes
+       continue
+       ;;
+
+      -version-info)
+       prev=vinfo
+       continue
+       ;;
+
+      -version-number)
+       prev=vinfo
+       vinfo_number=yes
+       continue
+       ;;
+
+      -weak)
+        prev=weak
+       continue
+       ;;
+
+      -Wc,*)
+       func_stripname '-Wc,' '' "$arg"
+       args=$func_stripname_result
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+         func_append arg " $func_quote_for_eval_result"
+         func_append compiler_flags " $func_quote_for_eval_result"
+       done
+       IFS="$save_ifs"
+       func_stripname ' ' '' "$arg"
+       arg=$func_stripname_result
+       ;;
+
+      -Wl,*)
+       func_stripname '-Wl,' '' "$arg"
+       args=$func_stripname_result
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+         func_append arg " $wl$func_quote_for_eval_result"
+         func_append compiler_flags " $wl$func_quote_for_eval_result"
+         func_append linker_flags " $func_quote_for_eval_result"
+       done
+       IFS="$save_ifs"
+       func_stripname ' ' '' "$arg"
+       arg=$func_stripname_result
+       ;;
+
+      -Xcompiler)
+       prev=xcompiler
+       continue
+       ;;
+
+      -Xlinker)
+       prev=xlinker
+       continue
+       ;;
+
+      -XCClinker)
+       prev=xcclinker
+       continue
+       ;;
+
+      # -msg_* for osf cc
+      -msg_*)
+       func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+
+      # Flags to be passed through unchanged, with rationale:
+      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
+      # -r[0-9][0-9]*        specify processor for the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
+      # +DA*, +DD*           enable 64-bit mode for the HP compiler
+      # -q*                  compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
+      # -F/path              path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # @file                GCC response files
+      # -tp=*                Portland pgcc target processor selection
+      # --sysroot=*          for sysroot support
+      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
+      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+        func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        func_append compiler_flags " $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+
+      *.$objext)
+       # A standard object.
+       func_append objs " $arg"
+       ;;
+
+      *.lo)
+       # A libtool-controlled object.
+
+       # Check to see that this really is a libtool object.
+       if func_lalib_unsafe_p "$arg"; then
+         pic_object=
+         non_pic_object=
+
+         # Read the .lo file
+         func_source "$arg"
+
+         if test -z "$pic_object" ||
+            test -z "$non_pic_object" ||
+            test "$pic_object" = none &&
+            test "$non_pic_object" = none; then
+           func_fatal_error "cannot find name of object for \`$arg'"
+         fi
+
+         # Extract subdirectory from the argument.
+         func_dirname "$arg" "/" ""
+         xdir="$func_dirname_result"
+
+         if test "$pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           pic_object="$xdir$pic_object"
+
+           if test "$prev" = dlfiles; then
+             if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+               func_append dlfiles " $pic_object"
+               prev=
+               continue
+             else
+               # If libtool objects are unsupported, then we need to preload.
+               prev=dlprefiles
+             fi
+           fi
+
+           # CHECK ME:  I think I busted this.  -Ossama
+           if test "$prev" = dlprefiles; then
+             # Preload the old-style object.
+             func_append dlprefiles " $pic_object"
+             prev=
+           fi
+
+           # A PIC object.
+           func_append libobjs " $pic_object"
+           arg="$pic_object"
+         fi
+
+         # Non-PIC object.
+         if test "$non_pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           non_pic_object="$xdir$non_pic_object"
+
+           # A standard non-PIC object
+           func_append non_pic_objects " $non_pic_object"
+           if test -z "$pic_object" || test "$pic_object" = none ; then
+             arg="$non_pic_object"
+           fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           func_append non_pic_objects " $non_pic_object"
+         fi
+       else
+         # Only an error if not doing a dry-run.
+         if $opt_dry_run; then
+           # Extract subdirectory from the argument.
+           func_dirname "$arg" "/" ""
+           xdir="$func_dirname_result"
+
+           func_lo2o "$arg"
+           pic_object=$xdir$objdir/$func_lo2o_result
+           non_pic_object=$xdir$func_lo2o_result
+           func_append libobjs " $pic_object"
+           func_append non_pic_objects " $non_pic_object"
+         else
+           func_fatal_error "\`$arg' is not a valid libtool object"
+         fi
+       fi
+       ;;
+
+      *.$libext)
+       # An archive.
+       func_append deplibs " $arg"
+       func_append old_deplibs " $arg"
+       continue
+       ;;
+
+      *.la)
+       # A libtool-controlled library.
+
+       func_resolve_sysroot "$arg"
+       if test "$prev" = dlfiles; then
+         # This library was specified with -dlopen.
+         func_append dlfiles " $func_resolve_sysroot_result"
+         prev=
+       elif test "$prev" = dlprefiles; then
+         # The library was specified with -dlpreopen.
+         func_append dlprefiles " $func_resolve_sysroot_result"
+         prev=
+       else
+         func_append deplibs " $func_resolve_sysroot_result"
+       fi
+       continue
+       ;;
+
+      # Some other compiler argument.
+      *)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    func_to_tool_file "$output_objdir/"
+    tool_output_objdir=$func_to_tool_file_result
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_preserve_dup_deps ; then
+       case "$libs " in
+       *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+       esac
+      fi
+      func_append libs " $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+       for pre_post_dep in $predeps $postdeps; do
+         case "$pre_post_deps " in
+         *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
+         esac
+         func_append pre_post_deps " $pre_post_dep"
+       done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+       passes="conv dlpreopen link"
+       for file in $dlfiles $dlprefiles; do
+         case $file in
+         *.la) ;;
+         *)
+           func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+           ;;
+         esac
+       done
+       ;;
+    prog)
+       compile_deplibs=
+       finalize_deplibs=
+       alldeplibs=no
+       newdlfiles=
+       newdlprefiles=
+       passes="conv scan dlopen dlpreopen link"
+       ;;
+    *)  passes="conv"
+       ;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+       ## FIXME: Find the place where the list is rebuilt in the wrong
+       ##        order, and fix it there properly
+        tmp_deplibs=
+       for deplib in $deplibs; do
+         tmp_deplibs="$deplib $tmp_deplibs"
+       done
+       deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+        test "$linkmode,$pass" = "prog,scan"; then
+       libs="$deplibs"
+       deplibs=
+      fi
+      if test "$linkmode" = prog; then
+       case $pass in
+       dlopen) libs="$dlfiles" ;;
+       dlpreopen) libs="$dlprefiles" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+       # Collect and forward deplibs of preopened libtool libs
+       for lib in $dlprefiles; do
+         # Ignore non-libtool-libs
+         dependency_libs=
+         func_resolve_sysroot "$lib"
+         case $lib in
+         *.la) func_source "$func_resolve_sysroot_result" ;;
+         esac
+
+         # Collect preopened libtool deplibs, except any this library
+         # has declared as weak libs
+         for deplib in $dependency_libs; do
+           func_basename "$deplib"
+            deplib_base=$func_basename_result
+           case " $weak_libs " in
+           *" $deplib_base "*) ;;
+           *) func_append deplibs " $deplib" ;;
+           esac
+         done
+       done
+       libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+       # Collect dlpreopened libraries
+       save_deplibs="$deplibs"
+       deplibs=
+      fi
+
+      for deplib in $libs; do
+       lib=
+       found=no
+       case $deplib in
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           func_append compiler_flags " $deplib"
+           if test "$linkmode" = lib ; then
+               case "$new_inherited_linker_flags " in
+                   *" $deplib "*) ;;
+                   * ) func_append new_inherited_linker_flags " $deplib" ;;
+               esac
+           fi
+         fi
+         continue
+         ;;
+       -l*)
+         if test "$linkmode" != lib && test "$linkmode" != prog; then
+           func_warning "\`-l' is ignored for archives/objects"
+           continue
+         fi
+         func_stripname '-l' '' "$deplib"
+         name=$func_stripname_result
+         if test "$linkmode" = lib; then
+           searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+         else
+           searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+         fi
+         for searchdir in $searchdirs; do
+           for search_ext in .la $std_shrext .so .a; do
+             # Search the libtool library
+             lib="$searchdir/lib${name}${search_ext}"
+             if test -f "$lib"; then
+               if test "$search_ext" = ".la"; then
+                 found=yes
+               else
+                 found=no
+               fi
+               break 2
+             fi
+           done
+         done
+         if test "$found" != yes; then
+           # deplib doesn't seem to be a libtool library
+           if test "$linkmode,$pass" = "prog,link"; then
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             deplibs="$deplib $deplibs"
+             test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+           fi
+           continue
+         else # deplib is a libtool library
+           # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+           # We need to do some special things here, and not later.
+           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+             case " $predeps $postdeps " in
+             *" $deplib "*)
+               if func_lalib_p "$lib"; then
+                 library_names=
+                 old_library=
+                 func_source "$lib"
+                 for l in $old_library $library_names; do
+                   ll="$l"
+                 done
+                 if test "X$ll" = "X$old_library" ; then # only static version available
+                   found=no
+                   func_dirname "$lib" "" "."
+                   ladir="$func_dirname_result"
+                   lib=$ladir/$old_library
+                   if test "$linkmode,$pass" = "prog,link"; then
+                     compile_deplibs="$deplib $compile_deplibs"
+                     finalize_deplibs="$deplib $finalize_deplibs"
+                   else
+                     deplibs="$deplib $deplibs"
+                     test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+                   fi
+                   continue
+                 fi
+               fi
+               ;;
+             *) ;;
+             esac
+           fi
+         fi
+         ;; # -l
+       *.ltframework)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           deplibs="$deplib $deplibs"
+           if test "$linkmode" = lib ; then
+               case "$new_inherited_linker_flags " in
+                   *" $deplib "*) ;;
+                   * ) func_append new_inherited_linker_flags " $deplib" ;;
+               esac
+           fi
+         fi
+         continue
+         ;;
+       -L*)
+         case $linkmode in
+         lib)
+           deplibs="$deplib $deplibs"
+           test "$pass" = conv && continue
+           newdependency_libs="$deplib $newdependency_libs"
+           func_stripname '-L' '' "$deplib"
+           func_resolve_sysroot "$func_stripname_result"
+           func_append newlib_search_path " $func_resolve_sysroot_result"
+           ;;
+         prog)
+           if test "$pass" = conv; then
+             deplibs="$deplib $deplibs"
+             continue
+           fi
+           if test "$pass" = scan; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           func_stripname '-L' '' "$deplib"
+           func_resolve_sysroot "$func_stripname_result"
+           func_append newlib_search_path " $func_resolve_sysroot_result"
+           ;;
+         *)
+           func_warning "\`-L' is ignored for archives/objects"
+           ;;
+         esac # linkmode
+         continue
+         ;; # -L
+       -R*)
+         if test "$pass" = link; then
+           func_stripname '-R' '' "$deplib"
+           func_resolve_sysroot "$func_stripname_result"
+           dir=$func_resolve_sysroot_result
+           # Make sure the xrpath contains only unique directories.
+           case "$xrpath " in
+           *" $dir "*) ;;
+           *) func_append xrpath " $dir" ;;
+           esac
+         fi
+         deplibs="$deplib $deplibs"
+         continue
+         ;;
+       *.la)
+         func_resolve_sysroot "$deplib"
+         lib=$func_resolve_sysroot_result
+         ;;
+       *.$libext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+           continue
+         fi
+         case $linkmode in
+         lib)
+           # Linking convenience modules into shared libraries is allowed,
+           # but linking other static libraries is non-portable.
+           case " $dlpreconveniencelibs " in
+           *" $deplib "*) ;;
+           *)
+             valid_a_lib=no
+             case $deplibs_check_method in
+               match_pattern*)
+                 set dummy $deplibs_check_method; shift
+                 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+                 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
+                   | $EGREP "$match_pattern_regex" > /dev/null; then
+                   valid_a_lib=yes
+                 fi
+               ;;
+               pass_all)
+                 valid_a_lib=yes
+               ;;
+             esac
+             if test "$valid_a_lib" != yes; then
+               echo
+               $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because the file extensions .$libext of this argument makes me believe"
+               echo "*** that it is just a static archive that I should not use here."
+             else
+               echo
+               $ECHO "*** Warning: Linking the shared library $output against the"
+               $ECHO "*** static library $deplib is not portable!"
+               deplibs="$deplib $deplibs"
+             fi
+             ;;
+           esac
+           continue
+           ;;
+         prog)
+           if test "$pass" != link; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           continue
+           ;;
+         esac # linkmode
+         ;; # *.$libext
+       *.lo | *.$objext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+         elif test "$linkmode" = prog; then
+           if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+             # If there is no dlopen support or we're linking statically,
+             # we need to preload.
+             func_append newdlprefiles " $deplib"
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             func_append newdlfiles " $deplib"
+           fi
+         fi
+         continue
+         ;;
+       %DEPLIBS%)
+         alldeplibs=yes
+         continue
+         ;;
+       esac # case $deplib
+
+       if test "$found" = yes || test -f "$lib"; then :
+       else
+         func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+       fi
+
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$lib" \
+         || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+       func_dirname "$lib" "" "."
+       ladir="$func_dirname_result"
+
+       dlname=
+       dlopen=
+       dlpreopen=
+       libdir=
+       library_names=
+       old_library=
+       inherited_linker_flags=
+       # If the library was installed with an old release of libtool,
+       # it will not redefine variables installed, or shouldnotlink
+       installed=yes
+       shouldnotlink=no
+       avoidtemprpath=
+
+
+       # Read the .la file
+       func_source "$lib"
+
+       # Convert "-framework foo" to "foo.ltframework"
+       if test -n "$inherited_linker_flags"; then
+         tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
+         for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+           case " $new_inherited_linker_flags " in
+             *" $tmp_inherited_linker_flag "*) ;;
+             *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
+           esac
+         done
+       fi
+       dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       if test "$linkmode,$pass" = "lib,link" ||
+          test "$linkmode,$pass" = "prog,scan" ||
+          { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+         test -n "$dlopen" && func_append dlfiles " $dlopen"
+         test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
+       fi
+
+       if test "$pass" = conv; then
+         # Only check for convenience libraries
+         deplibs="$lib $deplibs"
+         if test -z "$libdir"; then
+           if test -z "$old_library"; then
+             func_fatal_error "cannot find name of link library for \`$lib'"
+           fi
+           # It is a libtool convenience library, so add in its objects.
+           func_append convenience " $ladir/$objdir/$old_library"
+           func_append old_convenience " $ladir/$objdir/$old_library"
+         elif test "$linkmode" != prog && test "$linkmode" != lib; then
+           func_fatal_error "\`$lib' is not a convenience library"
+         fi
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           deplibs="$deplib $deplibs"
+           if $opt_preserve_dup_deps ; then
+             case "$tmp_libs " in
+             *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+             esac
+           fi
+           func_append tmp_libs " $deplib"
+         done
+         continue
+       fi # $pass = conv
+
+
+       # Get the name of the library we link against.
+       linklib=
+       if test -n "$old_library" &&
+          { test "$prefer_static_libs" = yes ||
+            test "$prefer_static_libs,$installed" = "built,no"; }; then
+         linklib=$old_library
+       else
+         for l in $old_library $library_names; do
+           linklib="$l"
+         done
+       fi
+       if test -z "$linklib"; then
+         func_fatal_error "cannot find name of link library for \`$lib'"
+       fi
+
+       # This library was specified with -dlopen.
+       if test "$pass" = dlopen; then
+         if test -z "$libdir"; then
+           func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+         fi
+         if test -z "$dlname" ||
+            test "$dlopen_support" != yes ||
+            test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking
+           # statically, we need to preload.  We also need to preload any
+           # dependent libraries so libltdl's deplib preloader doesn't
+           # bomb out in the load deplibs phase.
+           func_append dlprefiles " $lib $dependency_libs"
+         else
+           func_append newdlfiles " $lib"
+         fi
+         continue
+       fi # $pass = dlopen
+
+       # We need an absolute path.
+       case $ladir in
+       [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+       *)
+         abs_ladir=`cd "$ladir" && pwd`
+         if test -z "$abs_ladir"; then
+           func_warning "cannot determine absolute directory name of \`$ladir'"
+           func_warning "passing it literally to the linker, although it might fail"
+           abs_ladir="$ladir"
+         fi
+         ;;
+       esac
+       func_basename "$lib"
+       laname="$func_basename_result"
+
+       # Find the relevant object directory and library name.
+       if test "X$installed" = Xyes; then
+         if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           func_warning "library \`$lib' was moved."
+           dir="$ladir"
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+           dir="$lt_sysroot$libdir"
+           absdir="$lt_sysroot$libdir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+         if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           dir="$ladir"
+           absdir="$abs_ladir"
+           # Remove this search path later
+           func_append notinst_path " $abs_ladir"
+         else
+           dir="$ladir/$objdir"
+           absdir="$abs_ladir/$objdir"
+           # Remove this search path later
+           func_append notinst_path " $abs_ladir"
+         fi
+       fi # $installed = yes
+       func_stripname 'lib' '.la' "$laname"
+       name=$func_stripname_result
+
+       # This library was specified with -dlpreopen.
+       if test "$pass" = dlpreopen; then
+         if test -z "$libdir" && test "$linkmode" = prog; then
+           func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+         fi
+         case "$host" in
+           # special handling for platforms with PE-DLLs.
+           *cygwin* | *mingw* | *cegcc* )
+             # Linker will automatically link against shared library if both
+             # static and shared are present.  Therefore, ensure we extract
+             # symbols from the import library if a shared library is present
+             # (otherwise, the dlopen module name will be incorrect).  We do
+             # this by putting the import library name into $newdlprefiles.
+             # We recover the dlopen module name by 'saving' the la file
+             # name in a special purpose variable, and (later) extracting the
+             # dlname from the la file.
+             if test -n "$dlname"; then
+               func_tr_sh "$dir/$linklib"
+               eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
+               func_append newdlprefiles " $dir/$linklib"
+             else
+               func_append newdlprefiles " $dir/$old_library"
+               # Keep a list of preopened convenience libraries to check
+               # that they are being used correctly in the link pass.
+               test -z "$libdir" && \
+                 func_append dlpreconveniencelibs " $dir/$old_library"
+             fi
+           ;;
+           * )
+             # Prefer using a static library (so that no silly _DYNAMIC symbols
+             # are required to link).
+             if test -n "$old_library"; then
+               func_append newdlprefiles " $dir/$old_library"
+               # Keep a list of preopened convenience libraries to check
+               # that they are being used correctly in the link pass.
+               test -z "$libdir" && \
+                 func_append dlpreconveniencelibs " $dir/$old_library"
+             # Otherwise, use the dlname, so that lt_dlopen finds it.
+             elif test -n "$dlname"; then
+               func_append newdlprefiles " $dir/$dlname"
+             else
+               func_append newdlprefiles " $dir/$linklib"
+             fi
+           ;;
+         esac
+       fi # $pass = dlpreopen
+
+       if test -z "$libdir"; then
+         # Link the convenience library
+         if test "$linkmode" = lib; then
+           deplibs="$dir/$old_library $deplibs"
+         elif test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$dir/$old_library $compile_deplibs"
+           finalize_deplibs="$dir/$old_library $finalize_deplibs"
+         else
+           deplibs="$lib $deplibs" # used for prog,scan pass
+         fi
+         continue
+       fi
+
+
+       if test "$linkmode" = prog && test "$pass" != link; then
+         func_append newlib_search_path " $ladir"
+         deplibs="$lib $deplibs"
+
+         linkalldeplibs=no
+         if test "$link_all_deplibs" != no || test -z "$library_names" ||
+            test "$build_libtool_libs" = no; then
+           linkalldeplibs=yes
+         fi
+
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           case $deplib in
+           -L*) func_stripname '-L' '' "$deplib"
+                func_resolve_sysroot "$func_stripname_result"
+                func_append newlib_search_path " $func_resolve_sysroot_result"
+                ;;
+           esac
+           # Need to link against all dependency_libs?
+           if test "$linkalldeplibs" = yes; then
+             deplibs="$deplib $deplibs"
+           else
+             # Need to hardcode shared library paths
+             # or/and link against static libraries
+             newdependency_libs="$deplib $newdependency_libs"
+           fi
+           if $opt_preserve_dup_deps ; then
+             case "$tmp_libs " in
+             *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+             esac
+           fi
+           func_append tmp_libs " $deplib"
+         done # for deplib
+         continue
+       fi # $linkmode = prog...
+
+       if test "$linkmode,$pass" = "prog,link"; then
+         if test -n "$library_names" &&
+            { { test "$prefer_static_libs" = no ||
+                test "$prefer_static_libs,$installed" = "built,yes"; } ||
+              test -z "$old_library"; }; then
+           # We need to hardcode the library path
+           if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+             # Make sure the rpath contains only unique directories.
+             case "$temp_rpath:" in
+             *"$absdir:"*) ;;
+             *) func_append temp_rpath "$absdir:" ;;
+             esac
+           fi
+
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) func_append compile_rpath " $absdir" ;;
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) func_append finalize_rpath " $libdir" ;;
+             esac
+             ;;
+           esac
+         fi # $linkmode,$pass = prog,link...
+
+         if test "$alldeplibs" = yes &&
+            { test "$deplibs_check_method" = pass_all ||
+              { test "$build_libtool_libs" = yes &&
+                test -n "$library_names"; }; }; then
+           # We only need to search for static libraries
+           continue
+         fi
+       fi
+
+       link_static=no # Whether the deplib will be linked statically
+       use_static_libs=$prefer_static_libs
+       if test "$use_static_libs" = built && test "$installed" = yes; then
+         use_static_libs=no
+       fi
+       if test -n "$library_names" &&
+          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+         case $host in
+         *cygwin* | *mingw* | *cegcc*)
+             # No point in relinking DLLs because paths are not encoded
+             func_append notinst_deplibs " $lib"
+             need_relink=no
+           ;;
+         *)
+           if test "$installed" = no; then
+             func_append notinst_deplibs " $lib"
+             need_relink=yes
+           fi
+           ;;
+         esac
+         # This is a shared library
+
+         # Warn about portability, can't link against -module's on some
+         # systems (darwin).  Don't bleat about dlopened modules though!
+         dlopenmodule=""
+         for dlpremoduletest in $dlprefiles; do
+           if test "X$dlpremoduletest" = "X$lib"; then
+             dlopenmodule="$dlpremoduletest"
+             break
+           fi
+         done
+         if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+           echo
+           if test "$linkmode" = prog; then
+             $ECHO "*** Warning: Linking the executable $output against the loadable module"
+           else
+             $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+           fi
+           $ECHO "*** $linklib is not portable!"
+         fi
+         if test "$linkmode" = lib &&
+            test "$hardcode_into_libs" = yes; then
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) func_append compile_rpath " $absdir" ;;
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) func_append finalize_rpath " $libdir" ;;
+             esac
+             ;;
+           esac
+         fi
+
+         if test -n "$old_archive_from_expsyms_cmds"; then
+           # figure out the soname
+           set dummy $library_names
+           shift
+           realname="$1"
+           shift
+           libname=`eval "\\$ECHO \"$libname_spec\""`
+           # use dlname if we got it. it's perfectly good, no?
+           if test -n "$dlname"; then
+             soname="$dlname"
+           elif test -n "$soname_spec"; then
+             # bleh windows
+             case $host in
+             *cygwin* | mingw* | *cegcc*)
+               func_arith $current - $age
+               major=$func_arith_result
+               versuffix="-$major"
+               ;;
+             esac
+             eval soname=\"$soname_spec\"
+           else
+             soname="$realname"
+           fi
+
+           # Make a new name for the extract_expsyms_cmds to use
+           soroot="$soname"
+           func_basename "$soroot"
+           soname="$func_basename_result"
+           func_stripname 'lib' '.dll' "$soname"
+           newlib=libimp-$func_stripname_result.a
+
+           # If the library has no export list, then create one now
+           if test -f "$output_objdir/$soname-def"; then :
+           else
+             func_verbose "extracting exported symbol list from \`$soname'"
+             func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+           fi
+
+           # Create $newlib
+           if test -f "$output_objdir/$newlib"; then :; else
+             func_verbose "generating import library for \`$soname'"
+             func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+           fi
+           # make sure the library variables are pointing to the new library
+           dir=$output_objdir
+           linklib=$newlib
+         fi # test -n "$old_archive_from_expsyms_cmds"
+
+         if test "$linkmode" = prog || test "$opt_mode" != relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           lib_linked=yes
+           case $hardcode_action in
+           immediate | unsupported)
+             if test "$hardcode_direct" = no; then
+               add="$dir/$linklib"
+               case $host in
+                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+                   *-*-unixware7*) add_dir="-L$dir" ;;
+                 *-*-darwin* )
+                   # if the lib is a (non-dlopened) module then we can not
+                   # link against it, someone is ignoring the earlier warnings
+                   if /usr/bin/file -L $add 2> /dev/null |
+                        $GREP ": [^:]* bundle" >/dev/null ; then
+                     if test "X$dlopenmodule" != "X$lib"; then
+                       $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+                       if test -z "$old_library" ; then
+                         echo
+                         echo "*** And there doesn't seem to be a static archive available"
+                         echo "*** The link will probably fail, sorry"
+                       else
+                         add="$dir/$old_library"
+                       fi
+                     elif test -n "$old_library"; then
+                       add="$dir/$old_library"
+                     fi
+                   fi
+               esac
+             elif test "$hardcode_minus_L" = no; then
+               case $host in
+               *-*-sunos*) add_shlibpath="$dir" ;;
+               esac
+               add_dir="-L$dir"
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = no; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           relink)
+             if test "$hardcode_direct" = yes &&
+                test "$hardcode_direct_absolute" = no; then
+               add="$dir/$linklib"
+             elif test "$hardcode_minus_L" = yes; then
+               add_dir="-L$absdir"
+               # Try looking first in the location we're being installed to.
+               if test -n "$inst_prefix_dir"; then
+                 case $libdir in
+                   [\\/]*)
+                     func_append add_dir " -L$inst_prefix_dir$libdir"
+                     ;;
+                 esac
+               fi
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = yes; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           *) lib_linked=no ;;
+           esac
+
+           if test "$lib_linked" != yes; then
+             func_fatal_configuration "unsupported hardcode properties"
+           fi
+
+           if test -n "$add_shlibpath"; then
+             case :$compile_shlibpath: in
+             *":$add_shlibpath:"*) ;;
+             *) func_append compile_shlibpath "$add_shlibpath:" ;;
+             esac
+           fi
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+             test -n "$add" && compile_deplibs="$add $compile_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+             if test "$hardcode_direct" != yes &&
+                test "$hardcode_minus_L" != yes &&
+                test "$hardcode_shlibpath_var" = yes; then
+               case :$finalize_shlibpath: in
+               *":$libdir:"*) ;;
+               *) func_append finalize_shlibpath "$libdir:" ;;
+               esac
+             fi
+           fi
+         fi
+
+         if test "$linkmode" = prog || test "$opt_mode" = relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           # Finalize command for both is simple: just hardcode it.
+           if test "$hardcode_direct" = yes &&
+              test "$hardcode_direct_absolute" = no; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+             add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+             *":$libdir:"*) ;;
+             *) func_append finalize_shlibpath "$libdir:" ;;
+             esac
+             add="-l$name"
+           elif test "$hardcode_automatic" = yes; then
+             if test -n "$inst_prefix_dir" &&
+                test -f "$inst_prefix_dir$libdir/$linklib" ; then
+               add="$inst_prefix_dir$libdir/$linklib"
+             else
+               add="$libdir/$linklib"
+             fi
+           else
+             # We cannot seem to hardcode it, guess we'll fake it.
+             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+                 [\\/]*)
+                   func_append add_dir " -L$inst_prefix_dir$libdir"
+                   ;;
+               esac
+             fi
+             add="-l$name"
+           fi
+
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+             test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+           fi
+         fi
+       elif test "$linkmode" = prog; then
+         # Here we assume that one of hardcode_direct or hardcode_minus_L
+         # is not unsupported.  This is valid on all known static and
+         # shared platforms.
+         if test "$hardcode_direct" != unsupported; then
+           test -n "$old_library" && linklib="$old_library"
+           compile_deplibs="$dir/$linklib $compile_deplibs"
+           finalize_deplibs="$dir/$linklib $finalize_deplibs"
+         else
+           compile_deplibs="-l$name -L$dir $compile_deplibs"
+           finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+         fi
+       elif test "$build_libtool_libs" = yes; then
+         # Not a shared library
+         if test "$deplibs_check_method" != pass_all; then
+           # We're trying link a shared library against a static one
+           # but the system doesn't support it.
+
+           # Just print a warning and add the library to dependency_libs so
+           # that the program can be linked against the static library.
+           echo
+           $ECHO "*** Warning: This system can not link to static lib archive $lib."
+           echo "*** I have the capability to make that library automatically link in when"
+           echo "*** you link to this library.  But I can only do this if you have a"
+           echo "*** shared version of the library, which you do not appear to have."
+           if test "$module" = yes; then
+             echo "*** But as you try to build a module library, libtool will still create "
+             echo "*** a static module, that should work as long as the dlopening application"
+             echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+             if test -z "$global_symbol_pipe"; then
+               echo
+               echo "*** However, this would only work if libtool was able to extract symbol"
+               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+               echo "*** not find such a program.  So, this module is probably useless."
+               echo "*** \`nm' from GNU binutils and a full rebuild may help."
+             fi
+             if test "$build_old_libs" = no; then
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         else
+           deplibs="$dir/$old_library $deplibs"
+           link_static=yes
+         fi
+       fi # link shared/static library?
+
+       if test "$linkmode" = lib; then
+         if test -n "$dependency_libs" &&
+            { test "$hardcode_into_libs" != yes ||
+              test "$build_old_libs" = yes ||
+              test "$link_static" = yes; }; then
+           # Extract -R from dependency_libs
+           temp_deplibs=
+           for libdir in $dependency_libs; do
+             case $libdir in
+             -R*) func_stripname '-R' '' "$libdir"
+                  temp_xrpath=$func_stripname_result
+                  case " $xrpath " in
+                  *" $temp_xrpath "*) ;;
+                  *) func_append xrpath " $temp_xrpath";;
+                  esac;;
+             *) func_append temp_deplibs " $libdir";;
+             esac
+           done
+           dependency_libs="$temp_deplibs"
+         fi
+
+         func_append newlib_search_path " $absdir"
+         # Link against this library
+         test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+         # ... and its dependency_libs
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           newdependency_libs="$deplib $newdependency_libs"
+           case $deplib in
+              -L*) func_stripname '-L' '' "$deplib"
+                   func_resolve_sysroot "$func_stripname_result";;
+              *) func_resolve_sysroot "$deplib" ;;
+            esac
+           if $opt_preserve_dup_deps ; then
+             case "$tmp_libs " in
+             *" $func_resolve_sysroot_result "*)
+                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
+             esac
+           fi
+           func_append tmp_libs " $func_resolve_sysroot_result"
+         done
+
+         if test "$link_all_deplibs" != no; then
+           # Add the search paths of all dependency libraries
+           for deplib in $dependency_libs; do
+             path=
+             case $deplib in
+             -L*) path="$deplib" ;;
+             *.la)
+               func_resolve_sysroot "$deplib"
+               deplib=$func_resolve_sysroot_result
+               func_dirname "$deplib" "" "."
+               dir=$func_dirname_result
+               # We need an absolute path.
+               case $dir in
+               [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+               *)
+                 absdir=`cd "$dir" && pwd`
+                 if test -z "$absdir"; then
+                   func_warning "cannot determine absolute directory name of \`$dir'"
+                   absdir="$dir"
+                 fi
+                 ;;
+               esac
+               if $GREP "^installed=no" $deplib > /dev/null; then
+               case $host in
+               *-*-darwin*)
+                 depdepl=
+                 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+                 if test -n "$deplibrary_names" ; then
+                   for tmp in $deplibrary_names ; do
+                     depdepl=$tmp
+                   done
+                   if test -f "$absdir/$objdir/$depdepl" ; then
+                     depdepl="$absdir/$objdir/$depdepl"
+                     darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+                     func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+                     func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+                     path=
+                   fi
+                 fi
+                 ;;
+               *)
+                 path="-L$absdir/$objdir"
+                 ;;
+               esac
+               else
+                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+                 test -z "$libdir" && \
+                   func_fatal_error "\`$deplib' is not a valid libtool archive"
+                 test "$absdir" != "$libdir" && \
+                   func_warning "\`$deplib' seems to be moved"
+
+                 path="-L$absdir"
+               fi
+               ;;
+             esac
+             case " $deplibs " in
+             *" $path "*) ;;
+             *) deplibs="$path $deplibs" ;;
+             esac
+           done
+         fi # link_all_deplibs != no
+       fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+       if test "$linkmode" = "prog"; then
+         compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+         finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+       else
+         compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+       # Link the dlpreopened libraries before other libraries
+       for deplib in $save_deplibs; do
+         deplibs="$deplib $deplibs"
+       done
+      fi
+      if test "$pass" != dlopen; then
+       if test "$pass" != conv; then
+         # Make sure lib_search_path contains only unique directories.
+         lib_search_path=
+         for dir in $newlib_search_path; do
+           case "$lib_search_path " in
+           *" $dir "*) ;;
+           *) func_append lib_search_path " $dir" ;;
+           esac
+         done
+         newlib_search_path=
+       fi
+
+       if test "$linkmode,$pass" != "prog,link"; then
+         vars="deplibs"
+       else
+         vars="compile_deplibs finalize_deplibs"
+       fi
+       for var in $vars dependency_libs; do
+         # Add libraries to $var in reverse order
+         eval tmp_libs=\"\$$var\"
+         new_libs=
+         for deplib in $tmp_libs; do
+           # FIXME: Pedantically, this is the right thing to do, so
+           #        that some nasty dependency loop isn't accidentally
+           #        broken:
+           #new_libs="$deplib $new_libs"
+           # Pragmatically, this seems to cause very few problems in
+           # practice:
+           case $deplib in
+           -L*) new_libs="$deplib $new_libs" ;;
+           -R*) ;;
+           *)
+             # And here is the reason: when a library appears more
+             # than once as an explicit dependence of a library, or
+             # is implicitly linked in more than once by the
+             # compiler, it is considered special, and multiple
+             # occurrences thereof are not removed.  Compare this
+             # with having the same library being listed as a
+             # dependency of multiple other libraries: in this case,
+             # we know (pedantically, we assume) the library does not
+             # need to be listed more than once, so we keep only the
+             # last copy.  This is not always right, but it is rare
+             # enough that we require users that really mean to play
+             # such unportable linking tricks to link the library
+             # using -Wl,-lname, so that libtool does not consider it
+             # for duplicate removal.
+             case " $specialdeplibs " in
+             *" $deplib "*) new_libs="$deplib $new_libs" ;;
+             *)
+               case " $new_libs " in
+               *" $deplib "*) ;;
+               *) new_libs="$deplib $new_libs" ;;
+               esac
+               ;;
+             esac
+             ;;
+           esac
+         done
+         tmp_libs=
+         for deplib in $new_libs; do
+           case $deplib in
+           -L*)
+             case " $tmp_libs " in
+             *" $deplib "*) ;;
+             *) func_append tmp_libs " $deplib" ;;
+             esac
+             ;;
+           *) func_append tmp_libs " $deplib" ;;
+           esac
+         done
+         eval $var=\"$tmp_libs\"
+       done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+       case " $predeps $postdeps $compiler_lib_search_path " in
+       *" $i "*)
+         i=""
+         ;;
+       esac
+       if test -n "$i" ; then
+         func_append tmp_libs " $i"
+       fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+       func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+       func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+       func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+       func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+       func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      func_append objs "$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+       func_stripname 'lib' '.la' "$outputname"
+       name=$func_stripname_result
+       eval shared_ext=\"$shrext_cmds\"
+       eval libname=\"$libname_spec\"
+       ;;
+      *)
+       test "$module" = no && \
+         func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+       if test "$need_lib_prefix" != no; then
+         # Add the "lib" prefix for modules if required
+         func_stripname '' '.la' "$outputname"
+         name=$func_stripname_result
+         eval shared_ext=\"$shrext_cmds\"
+         eval libname=\"$libname_spec\"
+       else
+         func_stripname '' '.la' "$outputname"
+         libname=$func_stripname_result
+       fi
+       ;;
+      esac
+
+      if test -n "$objs"; then
+       if test "$deplibs_check_method" != pass_all; then
+         func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+       else
+         echo
+         $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+         $ECHO "*** objects $objs is not portable!"
+         func_append libobjs " $objs"
+       fi
+      fi
+
+      test "$dlself" != no && \
+       func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+       func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+       if test "$build_libtool_libs" = yes; then
+         # Building a libtool convenience library.
+         # Some compilers have problems with a `.al' extension so
+         # convenience libraries should have the same extension an
+         # archive normally would.
+         oldlibs="$output_objdir/$libname.$libext $oldlibs"
+         build_libtool_libs=convenience
+         build_old_libs=yes
+       fi
+
+       test -n "$vinfo" && \
+         func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+       test -n "$release" && \
+         func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+       # Parse the version information argument.
+       save_ifs="$IFS"; IFS=':'
+       set dummy $vinfo 0 0 0
+       shift
+       IFS="$save_ifs"
+
+       test -n "$7" && \
+         func_fatal_help "too many parameters to \`-version-info'"
+
+       # convert absolute version numbers to libtool ages
+       # this retains compatibility with .la files and attempts
+       # to make the code below a bit more comprehensible
+
+       case $vinfo_number in
+       yes)
+         number_major="$1"
+         number_minor="$2"
+         number_revision="$3"
+         #
+         # There are really only two kinds -- those that
+         # use the current revision as the major version
+         # and those that subtract age and use age as
+         # a minor version.  But, then there is irix
+         # which has an extra 1 added just for fun
+         #
+         case $version_type in
+         # correct linux to gnu/linux during the next big refactor
+         darwin|linux|osf|windows|none)
+           func_arith $number_major + $number_minor
+           current=$func_arith_result
+           age="$number_minor"
+           revision="$number_revision"
+           ;;
+         freebsd-aout|freebsd-elf|qnx|sunos)
+           current="$number_major"
+           revision="$number_minor"
+           age="0"
+           ;;
+         irix|nonstopux)
+           func_arith $number_major + $number_minor
+           current=$func_arith_result
+           age="$number_minor"
+           revision="$number_minor"
+           lt_irix_increment=no
+           ;;
+         esac
+         ;;
+       no)
+         current="$1"
+         revision="$2"
+         age="$3"
+         ;;
+       esac
+
+       # Check that each of the things are valid numbers.
+       case $current in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "CURRENT \`$current' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       case $revision in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "REVISION \`$revision' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       case $age in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "AGE \`$age' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       if test "$age" -gt "$current"; then
+         func_error "AGE \`$age' is greater than the current interface number \`$current'"
+         func_fatal_error "\`$vinfo' is not valid version information"
+       fi
+
+       # Calculate the version variables.
+       major=
+       versuffix=
+       verstring=
+       case $version_type in
+       none) ;;
+
+       darwin)
+         # Like Linux, but with the current version available in
+         # verstring for coding it into the library header
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix="$major.$age.$revision"
+         # Darwin ld doesn't like 0 for these options...
+         func_arith $current + 1
+         minor_current=$func_arith_result
+         xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+         verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current"
+         ;;
+
+       irix | nonstopux)
+         if test "X$lt_irix_increment" = "Xno"; then
+           func_arith $current - $age
+         else
+           func_arith $current - $age + 1
+         fi
+         major=$func_arith_result
+
+         case $version_type in
+           nonstopux) verstring_prefix=nonstopux ;;
+           *)         verstring_prefix=sgi ;;
+         esac
+         verstring="$verstring_prefix$major.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$revision
+         while test "$loop" -ne 0; do
+           func_arith $revision - $loop
+           iface=$func_arith_result
+           func_arith $loop - 1
+           loop=$func_arith_result
+           verstring="$verstring_prefix$major.$iface:$verstring"
+         done
+
+         # Before this point, $major must not contain `.'.
+         major=.$major
+         versuffix="$major.$revision"
+         ;;
+
+       linux) # correct to gnu/linux during the next big refactor
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix="$major.$age.$revision"
+         ;;
+
+       osf)
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix=".$current.$age.$revision"
+         verstring="$current.$age.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$age
+         while test "$loop" -ne 0; do
+           func_arith $current - $loop
+           iface=$func_arith_result
+           func_arith $loop - 1
+           loop=$func_arith_result
+           verstring="$verstring:${iface}.0"
+         done
+
+         # Make executables depend on our current version.
+         func_append verstring ":${current}.0"
+         ;;
+
+       qnx)
+         major=".$current"
+         versuffix=".$current"
+         ;;
+
+       sunos)
+         major=".$current"
+         versuffix=".$current.$revision"
+         ;;
+
+       windows)
+         # Use '-' rather than '.', since we only want one
+         # extension on DOS 8.3 filesystems.
+         func_arith $current - $age
+         major=$func_arith_result
+         versuffix="-$major"
+         ;;
+
+       *)
+         func_fatal_configuration "unknown library version type \`$version_type'"
+         ;;
+       esac
+
+       # Clear the version info if we defaulted, and they specified a release.
+       if test -z "$vinfo" && test -n "$release"; then
+         major=
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
+         if test "$need_version" = no; then
+           versuffix=
+         else
+           versuffix=".0.0"
+         fi
+       fi
+
+       # Remove version info from name if versioning should be avoided
+       if test "$avoid_version" = yes && test "$need_version" = no; then
+         major=
+         versuffix=
+         verstring=""
+       fi
+
+       # Check to see if the archive will have undefined symbols.
+       if test "$allow_undefined" = yes; then
+         if test "$allow_undefined_flag" = unsupported; then
+           func_warning "undefined symbols not allowed in $host shared libraries"
+           build_libtool_libs=no
+           build_old_libs=yes
+         fi
+       else
+         # Don't allow undefined symbols.
+         allow_undefined_flag="$no_undefined_flag"
+       fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_append libobjs " $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$opt_mode" != relink; then
+       # Remove our outputs, but don't remove object files since they
+       # may have been created when compiling PIC objects.
+       removelist=
+       tempremovelist=`$ECHO "$output_objdir/*"`
+       for p in $tempremovelist; do
+         case $p in
+           *.$objext | *.gcno)
+              ;;
+           $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+              if test "X$precious_files_regex" != "X"; then
+                if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+                then
+                  continue
+                fi
+              fi
+              func_append removelist " $p"
+              ;;
+           *) ;;
+         esac
+       done
+       test -n "$removelist" && \
+         func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+       func_append oldlibs " $output_objdir/$libname.$libext"
+
+       # Transform .lo files to .o files.
+       oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #        lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
+      #        deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
+      #        dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       temp_xrpath=
+       for libdir in $xrpath; do
+         func_replace_sysroot "$libdir"
+         func_append temp_xrpath " -R$func_replace_sysroot_result"
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) func_append finalize_rpath " $libdir" ;;
+         esac
+       done
+       if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+         dependency_libs="$temp_xrpath $dependency_libs"
+       fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+       case " $dlprefiles $dlfiles " in
+       *" $lib "*) ;;
+       *) func_append dlfiles " $lib" ;;
+       esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+       case "$dlprefiles " in
+       *" $lib "*) ;;
+       *) func_append dlprefiles " $lib" ;;
+       esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+       if test -n "$rpath"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
+           # these systems don't actually have a c library (as such)!
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C library is in the System framework
+           func_append deplibs " System.ltframework"
+           ;;
+         *-*-netbsd*)
+           # Don't link with libc until the a.out ld.so is fixed.
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           ;;
+         *)
+           # Add libc to deplibs on all other systems if necessary.
+           if test "$build_libtool_need_lc" = "yes"; then
+             func_append deplibs " -lc"
+           fi
+           ;;
+         esac
+       fi
+
+       # Transform deplibs into only deplibs that can be linked in shared.
+       name_save=$name
+       libname_save=$libname
+       release_save=$release
+       versuffix_save=$versuffix
+       major_save=$major
+       # I'm not sure if I'm treating the release correctly.  I think
+       # release should show up in the -l (ie -lgmp5) so we don't want to
+       # add it in twice.  Is that correct?
+       release=""
+       versuffix=""
+       major=""
+       newdeplibs=
+       droppeddeps=no
+       case $deplibs_check_method in
+       pass_all)
+         # Don't check for shared/static.  Everything works.
+         # This might be a little naive.  We might want to check
+         # whether the library exists or not.  But this is on
+         # osf3 & osf4 and I'm not really sure... Just
+         # implementing what was already the behavior.
+         newdeplibs=$deplibs
+         ;;
+       test_compile)
+         # This code stresses the "libraries are programs" paradigm to its
+         # limits. Maybe even breaks it.  We compile a program, linking it
+         # against the deplibs as a proxy for the library.  Then we can check
+         # whether they linked in statically or dynamically with ldd.
+         $opt_dry_run || $RM conftest.c
+         cat > conftest.c <<EOF
+         int main() { return 0; }
+EOF
+         $opt_dry_run || $RM conftest
+         if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+           ldd_output=`ldd conftest`
+           for i in $deplibs; do
+             case $i in
+             -l*)
+               func_stripname -l '' "$i"
+               name=$func_stripname_result
+               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                 case " $predeps $postdeps " in
+                 *" $i "*)
+                   func_append newdeplibs " $i"
+                   i=""
+                   ;;
+                 esac
+               fi
+               if test -n "$i" ; then
+                 libname=`eval "\\$ECHO \"$libname_spec\""`
+                 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+                 set dummy $deplib_matches; shift
+                 deplib_match=$1
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   func_append newdeplibs " $i"
+                 else
+                   droppeddeps=yes
+                   echo
+                   $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+                   echo "*** I have the capability to make that library automatically link in when"
+                   echo "*** you link to this library.  But I can only do this if you have a"
+                   echo "*** shared version of the library, which I believe you do not have"
+                   echo "*** because a test_compile did reveal that the linker did not use it for"
+                   echo "*** its dynamic dependency list that programs get resolved with at runtime."
+                 fi
+               fi
+               ;;
+             *)
+               func_append newdeplibs " $i"
+               ;;
+             esac
+           done
+         else
+           # Error occurred in the first compile.  Let's try to salvage
+           # the situation: Compile a separate program for each library.
+           for i in $deplibs; do
+             case $i in
+             -l*)
+               func_stripname -l '' "$i"
+               name=$func_stripname_result
+               $opt_dry_run || $RM conftest
+               if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+                 ldd_output=`ldd conftest`
+                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                   case " $predeps $postdeps " in
+                   *" $i "*)
+                     func_append newdeplibs " $i"
+                     i=""
+                     ;;
+                   esac
+                 fi
+                 if test -n "$i" ; then
+                   libname=`eval "\\$ECHO \"$libname_spec\""`
+                   deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+                   set dummy $deplib_matches; shift
+                   deplib_match=$1
+                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                     func_append newdeplibs " $i"
+                   else
+                     droppeddeps=yes
+                     echo
+                     $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+                     echo "*** I have the capability to make that library automatically link in when"
+                     echo "*** you link to this library.  But I can only do this if you have a"
+                     echo "*** shared version of the library, which you do not appear to have"
+                     echo "*** because a test_compile did reveal that the linker did not use this one"
+                     echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+                   fi
+                 fi
+               else
+                 droppeddeps=yes
+                 echo
+                 $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+                 echo "*** make it link in!  You will probably need to install it or some"
+                 echo "*** library that it depends on before this library will be fully"
+                 echo "*** functional.  Installing it before continuing would be even better."
+               fi
+               ;;
+             *)
+               func_append newdeplibs " $i"
+               ;;
+             esac
+           done
+         fi
+         ;;
+       file_magic*)
+         set dummy $deplibs_check_method; shift
+         file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+         for a_deplib in $deplibs; do
+           case $a_deplib in
+           -l*)
+             func_stripname -l '' "$a_deplib"
+             name=$func_stripname_result
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 func_append newdeplibs " $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval "\\$ECHO \"$libname_spec\""`
+               if test -n "$file_magic_glob"; then
+                 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
+               else
+                 libnameglob=$libname
+               fi
+               test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 if test "$want_nocaseglob" = yes; then
+                   shopt -s nocaseglob
+                   potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+                   $nocaseglob
+                 else
+                   potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+                 fi
+                 for potent_lib in $potential_libs; do
+                     # Follow soft links.
+                     if ls -lLd "$potent_lib" 2>/dev/null |
+                        $GREP " -> " >/dev/null; then
+                       continue
+                     fi
+                     # The statement above tries to avoid entering an
+                     # endless loop below, in case of cyclic links.
+                     # We might still enter an endless loop, since a link
+                     # loop can be closed while we follow links,
+                     # but so what?
+                     potlib="$potent_lib"
+                     while test -h "$potlib" 2>/dev/null; do
+                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+                       case $potliblink in
+                       [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+                       *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+                       esac
+                     done
+                     if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+                        $SED -e 10q |
+                        $EGREP "$file_magic_regex" > /dev/null; then
+                       func_append newdeplibs " $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+               else
+                 $ECHO "*** with $libname and none of the candidates passed a file format test"
+                 $ECHO "*** using a file magic. Last file checked: $potlib"
+               fi
+             fi
+             ;;
+           *)
+             # Add a -L argument.
+             func_append newdeplibs " $a_deplib"
+             ;;
+           esac
+         done # Gone through all deplibs.
+         ;;
+       match_pattern*)
+         set dummy $deplibs_check_method; shift
+         match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+         for a_deplib in $deplibs; do
+           case $a_deplib in
+           -l*)
+             func_stripname -l '' "$a_deplib"
+             name=$func_stripname_result
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 func_append newdeplibs " $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval "\\$ECHO \"$libname_spec\""`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                   potlib="$potent_lib" # see symlink-check above in file_magic test
+                   if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
+                      $EGREP "$match_pattern_regex" > /dev/null; then
+                     func_append newdeplibs " $a_deplib"
+                     a_deplib=""
+                     break 2
+                   fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+               else
+                 $ECHO "*** with $libname and none of the candidates passed a file format test"
+                 $ECHO "*** using a regex pattern. Last file checked: $potlib"
+               fi
+             fi
+             ;;
+           *)
+             # Add a -L argument.
+             func_append newdeplibs " $a_deplib"
+             ;;
+           esac
+         done # Gone through all deplibs.
+         ;;
+       none | unknown | *)
+         newdeplibs=""
+         tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
+         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+           for i in $predeps $postdeps ; do
+             # can't use Xsed below, because $i might contain '/'
+             tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+           done
+         fi
+         case $tmp_deplibs in
+         *[!\  \ ]*)
+           echo
+           if test "X$deplibs_check_method" = "Xnone"; then
+             echo "*** Warning: inter-library dependencies are not supported in this platform."
+           else
+             echo "*** Warning: inter-library dependencies are not known to be supported."
+           fi
+           echo "*** All declared inter-library dependencies are being dropped."
+           droppeddeps=yes
+           ;;
+         esac
+         ;;
+       esac
+       versuffix=$versuffix_save
+       major=$major_save
+       release=$release_save
+       libname=$libname_save
+       name=$name_save
+
+       case $host in
+       *-*-rhapsody* | *-*-darwin1.[012])
+         # On Rhapsody replace the C library with the System framework
+         newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
+         ;;
+       esac
+
+       if test "$droppeddeps" = yes; then
+         if test "$module" = yes; then
+           echo
+           echo "*** Warning: libtool could not satisfy all declared inter-library"
+           $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+           echo "*** a static module, that should work as long as the dlopening"
+           echo "*** application is linked with the -dlopen flag."
+           if test -z "$global_symbol_pipe"; then
+             echo
+             echo "*** However, this would only work if libtool was able to extract symbol"
+             echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+             echo "*** not find such a program.  So, this module is probably useless."
+             echo "*** \`nm' from GNU binutils and a full rebuild may help."
+           fi
+           if test "$build_old_libs" = no; then
+             oldlibs="$output_objdir/$libname.$libext"
+             build_libtool_libs=module
+             build_old_libs=yes
+           else
+             build_libtool_libs=no
+           fi
+         else
+           echo "*** The inter-library dependencies that have been dropped here will be"
+           echo "*** automatically added whenever a program is linked with this library"
+           echo "*** or is declared to -dlopen it."
+
+           if test "$allow_undefined" = no; then
+             echo
+             echo "*** Since this library must not contain undefined symbols,"
+             echo "*** because either the platform does not support them or"
+             echo "*** it was explicitly requested with -no-undefined,"
+             echo "*** libtool will only create a static version of it."
+             if test "$build_old_libs" = no; then
+               oldlibs="$output_objdir/$libname.$libext"
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         fi
+       fi
+       # Done checking deplibs!
+       deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+       *-*-darwin*)
+         newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $deplibs " in
+         *" -L$path/$objdir "*)
+           func_append new_libs " -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) func_append new_libs " $deplib" ;;
+         esac
+         ;;
+       *) func_append new_libs " $deplib" ;;
+       esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+       # Remove ${wl} instances when linking with ld.
+       # FIXME: should test the right _cmds variable.
+       case $archive_cmds in
+         *\$LD\ *) wl= ;;
+        esac
+       if test "$hardcode_into_libs" = yes; then
+         # Hardcode the library paths
+         hardcode_libdirs=
+         dep_rpath=
+         rpath="$finalize_rpath"
+         test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+         for libdir in $rpath; do
+           if test -n "$hardcode_libdir_flag_spec"; then
+             if test -n "$hardcode_libdir_separator"; then
+               func_replace_sysroot "$libdir"
+               libdir=$func_replace_sysroot_result
+               if test -z "$hardcode_libdirs"; then
+                 hardcode_libdirs="$libdir"
+               else
+                 # Just accumulate the unique libdirs.
+                 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+                 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+                   ;;
+                 *)
+                   func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+                   ;;
+                 esac
+               fi
+             else
+               eval flag=\"$hardcode_libdir_flag_spec\"
+               func_append dep_rpath " $flag"
+             fi
+           elif test -n "$runpath_var"; then
+             case "$perm_rpath " in
+             *" $libdir "*) ;;
+             *) func_append perm_rpath " $libdir" ;;
+             esac
+           fi
+         done
+         # Substitute the hardcoded libdirs into the rpath.
+         if test -n "$hardcode_libdir_separator" &&
+            test -n "$hardcode_libdirs"; then
+           libdir="$hardcode_libdirs"
+           eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
+         fi
+         if test -n "$runpath_var" && test -n "$perm_rpath"; then
+           # We should set the runpath_var.
+           rpath=
+           for dir in $perm_rpath; do
+             func_append rpath "$dir:"
+           done
+           eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+         fi
+         test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+       fi
+
+       shlibpath="$finalize_shlibpath"
+       test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+       if test -n "$shlibpath"; then
+         eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+       fi
+
+       # Get the real and link names of the library.
+       eval shared_ext=\"$shrext_cmds\"
+       eval library_names=\"$library_names_spec\"
+       set dummy $library_names
+       shift
+       realname="$1"
+       shift
+
+       if test -n "$soname_spec"; then
+         eval soname=\"$soname_spec\"
+       else
+         soname="$realname"
+       fi
+       if test -z "$dlname"; then
+         dlname=$soname
+       fi
+
+       lib="$output_objdir/$realname"
+       linknames=
+       for link
+       do
+         func_append linknames " $link"
+       done
+
+       # Use standard objects if they are pic
+       test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+       test "X$libobjs" = "X " && libobjs=
+
+       delfiles=
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+         export_symbols="$output_objdir/$libname.uexp"
+         func_append delfiles " $export_symbols"
+       fi
+
+       orig_export_symbols=
+       case $host_os in
+       cygwin* | mingw* | cegcc*)
+         if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+           # exporting using user supplied symfile
+           if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+             # and it's NOT already a .def file. Must figure out
+             # which of the given symbols are data symbols and tag
+             # them as such. So, trigger use of export_symbols_cmds.
+             # export_symbols gets reassigned inside the "prepare
+             # the list of exported symbols" if statement, so the
+             # include_expsyms logic still works.
+             orig_export_symbols="$export_symbols"
+             export_symbols=
+             always_export_symbols=yes
+           fi
+         fi
+         ;;
+       esac
+
+       # Prepare the list of exported symbols
+       if test -z "$export_symbols"; then
+         if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+           func_verbose "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $opt_dry_run || $RM $export_symbols
+           cmds=$export_symbols_cmds
+           save_ifs="$IFS"; IFS='~'
+           for cmd1 in $cmds; do
+             IFS="$save_ifs"
+             # Take the normal branch if the nm_file_list_spec branch
+             # doesn't work or if tool conversion is not needed.
+             case $nm_file_list_spec~$to_tool_file_cmd in
+               *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
+                 try_normal_branch=yes
+                 eval cmd=\"$cmd1\"
+                 func_len " $cmd"
+                 len=$func_len_result
+                 ;;
+               *)
+                 try_normal_branch=no
+                 ;;
+             esac
+             if test "$try_normal_branch" = yes \
+                && { test "$len" -lt "$max_cmd_len" \
+                     || test "$max_cmd_len" -le -1; }
+             then
+               func_show_eval "$cmd" 'exit $?'
+               skipped_export=false
+             elif test -n "$nm_file_list_spec"; then
+               func_basename "$output"
+               output_la=$func_basename_result
+               save_libobjs=$libobjs
+               save_output=$output
+               output=${output_objdir}/${output_la}.nm
+               func_to_tool_file "$output"
+               libobjs=$nm_file_list_spec$func_to_tool_file_result
+               func_append delfiles " $output"
+               func_verbose "creating $NM input file list: $output"
+               for obj in $save_libobjs; do
+                 func_to_tool_file "$obj"
+                 $ECHO "$func_to_tool_file_result"
+               done > "$output"
+               eval cmd=\"$cmd1\"
+               func_show_eval "$cmd" 'exit $?'
+               output=$save_output
+               libobjs=$save_libobjs
+               skipped_export=false
+             else
+               # The command line is too long to execute in one step.
+               func_verbose "using reloadable object file for export list..."
+               skipped_export=:
+               # Break out early, otherwise skipped_export may be
+               # set to false by a later but shorter cmd.
+               break
+             fi
+           done
+           IFS="$save_ifs"
+           if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+             func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+       fi
+
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         tmp_export_symbols="$export_symbols"
+         test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+         $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+       fi
+
+       if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+         # The given exports_symbols file has to be filtered, so filter it.
+         func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+         # FIXME: $output_objdir/$libname.filter potentially contains lots of
+         # 's' commands which not all seds can handle. GNU sed should be fine
+         # though. Also, the filter scales superlinearly with the number of
+         # global variables. join(1) would be nice here, but unfortunately
+         # isn't a blessed tool.
+         $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+         func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+         export_symbols=$output_objdir/$libname.def
+         $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+       fi
+
+       tmp_deplibs=
+       for test_deplib in $deplibs; do
+         case " $convenience " in
+         *" $test_deplib "*) ;;
+         *)
+           func_append tmp_deplibs " $test_deplib"
+           ;;
+         esac
+       done
+       deplibs="$tmp_deplibs"
+
+       if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec" &&
+           test "$compiler_needs_object" = yes &&
+           test -z "$libobjs"; then
+           # extract the archives, so we have objects to list.
+           # TODO: could optimize this to just extract one archive.
+           whole_archive_flag_spec=
+         fi
+         if test -n "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+           test "X$libobjs" = "X " && libobjs=
+         else
+           gentop="$output_objdir/${outputname}x"
+           func_append generated " $gentop"
+
+           func_extract_archives $gentop $convenience
+           func_append libobjs " $func_extract_archives_result"
+           test "X$libobjs" = "X " && libobjs=
+         fi
+       fi
+
+       if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+         eval flag=\"$thread_safe_flag_spec\"
+         func_append linker_flags " $flag"
+       fi
+
+       # Make a backup of the uninstalled library when relinking
+       if test "$opt_mode" = relink; then
+         $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+       fi
+
+       # Do each of the archive commands.
+       if test "$module" = yes && test -n "$module_cmds" ; then
+         if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+           eval test_cmds=\"$module_expsym_cmds\"
+           cmds=$module_expsym_cmds
+         else
+           eval test_cmds=\"$module_cmds\"
+           cmds=$module_cmds
+         fi
+       else
+         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+           eval test_cmds=\"$archive_expsym_cmds\"
+           cmds=$archive_expsym_cmds
+         else
+           eval test_cmds=\"$archive_cmds\"
+           cmds=$archive_cmds
+         fi
+       fi
+
+       if test "X$skipped_export" != "X:" &&
+          func_len " $test_cmds" &&
+          len=$func_len_result &&
+          test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         :
+       else
+         # The command line is too long to link in one step, link piecewise
+         # or, if using GNU ld and skipped_export is not :, use a linker
+         # script.
+
+         # Save the value of $output and $libobjs because we want to
+         # use them later.  If we have whole_archive_flag_spec, we
+         # want to use save_libobjs as it was before
+         # whole_archive_flag_spec was expanded, because we can't
+         # assume the linker understands whole_archive_flag_spec.
+         # This may have to be revisited, in case too many
+         # convenience libraries get linked in and end up exceeding
+         # the spec.
+         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+         fi
+         save_output=$output
+         func_basename "$output"
+         output_la=$func_basename_result
+
+         # Clear the reloadable object creation command queue and
+         # initialize k to one.
+         test_cmds=
+         concat_cmds=
+         objlist=
+         last_robj=
+         k=1
+
+         if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+           output=${output_objdir}/${output_la}.lnkscript
+           func_verbose "creating GNU ld script: $output"
+           echo 'INPUT (' > $output
+           for obj in $save_libobjs
+           do
+             func_to_tool_file "$obj"
+             $ECHO "$func_to_tool_file_result" >> $output
+           done
+           echo ')' >> $output
+           func_append delfiles " $output"
+           func_to_tool_file "$output"
+           output=$func_to_tool_file_result
+         elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+           output=${output_objdir}/${output_la}.lnk
+           func_verbose "creating linker input file list: $output"
+           : > $output
+           set x $save_libobjs
+           shift
+           firstobj=
+           if test "$compiler_needs_object" = yes; then
+             firstobj="$1 "
+             shift
+           fi
+           for obj
+           do
+             func_to_tool_file "$obj"
+             $ECHO "$func_to_tool_file_result" >> $output
+           done
+           func_append delfiles " $output"
+           func_to_tool_file "$output"
+           output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
+         else
+           if test -n "$save_libobjs"; then
+             func_verbose "creating reloadable object files..."
+             output=$output_objdir/$output_la-${k}.$objext
+             eval test_cmds=\"$reload_cmds\"
+             func_len " $test_cmds"
+             len0=$func_len_result
+             len=$len0
+
+             # Loop over the list of objects to be linked.
+             for obj in $save_libobjs
+             do
+               func_len " $obj"
+               func_arith $len + $func_len_result
+               len=$func_arith_result
+               if test "X$objlist" = X ||
+                  test "$len" -lt "$max_cmd_len"; then
+                 func_append objlist " $obj"
+               else
+                 # The command $test_cmds is almost too long, add a
+                 # command to the queue.
+                 if test "$k" -eq 1 ; then
+                   # The first file doesn't have a previous command to add.
+                   reload_objs=$objlist
+                   eval concat_cmds=\"$reload_cmds\"
+                 else
+                   # All subsequent reloadable object files will link in
+                   # the last one created.
+                   reload_objs="$objlist $last_robj"
+                   eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
+                 fi
+                 last_robj=$output_objdir/$output_la-${k}.$objext
+                 func_arith $k + 1
+                 k=$func_arith_result
+                 output=$output_objdir/$output_la-${k}.$objext
+                 objlist=" $obj"
+                 func_len " $last_robj"
+                 func_arith $len0 + $func_len_result
+                 len=$func_arith_result
+               fi
+             done
+             # Handle the remaining objects by creating one last
+             # reloadable object file.  All subsequent reloadable object
+             # files will link in the last one created.
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             reload_objs="$objlist $last_robj"
+             eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+             if test -n "$last_robj"; then
+               eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+             fi
+             func_append delfiles " $output"
+
+           else
+             output=
+           fi
+
+           if ${skipped_export-false}; then
+             func_verbose "generating symbol list for \`$libname.la'"
+             export_symbols="$output_objdir/$libname.exp"
+             $opt_dry_run || $RM $export_symbols
+             libobjs=$output
+             # Append the command to create the export file.
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+             if test -n "$last_robj"; then
+               eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+             fi
+           fi
+
+           test -n "$save_libobjs" &&
+             func_verbose "creating a temporary reloadable object file: $output"
+
+           # Loop through the commands generated above and execute them.
+           save_ifs="$IFS"; IFS='~'
+           for cmd in $concat_cmds; do
+             IFS="$save_ifs"
+             $opt_silent || {
+                 func_quote_for_expand "$cmd"
+                 eval "func_echo $func_quote_for_expand_result"
+             }
+             $opt_dry_run || eval "$cmd" || {
+               lt_exit=$?
+
+               # Restore the uninstalled library and exit
+               if test "$opt_mode" = relink; then
+                 ( cd "$output_objdir" && \
+                   $RM "${realname}T" && \
+                   $MV "${realname}U" "$realname" )
+               fi
+
+               exit $lt_exit
+             }
+           done
+           IFS="$save_ifs"
+
+           if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+             func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+
+          if ${skipped_export-false}; then
+           if test -n "$export_symbols" && test -n "$include_expsyms"; then
+             tmp_export_symbols="$export_symbols"
+             test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+             $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+           fi
+
+           if test -n "$orig_export_symbols"; then
+             # The given exports_symbols file has to be filtered, so filter it.
+             func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+             # FIXME: $output_objdir/$libname.filter potentially contains lots of
+             # 's' commands which not all seds can handle. GNU sed should be fine
+             # though. Also, the filter scales superlinearly with the number of
+             # global variables. join(1) would be nice here, but unfortunately
+             # isn't a blessed tool.
+             $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+             func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+             export_symbols=$output_objdir/$libname.def
+             $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+           fi
+         fi
+
+         libobjs=$output
+         # Restore the value of output.
+         output=$save_output
+
+         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+           test "X$libobjs" = "X " && libobjs=
+         fi
+         # Expand the library linking commands again to reset the
+         # value of $libobjs for piecewise linking.
+
+         # Do each of the archive commands.
+         if test "$module" = yes && test -n "$module_cmds" ; then
+           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+             cmds=$module_expsym_cmds
+           else
+             cmds=$module_cmds
+           fi
+         else
+           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+             cmds=$archive_expsym_cmds
+           else
+             cmds=$archive_cmds
+           fi
+         fi
+       fi
+
+       if test -n "$delfiles"; then
+         # Append the command to remove temporary files to $cmds.
+         eval cmds=\"\$cmds~\$RM $delfiles\"
+       fi
+
+       # Add any objects from preloaded convenience libraries
+       if test -n "$dlprefiles"; then
+         gentop="$output_objdir/${outputname}x"
+         func_append generated " $gentop"
+
+         func_extract_archives $gentop $dlprefiles
+         func_append libobjs " $func_extract_archives_result"
+         test "X$libobjs" = "X " && libobjs=
+       fi
+
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $opt_silent || {
+           func_quote_for_expand "$cmd"
+           eval "func_echo $func_quote_for_expand_result"
+         }
+         $opt_dry_run || eval "$cmd" || {
+           lt_exit=$?
+
+           # Restore the uninstalled library and exit
+           if test "$opt_mode" = relink; then
+             ( cd "$output_objdir" && \
+               $RM "${realname}T" && \
+               $MV "${realname}U" "$realname" )
+           fi
+
+           exit $lt_exit
+         }
+       done
+       IFS="$save_ifs"
+
+       # Restore the uninstalled library and exit
+       if test "$opt_mode" = relink; then
+         $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+         if test -n "$convenience"; then
+           if test -z "$whole_archive_flag_spec"; then
+             func_show_eval '${RM}r "$gentop"'
+           fi
+         fi
+
+         exit $EXIT_SUCCESS
+       fi
+
+       # Create links to the real library.
+       for linkname in $linknames; do
+         if test "$realname" != "$linkname"; then
+           func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+         fi
+       done
+
+       # If -module or -export-dynamic was specified, set the dlname.
+       if test "$module" = yes || test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+       func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+       func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+       func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+       func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+       test -n "$objs$old_deplibs" && \
+         func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+       libobj=$output
+       func_lo2o "$libobj"
+       obj=$func_lo2o_result
+       ;;
+      *)
+       libobj=
+       obj="$output"
+       ;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+       if test -n "$whole_archive_flag_spec"; then
+         eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+         reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+       else
+         gentop="$output_objdir/${obj}x"
+         func_append generated " $gentop"
+
+         func_extract_archives $gentop $convenience
+         reload_conv_objs="$reload_objs $func_extract_archives_result"
+       fi
+      fi
+
+      # If we're not building shared, we need to use non_pic_objs
+      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+       if test -n "$gentop"; then
+         func_show_eval '${RM}r "$gentop"'
+       fi
+
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+       if test -n "$gentop"; then
+         func_show_eval '${RM}r "$gentop"'
+       fi
+
+       # Create an invalid libtool object if no PIC, so that we don't
+       # accidentally link it into a program.
+       # $show "echo timestamp > $libobj"
+       # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+       # Only do commands if we really have different PIC objects.
+       reload_objs="$libobjs $reload_conv_objs"
+       output="$libobj"
+       func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+       func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+       *cygwin*) func_stripname '' '.exe' "$output"
+                 output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+       func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+       && test "$dlopen_self" = unknown \
+       && test "$dlopen_self_static" = unknown && \
+         func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+       # On Rhapsody replace the C library is the System framework
+       compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
+       finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
+       ;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+       # Don't allow lazy linking, it breaks C++ global constructors
+       # But is supposedly fixed on 10.4 or later (yay!).
+       if test "$tagname" = CXX ; then
+         case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+           10.[0123])
+             func_append compile_command " ${wl}-bind_at_load"
+             func_append finalize_command " ${wl}-bind_at_load"
+           ;;
+         esac
+       fi
+       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+       compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       ;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $compile_deplibs " in
+         *" -L$path/$objdir "*)
+           func_append new_libs " -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $compile_deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) func_append new_libs " $deplib" ;;
+         esac
+         ;;
+       *) func_append new_libs " $deplib" ;;
+       esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      func_append compile_command " $compile_deplibs"
+      func_append finalize_command " $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       for libdir in $rpath $xrpath; do
+         # This is the magic to use -rpath.
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) func_append finalize_rpath " $libdir" ;;
+         esac
+       done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           func_append rpath " $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$perm_rpath " in
+         *" $libdir "*) ;;
+         *) func_append perm_rpath " $libdir" ;;
+         esac
+       fi
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+         testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$libdir:"*) ;;
+         ::) dllsearchpath=$libdir;;
+         *) func_append dllsearchpath ":$libdir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         ::) dllsearchpath=$testbindir;;
+         *) func_append dllsearchpath ":$testbindir";;
+         esac
+         ;;
+       esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           func_append rpath " $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$finalize_perm_rpath " in
+         *" $libdir "*) ;;
+         *) func_append finalize_perm_rpath " $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+       # Transform all the library objects into standard objects.
+       compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+       finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+       func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cegcc* | *mingw32ce*)
+        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
+        wrappers_required=no
+        ;;
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+       # Replace the output file specification.
+       compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+       link_command="$compile_command$compile_rpath"
+
+       # We have no uninstalled library dependencies, so finalize right now.
+       exit_status=0
+       func_show_eval "$link_command" 'exit_status=$?'
+
+       if test -n "$postlink_cmds"; then
+         func_to_tool_file "$output"
+         postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+         func_execute_cmds "$postlink_cmds" 'exit $?'
+       fi
+
+       # Delete the generated files.
+       if test -f "$output_objdir/${outputname}S.${objext}"; then
+         func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+       fi
+
+       exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+       finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+       if test -n "$perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $perm_rpath; do
+           func_append rpath "$dir:"
+         done
+         compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+       if test -n "$finalize_perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $finalize_perm_rpath; do
+           func_append rpath "$dir:"
+         done
+         finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+      fi
+
+      if test "$no_install" = yes; then
+       # We don't need to create a wrapper script.
+       link_command="$compile_var$compile_command$compile_rpath"
+       # Replace the output file specification.
+       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+       # Delete the old output file.
+       $opt_dry_run || $RM $output
+       # Link the executable and exit
+       func_show_eval "$link_command" 'exit $?'
+
+       if test -n "$postlink_cmds"; then
+         func_to_tool_file "$output"
+         postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+         func_execute_cmds "$postlink_cmds" 'exit $?'
+       fi
+
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+       # Fast installation is not supported
+       link_command="$compile_var$compile_command$compile_rpath"
+       relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+       func_warning "this platform does not like uninstalled shared libraries"
+       func_warning "\`$output' will be relinked during installation"
+      else
+       if test "$fast_install" != no; then
+         link_command="$finalize_var$compile_command$finalize_rpath"
+         if test "$fast_install" = yes; then
+           relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+         else
+           # fast_install is set to needless
+           relink_command=
+         fi
+       else
+         link_command="$compile_var$compile_command$compile_rpath"
+         relink_command="$finalize_var$finalize_command$finalize_rpath"
+       fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      if test -n "$postlink_cmds"; then
+       func_to_tool_file "$output_objdir/$outputname"
+       postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+       func_execute_cmds "$postlink_cmds" 'exit $?'
+      fi
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+       # Preserve any variables that may affect compiler behavior
+       for var in $variables_saved_for_relink; do
+         if eval test -z \"\${$var+set}\"; then
+           relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+         elif eval var_value=\$$var; test -z "$var_value"; then
+           relink_command="$var=; export $var; $relink_command"
+         else
+           func_quote_for_eval "$var_value"
+           relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+         fi
+       done
+       relink_command="(cd `pwd`; $relink_command)"
+       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+       # win32 will think the script is a binary if it has
+       # a .exe suffix, so we strip it off here.
+       case $output in
+         *.exe) func_stripname '' '.exe' "$output"
+                output=$func_stripname_result ;;
+       esac
+       # test for cygwin because mv fails w/o .exe extensions
+       case $host in
+         *cygwin*)
+           exeext=.exe
+           func_stripname '' '.exe' "$outputname"
+           outputname=$func_stripname_result ;;
+         *) exeext= ;;
+       esac
+       case $host in
+         *cygwin* | *mingw* )
+           func_dirname_and_basename "$output" "" "."
+           output_name=$func_basename_result
+           output_path=$func_dirname_result
+           cwrappersource="$output_path/$objdir/lt-$output_name.c"
+           cwrapper="$output_path/$output_name.exe"
+           $RM $cwrappersource $cwrapper
+           trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+           func_emit_cwrapperexe_src > $cwrappersource
+
+           # The wrapper executable is built using the $host compiler,
+           # because it contains $host paths and files. If cross-
+           # compiling, it, like the target executable, must be
+           # executed on the $host or under an emulation environment.
+           $opt_dry_run || {
+             $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+             $STRIP $cwrapper
+           }
+
+           # Now, create the wrapper script for func_source use:
+           func_ltwrapper_scriptname $cwrapper
+           $RM $func_ltwrapper_scriptname_result
+           trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+           $opt_dry_run || {
+             # note: this script will not be executed, so do not chmod.
+             if test "x$build" = "x$host" ; then
+               $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+             else
+               func_emit_wrapper no > $func_ltwrapper_scriptname_result
+             fi
+           }
+         ;;
+         * )
+           $RM $output
+           trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+           func_emit_wrapper no > $output
+           chmod +x $output
+         ;;
+       esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+       oldobjs="$libobjs_save $symfileobj"
+       addlibs="$convenience"
+       build_libtool_libs=no
+      else
+       if test "$build_libtool_libs" = module; then
+         oldobjs="$libobjs_save"
+         build_libtool_libs=no
+       else
+         oldobjs="$old_deplibs $non_pic_objects"
+         if test "$preload" = yes && test -f "$symfileobj"; then
+           func_append oldobjs " $symfileobj"
+         fi
+       fi
+       addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+       gentop="$output_objdir/${outputname}x"
+       func_append generated " $gentop"
+
+       func_extract_archives $gentop $addlibs
+       func_append oldobjs " $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       cmds=$old_archive_from_new_cmds
+      else
+
+       # Add any objects from preloaded convenience libraries
+       if test -n "$dlprefiles"; then
+         gentop="$output_objdir/${outputname}x"
+         func_append generated " $gentop"
+
+         func_extract_archives $gentop $dlprefiles
+         func_append oldobjs " $func_extract_archives_result"
+       fi
+
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+       if (for obj in $oldobjs
+           do
+             func_basename "$obj"
+             $ECHO "$func_basename_result"
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         echo "copying selected object files to avoid basename conflicts..."
+         gentop="$output_objdir/${outputname}x"
+         func_append generated " $gentop"
+         func_mkdir_p "$gentop"
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           func_basename "$obj"
+           objbase="$func_basename_result"
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               func_arith $counter + 1
+               counter=$func_arith_result
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             func_append oldobjs " $gentop/$newobj"
+             ;;
+           *) func_append oldobjs " $obj" ;;
+           esac
+         done
+       fi
+       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+       tool_oldlib=$func_to_tool_file_result
+       eval cmds=\"$old_archive_cmds\"
+
+       func_len " $cmds"
+       len=$func_len_result
+       if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         cmds=$old_archive_cmds
+       elif test -n "$archiver_list_spec"; then
+         func_verbose "using command file archive linking..."
+         for obj in $oldobjs
+         do
+           func_to_tool_file "$obj"
+           $ECHO "$func_to_tool_file_result"
+         done > $output_objdir/$libname.libcmd
+         func_to_tool_file "$output_objdir/$libname.libcmd"
+         oldobjs=" $archiver_list_spec$func_to_tool_file_result"
+         cmds=$old_archive_cmds
+       else
+         # the command line is too long to link in one step, link in parts
+         func_verbose "using piecewise archive linking..."
+         save_RANLIB=$RANLIB
+         RANLIB=:
+         objlist=
+         concat_cmds=
+         save_oldobjs=$oldobjs
+         oldobjs=
+         # Is there a better way of finding the last object in the list?
+         for obj in $save_oldobjs
+         do
+           last_oldobj=$obj
+         done
+         eval test_cmds=\"$old_archive_cmds\"
+         func_len " $test_cmds"
+         len0=$func_len_result
+         len=$len0
+         for obj in $save_oldobjs
+         do
+           func_len " $obj"
+           func_arith $len + $func_len_result
+           len=$func_arith_result
+           func_append objlist " $obj"
+           if test "$len" -lt "$max_cmd_len"; then
+             :
+           else
+             # the above command should be used before it gets too long
+             oldobjs=$objlist
+             if test "$obj" = "$last_oldobj" ; then
+               RANLIB=$save_RANLIB
+             fi
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+             objlist=
+             len=$len0
+           fi
+         done
+         RANLIB=$save_RANLIB
+         oldobjs=$objlist
+         if test "X$oldobjs" = "X" ; then
+           eval cmds=\"\$concat_cmds\"
+         else
+           eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+         fi
+       fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+       if eval test -z \"\${$var+set}\"; then
+         relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+       elif eval var_value=\$$var; test -z "$var_value"; then
+         relink_command="$var=; export $var; $relink_command"
+       else
+         func_quote_for_eval "$var_value"
+         relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+       fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+       relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+       for installed in no yes; do
+         if test "$installed" = yes; then
+           if test -z "$install_libdir"; then
+             break
+           fi
+           output="$output_objdir/$outputname"i
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
+             case $deplib in
+             *.la)
+               func_basename "$deplib"
+               name="$func_basename_result"
+               func_resolve_sysroot "$deplib"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$deplib' is not a valid libtool archive"
+               func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
+               ;;
+             -L*)
+               func_stripname -L '' "$deplib"
+               func_replace_sysroot "$func_stripname_result"
+               func_append newdependency_libs " -L$func_replace_sysroot_result"
+               ;;
+             -R*)
+               func_stripname -R '' "$deplib"
+               func_replace_sysroot "$func_stripname_result"
+               func_append newdependency_libs " -R$func_replace_sysroot_result"
+               ;;
+             *) func_append newdependency_libs " $deplib" ;;
+             esac
+           done
+           dependency_libs="$newdependency_libs"
+           newdlfiles=
+
+           for lib in $dlfiles; do
+             case $lib in
+             *.la)
+               func_basename "$lib"
+               name="$func_basename_result"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$lib' is not a valid libtool archive"
+               func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
+               ;;
+             *) func_append newdlfiles " $lib" ;;
+             esac
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+             *.la)
+               # Only pass preopened files to the pseudo-archive (for
+               # eventual linking with the app. that links it) if we
+               # didn't already link the preopened objects directly into
+               # the library:
+               func_basename "$lib"
+               name="$func_basename_result"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$lib' is not a valid libtool archive"
+               func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
+               ;;
+             esac
+           done
+           dlprefiles="$newdlprefiles"
+         else
+           newdlfiles=
+           for lib in $dlfiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             func_append newdlfiles " $abs"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             func_append newdlprefiles " $abs"
+           done
+           dlprefiles="$newdlprefiles"
+         fi
+         $RM $output
+         # place dlname in correct position for cygwin
+         # In fact, it would be nice if we could use this code for all target
+         # systems that can't hard-code library paths into their executables
+         # and that have no shared library path variable independent of PATH,
+         # but it turns out we can't easily determine that from inspecting
+         # libtool variables, so we have to hard-code the OSs to which it
+         # applies here; at the moment, that means platforms that use the PE
+         # object format with DLL files.  See the long comment at the top of
+         # tests/bindir.at for full details.
+         tdlname=$dlname
+         case $host,$output,$installed,$module,$dlname in
+           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
+             # If a -bindir argument was supplied, place the dll there.
+             if test "x$bindir" != x ;
+             then
+               func_relative_path "$install_libdir" "$bindir"
+               tdlname=$func_relative_path_result$dlname
+             else
+               # Otherwise fall back on heuristic.
+               tdlname=../bin/$dlname
+             fi
+             ;;
+         esac
+         $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+         if test "$installed" = no && test "$need_relink" = yes; then
+           $ECHO >> $output "\
+relink_command=\"$relink_command\""
+         fi
+       done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) func_append RM " $arg"; rmforce=yes ;;
+      -*) func_append RM " $arg" ;;
+      *) func_append files " $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+       odir="$objdir"
+      else
+       odir="$dir/$objdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$opt_mode" = uninstall && odir="$dir"
+
+      # Remember odir for removal later, being careful to avoid duplicates
+      if test "$opt_mode" = clean; then
+       case " $rmdirs " in
+         *" $odir "*) ;;
+         *) func_append rmdirs " $odir" ;;
+       esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+        { test -h "$file"; } >/dev/null 2>&1 ||
+        test -f "$file"; then
+       :
+      elif test -d "$file"; then
+       exit_status=1
+       continue
+      elif test "$rmforce" = yes; then
+       continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+       # Possibly a libtool archive, so verify it.
+       if func_lalib_p "$file"; then
+         func_source $dir/$name
+
+         # Delete the libtool libraries and symlinks.
+         for n in $library_names; do
+           func_append rmfiles " $odir/$n"
+         done
+         test -n "$old_library" && func_append rmfiles " $odir/$old_library"
+
+         case "$opt_mode" in
+         clean)
+           case " $library_names " in
+           *" $dlname "*) ;;
+           *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
+           esac
+           test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
+           ;;
+         uninstall)
+           if test -n "$library_names"; then
+             # Do each command in the postuninstall commands.
+             func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+           fi
+
+           if test -n "$old_library"; then
+             # Do each command in the old_postuninstall commands.
+             func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+           fi
+           # FIXME: should reinstall the best remaining shared library.
+           ;;
+         esac
+       fi
+       ;;
+
+      *.lo)
+       # Possibly a libtool object, so verify it.
+       if func_lalib_p "$file"; then
+
+         # Read the .lo file
+         func_source $dir/$name
+
+         # Add PIC object to the list of files to remove.
+         if test -n "$pic_object" &&
+            test "$pic_object" != none; then
+           func_append rmfiles " $dir/$pic_object"
+         fi
+
+         # Add non-PIC object to the list of files to remove.
+         if test -n "$non_pic_object" &&
+            test "$non_pic_object" != none; then
+           func_append rmfiles " $dir/$non_pic_object"
+         fi
+       fi
+       ;;
+
+      *)
+       if test "$opt_mode" = clean ; then
+         noexename=$name
+         case $file in
+         *.exe)
+           func_stripname '' '.exe' "$file"
+           file=$func_stripname_result
+           func_stripname '' '.exe' "$name"
+           noexename=$func_stripname_result
+           # $file with .exe has already been added to rmfiles,
+           # add $file without .exe
+           func_append rmfiles " $file"
+           ;;
+         esac
+         # Do a test to see if this is a libtool program.
+         if func_ltwrapper_p "$file"; then
+           if func_ltwrapper_executable_p "$file"; then
+             func_ltwrapper_scriptname "$file"
+             relink_command=
+             func_source $func_ltwrapper_scriptname_result
+             func_append rmfiles " $func_ltwrapper_scriptname_result"
+           else
+             relink_command=
+             func_source $dir/$noexename
+           fi
+
+           # note $name still contains .exe if it was in $file originally
+           # as does the version of $file that was added into $rmfiles
+           func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
+           if test "$fast_install" = yes && test -n "$relink_command"; then
+             func_append rmfiles " $odir/lt-$name"
+           fi
+           if test "X$noexename" != "X$name" ; then
+             func_append rmfiles " $odir/lt-${noexename}.c"
+           fi
+         fi
+       fi
+       ;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+       func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$opt_mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$opt_mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/luksan/COPYRIGHT b/luksan/COPYRIGHT
new file mode 100644 (file)
index 0000000..8e2f44e
--- /dev/null
@@ -0,0 +1,45 @@
+---------------------------------------------------------------------------
+
+Copyright:
+
+    Subroutines PBUN, PNEW, PVAR, PSEN, Copyright ACM, 2001. The original
+    versions were published in Transactions on Mathematical Software, 
+    Vol.27, 2001, pp.193-213. Here are the author's modifications. They
+    are posted here by permission of ACM for your personal use. Not for
+    redistribution. Subroutines PLIP, PSEN, Copyright Jan Vlcek, 2007. 
+    The remaining subroutines, Copyright Ladislav Luksan, 2007. Many of  
+    sparse matrix modules were prepared by Miroslav Tuma.
+
+License: 
+
+    This library (with exception of PBUN, PNEW, PVAR, PSEN) is a free 
+    software; you can redistribute it and/or modify it under the terms 
+    of the GNU Lesser General Public License as published by the Free 
+    Software Foundation; either version 2.1 of the License, or (at your 
+    option) any later version (see http://www.gnu.org/copyleft/gpl.html).
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    Permission is hereby granted to use or copy this program under the
+    terms of the GNU LGPL, provided that the Copyright, this License,
+    and the Availability of the original version is retained on all copies.
+    User documentation of any code that uses this code or any modified
+    version of this code must cite the Copyright, this License, the
+    Availability note, and "Used by permission." Permission to modify
+    the code and to distribute modified code is granted, provided the
+    Copyright, this License, and the Availability note are retained,
+    and a notice that the code was modified is included.
+
+Availability:
+
+    http://www.cs.cas.cz/~luksan/subroutines.html
+
+Acknowledgements:
+
+    This work was supported by the Grant Agency of the Czech Academy of 
+    Sciences, under grant IAA1030405.
+
+    
diff --git a/luksan/Makefile.am b/luksan/Makefile.am
new file mode 100644 (file)
index 0000000..f302a79
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libluksan.la
+libluksan_la_SOURCES = plis.c plip.c pnet.c mssubs.c pssubs.c luksan.h
+
+EXTRA_DIST = README COPYRIGHT plis.txt v999-07.pdf
diff --git a/luksan/Makefile.in b/luksan/Makefile.in
new file mode 100644 (file)
index 0000000..8569024
--- /dev/null
@@ -0,0 +1,610 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = luksan
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libluksan_la_LIBADD =
+am_libluksan_la_OBJECTS = plis.lo plip.lo pnet.lo mssubs.lo pssubs.lo
+libluksan_la_OBJECTS = $(am_libluksan_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libluksan_la_SOURCES)
+DIST_SOURCES = $(libluksan_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libluksan.la
+libluksan_la_SOURCES = plis.c plip.c pnet.c mssubs.c pssubs.c luksan.h
+EXTRA_DIST = README COPYRIGHT plis.txt v999-07.pdf
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu luksan/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu luksan/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libluksan.la: $(libluksan_la_OBJECTS) $(libluksan_la_DEPENDENCIES) $(EXTRA_libluksan_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libluksan_la_OBJECTS) $(libluksan_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mssubs.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plip.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plis.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pnet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pssubs.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/luksan/README b/luksan/README
new file mode 100644 (file)
index 0000000..3ef4864
--- /dev/null
@@ -0,0 +1,23 @@
+These routines for nonlinear optimization are based on the Fortran 77
+code placed online by Professor Ladislav Luksan at his web site:
+
+       http://www.uivt.cas.cz/~luksan/subroutines.html
+
+and graciously licensed under the GNU Lesser General Public License
+(LGPL).  See also the COPYRIGHT file for details.
+
+The C conversions were done via f2c by S. G. Johnson, with the f2c
+output manually cleaned up somewhat, and then converted to use the
+NLopt termination conditions, C dynamic allocation, etc.
+
+In particular, we converted the subroutines PLIS, PLIP, and PNET (as
+well as various auxiliary routines required by this code), all of
+which solve general nonlinear unconstrained or box-constrained
+optimization problems.  Prof. Luksan also provides a large number of
+more specialized routines for cases where one has additional knowledge
+of the objective function, but these cases seem outside the scope of
+NLopt.
+
+[We also did not convert the PMIN, PBUN, PNEW, or PVAR subroutines
+since these were published in ACM Trans. on Math. Software (TOMS) and
+are subject to the non-free ACM licensing conditions.]
diff --git a/luksan/luksan.h b/luksan/luksan.h
new file mode 100644 (file)
index 0000000..01ac07b
--- /dev/null
@@ -0,0 +1,152 @@
+#ifndef LUKSAN_H
+#define LUKSAN_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result luksan_plis(int n, nlopt_func f, void *f_data,
+                  const double *lb, const double *ub, /* bounds */
+                  double *x, /* in: initial guess, out: minimizer */
+                  double *minf,
+                 nlopt_stopping *stop,
+                        int mf);
+
+nlopt_result luksan_plip(int n, nlopt_func f, void *f_data,
+                        const double *lb, const double *ub, /* bounds */
+                        double *x, /* in: initial guess, out: minimizer */
+                        double *minf,
+                        nlopt_stopping *stop,
+                        int mf,
+                        int method);
+
+nlopt_result luksan_pnet(int n, nlopt_func f, void *f_data,
+                        const double *lb, const double *ub, /* bounds */
+                        double *x, /* in: initial guess, out: minimizer */
+                        double *minf, 
+                        nlopt_stopping *stop,
+                        int mf,
+                        int mos1, int mos2);
+
+typedef struct {
+     double fl, fu, pl, rl, pu, ru;
+     int mes1, mes2, mes3, mode, mtyp;
+} ps1l01_state;
+
+/*****************************  internal routines *************************/
+
+/* mssubs.c: */
+void luksan_mxdcmd__(int *n, int *m, double *a, 
+                    double *x, double *alf, double *y, double *z__);
+void luksan_mxdrcb__(int *n, int *m, double *a, 
+                    double *b, double *u, double *v, double *x, int *
+                    ix, int *job);
+void luksan_mxdrcf__(int *n, int *m, double *a, 
+                    double *b, double *u, double *v, double *x, int *
+                    ix, int *job);
+void luksan_mxdrmm__(int *n, int *m, double *a, 
+                    double *x, double *y);
+void luksan_mxdrsu__(int *n, int *m, double *a, 
+                    double *b, double *u);
+void luksan_mxucop__(int *n, double *x, double *y,
+                    int *ix, int *job);
+void luksan_mxudir__(int *n, double *a, double *x,
+                    double *y, double *z__, int *ix, int *job);
+void luksan_mxuneg__(int *n, double *x, double *y,
+                    int *ix, int *job);
+void luksan_mxuzer__(int *n, double *x, int *ix, 
+                    int *job);
+void luksan_mxvcop__(int *n, double *x, double *y);
+void luksan_mxvdif__(int *n, double *x, double *y,
+                    double *z__);
+void luksan_mxvneg__(int *n, double *x, double *y);
+void luksan_mxvscl__(int *n, double *a, double *x,
+                    double *y);
+void luksan_mxvset__(int *n, double *a, double *x);
+double luksan_mxudot__(int *n, double *x, double *y, int *ix,
+                      int *job);
+double luksan_mxvdot__(int *n, double *x, double *y);
+void luksan_mxvdir__(int *n, double *a, double *x, 
+                    double *y, double *z__);
+void luksan_mxdcmu__(int *n, int *m, double *a, 
+                    double *alf, double *x, double *y);
+void luksan_mxvlin__(int *n, double *a, double *x, 
+                    double *b, double *y, double *z__);
+void luksan_mxdcmv__(int *n, int *m, double *a, 
+                    double *alf, double *x, double *u, double *bet, 
+                    double *y, double *v);
+void luksan_mxvsav__(int *n, double *x, double *y);
+void luksan_mxvine__(int *n, int *ix);
+double luksan_mxvmax__(int *n, double *x);
+
+/* pssubs.c: */
+void luksan_pcbs04__(int *nf, double *x, int *ix, 
+                    double *xl, double *xu, double *eps9, int *kbf);
+void luksan_ps1l01__(double *r__, double *rp, 
+                    double *f, double *fo, double *fp, double *p, 
+                    double *po, double *pp, double *minf, double *fmax, 
+                    double *rmin, double *rmax, double *tols, double *
+                    tolp, double *par1, double *par2, int *kd, int *ld, 
+                    int *nit, int *kit, int *nred, int *mred, int *
+                    maxst, int *iest, int *inits, int *iters, int *kters, 
+                    int *mes, int *isys, ps1l01_state *state);
+void luksan_pulsp3__(int *n, int *m, int *mf, 
+                    double *xm, double *gr, double *xo, double *go, 
+                    double *r__, double *po, double *sig, int *iterh, 
+                    int *met3);
+void luksan_pulvp3__(int *n, int *m, double *xm, 
+                    double *xr, double *gr, double *s, double *so, 
+                    double *xo, double *go, double *r__, double *po, 
+                    double *sig, int *iterh, int *met2, int *met3, 
+                    int *met5);
+void luksan_pyadc0__(int *nf, int *n, double *x, 
+                    int *ix, double *xl, double *xu, int *inew);
+void luksan_pyfut1__(int *n, double *f, double *
+                    fo, double *umax, double *gmax,
+                    int xstop, const nlopt_stopping *stop,
+                    double *tolg, int *kd, int *nit, int *kit, int *mit,
+                    int *nfg, int *mfg, int *ntesx, 
+                    int *mtesx, int *ntesf, int *mtesf, int *ites, 
+                    int *ires1, int *ires2, int *irest, int *iters, 
+                    int *iterm);
+void luksan_pyrmc0__(int *nf, int *n, int *ix, 
+                    double *g, double *eps8, double *umax, double *gmax, 
+                    double *rmax, int *iold, int *irest);
+void luksan_pytrcd__(int *nf, double *x, int *ix, 
+                    double *xo, double *g, double *go, double *r__, 
+                    double *f, double *fo, double *p, double *po, 
+                    double *dmax__, int *kbf, int *kd, int *ld, int *
+                    iters);
+void luksan_pytrcg__(int *nf, int *n, int *ix, 
+                    double *g, double *umax, double *gmax, int *kbf, 
+                    int *iold);
+void luksan_pytrcs__(int *nf, double *x, int *ix, 
+                    double *xo, double *xl, double *xu, double *g, 
+                    double *go, double *s, double *ro, double *fp, 
+                    double *fo, double *f, double *po, double *p, 
+                    double *rmax, double *eta9, int *kbf);
+void luksan_pnint1__(double *rl, double *ru, double *fl, 
+                    double *fu, double *pl, double *pu, double *r__, 
+                    int *mode, int *mtyp, int *merr);
+
+/* Common Block Declarations */
+typedef struct {
+     int nres, ndec, nin, nit;
+     /* int nfv;   -- now stored in stop->nevals */
+     int nfg, nfh;
+} stat_common;
+
+/* number of double variables that can be stored in scratch memory
+   ... it's >= 2007, and this is in the context of scientific computation,
+   so assume that at least 10M are available, and that sizeof(double)==8 */
+#define MEMAVAIL 1310720
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* LUKSAN_H */
diff --git a/luksan/mssubs.c b/luksan/mssubs.c
new file mode 100644 (file)
index 0000000..aa464af
--- /dev/null
@@ -0,0 +1,991 @@
+#include <math.h>
+#include "luksan.h"
+
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define iabs(a) ((a) < 0 ? -(a) : (a))
+
+/*     subroutines extracted from mssubs.for */
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* FUNCTION MXVMAX             ALL SYSTEMS                   91/12/01 */
+/* PURPOSE : */
+/* L-INFINITY NORM OF A VECTOR. */
+
+/* PARAMETERS : */
+/*  II  N  VECTOR DIMENSION. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RR  MXVMAX  L-INFINITY NORM OF THE VECTOR X. */
+
+double luksan_mxvmax__(int *n, double *x)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__;
+    double mxvmax;
+
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    mxvmax = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing MAX */
+       d__2 = mxvmax, d__3 = (d__1 = x[i__], fabs(d__1));
+       mxvmax = MAX2(d__2,d__3);
+/* L1: */
+    }
+    return mxvmax;
+} /* luksan_mxvmax__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVINE             ALL SYSTEMS                   94/12/01 */
+/* PURPOSE : */
+/* ELEMENTS OF THE INTEGER VECTOR ARE REPLACED BY THEIR ABSOLUTE VALUES. */
+
+/* PARAMETERS : */
+/*  II  N DIMENSION OF THE INTEGER VECTOR. */
+/*  IU  IX(N)  INTEGER VECTOR WHICH IS UPDATED SO THAT IX(I):=ABS(IX(I)) */
+/*         FOR ALL I. */
+
+void luksan_mxvine__(int *n, int *ix)
+{
+    /* System generated locals */
+    int i__1, i__2;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --ix;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       ix[i__] = (i__2 = ix[i__], iabs(i__2));
+/* L1: */
+    }
+    return;
+} /* luksan_mxvine__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDCMV               ALL SYSTEMS                91/12/01 */
+/* PURPOSE : */
+/* RANK-TWO UPDATE OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX A. */
+/* THIS MATRIX IS UPDATED BY THE RULE A:=A+ALF*X*TRANS(U)+BET*Y*TRANS(V). */
+
+/* PARAMETERS : */
+/*  II  N  NUMBER OF ROWS OF THE MATRIX A. */
+/*  II  M  NUMBER OF COLUMNS OF THE MATRIX A. */
+/*  RU  A(N*M)  RECTANGULAR MATRIX STORED COLUMNWISE IN THE */
+/*         ONE-DIMENSIONAL ARRAY. */
+/*  RI  ALF  SCALAR PARAMETER. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RI  U(M)  INPUT VECTOR. */
+/*  RI  BET  SCALAR PARAMETER. */
+/*  RI  Y(N)  INPUT VECTOR. */
+/*  RI  V(M)  INPUT VECTOR. */
+
+void luksan_mxdcmv__(int *n, int *m, double *a, 
+       double *alf, double *x, double *u, double *bet, 
+       double *y, double *v)
+{
+    /* System generated locals */
+    int i__1, i__2;
+
+    /* Local variables */
+    int i__, j, k;
+    double tempa, tempb;
+
+    /* Parameter adjustments */
+    --v;
+    --y;
+    --u;
+    --x;
+    --a;
+
+    /* Function Body */
+    k = 0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       tempa = *alf * u[j];
+       tempb = *bet * v[j];
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           a[k + i__] = a[k + i__] + tempa * x[i__] + tempb * y[i__];
+/* L1: */
+       }
+       k += *n;
+/* L2: */
+    }
+    return;
+} /* luksan_mxdcmv__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVSAV                ALL SYSTEMS                91/12/01 */
+/* PORTABILITY : ALL SYSTEMS */
+/* 91/12/01 LU : ORIGINAL VERSION */
+
+/* PURPOSE : */
+/* DIFFERENCE OF TWO VECTORS RETURNED IN THE SUBSTRACTED ONE. */
+
+/* PARAMETERS : */
+/*  II  N  VECTOR DIMENSION. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RU  Y(N)  UPDATE VECTOR WHERE Y:= X - Y. */
+
+void luksan_mxvsav__(int *n, double *x, double *y)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+    double temp;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp = y[i__];
+       y[i__] = x[i__] - y[i__];
+       x[i__] = temp;
+/* L10: */
+    }
+    return;
+} /* luksan_mxvsav__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVLIN                ALL SYSTEMS                92/12/01 */
+/* PURPOSE : */
+/* LINEAR COMBINATION OF TWO VECTORS. */
+
+/* PARAMETERS : */
+/*  II  N  VECTOR DIMENSION. */
+/*  RI  A  SCALING FACTOR. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RI  B  SCALING FACTOR. */
+/*  RI  Y(N)  INPUT VECTOR. */
+/*  RO  Z(N)  OUTPUT VECTOR WHERE Z:= A*X + B*Y. */
+
+void luksan_mxvlin__(int *n, double *a, double *x, 
+       double *b, double *y, double *z__)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --z__;
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       z__[i__] = *a * x[i__] + *b * y[i__];
+/* L1: */
+    }
+    return;
+} /* luksan_mxvlin__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDCMU               ALL SYSTEMS                91/12/01 */
+/* PURPOSE : */
+/* UPDATE OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX A. THIS MATRIX */
+/* IS UPDATED BY THE RULE A:=A+ALF*X*TRANS(Y). */
+
+/* PARAMETERS : */
+/*  II  N  NUMBER OF ROWS OF THE MATRIX A. */
+/*  II  M  NUMBER OF COLUMNS OF THE MATRIX A. */
+/*  RU  A(N*M)  RECTANGULAR MATRIX STORED COLUMNWISE IN THE */
+/*         ONE-DIMENSIONAL ARRAY. */
+/*  RI  ALF  SCALAR PARAMETER. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RI  Y(M)  INPUT VECTOR. */
+
+void luksan_mxdcmu__(int *n, int *m, double *a, 
+       double *alf, double *x, double *y)
+{
+    /* System generated locals */
+    int i__1, i__2;
+
+    /* Local variables */
+    int i__, j, k;
+    double temp;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+    --a;
+
+    /* Function Body */
+    k = 0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       temp = *alf * y[j];
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           a[k + i__] += temp * x[i__];
+/* L1: */
+       }
+       k += *n;
+/* L2: */
+    }
+    return;
+} /* luksan_mxdcmu__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVDIR                ALL SYSTEMS                91/12/01 */
+/* PURPOSE : */
+/* VECTOR AUGMENTED BY THE SCALED VECTOR. */
+
+/* PARAMETERS : */
+/*  II  N  VECTOR DIMENSION. */
+/*  RI  A  SCALING FACTOR. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RI  Y(N)  INPUT VECTOR. */
+/*  RO  Z(N)  OUTPUT VECTOR WHERE Z:= Y + A*X. */
+
+void luksan_mxvdir__(int *n, double *a, double *x, 
+                   double *y, double *z__)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --z__;
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       z__[i__] = y[i__] + *a * x[i__];
+/* L10: */
+    }
+} /* luksan_mxvdir__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDCMD               ALL SYSTEMS                91/12/01
+* PURPOSE :
+* MULTIPLICATION OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX A
+* BY A VECTOR X AND ADDITION OF THE SCALED VECTOR ALF*Y.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF ROWS OF THE MATRIX A.
+*  II  M  NUMBER OF COLUMNS OF THE MATRIX A.
+*  RI  A(N*M)  RECTANGULAR MATRIX STORED COLUMNWISE IN THE
+*         ONE-DIMENSIONAL ARRAY.
+*  RI  X(M)  INPUT VECTOR.
+*  RI  ALF  SCALING FACTOR.
+*  RI  Y(N)  INPUT VECTOR.
+*  RO  Z(N)  OUTPUT VECTOR EQUAL TO A*X+ALF*Y.
+*
+* SUBPROGRAMS USED :
+*  S   MXVDIR  VECTOR AUGMENTED BY THE SCALED VECTOR.
+*  S   MXVSCL  SCALING OF A VECTOR.
+*/
+void luksan_mxdcmd__(int *n, int *m, double *a, 
+       double *x, double *alf, double *y, double *z__)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int j, k;
+
+    /* Parameter adjustments */
+    --z__;
+    --y;
+    --x;
+    --a;
+
+    /* Function Body */
+    luksan_mxvscl__(n, alf, &y[1], &z__[1]);
+    k = 0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       luksan_mxvdir__(n, &x[j], &a[k + 1], &z__[1], &z__[1]);
+       k += *n;
+/* L1: */
+    }
+    return;
+} /* luksan_mxdcmd__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDRCB               ALL SYSTEMS                91/12/01
+* PURPOSE :
+* BACKWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION OF
+* THE VECTOR X BY AN IMPLICIT BFGS UPDATE.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF ROWS OF THE MATRICES A AND B.
+*  II  M  NUMBER OF COLUMNS OF THE MATRICES A AND B.
+*  RI  A(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RI  B(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RI  U(M)  VECTOR OF SCALAR COEFFICIENTS.
+*  RO  V(M)  VECTOR OF SCALAR COEFFICIENTS.
+*  RU  X(N)  PREMULTIPLIED VECTOR.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*
+* SUBPROGRAM USED :
+*  S   MXUDIR  VECTOR AUGMENTED BY THE SCALED VECTOR.
+*  RF  MXUDOT  DOT PRODUCT OF VECTORS.
+*
+* METHOD :
+* H.MATTHIES, G.STRANG: THE SOLUTION OF NONLINEAR FINITE ELEMENT
+* EQUATIONS. INT.J.NUMER. METHODS ENGN. 14 (1979) 1613-1626.
+*/
+void luksan_mxdrcb__(int *n, int *m, double *a, 
+       double *b, double *u, double *v, double *x, int *
+       ix, int *job)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1;
+
+    /* Local variables */
+    int i__, k;
+
+    /* Parameter adjustments */
+    --ix;
+    --x;
+    --v;
+    --u;
+    --b;
+    --a;
+
+    /* Function Body */
+    k = 1;
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       v[i__] = u[i__] * luksan_mxudot__(n, &x[1], &a[k], &ix[1], job);
+       d__1 = -v[i__];
+       luksan_mxudir__(n, &d__1, &b[k], &x[1], &x[1], &ix[1], job);
+       k += *n;
+/* L1: */
+    }
+    return;
+} /* luksan_mxdrcb__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDRCF               ALL SYSTEMS                91/12/01
+* PURPOSE :
+* FORWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION OF
+* THE VECTOR X BY AN IMPLICIT BFGS UPDATE.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF ROWS OF THE MATRICES A AND B.
+*  II  M  NUMBER OF COLUMNS OF THE MATRICES A AND B.
+*  RI  A(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RI  B(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RI  U(M)  VECTOR OF SCALAR COEFFICIENTS.
+*  RI  V(M)  VECTOR OF SCALAR COEFFICIENTS.
+*  RU  X(N)  PREMULTIPLIED VECTOR.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*
+* SUBPROGRAM USED :
+*  S   MXUDIR  VECTOR AUGMENTED BY THE SCALED VECTOR.
+*  RF  MXUDOT  DOT PRODUCT OF VECTORS.
+*
+* METHOD :
+* H.MATTHIES, G.STRANG: THE SOLUTION OF NONLINEAR FINITE ELEMENT
+* EQUATIONS. INT.J.NUMER. METHODS ENGN. 14 (1979) 1613-1626.
+*/
+void luksan_mxdrcf__(int *n, int *m, double *a, 
+       double *b, double *u, double *v, double *x, int *
+       ix, int *job)
+{
+    /* System generated locals */
+    double d__1;
+
+    /* Local variables */
+    int i__, k;
+    double temp;
+
+    /* Parameter adjustments */
+    --ix;
+    --x;
+    --v;
+    --u;
+    --b;
+    --a;
+
+    /* Function Body */
+    k = (*m - 1) * *n + 1;
+    for (i__ = *m; i__ >= 1; --i__) {
+       temp = u[i__] * luksan_mxudot__(n, &x[1], &b[k], &ix[1], job);
+       d__1 = v[i__] - temp;
+       luksan_mxudir__(n, &d__1, &a[k], &x[1], &x[1], &ix[1], job);
+       k -= *n;
+/* L1: */
+    }
+    return;
+} /* luksan_mxdrcf__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDRMM               ALL SYSTEMS                91/12/01
+* PURPOSE :
+* MULTIPLICATION OF A ROWWISE STORED DENSE RECTANGULAR MATRIX A BY
+* A VECTOR X.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF COLUMNS OF THE MATRIX A.
+*  II  M  NUMBER OF ROWS OF THE MATRIX A.
+*  RI  A(M*N)  RECTANGULAR MATRIX STORED ROWWISE IN THE
+*         ONE-DIMENSIONAL ARRAY.
+*  RI  X(N)  INPUT VECTOR.
+*  RO  Y(M)  OUTPUT VECTOR EQUAL TO A*X.
+*/
+void luksan_mxdrmm__(int *n, int *m, double *a, 
+       double *x, double *y)
+{
+    /* System generated locals */
+    int i__1, i__2;
+
+    /* Local variables */
+    int i__, j, k;
+    double temp;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+    --a;
+
+    /* Function Body */
+    k = 0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       temp = 0.;
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           temp += a[k + i__] * x[i__];
+/* L1: */
+       }
+       y[j] = temp;
+       k += *n;
+/* L2: */
+    }
+    return;
+} /* luksan_mxdrmm__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXDRSU               ALL SYSTEMS                91/12/01
+* PURPOSE :
+* SHIFT OF COLUMNS OF THE RECTANGULAR MATRICES A AND B. SHIFT OF
+* ELEMENTS OF THE VECTOR U. THESE SHIFTS ARE USED IN THE LIMITED
+* MEMORY BFGS METHOD.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF ROWS OF THE MATRIX A AND B.
+*  II  M  NUMBER OF COLUMNS OF THE MATRIX A AND B.
+*  RU  A(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RU  B(N*M)  RECTANGULAR MATRIX STORED AS A ONE-DIMENSIONAL ARRAY.
+*  RU  U(M)  VECTOR.
+*/
+void luksan_mxdrsu__(int *n, int *m, double *a, 
+                    double *b, double *u)
+{
+    int i__, k, l;
+
+    /* Parameter adjustments */
+    --u;
+    --b;
+    --a;
+
+    /* Function Body */
+    k = (*m - 1) * *n + 1;
+    for (i__ = *m - 1; i__ >= 1; --i__) {
+       l = k - *n;
+       luksan_mxvcop__(n, &a[l], &a[k]);
+       luksan_mxvcop__(n, &b[l], &b[k]);
+       u[i__ + 1] = u[i__];
+       k = l;
+/* L1: */
+    }
+    return;
+} /* luksan_mxdrsu__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXUCOP                ALL SYSTEMS                99/12/01
+* PURPOSE :
+* COPY OF THE VECTOR WITH INITIATION OF THE ACTIVE PART.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RO  Y(N)  OUTPUT VECTOR WHERE Y:= X.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*/
+void luksan_mxucop__(int *n, double *x, double *y,
+        int *ix, int *job)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --ix;
+    --y;
+    --x;
+
+    /* Function Body */
+    if (*job == 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           y[i__] = x[i__];
+/* L1: */
+       }
+    } else if (*job > 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] >= 0) {
+               y[i__] = x[i__];
+           } else {
+               y[i__] = 0.;
+           }
+/* L2: */
+       }
+    } else {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] != -5) {
+               y[i__] = x[i__];
+           } else {
+               y[i__] = 0.;
+           }
+/* L3: */
+       }
+    }
+    return;
+} /* luksan_mxucop__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXUDIR                ALL SYSTEMS                99/12/01
+* PURPOSE :
+* VECTOR AUGMENTED BY THE SCALED VECTOR IN A BOUND CONSTRAINED CASE.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  A  SCALING FACTOR.
+*  RI  X(N)  INPUT VECTOR.
+*  RI  Y(N)  INPUT VECTOR.
+*  RO  Z(N)  OUTPUT VECTOR WHERE Z:= Y + A*X.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*/
+void luksan_mxudir__(int *n, double *a, double *x,
+        double *y, double *z__, int *ix, int *job)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --ix;
+    --z__;
+    --y;
+    --x;
+
+    /* Function Body */
+    if (*job == 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           z__[i__] = y[i__] + *a * x[i__];
+/* L1: */
+       }
+    } else if (*job > 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] >= 0) {
+               z__[i__] = y[i__] + *a * x[i__];
+           }
+/* L2: */
+       }
+    } else {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] != -5) {
+               z__[i__] = y[i__] + *a * x[i__];
+           }
+/* L3: */
+       }
+    }
+    return;
+} /* luksan_mxudir__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* FUNCTION MXVDOT                  ALL SYSTEMS                91/12/01 */
+/* PURPOSE : */
+/* DOT PRODUCT OF TWO VECTORS. */
+
+/* PARAMETERS : */
+/*  II  N  VECTOR DIMENSION. */
+/*  RI  X(N)  INPUT VECTOR. */
+/*  RI  Y(N)  INPUT VECTOR. */
+/*  RR  MXVDOT  VALUE OF DOT PRODUCT MXVDOT=TRANS(X)*Y. */
+
+double luksan_mxvdot__(int *n, double *x, double *y)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+    double temp;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+
+    /* Function Body */
+    temp = 0.;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp += x[i__] * y[i__];
+/* L10: */
+    }
+    return temp;
+} /* luksan_mxvdot__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* FUNCTION MXUDOT                  ALL SYSTEMS                99/12/01
+* PURPOSE :
+* DOT PRODUCT OF VECTORS IN A BOUND CONSTRAINED CASE.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RI  Y(N)  INPUT VECTOR.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*  RR  MXUDOT  VALUE OF DOT PRODUCT MXUDOT=TRANS(X)*Y.
+*/
+double luksan_mxudot__(int *n, double *x, double *y, int *ix,
+                      int *job)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+    double temp;
+
+    /* Parameter adjustments */
+    --ix;
+    --y;
+    --x;
+
+    /* Function Body */
+    temp = 0.;
+    if (*job == 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           temp += x[i__] * y[i__];
+/* L1: */
+       }
+    } else if (*job > 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] >= 0) {
+               temp += x[i__] * y[i__];
+           }
+/* L2: */
+       }
+    } else {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] != -5) {
+               temp += x[i__] * y[i__];
+           }
+/* L3: */
+       }
+    }
+    return temp;
+} /* luksan_mxudot__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXUNEG                ALL SYSTEMS                00/12/01
+* PURPOSE :
+* COPY OF THE VECTOR WITH INITIATION OF THE ACTIVE PART.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RO  Y(N)  OUTPUT VECTOR WHERE Y:= X.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*/
+void luksan_mxuneg__(int *n, double *x, double *y,
+        int *ix, int *job)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --ix;
+    --y;
+    --x;
+
+    /* Function Body */
+    if (*job == 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           y[i__] = -x[i__];
+/* L1: */
+       }
+    } else if (*job > 0) {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] >= 0) {
+               y[i__] = -x[i__];
+           } else {
+               y[i__] = 0.;
+           }
+/* L2: */
+       }
+    } else {
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] != -5) {
+               y[i__] = -x[i__];
+           } else {
+               y[i__] = 0.;
+           }
+/* L3: */
+       }
+    }
+    return;
+} /* luksan_mxuneg__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXUZER                ALL SYSTEMS                99/12/01
+* PURPOSE :
+* VECTOR ELEMENTS CORRESPONDING TO ACTIVE BOUNDS ARE SET TO ZERO.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RO  X(N)  OUTPUT VECTOR SUCH THAT X(I)=A FOR ALL I.
+*  II  IX(N)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  II  JOB  OPTION. IF JOB.GT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).LE.-1. IF JOB.LT.0 THEN INDEX I IS NOT USED WHENEVER
+*         IX(I).EQ.-5.
+*/
+void luksan_mxuzer__(int *n, double *x, int *ix, 
+                    int *job)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --ix;
+    --x;
+
+    /* Function Body */
+    if (*job == 0) {
+       return;
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (ix[i__] < 0) {
+           x[i__] = 0.;
+       }
+/* L1: */
+    }
+    return;
+} /* luksan_mxuzer__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVCOP                ALL SYSTEMS                88/12/01
+* PURPOSE :
+* COPYING OF A VECTOR.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RO  Y(N)  OUTPUT VECTOR WHERE Y:= X.
+*/
+void luksan_mxvcop__(int *n, double *x, double *y)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       y[i__] = x[i__];
+/* L10: */
+    }
+    return;
+} /* luksan_mxvcop__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVDIF                ALL SYSTEMS                88/12/01
+* PURPOSE :
+* VECTOR DIFFERENCE.
+*
+* PARAMETERS :
+*  RI  X(N)  INPUT VECTOR.
+*  RI  Y(N)  INPUT VECTOR.
+*  RO  Z(N)  OUTPUT VECTOR WHERE Z:= X - Y.
+*/
+void luksan_mxvdif__(int *n, double *x, double *y,
+        double *z__)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --z__;
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       z__[i__] = x[i__] - y[i__];
+/* L10: */
+    }
+    return;
+} /* luksan_mxvdif__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVNEG                ALL SYSTEMS                88/12/01
+* PURPOSE :
+* CHANGE THE SIGNS OF VECTOR ELEMENTS.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RO  Y(N)  OUTPUT VECTOR WHERE Y:= - X.
+*/
+void luksan_mxvneg__(int *n, double *x, double *y)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       y[i__] = -x[i__];
+/* L10: */
+    }
+    return;
+} /* luksan_mxvneg__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVSCL                ALL SYSTEMS                88/12/01
+* PURPOSE :
+* SCALING OF A VECTOR.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  X(N)  INPUT VECTOR.
+*  RI  A  SCALING FACTOR.
+*  RO  Y(N)  OUTPUT VECTOR WHERE Y:= A*X.
+*/
+void luksan_mxvscl__(int *n, double *a, double *x,
+        double *y)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --y;
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       y[i__] = *a * x[i__];
+/* L1: */
+    }
+    return;
+} /* luksan_mxvscl__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE MXVSET                ALL SYSTEMS                88/12/01
+* PURPOSE :
+* A SCALAR IS SET TO ALL THE ELEMENTS OF A VECTOR.
+*
+* PARAMETERS :
+*  II  N  VECTOR DIMENSION.
+*  RI  A  INITIAL VALUE.
+*  RO  X(N)  OUTPUT VECTOR SUCH THAT X(I)=A FOR ALL I.
+*/
+void luksan_mxvset__(int *n, double *a, double *x)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       x[i__] = *a;
+/* L10: */
+    }
+    return;
+} /* luksan_mxvset__ */
+
diff --git a/luksan/plip.c b/luksan/plip.c
new file mode 100644 (file)
index 0000000..8bce79e
--- /dev/null
@@ -0,0 +1,520 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "luksan.h"
+
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define MIN2(a,b) ((a) < (b) ? (a) : (b))
+
+/* *********************************************************************** */
+/* SUBROUTINE PLIP               ALL SYSTEMS                   01/09/22 */
+/* PURPOSE : */
+/* GENERAL SUBROUTINE FOR LARGE-SCALE BOX CONSTRAINED MINIMIZATION THAT */
+/* USE THE SHIFTED LIMITED MEMORY VARIABLE METRIC METHOD BASED ON THE */
+/* PRODUCT FORM UPDATES. */
+
+/* PARAMETERS : */
+/*  II  NF  NUMBER OF VARIABLES. */
+/*  II  NB  CHOICE OF SIMPLE BOUNDS. NB=0-SIMPLE BOUNDS SUPPRESSED. */
+/*         NB>0-SIMPLE BOUNDS ACCEPTED. */
+/*  RI  X(NF)  VECTOR OF VARIABLES. */
+/*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS. IX(I)=0-VARIABLE */
+/*         X(I) IS UNBOUNDED. IX(I)=1-LOVER BOUND XL(I).LE.X(I). */
+/*         IX(I)=2-UPPER BOUND X(I).LE.XU(I). IX(I)=3-TWO SIDE BOUND */
+/*         XL(I).LE.X(I).LE.XU(I). IX(I)=5-VARIABLE X(I) IS FIXED. */
+/*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES. */
+/*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES. */
+/*  RA  GF(NF)  GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*  RO  S(NF)  DIRECTION VECTOR. */
+/*  RU  XO(NF)  VECTORS OF VARIABLES DIFFERENCE. */
+/*  RI  GO(NF)  GRADIENTS DIFFERENCE. */
+/*  RA  SO(NF)  AUXILIARY VECTOR. */
+/*  RA  XM(NF*MF)  AUXILIARY VECTOR. */
+/*  RA  XR(MF)  AUXILIARY VECTOR. */
+/*  RA  GR(MF)  AUXILIARY VECTOR. */
+/*  RI  XMAX  MAXIMUM STEPSIZE. */
+/*  RI  TOLX  TOLERANCE FOR CHANGE OF VARIABLES. */
+/*  RI  TOLF  TOLERANCE FOR CHANGE OF FUNCTION VALUES. */
+/*  RI  TOLB  TOLERANCE FOR THE FUNCTION VALUE. */
+/*  RI  TOLG  TOLERANCE FOR THE GRADIENT NORM. */
+/*  RI  MINF_EST  ESTIMATION OF THE MINIMUM FUNCTION VALUE. */
+/*  RO  GMAX  MAXIMUM PARTIAL DERIVATIVE. */
+/*  RO  F  VALUE OF THE OBJECTIVE FUNCTION. */
+/*  II  MIT  MAXIMUM NUMBER OF ITERATIONS. */
+/*  II  MFV  MAXIMUM NUMBER OF FUNCTION EVALUATIONS. */
+/*  II  IEST  ESTIMATION INDICATOR. IEST=0-MINIMUM IS NOT ESTIMATED. */
+/*         IEST=1-MINIMUM IS ESTIMATED BY THE VALUE MINF_EST. */
+/*  II  MET  METHOD USED. MET=1-RANK-ONE METHOD. MET=2-RANK-TWO */
+/*         METHOD. */
+/*  II  MF  NUMBER OF LIMITED MEMORY STEPS. */
+/*  IO  ITERM  VARIABLE THAT INDICATES THE CAUSE OF TERMINATION. */
+/*         ITERM=1-IF ABS(X-XO) WAS LESS THAN OR EQUAL TO TOLX IN */
+/*                   MTESX (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=2-IF ABS(F-FO) WAS LESS THAN OR EQUAL TO TOLF IN */
+/*                   MTESF (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=3-IF F IS LESS THAN OR EQUAL TO TOLB. */
+/*         ITERM=4-IF GMAX IS LESS THAN OR EQUAL TO TOLG. */
+/*         ITERM=6-IF THE TERMINATION CRITERION WAS NOT SATISFIED, */
+/*                   BUT THE SOLUTION OBTAINED IS PROBABLY ACCEPTABLE. */
+/*         ITERM=11-IF NIT EXCEEDED MIT. ITERM=12-IF NFV EXCEEDED MFV. */
+/*         ITERM=13-IF NFG EXCEEDED MFG. ITERM<0-IF THE METHOD FAILED. */
+
+/* VARIABLES IN COMMON /STAT/ (STATISTICS) : */
+/*  IO  NRES  NUMBER OF RESTARTS. */
+/*  IO  NDEC  NUMBER OF MATRIX DECOMPOSITION. */
+/*  IO  NIN  NUMBER OF INNER ITERATIONS. */
+/*  IO  NIT  NUMBER OF ITERATIONS. */
+/*  IO  NFV  NUMBER OF FUNCTION EVALUATIONS. */
+/*  IO  NFG  NUMBER OF GRADIENT EVALUATIONS. */
+/*  IO  NFH  NUMBER OF HESSIAN EVALUATIONS. */
+
+/* SUBPROGRAMS USED : */
+/*  S   PCBS04  ELIMINATION OF BOX CONSTRAINT VIOLATIONS. */
+/*  S   PS1L01  STEPSIZE SELECTION USING LINE SEARCH. */
+/*  S   PULSP3  SHIFTED VARIABLE METRIC UPDATE. */
+/*  S   PULVP3  SHIFTED LIMITED-MEMORY VARIABLE METRIC UPDATE. */
+/*  S   PYADC0  ADDITION OF A BOX CONSTRAINT. */
+/*  S   PYFUT1  TEST ON TERMINATION. */
+/*  S   PYRMC0  DELETION OF A BOX CONSTRAINT. */
+/*  S   PYTRCD  COMPUTATION OF PROJECTED DIFFERENCES FOR THE VARIABLE METRIC */
+/*         UPDATE. */
+/*  S   PYTRCG  COMPUTATION OF THE PROJECTED GRADIENT. */
+/*  S   PYTRCS  COMPUTATION OF THE PROJECTED DIRECTION VECTOR. */
+/*  S   MXDRMM  MULTIPLICATION OF A ROWWISE STORED DENSE RECTANGULAR */
+/*         MATRIX A BY A VECTOR X. */
+/*  S   MXDCMD  MULTIPLICATION OF A COLUMNWISE STORED DENSE RECTANGULAR */
+/*         MATRIX A BY A VECTOR X AND ADDITION OF THE SCALED VECTOR */
+/*         ALF*Y. */
+/*  S   MXUCOP  COPYING OF A VECTOR. */
+/*  S   MXUDIR  VECTOR AUGMENTED BY THE SCALED VECTOR. */
+/*  RF  MXUDOT  DOT PRODUCT OF TWO VECTORS. */
+/*  S   MXUNEG  COPYING OF A VECTOR WITH CHANGE OF THE SIGN. */
+/*  S   MXUZER  VECTOR ELEMENTS CORRESPONDING TO ACTIVE BOUNDS ARE SET */
+/*         TO ZERO. */
+/*  S   MXVCOP  COPYING OF A VECTOR. */
+
+/* EXTERNAL SUBROUTINES : */
+/*  SE  OBJ  COMPUTATION OF THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL OBJ(NF,X,FF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND FF IS */
+/*         THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*  SE  DOBJ  COMPUTATION OF THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL DOBJ(NF,X,GF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND GF(NF) */
+/*         IS THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/* -- OBJ and DOBJ are replaced by a single function, objgrad, in NLopt */
+
+/* METHOD : */
+/* HYBRID METHOD WITH SPARSE MARWIL UPDATES FOR SPARSE LEAST SQUARES */
+/* PROBLEMS. */
+
+static void plip_(int *nf, int *nb, double *x, int *
+                 ix, double *xl, double *xu, double *gf, double *s, 
+                 double *xo, double *go, double *so, double *xm, 
+                 double *xr, double *gr, double *xmax, double *tolx, 
+                 double *tolf, double *tolb, double *tolg, 
+                 nlopt_stopping *stop, double *
+                 minf_est, double *gmax, double *f, int *mit, int *mfv, 
+                 int *iest, int *met, int *mf, 
+                 int *iterm, stat_common *stat_1,
+                 nlopt_func objgrad, void *objgrad_data)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Builtin functions */
+
+    /* Local variables */
+    int i__, n;
+    double p, r__;
+    int kd, ld;
+    double fo, fp;
+    int nn;
+    double po, pp, ro, rp;
+    int kbf, mec, mfg;
+    double par;
+    int mes, kit;
+    double alf1, alf2, eta0, eta9, par1, par2;
+    int mes1, mes2, mes3, met3;
+    double eps8, eps9;
+    int meta, mred, nred, iold;
+    double maxf, dmax__;
+    int xstop = 0;
+    int inew;
+    double told;
+    int ites;
+    double rmin, rmax, umax, tolp, tols;
+    int isys;
+    int ires1, ires2;
+    int iterd, iterh, mtesf, ntesf;
+    double gnorm;
+    int iters, irest, inits, kters, maxst;
+    double snorm;
+    int mtesx, ntesx;
+    ps1l01_state state;
+
+/*     INITIATION */
+
+    /* Parameter adjustments */
+    --gr;
+    --xr;
+    --xm;
+    --so;
+    --go;
+    --xo;
+    --s;
+    --gf;
+    --xu;
+    --xl;
+    --ix;
+    --x;
+
+    /* Function Body */
+    kbf = 0;
+    if (*nb > 0) {
+       kbf = 2;
+    }
+    stat_1->nres = 0;
+    stat_1->ndec = 0;
+    stat_1->nin = 0;
+    stat_1->nit = 0;
+    stat_1->nfg = 0;
+    stat_1->nfh = 0;
+    isys = 0;
+    ites = 1;
+    mtesx = 2;
+    mtesf = 2;
+    inits = 2;
+    *iterm = 0;
+    iterd = 0;
+    iters = 2;
+    iterh = 0;
+    kters = 3;
+    irest = 0;
+    ires1 = 999;
+    ires2 = 0;
+    mred = 10;
+    meta = 1;
+    met3 = 4;
+    mec = 4;
+    mes = 4;
+    mes1 = 2;
+    mes2 = 2;
+    mes3 = 2;
+    eta0 = 1e-15;
+    eta9 = 1e120;
+    eps8 = 1.;
+    eps9 = 1e-8;
+    alf1 = 1e-10;
+    alf2 = 1e10;
+    rmax = eta9;
+    dmax__ = eta9;
+    maxf = 1e20;
+    if (*iest <= 0) {
+        *minf_est = -HUGE_VAL; /* changed from -1e60 by SGJ */
+    }
+    if (*iest > 0) {
+       *iest = 1;
+    }
+    if (*xmax <= 0.) {
+       *xmax = 1e16;
+    }
+    if (*tolx <= 0.) {
+       *tolx = 1e-16;
+    }
+    if (*tolf <= 0.) {
+       *tolf = 1e-14;
+    }
+    if (*tolg <= 0.) {
+        *tolg = 1e-8; /* SGJ: was 1e-6, but this sometimes stops too soon */
+    }
+#if 0
+    /* removed by SGJ: this check prevented us from using minf_max <= 0,
+       which doesn't make sense.  Instead, if you don't want to have a
+       lower limit, you should set minf_max = -HUGE_VAL */
+    if (*tolb <= 0.) {
+       *tolb = *minf_est + 1e-16;
+    }
+#endif
+    told = 1e-4;
+    tols = 1e-4;
+    tolp = .9;
+    if (*met <= 0) {
+       *met = 2;
+    }
+    /* changed by SGJ: default is no limit (INT_MAX) on # iterations/fevals */
+    if (*mit <= 0) {
+       *mit = INT_MAX;
+    }
+    if (*mfv <= 0) {
+       *mfv = INT_MAX;
+    }
+    mfg = *mfv;
+    kd = 1;
+    ld = -1;
+    kit = -(ires1 * *nf + ires2);
+    fo = *minf_est;
+
+/*     INITIAL OPERATIONS WITH SIMPLE BOUNDS */
+
+    if (kbf > 0) {
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if ((ix[i__] == 3 || ix[i__] == 4) && xu[i__] <= xl[i__]) {
+               xu[i__] = xl[i__];
+               ix[i__] = 5;
+           } else if (ix[i__] == 5 || ix[i__] == 6) {
+               xl[i__] = x[i__];
+               xu[i__] = x[i__];
+               ix[i__] = 5;
+           }
+/* L2: */
+       }
+       luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+    }
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+L11120:
+    luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
+    luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg, 
+           &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, &mfg, 
+           &ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
+           iters, iterm);
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+    if (kbf > 0 && rmax > 0.) {
+       luksan_pyrmc0__(nf, &n, &ix[1], &gf[1], &eps8, &umax, gmax, &rmax, &
+               iold, &irest);
+    }
+L11130:
+    if (irest > 0) {
+       nn = 0;
+       par = 1.;
+       ld = MIN2(ld,1);
+       if (kit < stat_1->nit) {
+           ++stat_1->nres;
+           kit = stat_1->nit;
+       } else {
+           *iterm = -10;
+           if (iters < 0) {
+               *iterm = iters - 5;
+           }
+       }
+    }
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+
+/*     DIRECTION DETERMINATION */
+
+    gnorm = sqrt(luksan_mxudot__(nf, &gf[1], &gf[1], &ix[1], &kbf));
+
+/*     NEWTON LIKE STEP */
+
+    luksan_mxuneg__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    luksan_mxdrmm__(nf, &nn, &xm[1], &s[1], &gr[1]);
+    luksan_mxdcmd__(nf, &nn, &xm[1], &gr[1], &par, &s[1], &s[1]);
+    luksan_mxuzer__(nf, &s[1], &ix[1], &kbf);
+    iterd = 1;
+    snorm = sqrt(luksan_mxudot__(nf, &s[1], &s[1], &ix[1], &kbf));
+
+/*     TEST ON DESCENT DIRECTION AND PREPARATION OF LINE SEARCH */
+
+    if (kd > 0) {
+       p = luksan_mxudot__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    }
+    if (iterd < 0) {
+       *iterm = iterd;
+    } else {
+
+/*     TEST ON DESCENT DIRECTION */
+
+       if (snorm <= 0.) {
+           irest = MAX2(irest,1);
+       } else if (p + told * gnorm * snorm <= 0.) {
+           irest = 0;
+       } else {
+
+/*     UNIFORM DESCENT CRITERION */
+
+           irest = MAX2(irest,1);
+       }
+       if (irest == 0) {
+
+/*     PREPARATION OF LINE SEARCH */
+
+           nred = 0;
+           rmin = alf1 * gnorm / snorm;
+/* Computing MIN */
+           d__1 = alf2 * gnorm / snorm, d__2 = *xmax / snorm;
+           rmax = MIN2(d__1,d__2);
+       }
+    }
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+    if (irest != 0) {
+       goto L11130;
+    }
+    luksan_pytrcs__(nf, &x[1], &ix[1], &xo[1], &xl[1], &xu[1], &gf[1], &go[1],
+            &s[1], &ro, &fp, &fo, f, &po, &p, &rmax, &eta9, &kbf);
+    if (rmax == 0.) {
+       goto L11175;
+    }
+L11170:
+    luksan_ps1l01__(&r__, &rp, f, &fo, &fp, &p, &po, &pp, minf_est, &maxf, &rmin, 
+           &rmax, &tols, &tolp, &par1, &par2, &kd, &ld, &stat_1->nit, &kit, &
+           nred, &mred, &maxst, iest, &inits, &iters, &kters, &mes,
+                   &isys, &state);
+    if (isys == 0) {
+       goto L11174;
+    }
+    luksan_mxudir__(nf, &r__, &s[1], &xo[1], &x[1], &ix[1], &kbf);
+    luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    p = luksan_mxudot__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    goto L11170;
+L11174:
+    if (iters <= 0) {
+       r__ = 0.;
+       *f = fo;
+       p = po;
+       luksan_mxvcop__(nf, &xo[1], &x[1]);
+       luksan_mxvcop__(nf, &go[1], &gf[1]);
+       irest = MAX2(irest,1);
+       ld = kd;
+       goto L11130;
+    }
+    luksan_mxuneg__(nf, &go[1], &s[1], &ix[1], &kbf);
+    luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
+           p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+    xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
+    luksan_mxucop__(nf, &gf[1], &so[1], &ix[1], &kbf);
+    if (nn < *mf) {
+       luksan_pulsp3__(nf, &nn, mf, &xm[1], &gr[1], &xo[1], &go[1], &r__, &
+               po, &par, &iterh, &met3);
+    } else {
+       luksan_pulvp3__(nf, &nn, &xm[1], &xr[1], &gr[1], &s[1], &so[1], &xo[1]
+               , &go[1], &r__, &po, &par, &iterh, &mec, &met3, met);
+    }
+L11175:
+    if (iterh != 0) {
+       irest = MAX2(irest,1);
+    }
+    if (kbf > 0) {
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+    }
+    goto L11120;
+L11190:
+    return;
+} /* plip_ */
+
+/* NLopt wrapper around plip_, handling dynamic allocation etc. */
+nlopt_result luksan_plip(int n, nlopt_func f, void *f_data,
+                        const double *lb, const double *ub, /* bounds */
+                        double *x, /* in: initial guess, out: minimizer */
+                        double *minf,
+                        nlopt_stopping *stop,
+                        int mf, /* subspace dimension (0 for default) */
+                        int method) /* 1 or 2, see below */
+{
+     int i, *ix, nb = 1;
+     double *work, *xl, *xu, *gf, *s, *xo, *go, *so, *xm, *xr, *gr;
+     double gmax, minf_est;
+     double xmax = 0; /* no maximum */
+     double tolg = 0; /* default gradient tolerance */
+     int iest = 0; /* we have no estimate of min function value */
+     int mit = 0; /* default no limit on #iterations */
+     int mfv = stop->maxeval;
+     stat_common stat;
+     int iterm;
+
+     ix = (int*) malloc(sizeof(int) * n);
+     if (!ix) return NLOPT_OUT_OF_MEMORY;
+
+     if (mf <= 0) {
+         mf = MAX2(MEMAVAIL/n, 10);
+         if (stop->maxeval && stop->maxeval <= mf)
+              mf = MAX2(stop->maxeval, 1);
+     }
+
+ retry_alloc:
+     work = (double*) malloc(sizeof(double) * (n * 7 + MAX2(n,n*mf) + 
+                                              MAX2(n,mf)*2));
+     if (!work) { 
+         if (mf > 0) {
+              mf = 0; /* allocate minimal memory */
+              goto retry_alloc;
+         }
+         free(ix);
+         return NLOPT_OUT_OF_MEMORY;
+     }
+
+     xl = work; xu = xl + n;
+     gf = xu + n; s = gf + n; xo = s + n; go = xo + n; so = go + n;
+     xm = so + n;
+     xr = xm + MAX2(n*mf,n); gr = xr + MAX2(n,mf);
+
+     for (i = 0; i < n; ++i) {
+         int lbu = lb[i] <= -0.99 * HUGE_VAL; /* lb unbounded */
+         int ubu = ub[i] >= 0.99 * HUGE_VAL;  /* ub unbounded */
+         ix[i] = lbu ? (ubu ? 0 : 2) : (ubu ? 1 : (lb[i] == ub[i] ? 5 : 3));
+         xl[i] = lb[i];
+         xu[i] = ub[i];
+     }
+
+     /* ?  xo does not seem to be initialized in the
+       original Fortran code, but it is used upon
+       input to plip if mf > 0 ... perhaps ALLOCATE initializes
+       arrays to zero by default? */
+     memset(xo, 0, sizeof(double) * MAX2(n,n*mf));
+
+     plip_(&n, &nb, x, ix, xl, xu, 
+          gf, s, xo, go, so, xm, xr, gr,
+          &xmax,
+
+          /* fixme: pass tol_rel and tol_abs and use NLopt check */
+          &stop->xtol_rel,
+          &stop->ftol_rel,
+          &stop->minf_max,
+          &tolg,
+          stop,
+
+          &minf_est, &gmax,
+          minf,
+          &mit, &mfv,
+          &iest,
+          &method, /* 1 == rank-one method VAR1, 2 == rank-two method VAR2 */
+          &mf,
+          &iterm, &stat,
+          f, f_data);
+
+     free(work);
+     free(ix);
+
+     switch (iterm) {
+        case 1: return NLOPT_XTOL_REACHED;
+        case 2: return NLOPT_FTOL_REACHED;
+        case 3: return NLOPT_MINF_MAX_REACHED;
+        case 4: return NLOPT_SUCCESS; /* gradient tolerance reached */
+        case 6: return NLOPT_SUCCESS;
+        case 12: case 13: return NLOPT_MAXEVAL_REACHED;
+        case 100: return NLOPT_MAXTIME_REACHED;
+        case -999: return NLOPT_FORCED_STOP;
+        default: return NLOPT_FAILURE;
+     }
+}
diff --git a/luksan/plis.c b/luksan/plis.c
new file mode 100644 (file)
index 0000000..11d371f
--- /dev/null
@@ -0,0 +1,513 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "luksan.h"
+
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define MIN2(a,b) ((a) < (b) ? (a) : (b))
+
+/* *********************************************************************** */
+/* SUBROUTINE PLIS               ALL SYSTEMS                   01/09/22 */
+/* PURPOSE : */
+/* GENERAL SUBROUTINE FOR LARGE-SCALE BOX CONSTRAINED MINIMIZATION THAT */
+/* USE THE LIMITED MEMORY VARIABLE METRIC METHOD BASED ON THE STRANG */
+/* RECURRENCES. */
+
+/* PARAMETERS : */
+/*  II  NF  NUMBER OF VARIABLES. */
+/*  II  NB  CHOICE OF SIMPLE BOUNDS. NB=0-SIMPLE BOUNDS SUPPRESSED. */
+/*         NB>0-SIMPLE BOUNDS ACCEPTED. */
+/*  RI  X(NF)  VECTOR OF VARIABLES. */
+/*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS. IX(I)=0-VARIABLE */
+/*         X(I) IS UNBOUNDED. IX(I)=1-LOVER BOUND XL(I).LE.X(I). */
+/*         IX(I)=2-UPPER BOUND X(I).LE.XU(I). IX(I)=3-TWO SIDE BOUND */
+/*         XL(I).LE.X(I).LE.XU(I). IX(I)=5-VARIABLE X(I) IS FIXED. */
+/*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES. */
+/*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES. */
+/*  RO  GF(NF)  GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*  RO  S(NF)  DIRECTION VECTOR. */
+/*  RU  XO(NF)  VECTORS OF VARIABLES DIFFERENCE. */
+/*  RI  GO(NF)  GRADIENTS DIFFERENCE. */
+/*  RA  UO(NF)  AUXILIARY VECTOR. */
+/*  RA  VO(NF)  AUXILIARY VECTOR. */
+/*  RI  XMAX  MAXIMUM STEPSIZE. */
+/*  RI  TOLX  TOLERANCE FOR CHANGE OF VARIABLES. */
+/*  RI  TOLF  TOLERANCE FOR CHANGE OF FUNCTION VALUES. */
+/*  RI  TOLB  TOLERANCE FOR THE FUNCTION VALUE. */
+/*  RI  TOLG  TOLERANCE FOR THE GRADIENT NORM. */
+/*  RI  MINF_EST  ESTIMATION OF THE MINIMUM FUNCTION VALUE. */
+/*  RO  GMAX  MAXIMUM PARTIAL DERIVATIVE. */
+/*  RO  F  VALUE OF THE OBJECTIVE FUNCTION. */
+/*  II  MIT  MAXIMUM NUMBER OF ITERATIONS. */
+/*  II  MFV  MAXIMUM NUMBER OF FUNCTION EVALUATIONS. */
+/*  II  IEST  ESTIMATION INDICATOR. IEST=0-MINIMUM IS NOT ESTIMATED. */
+/*         IEST=1-MINIMUM IS ESTIMATED BY THE VALUE MINF_EST. */
+/*  II  MF  NUMBER OF LIMITED MEMORY STEPS. */
+/*  IO  ITERM  VARIABLE THAT INDICATES THE CAUSE OF TERMINATION. */
+/*         ITERM=1-IF ABS(X-XO) WAS LESS THAN OR EQUAL TO TOLX IN */
+/*                   MTESX (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=2-IF ABS(F-FO) WAS LESS THAN OR EQUAL TO TOLF IN */
+/*                   MTESF (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=3-IF F IS LESS THAN OR EQUAL TO TOLB. */
+/*         ITERM=4-IF GMAX IS LESS THAN OR EQUAL TO TOLG. */
+/*         ITERM=6-IF THE TERMINATION CRITERION WAS NOT SATISFIED, */
+/*                   BUT THE SOLUTION OBTAINED IS PROBABLY ACCEPTABLE. */
+/*         ITERM=11-IF NIT EXCEEDED MIT. ITERM=12-IF NFV EXCEEDED MFV. */
+/*         ITERM=13-IF NFG EXCEEDED MFG. ITERM<0-IF THE METHOD FAILED. */
+
+/* VARIABLES IN COMMON /STAT/ (STATISTICS) : */
+/*  IO  NRES  NUMBER OF RESTARTS. */
+/*  IO  NDEC  NUMBER OF MATRIX DECOMPOSITION. */
+/*  IO  NIN  NUMBER OF INNER ITERATIONS. */
+/*  IO  NIT  NUMBER OF ITERATIONS. */
+/*  IO  NFV  NUMBER OF FUNCTION EVALUATIONS. */
+/*  IO  NFG  NUMBER OF GRADIENT EVALUATIONS. */
+/*  IO  NFH  NUMBER OF HESSIAN EVALUATIONS. */
+
+/* SUBPROGRAMS USED : */
+/*  S   PCBS04  ELIMINATION OF BOX CONSTRAINT VIOLATIONS. */
+/*  S   PS1L01  STEPSIZE SELECTION USING LINE SEARCH. */
+/*  S   PYADC0  ADDITION OF A BOX CONSTRAINT. */
+/*  S   PYFUT1  TEST ON TERMINATION. */
+/*  S   PYRMC0  DELETION OF A BOX CONSTRAINT. */
+/*  S   PYTRCD  COMPUTATION OF PROJECTED DIFFERENCES FOR THE VARIABLE METRIC */
+/*         UPDATE. */
+/*  S   PYTRCG  COMPUTATION OF THE PROJECTED GRADIENT. */
+/*  S   PYTRCS  COMPUTATION OF THE PROJECTED DIRECTION VECTOR. */
+/*  S   MXDRCB BACKWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION */
+/*         OF THE VECTOR X BY AN IMPLICIT BFGS UPDATE. */
+/*  S   MXDRCF FORWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION */
+/*         OF THE VECTOR X BY AN IMPLICIT BFGS UPDATE. */
+/*  S   MXDRSU SHIFT OF COLUMNS OF THE RECTANGULAR MATRICES A AND B. */
+/*         SHIFT OF ELEMENTS OF THE VECTOR U. THESE SHIFTS ARE USED IN */
+/*         THE LIMITED MEMORY BFGS METHOD. */
+/*  S   MXUDIR  VECTOR AUGMENTED BY THE SCALED VECTOR. */
+/*  RF  MXUDOT  DOT PRODUCT OF TWO VECTORS. */
+/*  S   MXUNEG  COPYING OF A VECTOR WITH CHANGE OF THE SIGN. */
+/*  S   MXVCOP  COPYING OF A VECTOR. */
+/*  S   MXVSCL  SCALING OF A VECTOR. */
+
+/* EXTERNAL SUBROUTINES : */
+/*  SE  OBJ  COMPUTATION OF THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL OBJ(NF,X,FF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND FF IS */
+/*         THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*  SE  DOBJ  COMPUTATION OF THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL DOBJ(NF,X,GF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND GF(NF) */
+/*         IS THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/* -- OBJ and DOBJ are replaced by a single function, objgrad, in NLopt */
+
+/* METHOD : */
+/* LIMITED MEMORY VARIABLE METRIC METHOD BASED ON THE STRANG */
+/* RECURRENCES. */
+
+static void plis_(int *nf, int *nb, double *x, int *
+                 ix, double *xl, double *xu, double *gf, double *s, 
+                 double *xo, double *go, double *uo, double *vo, 
+                 double *xmax, double *tolx, double *tolf, double *
+                 tolb, double *tolg, nlopt_stopping *stop,
+                 double *minf_est, double *gmax, 
+                 double *f, int *mit, int *mfv, int *iest, int *mf,
+                 int *iterm, stat_common *stat_1,
+                 nlopt_func objgrad, void *objgrad_data)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Builtin functions */
+
+    /* Local variables */
+    double a, b;
+    int i__, k, n;
+    double p, r__;
+    int kd, ld;
+    double fo, fp, po, pp, ro, rp;
+    int kbf, mfg;
+    int mes, kit;
+    double alf1, alf2, eta0, eta9, par1, par2;
+    int mes1, mes2, mes3;
+    double eps8, eps9;
+    int mred, iold, nred;
+    double maxf, dmax__;
+    int xstop = 0;
+    int inew;
+    double told;
+    int ites;
+    double rmin, rmax, umax, tolp, tols;
+    int isys;
+    int ires1, ires2;
+    int iterd, mtesf, ntesf;
+    double gnorm;
+    int iters, irest, inits, kters, maxst;
+    double snorm;
+    int mtesx, ntesx;
+    ps1l01_state state;
+
+/*     INITIATION */
+
+    /* Parameter adjustments */
+    --vo;
+    --uo;
+    --go;
+    --xo;
+    --s;
+    --gf;
+    --xu;
+    --xl;
+    --ix;
+    --x;
+
+    /* Function Body */
+    kbf = 0;
+    if (*nb > 0) {
+       kbf = 2;
+    }
+    stat_1->nres = 0;
+    stat_1->ndec = 0;
+    stat_1->nin = 0;
+    stat_1->nit = 0;
+    stat_1->nfg = 0;
+    stat_1->nfh = 0;
+    isys = 0;
+    ites = 1;
+    mtesx = 2;
+    mtesf = 2;
+    inits = 2;
+    *iterm = 0;
+    iterd = 0;
+    iters = 2;
+    kters = 3;
+    irest = 0;
+    ires1 = 999;
+    ires2 = 0;
+    mred = 10;
+    mes = 4;
+    mes1 = 2;
+    mes2 = 2;
+    mes3 = 2;
+    eta0 = 1e-15;
+    eta9 = 1e120;
+    eps8 = 1.;
+    eps9 = 1e-8;
+    alf1 = 1e-10;
+    alf2 = 1e10;
+    rmax = eta9;
+    dmax__ = eta9;
+    maxf = 1e20;
+    if (*iest <= 0) {
+        *minf_est = -HUGE_VAL; /* changed from -1e60 by SGJ */
+    }
+    if (*iest > 0) {
+       *iest = 1;
+    }
+    if (*xmax <= 0.) {
+       *xmax = 1e16;
+    }
+    if (*tolx <= 0.) {
+       *tolx = 1e-16;
+    }
+    if (*tolf <= 0.) {
+       *tolf = 1e-14;
+    }
+    if (*tolg <= 0.) {
+        *tolg = 1e-8; /* SGJ: was 1e-6, but this sometimes stops too soon */
+    }
+#if 0
+    /* removed by SGJ: this check prevented us from using minf_max <= 0,
+       which doesn't make sense.  Instead, if you don't want to have a
+       lower limit, you should set minf_max = -HUGE_VAL */
+    if (*tolb <= 0.) {
+       *tolb = *minf_est + 1e-16;
+    }
+#endif
+    told = 1e-4;
+    tols = 1e-4;
+    tolp = .8;
+    /* changed by SGJ: default is no limit (INT_MAX) on # iterations/fevals */
+    if (*mit <= 0) {
+       *mit = INT_MAX;
+    }
+    if (*mfv <= 0) {
+       *mfv = INT_MAX;
+    }
+    mfg = *mfv;
+    kd = 1;
+    ld = -1;
+    kit = -(ires1 * *nf + ires2);
+    fo = *minf_est;
+
+/*     INITIAL OPERATIONS WITH SIMPLE BOUNDS */
+
+    if (kbf > 0) {
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if ((ix[i__] == 3 || ix[i__] == 4) && xu[i__] <= xl[i__]) {
+               xu[i__] = xl[i__];
+               ix[i__] = 5;
+           } else if (ix[i__] == 5 || ix[i__] == 6) {
+               xl[i__] = x[i__];
+               xu[i__] = x[i__];
+               ix[i__] = 5;
+           }
+/* L2: */
+       }
+       luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+    }
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+L11120:
+    luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
+    luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg, 
+           &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, &mfg, 
+           &ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
+           iters, iterm);
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+    if (kbf > 0 && rmax > 0.) {
+       luksan_pyrmc0__(nf, &n, &ix[1], &gf[1], &eps8, &umax, gmax, &rmax, &
+               iold, &irest);
+    }
+L11130:
+
+/*     DIRECTION DETERMINATION */
+
+    gnorm = sqrt(luksan_mxudot__(nf, &gf[1], &gf[1], &ix[1], &kbf));
+    if (irest != 0) {
+       goto L12620;
+    }
+/* Computing MIN */
+    i__1 = stat_1->nit - kit;
+    k = MIN2(i__1,*mf);
+    if (k <= 0) {
+       irest = MAX2(irest,1);
+       goto L12620;
+    }
+
+/*     DETERMINATION OF THE PARAMETER B */
+
+    b = luksan_mxudot__(nf, &xo[1], &go[1], &ix[1], &kbf);
+    if (b <= 0.) {
+       irest = MAX2(irest,1);
+       goto L12620;
+    }
+    uo[1] = 1. / b;
+    luksan_mxuneg__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    luksan_mxdrcb__(nf, &k, &xo[1], &go[1], &uo[1], &vo[1], &s[1], &ix[1], &
+           kbf);
+    a = luksan_mxudot__(nf, &go[1], &go[1], &ix[1], &kbf);
+    if (a > 0.) {
+       d__1 = b / a;
+       luksan_mxvscl__(nf, &d__1, &s[1], &s[1]);
+    }
+    luksan_mxdrcf__(nf, &k, &xo[1], &go[1], &uo[1], &vo[1], &s[1], &ix[1], &
+           kbf);
+    snorm = sqrt(luksan_mxudot__(nf, &s[1], &s[1], &ix[1], &kbf));
+/* Computing MIN */
+    i__1 = k + 1;
+    k = MIN2(i__1,*mf);
+    luksan_mxdrsu__(nf, &k, &xo[1], &go[1], &uo[1]);
+L12620:
+    iterd = 0;
+    if (irest != 0) {
+
+/*     STEEPEST DESCENT DIRECTION */
+
+       luksan_mxuneg__(nf, &gf[1], &s[1], &ix[1], &kbf);
+       snorm = gnorm;
+       if (kit < stat_1->nit) {
+           ++stat_1->nres;
+           kit = stat_1->nit;
+       } else {
+            *iterm = -10;
+           if (iters < 0) {
+               *iterm = iters - 5;
+           }
+       }
+    }
+
+/*     TEST ON DESCENT DIRECTION AND PREPARATION OF LINE SEARCH */
+
+    if (kd > 0) {
+       p = luksan_mxudot__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    }
+    if (iterd < 0) {
+       *iterm = iterd;
+    } else {
+
+/*     TEST ON DESCENT DIRECTION */
+
+       if (snorm <= 0.) {
+           irest = MAX2(irest,1);
+       } else if (p + told * gnorm * snorm <= 0.) {
+           irest = 0;
+       } else {
+
+/*     UNIFORM DESCENT CRITERION */
+
+           irest = MAX2(irest,1);
+       }
+       if (irest == 0) {
+
+/*     PREPARATION OF LINE SEARCH */
+
+           nred = 0;
+           rmin = alf1 * gnorm / snorm;
+/* Computing MIN */
+           d__1 = alf2 * gnorm / snorm, d__2 = *xmax / snorm;
+           rmax = MIN2(d__1,d__2);
+       }
+    }
+    if (*iterm != 0) {
+       goto L11190;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11190; }
+    if (irest != 0) {
+       goto L11130;
+    }
+    luksan_pytrcs__(nf, &x[1], &ix[1], &xo[1], &xl[1], &xu[1], &gf[1], &go[1],
+            &s[1], &ro, &fp, &fo, f, &po, &p, &rmax, &eta9, &kbf);
+    if (rmax == 0.) {
+       goto L11175;
+    }
+L11170:
+    luksan_ps1l01__(&r__, &rp, f, &fo, &fp, &p, &po, &pp, minf_est, &maxf, &rmin, 
+           &rmax, &tols, &tolp, &par1, &par2, &kd, &ld, &stat_1->nit, &kit, &
+           nred, &mred, &maxst, iest, &inits, &iters, &kters, &mes,
+                   &isys, &state);
+    if (isys == 0) {
+       goto L11174;
+    }
+    luksan_mxudir__(nf, &r__, &s[1], &xo[1], &x[1], &ix[1], &kbf);
+    luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    p = luksan_mxudot__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    goto L11170;
+L11174:
+    if (iters <= 0) {
+       r__ = 0.;
+       *f = fo;
+       p = po;
+       luksan_mxvcop__(nf, &xo[1], &x[1]);
+       luksan_mxvcop__(nf, &go[1], &gf[1]);
+       irest = MAX2(irest,1);
+       ld = kd;
+       goto L11130;
+    }
+    luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
+           p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+    xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
+L11175:
+    if (kbf > 0) {
+       luksan_mxvine__(nf, &ix[1]);
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+    }
+    goto L11120;
+L11190:
+    return;
+} /* plis_ */
+
+/* NLopt wrapper around plis_, handling dynamic allocation etc. */
+nlopt_result luksan_plis(int n, nlopt_func f, void *f_data,
+                 const double *lb, const double *ub, /* bounds */
+                 double *x, /* in: initial guess, out: minimizer */
+                 double *minf,
+                 nlopt_stopping *stop,
+                        int mf) /* subspace dimension, 0 for default */
+{
+     int i, *ix, nb = 1;
+     double *work, *xl, *xu, *xo, *gf, *s, *go, *uo, *vo;
+     double gmax, minf_est;
+     double xmax = 0; /* no maximum */
+     double tolg = 0; /* default gradient tolerance */
+     int iest = 0; /* we have no estimate of min function value */
+     int mit = 0; /* default no limit on #iterations */
+     int mfv = stop->maxeval;
+     stat_common stat;
+     int iterm;
+
+     ix = (int*) malloc(sizeof(int) * n);
+     if (!ix) return NLOPT_OUT_OF_MEMORY;
+
+     if (mf <= 0) {
+         mf = MAX2(MEMAVAIL/n, 10);
+         if (stop->maxeval && stop->maxeval <= mf)
+              mf = MAX2(stop->maxeval, 1);
+     }
+
+ retry_alloc:
+     work = (double*) malloc(sizeof(double) * (n * 4 + MAX2(n,n*mf)*2 + 
+                                              MAX2(n,mf)*2));
+     if (!work) { 
+         if (mf > 0) {
+              mf = 0; /* allocate minimal memory */
+              goto retry_alloc;
+         }
+         free(ix);
+         return NLOPT_OUT_OF_MEMORY;
+     }
+
+     xl = work; xu = xl + n; gf = xu + n; s = gf + n; 
+     xo = s + n; go = xo + MAX2(n,n*mf);
+     uo = go + MAX2(n,n*mf); vo = uo + MAX2(n,mf);
+
+     for (i = 0; i < n; ++i) {
+         int lbu = lb[i] <= -0.99 * HUGE_VAL; /* lb unbounded */
+         int ubu = ub[i] >= 0.99 * HUGE_VAL;  /* ub unbounded */
+         ix[i] = lbu ? (ubu ? 0 : 2) : (ubu ? 1 : (lb[i] == ub[i] ? 5 : 3));
+         xl[i] = lb[i];
+         xu[i] = ub[i];
+     }
+
+     /* ?  xo does not seem to be initialized in the
+       original Fortran code, but it is used upon
+       input to plis if mf > 0 ... perhaps ALLOCATE initializes
+       arrays to zero by default? */
+     memset(xo, 0, sizeof(double) * MAX2(n,n*mf));
+
+     plis_(&n, &nb, x, ix, xl, xu, 
+          gf, s, xo, go, uo, vo,
+          &xmax,
+
+          /* fixme: pass tol_rel and tol_abs and use NLopt check */
+          &stop->xtol_rel,
+          &stop->ftol_rel,
+          &stop->minf_max,
+          &tolg,
+          stop,
+
+          &minf_est, &gmax,
+          minf,
+          &mit, &mfv,
+          &iest,
+          &mf,
+          &iterm, &stat,
+          f, f_data);
+
+     free(work);
+     free(ix);
+
+     switch (iterm) {
+        case 1: return NLOPT_XTOL_REACHED;
+        case 2: return NLOPT_FTOL_REACHED;
+        case 3: return NLOPT_MINF_MAX_REACHED;
+        case 4: return NLOPT_SUCCESS; /* gradient tolerance reached */
+        case 6: return NLOPT_SUCCESS;
+        case 12: case 13: return NLOPT_MAXEVAL_REACHED;
+        case 100: return NLOPT_MAXTIME_REACHED;
+        case -999: return NLOPT_FORCED_STOP;
+        default: return NLOPT_FAILURE;
+     }
+}
diff --git a/luksan/plis.txt b/luksan/plis.txt
new file mode 100644 (file)
index 0000000..bc2f4c2
--- /dev/null
@@ -0,0 +1,301 @@
+***********************************************************************
+*                                                                     *
+*         PLIS - A LIMITED MEMORY VARIABLE METRIC ALGORITHM FOR       *
+*                LARGE-SCALE OPTIMIZATION.                            *
+*                                                                     *
+***********************************************************************
+
+
+1. Introduction:
+----------------
+
+      The double-precision FORTRAN 77 basic subroutine PLIS is designed
+to find a close approximation to a local minimum of a nonlinear
+function F(X) with simple bounds on variables. Here X is a vector of NF
+variables and F(X) is a smooth function. We suppose that NF is large
+but the sparsity pattern of the Hessian matrix is not known (or the
+Hessian matrix is dense). Simple bounds are assumed in the form
+
+               X(I) unbounded if  IX(I) = 0,
+      XL(I) <= X(I)           if  IX(I) = 1,
+               X(I) <= XU(I)  if  IX(I) = 2,
+      XL(I) <= X(I) <= XU(I)  if  IX(I) = 3,
+      XL(I)  = X(I)  = XU(I)  if  IX(I) = 5,
+
+where 1 <= I <= NF. To simplify user's work, two additional easy to use
+subroutines are added. They call the basic general subroutine PLIS:
+
+      PLISU - unconstrained large-scale optimization,
+      PLISS - large-scale optimization with simple bounds.
+
+All subroutines contain a description of formal parameters and
+extensive comments. Furthermore, two test programs TLISU and TLISS are
+included, which contain several test problems (see e.g. [2]). These
+test programs serve as examples for using the subroutines, verify their
+correctness and demonstrate their efficiency.
+      In this short guide, we describe all subroutines which can be
+called from the user's program. A detailed description of the method is
+given in [1]. In the description of formal parameters, we introduce a
+type of the argument that specifies whether the argument must have a
+value defined on entry to the subroutine (I), whether it is a value
+which will be returned (O), or both (U), or whether it is an auxiliary
+value (A). Note that the arguments of the type I can be changed on
+output under some circumstances, especially if improper input values
+were given. Besides formal parameters, we can use a COMMON /STAT/ block
+containing statistical information. This block, used in each subroutine
+has the following form:
+
+      COMMON /STAT/ NRES,NDEC,NIN,NIT,NFV,NFG,NFH
+
+The arguments have the following meaning:
+
+ Argument  Type Significance
+ ----------------------------------------------------------------------
+  NRES      O   Positive INTEGER variable that indicates the number of
+                restarts.
+  NDEC      O   Positive INTEGER variable that indicates the number of
+                matrix decompositions.
+  NIN       O   Positive INTEGER variable that indicates the number of
+                inner iterations (for solving linear systems).
+  NIT       O   Positive INTEGER variable that indicates the number of
+                iterations.
+  NFV       O   Positive INTEGER variable that indicates the number of
+                function evaluations.
+  NFG       O   Positive INTEGER variable that specifies the number of
+                gradient evaluations.
+  NFH       O   Positive INTEGER variable that specifies the number of
+                Hessian evaluations.
+
+
+2. Subroutines PLISU, PLISS:
+----------------------------
+
+The calling sequences are
+
+      CALL PLISU(NF,X,IPAR,RPAR,F,GMAX,IPRNT,ITERM)
+      CALL PLISS(NF,X,IX,XL,XU,IPAR,RPAR,F,GMAX,IPRNT,ITERM)
+
+The arguments have the following meaning.
+
+ Argument  Type Significance
+ ----------------------------------------------------------------------
+  NF        I   Positive INTEGER variable that specifies the number of
+                variables of the objective function.
+  X(NF)     U   On input, DOUBLE PRECISION vector with the initial
+                estimate to the solution. On output, the approximation
+                to the minimum.
+  IX(NF)    I   On input (significant only if NB>0) INTEGER vector
+                containing the simple bounds types:
+                   IX(I)=0 - the variable X(I) is unbounded,
+                   IX(I)=1 - the lower bound X(I) >= XL(I),
+                   IX(I)=2 - the upper bound X(I) <= XU(I),
+                   IX(I)=3 - the two side bound XL(I) <= X(I) <= XU(I),
+                   IX(I)=5 - the variable X(I) is fixed (given by its
+                             initial estimate).
+  XL(NF)    I   DOUBLE PRECISION vector with lower bounds for variables
+                (significant only if NB>0).
+  XU(NF)    I   DOUBLE PRECISION vector with upper bounds for variables
+                (significant only if NB>0).
+  IPAR(7)   I   INTEGER parameters:
+                  IPAR(1)=MIT,  IPAR(2)=MFV,  IPAR(3)-NONE,
+                  IPAR(4)=IEST, IPAR(5)-NONE, IPAR(6)-NONE,
+                  IPAR(7)=MF.
+                Parameters MIT, MFV, IEST, MF are described in Section 3
+                together with other parameters of the subroutine PLIS.
+  RPAR(9)   I   DOUBLE PRECISION parameters:
+                  RPAR(1)=XMAX,  RPAR(2)=TOLX,  RPAR(3)=TOLF,
+                  RPAR(4)=TOLB,  RPAR(5)=TOLG,  RPAR(6)=FMIN,
+                  RPAR(7)-NONE,  RPAR(6)-NONE,  RPAR(9)-NONE.
+                Parameters XMAX, TOLX, TOLF, TOLB, TOLG, FMIN are
+                described in Section 3 together with other parameters
+                of the subroutine PLIS.
+  F         O   DOUBLE PRECISION value of the objective function at the
+                solution X.
+  GMAX      O   DOUBLE PRECISION maximum absolute value of a partial
+                derivative of the Lagrangian function.
+  IPRNT     I   INTEGER variable that specifies PRINT:
+                  IPRNT= 0 - print is suppressed,
+                  IPRNT= 1 - basic print of final results,
+                  IPRNT=-1 - extended print of final results,
+                  IPRNT= 2 - basic print of intermediate and final
+                             results,
+                  IPRNT=-2 - extended print of intermediate and final
+                             results.
+  ITERM     O   INTEGER variable that indicates the cause of termination:
+                  ITERM= 1 - if |X - XO| was less than or equal to TOLX
+                             in two subsequent iterations,
+                  ITERM= 2 - if |F - FO| was less than or equal to TOLF
+                             in two subsequent iterations,
+                  ITERM= 3 - if F is less than or equal to TOLB,
+                  ITERM= 4 - if GMAX is less than or equal to TOLG,
+                  ITERM= 6 - if termination criterion was not satisfied,
+                             but the solution is probably acceptable,
+                  ITERM=11 - if NIT exceeded MIT,
+                  ITERM=12 - if NFV exceeded MFV,
+                  ITERM< 0 - if the method failed.
+
+      The subroutines PLISU, PLISS require the user supplied subroutines
+OBJ and DOBJ that define the objective function and its gradient and
+have the form
+
+      SUBROUTINE  OBJ(NF,X,F)
+      SUBROUTINE DOBJ(NF,X,G)
+
+The arguments of the user supplied subroutines have the following
+meaning.
+
+ Argument  Type Significance
+ ----------------------------------------------------------------------
+  NF        I   Positive INTEGER variable that specifies the number of
+                variables of the objective function.
+  X(NF)     I   DOUBLE PRECISION an estimate to the solution.
+  F         O   DOUBLE PRECISION value of the objective function at the
+                point X.
+  G(NF)     O   DOUBLE PRECISION gradient of the objective function
+                at the point X.
+
+
+3. Subroutine PLIS:
+-------------------
+
+      This general subroutine is called from all subroutines described
+in Section 2. The calling sequence is
+
+      CALL PLIS(NF,NB,X,IX,XL,XU,GF,S,XO,GO,UO,VO,XMAX,TOLX,TOLF,TOLB,
+     & TOLG,FMIN,GMAX,F,MIT,MFV,IEST,MF,IPRNT,ITERM)
+
+The arguments NF, NB, X, IX, XL, XU, GMAX, F, IPRNT, ITERM, have the
+same meaning as in Section 2. Other arguments have the following meaning:
+
+ Argument  Type Significance
+ ----------------------------------------------------------------------
+  GF(NF)    A   DOUBLE PRECISION gradient of the objective function.
+  S(NF)     A   DOUBLE PRECISION direction vector.
+  XO(NF*MF) A   DOUBLE PRECISION array which contains increments of
+                variables.
+  GO(NF*MF) A   DOUBLE PRECISION array which contains increments of
+                gradients.
+  UO(MF)    A   DOUBLE PRECISION Auxiliary array.
+  VO(MF)    A   DOUBLE PRECISION Auxiliary array.
+  XMAX      I   DOUBLE PRECISION maximum stepsize; the choice XMAX=0
+                causes that the default value 1.0D+16 will be taken.
+  TOLX      I   DOUBLE PRECISION tolerance for the change of the
+                coordinate vector X; the choice TOLX=0 causes that the
+                default value TOLX=1.0D-16 will be taken.
+  TOLF      I   DOUBLE PRECISION tolerance for the change of function
+                values; the choice TOLF=0 causes that the default
+                value TOLF=1.0D-14 will be taken.
+  TOLB      I   DOUBLE PRECISION minimum acceptable function value;
+                the choice TOLB=0 causes that the default value
+                TOLB=FMIN+1.0D-16 will be taken.
+  TOLG      I   DOUBLE PRECISION tolerance for the Lagrangian function
+                gradient; the choice TOLG=0 causes that the default
+                value TOLG=1.0D-6 will be taken.
+  FMIN      I   DOUBLE PRECISION lower bound for the minimum function
+                value.
+  MIT       I   INTEGER variable that specifies the maximum number of
+                iterations; the choice MIT=0 causes that the default
+                value 9000 will be taken.
+  MFV       I   INTEGER variable that specifies the maximum number of
+                function evaluations; the choice MFV=0 causes that
+                the default value 9000 will be taken.
+  IEST      I   INTEGER estimation of the minimum functiom value for
+                the line search:
+                  IEST=0 - estimation is not used,
+                  IEST=1 - lower bound FMIN is used as an estimation
+                           for the minimum function value.
+  MF        I   The number of limited-memory variable metric updates
+                in each iteration (they use 2*MF stored vectors).
+
+The choice of parameter XMAX can be sensitive in many cases. First, the
+objective function can be evaluated only in a relatively small region
+(if it contains exponentials) so that the maximum stepsize is necessary.
+Secondly, the problem can be very ill-conditioned far from the solution
+point so that large steps can be unsuitable. Finally, if the problem has
+more local solutions, a suitably chosen maximum stepsize can lead to
+obtaining a better local solution.
+      The subroutine PLIS requires the user supplied subroutines OBJ
+and DOBJ which are described in Section 2.
+
+4. Verification of the subroutines:
+-----------------------------------
+
+      Subroutine PLISU can be verified and tested using the program
+TLISU. This program calls the subroutines TIUD14 (initiation), TFFU14
+(function evaluation) and TFGU14 (gradient evaluation) containing
+22 unconstrained test problems with at most 1000 variables [2]. The
+results obtained by the program TLISU on a PC computer with Microsoft
+Power Station Fortran compiler have the following form.
+
+NIT= 4988  NFV= 5554  NFG= 5554  F= 0.963780013E-14  G= 0.891E-06  ITERM=  4
+NIT=  425  NFV=  454  NFG=  454  F=  14.9944763      G= 0.773E-05  ITERM=  2
+NIT=   74  NFV=   78  NFG=   78  F= 0.655101686E-09  G= 0.539E-06  ITERM=  4
+NIT=  103  NFV=  112  NFG=  112  F=  269.499543      G= 0.899E-06  ITERM=  4
+NIT=   24  NFV=   26  NFG=   26  F= 0.130639280E-11  G= 0.671E-06  ITERM=  4
+NIT=   30  NFV=   31  NFG=   31  F= 0.216102227E-10  G= 0.946E-06  ITERM=  4
+NIT=   38  NFV=   43  NFG=   43  F=  335.137433      G= 0.730E-06  ITERM=  4
+NIT=   29  NFV=   33  NFG=   33  F=  761774.954      G= 0.432E-03  ITERM=  2
+NIT=   13  NFV=   16  NFG=   16  F=  316.436141      G= 0.369E-06  ITERM=  4
+NIT= 1540  NFV= 1582  NFG= 1582  F= -124.630000      G= 0.124E-04  ITERM=  2
+NIT=  114  NFV=  138  NFG=  138  F=  10.7765879      G= 0.380E-06  ITERM=  4
+NIT=  248  NFV=  267  NFG=  267  F=  982.273617      G= 0.123E-04  ITERM=  2
+NIT=    7  NFV=    8  NFG=    8  F= 0.165734137E-12  G= 0.453E-06  ITERM=  4
+NIT=   10  NFV=   12  NFG=   12  F= 0.128729169E-08  G= 0.916E-06  ITERM=  4
+NIT= 2830  NFV= 2929  NFG= 2929  F=  1.92401599      G= 0.936E-06  ITERM=  4
+NIT=  196  NFV=  210  NFG=  210  F= -427.404476      G= 0.991E-05  ITERM=  2
+NIT= 1007  NFV= 1032  NFG= 1032  F=-0.379921091E-01  G= 0.876E-06  ITERM=  4
+NIT= 1449  NFV= 1474  NFG= 1474  F=-0.245741193E-01  G= 0.862E-06  ITERM=  4
+NIT= 1393  NFV= 1431  NFG= 1431  F=  59.5986241      G= 0.259E-05  ITERM=  2
+NIT= 2129  NFV= 2191  NFG= 2191  F= -1.00013520      G= 0.908E-06  ITERM=  4
+NIT= 2120  NFV= 2169  NFG= 2169  F=  2.13866377      G= 0.927E-06  ITERM=  4
+NIT= 1305  NFV= 1346  NFG= 1346  F=  1.00000000      G= 0.982E-06  ITERM=  4
+NITER =20072    NFVAL =21136    NSUCC =   22
+TIME= 0:00:10.78
+
+The rows corresponding to individual test problems contain the number of
+iterations NIT, the number of function evaluations NFV, the number of
+gradient evaluations NFG, the final value of the objective function F,
+the norm of gradient G and the cause of termination ITERM.
+      Subroutine PLISS can be verified and tested using the program
+TLISS. This program calls the subroutines TIUD14 (initiation), TFFU14
+(function evaluation), TFGU14 (gradient evaluation) containing 22 box
+constrained test problems with at most 1000 variables [2]. The results
+obtained by the program TLISS on a PC computer with Microsoft Power
+Station Fortran compiler have the following form.
+
+NIT= 5063  NFV= 5738  NFG= 5738  F=  0.00000000      G= 0.000E+00  ITERM=  3
+NIT= 3167  NFV= 4664  NFG= 4664  F=  3926.45961      G= 0.626E-04  ITERM=  2
+NIT=  113  NFV=  124  NFG=  124  F= 0.459503394E-12  G= 0.600E-06  ITERM=  4
+NIT=   59  NFV=   64  NFG=   64  F=  269.522686      G= 0.838E-06  ITERM=  4
+NIT=   24  NFV=   26  NFG=   26  F= 0.130639280E-11  G= 0.671E-06  ITERM=  4
+NIT=   30  NFV=   31  NFG=   31  F= 0.216102227E-10  G= 0.946E-06  ITERM=  4
+NIT=   33  NFV=   40  NFG=   40  F=  337.722479      G= 0.592E-06  ITERM=  4
+NIT=   50  NFV=   55  NFG=   55  F=  761925.725      G= 0.240E-03  ITERM=  2
+NIT=  505  NFV=  508  NFG=  508  F=  428.056916      G= 0.334E-07  ITERM=  4
+NIT= 1167  NFV= 1227  NFG= 1227  F= -81.0913589      G= 0.100E-04  ITERM=  2
+NIT=   20  NFV=   26  NFG=   26  F=  96517.2947      G= 0.745E-05  ITERM=  2
+NIT=   91  NFV=  109  NFG=  109  F=  4994.21410      G= 0.104E-04  ITERM=  2
+NIT=    7  NFV=    8  NFG=    8  F= 0.165734137E-12  G= 0.453E-06  ITERM=  4
+NIT=   10  NFV=   12  NFG=   12  F= 0.128729169E-08  G= 0.916E-06  ITERM=  4
+NIT= 2830  NFV= 2929  NFG= 2929  F=  1.92401599      G= 0.936E-06  ITERM=  4
+NIT=  178  NFV=  184  NFG=  184  F= -427.391653      G= 0.107E-04  ITERM=  2
+NIT= 1007  NFV= 1032  NFG= 1032  F=-0.379921091E-01  G= 0.876E-06  ITERM=  4
+NIT= 1449  NFV= 1474  NFG= 1474  F=-0.245741193E-01  G= 0.862E-06  ITERM=  4
+NIT= 1561  NFV= 1595  NFG= 1595  F=  1654.94525      G= 0.112E-04  ITERM=  2
+NIT= 2075  NFV= 2121  NFG= 2121  F= -1.00013520      G= 0.916E-06  ITERM=  4
+NIT= 1361  NFV= 1389  NFG= 1389  F=  2.41354873      G= 0.709E-06  ITERM=  4
+NIT= 1562  NFV= 1598  NFG= 1598  F=  1.00000000      G= 0.786E-06  ITERM=  4
+NITER =22362    NFVAL =24954    NSUCC =   22
+TIME= 0:00:12.39
+
+References:
+-----------
+
+[1] Luksan L., Matonoha C., Vlcek J.: LSA: Algorithms for large-scale
+    unconstrained and box constrained optimization Technical Report V-896.
+    Prague, ICS AS CR, 2004.
+
+[2] Luksan L., Vlcek J.: Sparse and partially separable test problems
+    for unconstrained and equality constrained optimization. Research
+    Report V-767, Institute of Computer Science, Academy of Sciences
+    of the Czech Republic, Prague, Czech Republic, 1998.
diff --git a/luksan/pnet.c b/luksan/pnet.c
new file mode 100644 (file)
index 0000000..d57461c
--- /dev/null
@@ -0,0 +1,664 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "luksan.h"
+
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define MIN2(a,b) ((a) < (b) ? (a) : (b))
+
+/* Table of constant values */
+
+static double c_b7 = 0.;
+
+/* *********************************************************************** */
+/* SUBROUTINE PNET               ALL SYSTEMS                   01/09/22 */
+/* PURPOSE : */
+/* GENERAL SUBROUTINE FOR LARGE-SCALE BOX CONSTRAINED MINIMIZATION THAT */
+/* USE THE LIMITED MEMORY VARIABLE METRIC METHOD BASED ON THE STRANG */
+/* RECURRENCES. */
+
+/* PARAMETERS : */
+/*  II  NF  NUMBER OF VARIABLES. */
+/*  II  NB  CHOICE OF SIMPLE BOUNDS. NB=0-SIMPLE BOUNDS SUPPRESSED. */
+/*         NB>0-SIMPLE BOUNDS ACCEPTED. */
+/*  RI  X(NF)  VECTOR OF VARIABLES. */
+/*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS. IX(I)=0-VARIABLE */
+/*         X(I) IS UNBOUNDED. IX(I)=1-LOVER BOUND XL(I).LE.X(I). */
+/*         IX(I)=2-UPPER BOUND X(I).LE.XU(I). IX(I)=3-TWO SIDE BOUND */
+/*         XL(I).LE.X(I).LE.XU(I). IX(I)=5-VARIABLE X(I) IS FIXED. */
+/*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES. */
+/*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES. */
+/*  RO  GF(NF)  GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*  RA  GN(NF)  OLD GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*  RO  S(NF)  DIRECTION VECTOR. */
+/*  RA  XO(NF)  ARRAY CONTAINING INCREMENTS OF VARIABLES. */
+/*  RA  GO(NF)  ARRAY CONTAINING INCREMENTS OF GRADIENTS. */
+/*  RA  XS(NF)  AUXILIARY VECTOR. */
+/*  RA  GS(NF)  AUXILIARY VECTOR. */
+/*  RA  XM(NF*MF)  ARRAY CONTAINING INCREMENTS OF VARIABLES. */
+/*  RA  GM(NF*MF)  ARRAY CONTAINING INCREMENTS OF GRADIENTS. */
+/*  RA  U1(MF)  AUXILIARY VECTOR. */
+/*  RA  U2(MF)  AUXILIARY VECTOR. */
+/*  RI  XMAX  MAXIMUM STEPSIZE. */
+/*  RI  TOLX  TOLERANCE FOR CHANGE OF VARIABLES. */
+/*  RI  TOLF  TOLERANCE FOR CHANGE OF FUNCTION VALUES. */
+/*  RI  TOLB  TOLERANCE FOR THE FUNCTION VALUE. */
+/*  RI  TOLG  TOLERANCE FOR THE GRADIENT NORM. */
+/*  RI  MINF_EST  ESTIMATION OF THE MINIMUM FUNCTION VALUE. */
+/*  RO  GMAX  MAXIMUM PARTIAL DERIVATIVE. */
+/*  RO  F  VALUE OF THE OBJECTIVE FUNCTION. */
+/*  II  MIT  MAXIMUM NUMBER OF ITERATIONS. */
+/*  II  MFV  MAXIMUM NUMBER OF FUNCTION EVALUATIONS. */
+/*  II  MFG  MAXIMUM NUMBER OF GRADIENT EVALUATIONS. */
+/*  II  IEST  ESTIMATION INDICATOR. IEST=0-MINIMUM IS NOT ESTIMATED. */
+/*         IEST=1-MINIMUM IS ESTIMATED BY THE VALUE MINF_EST. */
+/*  II  MOS1  CHOICE OF RESTARTS AFTER A CONSTRAINT CHANGE. */
+/*         MOS1=1-RESTARTS ARE SUPPRESSED. MOS1=2-RESTARTS WITH */
+/*         STEEPEST DESCENT DIRECTIONS ARE USED. */
+/*  II  MOS1  CHOICE OF DIRECTION VECTORS AFTER RESTARTS. MOS1=1-THE */
+/*         NEWTON DIRECTIONS ARE USED. MOS1=2-THE STEEPEST DESCENT */
+/*         DIRECTIONS ARE USED. */
+/*  II  MOS2  CHOICE OF PRECONDITIONING STRATEGY. MOS2=1-PRECONDITIONING */
+/*         IS NOT USED. MOS2=2-PRECONDITIONING BY THE LIMITED MEMORY */
+/*         BFGS METHOD IS USED. */
+/*  II  MF  THE NUMBER OF LIMITED-MEMORY VARIABLE METRIC UPDATES */
+/*         IN EACH ITERATION (THEY USE 2*MF STORED VECTORS). */
+/*  IO  ITERM  VARIABLE THAT INDICATES THE CAUSE OF TERMINATION. */
+/*         ITERM=1-IF ABS(X-XO) WAS LESS THAN OR EQUAL TO TOLX IN */
+/*                   MTESX (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=2-IF ABS(F-FO) WAS LESS THAN OR EQUAL TO TOLF IN */
+/*                   MTESF (USUALLY TWO) SUBSEQUEBT ITERATIONS. */
+/*         ITERM=3-IF F IS LESS THAN OR EQUAL TO TOLB. */
+/*         ITERM=4-IF GMAX IS LESS THAN OR EQUAL TO TOLG. */
+/*         ITERM=6-IF THE TERMINATION CRITERION WAS NOT SATISFIED, */
+/*                   BUT THE SOLUTION OBTAINED IS PROBABLY ACCEPTABLE. */
+/*         ITERM=11-IF NIT EXCEEDED MIT. ITERM=12-IF NFV EXCEEDED MFV. */
+/*         ITERM=13-IF NFG EXCEEDED MFG. ITERM<0-IF THE METHOD FAILED. */
+
+/* VARIABLES IN COMMON /STAT/ (STATISTICS) : */
+/*  IO  NRES  NUMBER OF RESTARTS. */
+/*  IO  NDEC  NUMBER OF MATRIX DECOMPOSITION. */
+/*  IO  NIN  NUMBER OF INNER ITERATIONS. */
+/*  IO  NIT  NUMBER OF ITERATIONS. */
+/*  IO  NFV  NUMBER OF FUNCTION EVALUATIONS. */
+/*  IO  NFG  NUMBER OF GRADIENT EVALUATIONS. */
+/*  IO  NFH  NUMBER OF HESSIAN EVALUATIONS. */
+
+/* SUBPROGRAMS USED : */
+/*  S   PCBS04  ELIMINATION OF BOX CONSTRAINT VIOLATIONS. */
+/*  S   PS1L01  STEPSIZE SELECTION USING LINE SEARCH. */
+/*  S   PYADC0  ADDITION OF A BOX CONSTRAINT. */
+/*  S   PYFUT1  TEST ON TERMINATION. */
+/*  S   PYRMC0  DELETION OF A BOX CONSTRAINT. */
+/*  S   PYTRCD  COMPUTATION OF PROJECTED DIFFERENCES FOR THE VARIABLE METRIC */
+/*         UPDATE. */
+/*  S   PYTRCG  COMPUTATION OF THE PROJECTED GRADIENT. */
+/*  S   PYTRCS  COMPUTATION OF THE PROJECTED DIRECTION VECTOR. */
+/*  S   MXDRCB BACKWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION */
+/*         OF THE VECTOR X BY AN IMPLICIT BFGS UPDATE. */
+/*  S   MXDRCF FORWARD PART OF THE STRANG FORMULA FOR PREMULTIPLICATION */
+/*         OF THE VECTOR X BY AN IMPLICIT BFGS UPDATE. */
+/*  S   MXDRSU SHIFT OF COLUMNS OF THE RECTANGULAR MATRICES A AND B. */
+/*         SHIFT OF ELEMENTS OF THE VECTOR U. THESE SHIFTS ARE USED IN */
+/*         THE LIMITED MEMORY BFGS METHOD. */
+/*  S   MXUDIR  VECTOR AUGMENTED BY THE SCALED VECTOR. */
+/*  RF  MXUDOT  DOT PRODUCT OF TWO VECTORS. */
+/*  S   MXVNEG  COPYING OF A VECTOR WITH CHANGE OF THE SIGN. */
+/*  S   MXVCOP  COPYING OF A VECTOR. */
+/*  S   MXVSCL  SCALING OF A VECTOR. */
+/*  S   MXVSET  INITIATINON OF A VECTOR. */
+/*  S   MXVDIF  DIFFERENCE OF TWO VECTORS. */
+
+/* EXTERNAL SUBROUTINES : */
+/*  SE  OBJ  COMPUTATION OF THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL OBJ(NF,X,FF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND FF IS */
+/*         THE VALUE OF THE OBJECTIVE FUNCTION. */
+/*  SE  DOBJ  COMPUTATION OF THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/*         CALLING SEQUENCE: CALL DOBJ(NF,X,GF) WHERE NF IS THE NUMBER */
+/*         OF VARIABLES, X(NF) IS THE VECTOR OF VARIABLES AND GF(NF) */
+/*         IS THE GRADIENT OF THE OBJECTIVE FUNCTION. */
+/* -- OBJ and DOBJ are replaced by a single function, objgrad, in NLopt */
+
+/* METHOD : */
+/* LIMITED MEMORY VARIABLE METRIC METHOD BASED ON THE STRANG */
+/* RECURRENCES. */
+
+static void pnet_(int *nf, int *nb, double *x, int *
+                 ix, double *xl, double *xu, double *gf, double *gn, 
+                 double *s, double *xo, double *go, double *xs, 
+                 double *gs, double *xm, double *gm, double *u1, 
+                 double *u2, double *xmax, double *tolx, double *tolf, 
+                 double *tolb, double *tolg, nlopt_stopping *stop,
+                 double *minf_est, double *
+                 gmax, double *f, int *mit, int *mfv, int *mfg, 
+                 int *iest, int *mos1, int *mos2, int *mf, 
+                 int *iterm, stat_common *stat_1,
+                 nlopt_func objgrad, void *objgrad_data)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Builtin functions */
+
+    /* Local variables */
+    double a, b;
+    int i__, n;
+    double p, r__;
+    int kd, ld;
+    double fo, fp, po, pp, ro, rp;
+    int mx, kbf;
+    double alf;
+    double par;
+    int mes, kit;
+    double rho, eps;
+    int mmx;
+    double alf1, alf2, eta0, eta9, par1, par2;
+    int mes1, mes2, mes3;
+    double rho1, rho2, eps8, eps9;
+    int mred, iold, nred;
+    double maxf, dmax__;
+    int xstop = 0;
+    int inew;
+    double told;
+    int ites;
+    double rmin, rmax, umax, tolp, tols;
+    int isys;
+    int ires1, ires2;
+    int iterd, mtesf, ntesf;
+    double gnorm;
+    int iters, irest, inits, kters, maxst;
+    double snorm;
+    int mtesx, ntesx;
+    ps1l01_state state;
+
+/*     INITIATION */
+
+    /* Parameter adjustments */
+    --u2;
+    --u1;
+    --gm;
+    --xm;
+    --gs;
+    --xs;
+    --go;
+    --xo;
+    --s;
+    --gn;
+    --gf;
+    --xu;
+    --xl;
+    --ix;
+    --x;
+
+    /* Function Body */
+    kbf = 0;
+    if (*nb > 0) {
+       kbf = 2;
+    }
+    stat_1->nres = 0;
+    stat_1->ndec = 0;
+    stat_1->nin = 0;
+    stat_1->nit = 0;
+    stat_1->nfg = 0;
+    stat_1->nfh = 0;
+    isys = 0;
+    ites = 1;
+    mtesx = 2;
+    mtesf = 2;
+    inits = 2;
+    *iterm = 0;
+    iterd = 0;
+    iters = 2;
+    kters = 3;
+    irest = 0;
+    ires1 = 999;
+    ires2 = 0;
+    mred = 10;
+    mes = 4;
+    mes1 = 2;
+    mes2 = 2;
+    mes3 = 2;
+    eps = .8;
+    eta0 = 1e-15;
+    eta9 = 1e120;
+    eps8 = 1.;
+    eps9 = 1e-8;
+    alf1 = 1e-10;
+    alf2 = 1e10;
+    rmax = eta9;
+    dmax__ = eta9;
+    maxf = 1e20;
+    if (*iest <= 0) {
+        *minf_est = -HUGE_VAL; /* changed from -1e60 by SGJ */
+    }
+    if (*iest > 0) {
+       *iest = 1;
+    }
+    if (*xmax <= 0.) {
+       *xmax = 1e16;
+    }
+    if (*tolx <= 0.) {
+       *tolx = 1e-16;
+    }
+    if (*tolf <= 0.) {
+       *tolf = 1e-14;
+    }
+    if (*tolg <= 0.) {
+        *tolg = 1e-8; /* SGJ: was 1e-6, but this sometimes stops too soon */
+    }
+#if 0
+    /* removed by SGJ: this check prevented us from using minf_max <= 0,
+       which doesn't make sense.  Instead, if you don't want to have a
+       lower limit, you should set minf_max = -HUGE_VAL */
+    if (*tolb <= 0.) {
+       *tolb = *minf_est + 1e-16;
+    }
+#endif
+    told = 1e-4;
+    tols = 1e-4;
+    tolp = .9;
+    /* changed by SGJ: default is no limit (INT_MAX) on # iterations/fevals */
+    if (*mit <= 0) {
+       *mit = INT_MAX;
+    }
+    if (*mfv <= 0) {
+       *mfv = INT_MAX;
+    }
+    if (*mfg <= 0) {
+       *mfg = INT_MAX;
+    }
+    if (*mos1 <= 0) {
+       *mos1 = 1;
+    }
+    if (*mos2 <= 0) {
+       *mos2 = 1;
+    }
+    kd = 1;
+    ld = -1;
+    kit = -(ires1 * *nf + ires2);
+    fo = *minf_est;
+
+/*     INITIAL OPERATIONS WITH SIMPLE BOUNDS */
+
+    if (kbf > 0) {
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if ((ix[i__] == 3 || ix[i__] == 4) && xu[i__] <= xl[i__]) {
+               xu[i__] = xl[i__];
+               ix[i__] = 5;
+           } else if (ix[i__] == 5 || ix[i__] == 6) {
+               xl[i__] = x[i__];
+               xu[i__] = x[i__];
+               ix[i__] = 5;
+           }
+/* L2: */
+       }
+       luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+    }
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11080; }
+    ld = kd;
+L11020:
+    luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
+    luksan_mxvcop__(nf, &gf[1], &gn[1]);
+    luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg, 
+           &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, mfg, &
+           ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
+           iters, iterm);
+    if (*iterm != 0) {
+       goto L11080;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11080; }
+    if (kbf > 0) {
+       luksan_pyrmc0__(nf, &n, &ix[1], &gn[1], &eps8, &umax, gmax, &rmax, &
+               iold, &irest);
+       if (umax > eps8 * *gmax) {
+           irest = MAX2(irest,1);
+       }
+    }
+    luksan_mxvcop__(nf, &x[1], &xo[1]);
+L11040:
+
+/*     DIRECTION DETERMINATION */
+
+    if (irest != 0) {
+       if (kit < stat_1->nit) {
+           mx = 0;
+           ++stat_1->nres;
+           kit = stat_1->nit;
+       } else {
+           *iterm = -10;
+           if (iters < 0) {
+               *iterm = iters - 5;
+           }
+           goto L11080;
+       }
+       if (*mos1 > 1) {
+           luksan_mxvneg__(nf, &gn[1], &s[1]);
+           gnorm = sqrt(luksan_mxudot__(nf, &gn[1], &gn[1], &ix[1], &kbf));
+           snorm = gnorm;
+           goto L12560;
+       }
+    }
+    rho1 = luksan_mxudot__(nf, &gn[1], &gn[1], &ix[1], &kbf);
+    gnorm = sqrt(rho1);
+/* Computing MIN */
+    d__1 = eps, d__2 = sqrt(gnorm);
+    par = MIN2(d__1,d__2);
+    if (par > .01) {
+/* Computing MIN */
+       d__1 = par, d__2 = 1. / (double) stat_1->nit;
+       par = MIN2(d__1,d__2);
+    }
+    par *= par;
+
+/*     CG INITIATION */
+
+    rho = rho1;
+    snorm = 0.;
+    luksan_mxvset__(nf, &c_b7, &s[1]);
+    luksan_mxvneg__(nf, &gn[1], &gs[1]);
+    luksan_mxvcop__(nf, &gs[1], &xs[1]);
+    if (*mos2 > 1) {
+       if (mx == 0) {
+           b = 0.;
+       } else {
+           b = luksan_mxudot__(nf, &xm[1], &gm[1], &ix[1], &kbf);
+       }
+       if (b > 0.) {
+           u1[1] = 1. / b;
+           luksan_mxdrcb__(nf, &mx, &xm[1], &gm[1], &u1[1], &u2[1], &xs[1], &
+                   ix[1], &kbf);
+           a = luksan_mxudot__(nf, &gm[1], &gm[1], &ix[1], &kbf);
+           if (a > 0.) {
+               d__1 = b / a;
+               luksan_mxvscl__(nf, &d__1, &xs[1], &xs[1]);
+           }
+           luksan_mxdrcf__(nf, &mx, &xm[1], &gm[1], &u1[1], &u2[1], &xs[1], &
+                   ix[1], &kbf);
+       }
+    }
+    rho = luksan_mxudot__(nf, &gs[1], &xs[1], &ix[1], &kbf);
+/*      SIG=RHO */
+    mmx = *nf + 3;
+    nred = 0;
+L12520:
+    ++nred;
+    if (nred > mmx) {
+       goto L12550;
+    }
+    fo = *f;
+    pp = sqrt(eta0 / luksan_mxudot__(nf, &xs[1], &xs[1], &ix[1], &kbf));
+    ld = 0;
+    luksan_mxudir__(nf, &pp, &xs[1], &xo[1], &x[1], &ix[1], &kbf);
+    objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    ld = kd;
+    luksan_mxvdif__(nf, &gf[1], &gn[1], &go[1]);
+    *f = fo;
+    d__1 = 1. / pp;
+    luksan_mxvscl__(nf, &d__1, &go[1], &go[1]);
+    alf = luksan_mxudot__(nf, &xs[1], &go[1], &ix[1], &kbf);
+    if (alf <= 1. / eta9) {
+/*      IF (ALF.LE.1.0D-8*SIG) THEN */
+
+/*     CG FAILS (THE MATRIX IS NOT POSITIVE DEFINITE) */
+
+       if (nred == 1) {
+           luksan_mxvneg__(nf, &gn[1], &s[1]);
+           snorm = gnorm;
+       }
+       iterd = 0;
+       goto L12560;
+    } else {
+       iterd = 2;
+    }
+
+/*     CG STEP */
+
+    alf = rho / alf;
+    luksan_mxudir__(nf, &alf, &xs[1], &s[1], &s[1], &ix[1], &kbf);
+    d__1 = -alf;
+    luksan_mxudir__(nf, &d__1, &go[1], &gs[1], &gs[1], &ix[1], &kbf);
+    rho2 = luksan_mxudot__(nf, &gs[1], &gs[1], &ix[1], &kbf);
+    snorm = sqrt(luksan_mxudot__(nf, &s[1], &s[1], &ix[1], &kbf));
+    if (rho2 <= par * rho1) {
+       goto L12560;
+    }
+    if (nred >= mmx) {
+       goto L12550;
+    }
+    if (*mos2 > 1) {
+       if (b > 0.) {
+           luksan_mxvcop__(nf, &gs[1], &go[1]);
+           luksan_mxdrcb__(nf, &mx, &xm[1], &gm[1], &u1[1], &u2[1], &go[1], &
+                   ix[1], &kbf);
+           if (a > 0.) {
+               d__1 = b / a;
+               luksan_mxvscl__(nf, &d__1, &go[1], &go[1]);
+           }
+           luksan_mxdrcf__(nf, &mx, &xm[1], &gm[1], &u1[1], &u2[1], &go[1], &
+                   ix[1], &kbf);
+           rho2 = luksan_mxudot__(nf, &gs[1], &go[1], &ix[1], &kbf);
+           alf = rho2 / rho;
+           luksan_mxudir__(nf, &alf, &xs[1], &go[1], &xs[1], &ix[1], &kbf);
+       } else {
+           alf = rho2 / rho;
+           luksan_mxudir__(nf, &alf, &xs[1], &gs[1], &xs[1], &ix[1], &kbf);
+       }
+    } else {
+       alf = rho2 / rho;
+       luksan_mxudir__(nf, &alf, &xs[1], &gs[1], &xs[1], &ix[1], &kbf);
+    }
+    rho = rho2;
+/*      SIG=RHO2+ALF*ALF*SIG */
+    goto L12520;
+L12550:
+
+/*     AN INEXACT SOLUTION IS OBTAINED */
+
+L12560:
+
+/*     ------------------------------ */
+/*     END OF DIRECTION DETERMINATION */
+/*     ------------------------------ */
+
+    luksan_mxvcop__(nf, &xo[1], &x[1]);
+    luksan_mxvcop__(nf, &gn[1], &gf[1]);
+    if (kd > 0) {
+       p = luksan_mxudot__(nf, &gn[1], &s[1], &ix[1], &kbf);
+    }
+    if (iterd < 0) {
+       *iterm = iterd;
+    } else {
+
+/*     TEST ON DESCENT DIRECTION */
+
+       if (snorm <= 0.) {
+           irest = MAX2(irest,1);
+       } else if (p + told * gnorm * snorm <= 0.) {
+           irest = 0;
+       } else {
+
+/*     UNIFORM DESCENT CRITERION */
+
+           irest = MAX2(irest,1);
+       }
+       if (irest == 0) {
+
+/*     PREPARATION OF LINE SEARCH */
+
+           nred = 0;
+           rmin = alf1 * gnorm / snorm;
+/* Computing MIN */
+           d__1 = alf2 * gnorm / snorm, d__2 = *xmax / snorm;
+           rmax = MIN2(d__1,d__2);
+       }
+    }
+    ld = kd;
+    if (*iterm != 0) {
+       goto L11080;
+    }
+    if (nlopt_stop_time(stop)) { *iterm = 100; goto L11080; }
+    if (irest != 0) {
+       goto L11040;
+    }
+    luksan_pytrcs__(nf, &x[1], &ix[1], &xo[1], &xl[1], &xu[1], &gf[1], &go[1],
+            &s[1], &ro, &fp, &fo, f, &po, &p, &rmax, &eta9, &kbf);
+    if (rmax == 0.) {
+       goto L11075;
+    }
+L11060:
+    luksan_ps1l01__(&r__, &rp, f, &fo, &fp, &p, &po, &pp, minf_est, &maxf, &rmin, 
+           &rmax, &tols, &tolp, &par1, &par2, &kd, &ld, &stat_1->nit, &kit, &
+           nred, &mred, &maxst, iest, &inits, &iters, &kters, &mes,
+                   &isys, &state);
+    if (isys == 0) {
+       goto L11064;
+    }
+    luksan_mxudir__(nf, &r__, &s[1], &xo[1], &x[1], &ix[1], &kbf);
+    luksan_pcbs04__(nf, &x[1], &ix[1], &xl[1], &xu[1], &eps9, &kbf);
+    *f = objgrad(*nf, &x[1], &gf[1], objgrad_data);
+    ++stop->nevals;
+    ++stat_1->nfg;
+    ld = kd;
+    p = luksan_mxudot__(nf, &gf[1], &s[1], &ix[1], &kbf);
+    goto L11060;
+L11064:
+    if (iters <= 0) {
+       r__ = 0.;
+       *f = fo;
+       p = po;
+       luksan_mxvcop__(nf, &xo[1], &x[1]);
+       luksan_mxvcop__(nf, &go[1], &gf[1]);
+       irest = MAX2(irest,1);
+       ld = kd;
+       goto L11040;
+    }
+    luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
+           p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+    xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
+    if (*mos2 > 1) {
+/* Computing MIN */
+       i__1 = mx + 1;
+       mx = MIN2(i__1,*mf);
+       luksan_mxdrsu__(nf, &mx, &xm[1], &gm[1], &u1[1]);
+       luksan_mxvcop__(nf, &xo[1], &xm[1]);
+       luksan_mxvcop__(nf, &go[1], &gm[1]);
+    }
+L11075:
+    if (kbf > 0) {
+       luksan_pyadc0__(nf, &n, &x[1], &ix[1], &xl[1], &xu[1], &inew);
+       if (inew > 0) {
+           irest = MAX2(irest,1);
+       }
+    }
+    goto L11020;
+L11080:
+    return;
+} /* pnet_ */
+
+/* NLopt wrapper around pnet_, handling dynamic allocation etc. */
+nlopt_result luksan_pnet(int n, nlopt_func f, void *f_data,
+                        const double *lb, const double *ub, /* bounds */
+                        double *x, /* in: initial guess, out: minimizer */
+                        double *minf, 
+                        nlopt_stopping *stop,
+                        int mf, /* subspace dimension (0 for default) */
+                        int mos1, int mos2) /* 1 or 2 */
+{
+     int i, *ix, nb = 1;
+     double *work;
+     double *xl, *xu, *gf, *gn, *s, *xo, *go, *xs, *gs, *xm, *gm, *u1, *u2;
+     double gmax, minf_est;
+     double xmax = 0; /* no maximum */
+     double tolg = 0; /* default gradient tolerance */
+     int iest = 0; /* we have no estimate of min function value */
+     int mit = 0, mfg = 0; /* default no limit on #iterations */
+     int mfv = stop->maxeval;
+     stat_common stat;
+     int iterm;
+
+     ix = (int*) malloc(sizeof(int) * n);
+     if (!ix) return NLOPT_OUT_OF_MEMORY;
+
+     if (mf <= 0) {
+         mf = MAX2(MEMAVAIL/n, 10);
+         if (stop->maxeval && stop->maxeval <= mf)
+              mf = MAX2(stop->maxeval, 1);
+     }
+
+ retry_alloc:
+     work = (double*) malloc(sizeof(double) * (n * 9 + MAX2(n,n*mf)*2 + 
+                                              MAX2(n,mf)*2));
+     if (!work) { 
+         if (mf > 0) {
+              mf = 0; /* allocate minimal memory */
+              goto retry_alloc;
+         }
+         free(ix);
+         return NLOPT_OUT_OF_MEMORY;
+     }
+
+     xl = work; xu = xl + n;
+     gf = xu + n; gn = gf + n; s = gn + n; 
+     xo = s + n; go = xo + n; xs = go + n; gs = xs + n;
+     xm = gs + n; gm = xm + MAX2(n*mf,n);
+     u1 = gm + MAX2(n*mf,n); u2 = u1 + MAX2(n,mf);
+
+     for (i = 0; i < n; ++i) {
+         int lbu = lb[i] <= -0.99 * HUGE_VAL; /* lb unbounded */
+         int ubu = ub[i] >= 0.99 * HUGE_VAL;  /* ub unbounded */
+         ix[i] = lbu ? (ubu ? 0 : 2) : (ubu ? 1 : (lb[i] == ub[i] ? 5 : 3));
+         xl[i] = lb[i];
+         xu[i] = ub[i];
+     }
+
+     /* ?  xo does not seem to be initialized in the
+       original Fortran code, but it is used upon
+       input to pnet if mf > 0 ... perhaps ALLOCATE initializes
+       arrays to zero by default? */
+     memset(xo, 0, sizeof(double) * MAX2(n,n*mf));
+
+     pnet_(&n, &nb, x, ix, xl, xu, 
+          gf, gn, s, xo, go, xs, gs, xm, gm, u1, u2,
+          &xmax,
+
+          /* fixme: pass tol_rel and tol_abs and use NLopt check */
+          &stop->xtol_rel,
+          &stop->ftol_rel,
+          &stop->minf_max,
+          &tolg,
+          stop,
+
+          &minf_est, &gmax,
+          minf,
+          &mit, &mfv, &mfg,
+          &iest,
+          &mos1, &mos2,
+          &mf,
+          &iterm, &stat,
+          f, f_data);
+
+     free(work);
+     free(ix);
+
+     switch (iterm) {
+        case 1: return NLOPT_XTOL_REACHED;
+        case 2: return NLOPT_FTOL_REACHED;
+        case 3: return NLOPT_MINF_MAX_REACHED;
+        case 4: return NLOPT_SUCCESS; /* gradient tolerance reached */
+        case 6: return NLOPT_SUCCESS;
+        case 12: case 13: return NLOPT_MAXEVAL_REACHED;
+        case 100: return NLOPT_MAXTIME_REACHED;
+        case -999: return NLOPT_FORCED_STOP;
+        default: return NLOPT_FAILURE;
+     }
+}
diff --git a/luksan/pssubs.c b/luksan/pssubs.c
new file mode 100644 (file)
index 0000000..cfec171
--- /dev/null
@@ -0,0 +1,1269 @@
+#include <math.h>
+#include "luksan.h"
+
+#define FALSE_ 0
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define MIN2(a,b) ((a) < (b) ? (a) : (b))
+#define iabs(a) ((a) < 0 ? -(a) : (a))
+
+/*     subroutines extracted from pssubs.for */
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PCBS04             ALL SYSTEMS                   98/12/01
+* PURPOSE :
+* INITIATION OF THE VECTOR CONTAINING TYPES OF CONSTRAINTS.
+*
+* PARAMETERS :
+*  II  NF  NUMBER OF VARIABLES.
+*  RI  X(NF)  VECTOR OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES.
+*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES.
+*  RI  EPS9  TOLERANCE FOR ACTIVE CONSTRAINTS.
+*  II  KBF  SPECIFICATION OF SIMPLE BOUNDS. KBF=0-NO SIMPLE BOUNDS.
+*         KBF=1-ONE SIDED SIMPLE BOUNDS. KBF=2=TWO SIDED SIMPLE BOUNDS.
+*/
+void luksan_pcbs04__(int *nf, double *x, int *ix, 
+       double *xl, double *xu, double *eps9, int *kbf)
+{
+    /* System generated locals */
+    int i__1, i__2;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__, ixi;
+    double temp;
+
+    /* Parameter adjustments */
+    --xu;
+    --xl;
+    --ix;
+    --x;
+
+    /* Function Body */
+    if (*kbf > 0) {
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           temp = 1.;
+           ixi = (i__2 = ix[i__], iabs(i__2));
+/* Computing MAX */
+           d__2 = (d__1 = xl[i__], fabs(d__1));
+           if ((ixi == 1 || ixi == 3 || ixi == 4) && x[i__] <= xl[i__] + *
+                   eps9 * MAX2(d__2,temp)) {
+               x[i__] = xl[i__];
+           }
+/* Computing MAX */
+           d__2 = (d__1 = xu[i__], fabs(d__1));
+           if ((ixi == 2 || ixi == 3 || ixi == 4) && x[i__] >= xu[i__] - *
+                   eps9 * MAX2(d__2,temp)) {
+               x[i__] = xu[i__];
+           }
+/* L1: */
+       }
+    }
+    return;
+} /* luksan_pcbs04__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PNINT1                ALL SYSTEMS                91/12/01 */
+/* PURPOSE : */
+/* EXTRAPOLATION OR INTERPOLATION FOR LINE SEARCH WITH DIRECTIONAL */
+/* DERIVATIVES. */
+
+/* PARAMETERS : */
+/*  RI  RL  LOWER VALUE OF THE STEPSIZE PARAMETER. */
+/*  RI  RU  UPPER VALUE OF THE STEPSIZE PARAMETER. */
+/*  RI  FL  VALUE OF THE OBJECTIVE FUNCTION FOR R=RL. */
+/*  RI  FU  VALUE OF THE OBJECTIVE FUNCTION FOR R=RU. */
+/*  RI  PL  DIRECTIONAL DERIVATIVE FOR R=RL. */
+/*  RI  PU  DIRECTIONAL DERIVATIVE FOR R=RU. */
+/*  RO  R  VALUE OF THE STEPSIZE PARAMETER OBTAINED. */
+/*  II  MODE  MODE OF LINE SEARCH. */
+/*  II  MTYP  METHOD SELECTION. MTYP=1-BISECTION. MTYP=2-QUADRATIC */
+/*         INTERPOLATION (WITH ONE DIRECTIONAL DERIVATIVE). */
+/*         MTYP=3-QUADRATIC INTERPOLATION (WITH TWO DIRECTIONAL */
+/*         DERIVATIVES). MTYP=4-CUBIC INTERPOLATION. MTYP=5-CONIC */
+/*         INTERPOLATION. */
+/*  IO  MERR  ERROR INDICATOR. MERR=0 FOR NORMAL RETURN. */
+
+/* METHOD : */
+/* EXTRAPOLATION OR INTERPOLATION WITH STANDARD MODEL FUNCTIONS. */
+
+void luksan_pnint1__(double *rl, double *ru, double *fl, 
+       double *fu, double *pl, double *pu, double *r__, 
+       int *mode, int *mtyp, int *merr)
+{
+    /* System generated locals */
+    double d__1, d__2;
+
+    /* Local variables */
+    double a, b, c__, d__, den, dis;
+    int ntyp;
+
+    *merr = 0;
+    if (*mode <= 0) {
+       return;
+    }
+    if (*pl >= 0.) {
+       *merr = 2;
+       return;
+    } else if (*ru <= *rl) {
+       *merr = 3;
+       return;
+    }
+    for (ntyp = *mtyp; ntyp >= 1; --ntyp) {
+       if (ntyp == 1) {
+
+/*     BISECTION */
+
+           if (*mode == 1) {
+               *r__ = *ru * 4.;
+               return;
+           } else {
+               *r__ = (*rl + *ru) * .5;
+               return;
+           }
+       } else if (ntyp == *mtyp) {
+           a = (*fu - *fl) / (*pl * (*ru - *rl));
+           b = *pu / *pl;
+       }
+       if (ntyp == 2) {
+
+/*     QUADRATIC EXTRAPOLATION OR INTERPOLATION WITH ONE DIRECTIONAL */
+/*     DERIVATIVE */
+
+           den = (1. - a) * 2.;
+       } else if (ntyp == 3) {
+
+/*     QUADRATIC EXTRAPOLATION OR INTERPOLATION WITH TWO DIRECTIONAL */
+/*     DERIVATIVES */
+
+           den = 1. - b;
+       } else if (ntyp == 4) {
+
+/*     CUBIC EXTRAPOLATION OR INTERPOLATION */
+
+           c__ = b - a * 2. + 1.;
+           d__ = b - a * 3. + 2.;
+           dis = d__ * d__ - c__ * 3.;
+           if (dis < 0.) {
+               goto L1;
+           }
+           den = d__ + sqrt(dis);
+       } else if (ntyp == 5) {
+
+/*     CONIC EXTRAPOLATION OR INTERPOLATION */
+
+           dis = a * a - b;
+           if (dis < 0.) {
+               goto L1;
+           }
+           den = a + sqrt(dis);
+           if (den <= 0.) {
+               goto L1;
+           }
+/* Computing 3rd power */
+           d__1 = 1. / den;
+           den = 1. - b * (d__1 * (d__1 * d__1));
+       }
+       if (*mode == 1 && den > 0. && den < 1.) {
+
+/*     EXTRAPOLATION ACCEPTED */
+
+           *r__ = *rl + (*ru - *rl) / den;
+/* Computing MAX */
+           d__1 = *r__, d__2 = *ru * 1.1;
+           *r__ = MAX2(d__1,d__2);
+/* Computing MIN */
+           d__1 = *r__, d__2 = *ru * 1e3;
+           *r__ = MIN2(d__1,d__2);
+           return;
+       } else if (*mode == 2 && den > 1.) {
+
+/*     INTERPOLATION ACCEPTED */
+
+           *r__ = *rl + (*ru - *rl) / den;
+           if (*rl == 0.) {
+/* Computing MAX */
+               d__1 = *r__, d__2 = *rl + (*ru - *rl) * .01;
+               *r__ = MAX2(d__1,d__2);
+           } else {
+/* Computing MAX */
+               d__1 = *r__, d__2 = *rl + (*ru - *rl) * .1;
+               *r__ = MAX2(d__1,d__2);
+           }
+/* Computing MIN */
+           d__1 = *r__, d__2 = *rl + (*ru - *rl) * .9;
+           *r__ = MIN2(d__1,d__2);
+           return;
+       }
+L1:
+       ;
+    }
+    return;
+} /* luksan_pnint1__ */
+
+/* save and restore state, replacing old non-reeentrant implementation
+   that used static local variables */
+#define SS(var) state->var = var
+#define SAVE_STATE SS(fl); SS(fu); SS(pl); SS(rl); SS(pu); SS(ru); \
+                   SS(mes1); SS(mes2); SS(mes3); SS(mode); SS(mtyp)
+#define RS(var) var = state->var
+#define RESTORE_STATE RS(fl); RS(fu); RS(pl); RS(rl); RS(pu); RS(ru); \
+                      RS(mes1); RS(mes2); RS(mes3); RS(mode); RS(mtyp)
+
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PS1L01                ALL SYSTEMS                97/12/01
+* PURPOSE :
+*  STANDARD LINE SEARCH WITH DIRECTIONAL DERIVATIVES.
+*
+* PARAMETERS :
+*  RO  R  VALUE OF THE STEPSIZE PARAMETER.
+*  RO  RP  PREVIOUS VALUE OF THE STEPSIZE PARAMETER.
+*  RO  F  VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  FO  INITIAL VALUE OF THE OBJECTIVE FUNCTION.
+*  RO  FP  PREVIOUS VALUE OF THE OBJECTIVE FUNCTION.
+*  RO  P  VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RI  PO  INITIAL VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RO  PP  PREVIOUS VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RI  FMIN  LOWER BOUND FOR VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  MAXF  UPPER BOUND FOR VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  RMIN  MINIMUM VALUE OF THE STEPSIZE PARAMETER
+*  RI  RMAX  MAXIMUM VALUE OF THE STEPSIZE PARAMETER
+*  RI  TOLS  TERMINATION TOLERANCE FOR LINE SEARCH (IN TEST ON THE
+*         CHANGE OF THE FUNCTION VALUE).
+*  RI  TOLP  TERMINATION TOLERANCE FOR LINE SEARCH (IN TEST ON THE
+*         CHANGE OF THE DIRECTIONAL DERIVATIVE).
+*  RO  PAR1  PARAMETER FOR CONTROLLED SCALING OF VARIABLE METRIC
+*         UPDATES.
+*  RO  PAR2  PARAMETER FOR CONTROLLED SCALING OF VARIABLE METRIC
+*         UPDATES.
+*  II  KD  DEGREE OF REQUIRED DERIVATIVES.
+*  IO  LD  DEGREE OF PREVIOUSLY COMPUTED DERIVATIVES OF OBJECTIVE
+*  II  NIT  ACTUAL NUMBER OF ITERATIONS.
+*  II  KIT  NUMBER OF THE ITERATION AFTER LAST RESTART.
+*  IO  NRED  ACTUAL NUMBER OF EXTRAPOLATIONS OR INTERPOLATIONS.
+*  II  MRED  MAXIMUM NUMBER OF EXTRAPOLATIONS OR INTERPOLATIONS.
+*  IO  MAXST  MAXIMUM STEPSIZE INDICATOR. MAXST=0 OR MAXST=1 IF MAXIMUM
+*         STEPSIZE WAS NOT OR WAS REACHED.
+*  II  IEST  LOWER BOUND SPECIFICATION. IEST=0 OR IEST=1 IF LOWER BOUND
+*         IS NOT OR IS GIVEN.
+*  II  INITS  CHOICE OF THE INITIAL STEPSIZE. INITS=0-INITIAL STEPSIZE
+*         IS SPECIFIED IN THE CALLING PROGRAM. INITS=1-UNIT INITIAL
+*         STEPSIZE. INITS=2-COMBINED UNIT AND QUADRATICALLY ESTIMATED
+*         INITIAL STEPSIZE. INITS=3-QUADRATICALLY ESTIMATED INITIAL
+*         STEPSIZE.
+*  IO  ITERS  TERMINATION INDICATOR. ITERS=0-ZERO STEP. ITERS=1-PERFECT
+*         LINE SEARCH. ITERS=2 GOLDSTEIN STEPSIZE. ITERS=3-CURRY
+*         STEPSIZE. ITERS=4-EXTENDED CURRY STEPSIZE.
+*         ITERS=5-ARMIJO STEPSIZE. ITERS=6-FIRST STEPSIZE.
+*         ITERS=7-MAXIMUM STEPSIZE. ITERS=8-UNBOUNDED FUNCTION.
+*         ITERS=-1-MRED REACHED. ITERS=-2-POSITIVE DIRECTIONAL
+*         DERIVATIVE. ITERS=-3-ERROR IN INTERPOLATION.
+*  II  KTERS  TERMINATION SELECTION. KTERS=1-PERFECT LINE SEARCH.
+*         KTERS=2-GOLDSTEIN STEPSIZE. KTERS=3-CURRY STEPSIZE.
+*         KTERS=4-EXTENDED CURRY STEPSIZE. KTERS=5-ARMIJO STEPSIZE.
+*         KTERS=6-FIRST STEPSIZE.
+*  II  MES  METHOD SELECTION. MES=1-BISECTION. MES=2-QUADRATIC
+*         INTERPOLATION (WITH ONE DIRECTIONAL DERIVATIVE).
+*         MES=3-QUADRATIC INTERPOLATION (WITH TWO DIRECTIONAL
+*         DERIVATIVES). MES=4-CUBIC INTERPOLATION. MES=5-CONIC
+*         INTERPOLATION.
+*  IU  ISYS  CONTROL PARAMETER.
+*
+* SUBPROGRAM USED :
+*  S   PNINT1  EXTRAPOLATION OR INTERPOLATION WITH DIRECTIONAL
+*         DERIVATIVES.
+*
+* METHOD :
+* SAFEGUARDED EXTRAPOLATION AND INTERPOLATION WITH STANDARD TERMINATION
+* CRITERIA.
+*/
+void luksan_ps1l01__(double *r__, double *rp, 
+       double *f, double *fo, double *fp, double *p, 
+       double *po, double *pp, double *minf, double *maxf, 
+       double *rmin, double *rmax, double *tols, double *
+       tolp, double *par1, double *par2, int *kd, int *ld, 
+       int *nit, int *kit, int *nred, int *mred, int *
+       maxst, int *iest, int *inits, int *iters, int *kters, 
+       int *mes, int *isys, ps1l01_state *state)
+{
+    /* System generated locals */
+    double d__1, d__2;
+
+    /* Local variables */
+    unsigned l1, l2, l3, m1, l5, m2, l7, m3;
+    double fl, fu, pl, rl, pu, ru;
+    int mes1, mes2, mes3, mode;
+    int merr;
+    int mtyp;
+    int init1;
+    double rtemp;
+
+    RESTORE_STATE;
+
+    if (*isys == 1) {
+       goto L3;
+    }
+    mes1 = 2;
+    mes2 = 2;
+    mes3 = 2;
+    *iters = 0;
+    if (*po >= 0.) {
+       *r__ = 0.;
+       *iters = -2;
+       goto L4;
+    }
+    if (*rmax <= 0.) {
+       *iters = 0;
+       goto L4;
+    }
+
+/*     INITIAL STEPSIZE SELECTION */
+
+    if (*inits > 0) {
+       rtemp = *minf - *f;
+    } else if (*iest == 0) {
+       rtemp = *f - *fp;
+    } else {
+/* Computing MAX */
+       d__1 = *f - *fp, d__2 = *minf - *f;
+       rtemp = MAX2(d__1,d__2);
+    }
+    init1 = iabs(*inits);
+    *rp = 0.;
+    *fp = *fo;
+    *pp = *po;
+    if (init1 == 0) {
+    } else if (init1 == 1 || (*inits >= 1 && *iest == 0)) {
+       *r__ = 1.;
+    } else if (init1 == 2) {
+/* Computing MIN */
+       d__1 = 1., d__2 = rtemp * 4. / *po;
+       *r__ = MIN2(d__1,d__2);
+    } else if (init1 == 3) {
+/* Computing MIN */
+       d__1 = 1., d__2 = rtemp * 2. / *po;
+       *r__ = MIN2(d__1,d__2);
+    } else if (init1 == 4) {
+       *r__ = rtemp * 2. / *po;
+    }
+    *r__ = MAX2(*r__,*rmin);
+    *r__ = MIN2(*r__,*rmax);
+    mode = 0;
+    ru = 0.;
+    fu = *fo;
+    pu = *po;
+
+/*     NEW STEPSIZE SELECTION (EXTRAPOLATION OR INTERPOLATION) */
+
+L2:
+    luksan_pnint1__(&rl, &ru, &fl, &fu, &pl, &pu, r__, &mode, &mtyp, &merr);
+    if (merr > 0) {
+       *iters = -merr;
+       goto L4;
+    } else if (mode == 1) {
+       --(*nred);
+       *r__ = MIN2(*r__,*rmax);
+    } else if (mode == 2) {
+       ++(*nred);
+    }
+
+/*     COMPUTATION OF THE NEW FUNCTION VALUE AND THE NEW DIRECTIONAL */
+/*     DERIVATIVE */
+
+    *kd = 1;
+    *ld = -1;
+    *isys = 1;
+    SAVE_STATE;
+    return;
+L3:
+    if (mode == 0) {
+       *par1 = *p / *po;
+       *par2 = *f - *fo;
+    }
+    if (*iters != 0) {
+       goto L4;
+    }
+    if (*f <= *minf) {
+       *iters = 7;
+       goto L4;
+    } else {
+       l1 = *r__ <= *rmin && *nit != *kit;
+       l2 = *r__ >= *rmax;
+       l3 = *f - *fo <= *tols * *r__ * *po;
+       l5 = *p >= *tolp * *po || (mes2 == 2 && mode == 2);
+       l7 = mes2 <= 2 || mode != 0;
+       m1 = FALSE_;
+       m2 = FALSE_;
+       m3 = l3;
+       if (mes3 >= 1) {
+           m1 = fabs(*p) <= fabs(*po) * .01 && *fo - *f >= fabs(*fo) * 
+                   9.9999999999999994e-12;
+           l3 = l3 || m1;
+       }
+       if (mes3 >= 2) {
+           m2 = fabs(*p) <= fabs(*po) * .5 && (d__1 = *fo - *f, fabs(d__1)) <= 
+                   fabs(*fo) * 2.0000000000000001e-13;
+           l3 = l3 || m2;
+       }
+       *maxst = 0;
+       if (l2) {
+           *maxst = 1;
+       }
+    }
+
+/*     TEST ON TERMINATION */
+
+    if (l1 && ! l3) {
+       *iters = 0;
+       goto L4;
+    } else if (l2 && l3 && ! l5) {
+       *iters = 7;
+       goto L4;
+    } else if (m3 && mes1 == 3) {
+       *iters = 5;
+       goto L4;
+    } else if (l3 && l5 && l7) {
+       *iters = 4;
+       goto L4;
+    } else if (*kters < 0 || (*kters == 6 && l7)) {
+       *iters = 6;
+       goto L4;
+    } else if (iabs(*nred) >= *mred) {
+       *iters = -1;
+       goto L4;
+    } else {
+       *rp = *r__;
+       *fp = *f;
+       *pp = *p;
+       mode = MAX2(mode,1);
+       mtyp = iabs(*mes);
+       if (*f >= *maxf) {
+           mtyp = 1;
+       }
+    }
+    if (mode == 1) {
+
+/*     INTERVAL CHANGE AFTER EXTRAPOLATION */
+
+       rl = ru;
+       fl = fu;
+       pl = pu;
+       ru = *r__;
+       fu = *f;
+       pu = *p;
+       if (! l3) {
+           *nred = 0;
+           mode = 2;
+       } else if (mes1 == 1) {
+           mtyp = 1;
+       }
+    } else {
+
+/*     INTERVAL CHANGE AFTER INTERPOLATION */
+
+       if (! l3) {
+           ru = *r__;
+           fu = *f;
+           pu = *p;
+       } else {
+           rl = *r__;
+           fl = *f;
+           pl = *p;
+       }
+    }
+    goto L2;
+L4:
+    *isys = 0;
+    SAVE_STATE;
+    return;
+} /* luksan_ps1l01__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PULSP3                ALL SYSTEMS                02/12/01
+* PURPOSE :
+* LIMITED STORAGE VARIABLE METRIC UPDATE.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF VARIABLES (NUMBER OF ROWS OF XM).
+*  II  M  NUMBER OF COLUMNS OF XM.
+*  II  MF  MAXIMUM NUMBER OF COLUMNS OF XM.
+*  RI  XM(N*M)  RECTANGULAR MATRIX IN THE PRODUCT FORM SHIFTED BROYDEN
+*         METHOD (STORED COLUMNWISE): H-SIGMA*I=XM*TRANS(XM)
+*  RO  GR(M)  MATRIX TRANS(XM)*GO.
+*  RU  XO(N)  VECTORS OF VARIABLES DIFFERENCE XO AND VECTOR XO-TILDE.
+*  RU  GO(N)  GRADIENT DIFFERENCE GO AND VECTOR XM*TRANS(XM)*GO.
+*  RI  R  STEPSIZE PARAMETER.
+*  RI  PO  OLD DIRECTIONAL DERIVATIVE (MULTIPLIED BY R)
+*  RU  SIG  SCALING PARAMETER (ZETA AND SIGMA).
+*  IO  ITERH  TERMINATION INDICATOR. ITERH<0-BAD DECOMPOSITION.
+*         ITERH=0-SUCCESSFUL UPDATE. ITERH>0-NONPOSITIVE PARAMETERS.
+*  II  MET3  CHOICE OF SIGMA (1-CONSTANT, 2-QUADRATIC EQUATION).
+*
+* SUBPROGRAMS USED :
+*  S   MXDRMM  MULTIPLICATION OF A ROWWISE STORED DENSE RECTANGULAR
+*         MATRIX BY A VECTOR.
+*  S   MXDCMU  UPDATE OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX.
+*         WITH CONTROLLING OF POSITIVE DEFINITENESS.
+*  S   MXVDIR  VECTOR AUGMENTED BY A SCALED VECTOR.
+*  RF  MXVDOT  DOT PRODUCT OF VECTORS.
+*  S   MXVSCL  SCALING OF A VECTOR.
+*
+* METHOD :
+* SHIFTED BFGS METHOD IN THE PRODUCT FORM.
+*/
+void luksan_pulsp3__(int *n, int *m, int *mf, 
+       double *xm, double *gr, double *xo, double *go, 
+       double *r__, double *po, double *sig, int *iterh, 
+       int *met3)
+{
+    /* System generated locals */
+    double d__1, d__2, d__3, d__4;
+
+    /* Builtin functions */
+
+    /* Local variables */
+    double a, b, c__, aa, bb, ah, den, par, pom;
+
+    /* Parameter adjustments */
+    --go;
+    --xo;
+    --gr;
+    --xm;
+
+    /* Function Body */
+    if (*m >= *mf) {
+       return;
+    }
+    b = luksan_mxvdot__(n, &xo[1], &go[1]);
+    if (b <= 0.) {
+       *iterh = 2;
+       goto L22;
+    }
+    luksan_mxdrmm__(n, m, &xm[1], &go[1], &gr[1]);
+    ah = luksan_mxvdot__(n, &go[1], &go[1]);
+    aa = luksan_mxvdot__(m, &gr[1], &gr[1]);
+    a = aa + ah * *sig;
+    c__ = -(*r__) * *po;
+
+/*     DETERMINATION OF THE PARAMETER SIG (SHIFT) */
+
+    par = 1.;
+    pom = b / ah;
+    if (a > 0.) {
+       den = luksan_mxvdot__(n, &xo[1], &xo[1]);
+       if (*met3 <= 4) {
+/* Computing MAX */
+           d__1 = 0., d__2 = 1. - aa / a;
+/* Computing MAX */
+           d__3 = 0., d__4 = 1. - b * b / (den * ah);
+           *sig = sqrt((MAX2(d__1,d__2))) / (sqrt((MAX2(d__3,d__4))) + 1.) * 
+                   pom;
+       } else {
+/* Computing MAX */
+           d__1 = 0., d__2 = *sig * ah / a;
+/* Computing MAX */
+           d__3 = 0., d__4 = 1. - b * b / (den * ah);
+           *sig = sqrt((MAX2(d__1,d__2))) / (sqrt((MAX2(d__3,d__4))) + 1.) * 
+                   pom;
+       }
+/* Computing MAX */
+       d__1 = *sig, d__2 = pom * .2;
+       *sig = MAX2(d__1,d__2);
+/* Computing MIN */
+       d__1 = *sig, d__2 = pom * .8;
+       *sig = MIN2(d__1,d__2);
+    } else {
+       *sig = pom * .25;
+    }
+
+/*     COMPUTATION OF SHIFTED XO AND SHIFTED B */
+
+    bb = b - ah * *sig;
+    d__1 = -(*sig);
+    luksan_mxvdir__(n, &d__1, &go[1], &xo[1], &xo[1]);
+
+/*     BFGS-BASED SHIFTED BFGS UPDATE */
+
+    pom = 1.;
+    d__1 = -1. / bb;
+    luksan_mxdcmu__(n, m, &xm[1], &d__1, &xo[1], &gr[1]);
+    d__1 = sqrt(par / bb);
+    luksan_mxvscl__(n, &d__1, &xo[1], &xm[*n * *m + 1]);
+    ++(*m);
+L22:
+    *iterh = 0;
+    return;
+} /* luksan_pulsp3__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PULVP3                ALL SYSTEMS                03/12/01
+* PURPOSE :
+* RANK-TWO LIMITED-STORAGE VARIABLE-METRIC METHODS IN THE PRODUCT FORM.
+*
+* PARAMETERS :
+*  II  N  NUMBER OF VARIABLES (NUMBER OF ROWS OF XM).
+*  II  M  NUMBER OF COLUMNS OF XM.
+*  RI  XM(N*M)  RECTANGULAR MATRIX IN THE PRODUCT FORM SHIFTED BROYDEN
+*         METHOD (STORED COLUMNWISE): H-SIGMA*I=XM*TRANS(XM)
+*  RO  XR(M)  VECTOR TRANS(XM)*H**(-1)*XO.
+*  RO  GR(M)  MATRIX TRANS(XM)*GO.
+*  RA  S(N)  AUXILIARY VECTORS (H**(-1)*XO AND U).
+*  RA  SO(N)  AUXILIARY VECTORS ((H-SIGMA*I)*H**(-1)*XO AND V).
+*  RU  XO(N)  VECTORS OF VARIABLES DIFFERENCE XO AND VECTOR XO-TILDE.
+*  RU  GO(N)  GRADIENT DIFFERENCE GO AND VECTOR XM*TRANS(XM)*GO.
+*  RI  R  STEPSIZE PARAMETER.
+*  RI  PO  OLD DIRECTIONAL DERIVATIVE (MULTIPLIED BY R)
+*  RU  SIG  SCALING PARAMETER (ZETA AND SIGMA).
+*  IO  ITERH  TERMINATION INDICATOR. ITERH<0-BAD DECOMPOSITION.
+*         ITERH=0-SUCCESSFUL UPDATE. ITERH>0-NONPOSITIVE PARAMETERS.
+*  II  MET2  CHOICE OF THE CORRECTION PARAMETER (1-THE UNIT VALUE,
+*         2-THE BALANCING VALUE, 3-THE SQUARE ROOT, 4-THE GEOMETRIC
+*         MEAN).
+*  II  MET3  CHOICE OF THE SHIFT PARAMETER (4-THE FIRST FORMULA,
+*         5-THE SECOND FORMULA).
+*  II  MET5  CHOICE OF THE METHOD (1-RANK-ONE METHOD, 2-RANK-TWO
+*         METHOD).
+*
+* SUBPROGRAMS USED :
+*  S   MXDRMM  MULTIPLICATION OF A ROWWISE STORED DENSE RECTANGULAR
+*         MATRIX BY A VECTOR.
+*  S   MXDCMU  UPDATE OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX.
+*         WITH CONTROLLING OF POSITIVE DEFINITENESS. RANK-ONE FORMULA.
+*  S   MXDCMV  UPDATE OF A COLUMNWISE STORED DENSE RECTANGULAR MATRIX.
+*         WITH CONTROLLING OF POSITIVE DEFINITENESS. RANK-TWO FORMULA.
+*  S   MXVDIR  VECTOR AUGMENTED BY A SCALED VECTOR.
+*  RF  MXVDOT  DOT PRODUCT OF VECTORS.
+*  S   MXVLIN  LINEAR COMBINATION OF TWO VECTORS.
+*  S   MXVSCL  SCALING OF A VECTOR.
+*
+* METHOD :
+* RANK-ONE LIMITED-STORAGE VARIABLE-METRIC METHOD IN THE PRODUCT FORM.
+*/
+void luksan_pulvp3__(int *n, int *m, double *xm, 
+       double *xr, double *gr, double *s, double *so, 
+       double *xo, double *go, double *r__, double *po, 
+       double *sig, int *iterh, int *met2, int *met3, 
+       int *met5)
+{
+    /* System generated locals */
+    double d__1, d__2, d__3, d__4;
+
+    /* Builtin functions */
+
+    /* Local variables */
+    double a, b, c__, aa, bb, cc, ah, den, par, pom, zet;
+
+    /* Parameter adjustments */
+    --go;
+    --xo;
+    --so;
+    --s;
+    --gr;
+    --xr;
+    --xm;
+
+    /* Function Body */
+    zet = *sig;
+
+/*     COMPUTATION OF B */
+
+    b = luksan_mxvdot__(n, &xo[1], &go[1]);
+    if (b <= 0.) {
+       *iterh = 2;
+       goto L22;
+    }
+
+/*     COMPUTATION OF GR=TRANS(XM)*GO, XR=TRANS(XM)*H**(-1)*XO */
+/*     AND S=H**(-1)*XO, SO=(H-SIGMA*I)*H**(-1)*XO. COMPUTATION */
+/*     OF AA=GR*GR, BB=GR*XR, CC=XR*XR. COMPUTATION OF A AND C. */
+
+    luksan_mxdrmm__(n, m, &xm[1], &go[1], &gr[1]);
+    luksan_mxvscl__(n, r__, &s[1], &s[1]);
+    luksan_mxdrmm__(n, m, &xm[1], &s[1], &xr[1]);
+    d__1 = -(*sig);
+    luksan_mxvdir__(n, &d__1, &s[1], &xo[1], &so[1]);
+    ah = luksan_mxvdot__(n, &go[1], &go[1]);
+    aa = luksan_mxvdot__(m, &gr[1], &gr[1]);
+    bb = luksan_mxvdot__(m, &gr[1], &xr[1]);
+    cc = luksan_mxvdot__(m, &xr[1], &xr[1]);
+    a = aa + ah * *sig;
+    c__ = -(*r__) * *po;
+
+/*     DETERMINATION OF THE PARAMETER SIG (SHIFT) */
+
+    pom = b / ah;
+    if (a > 0.) {
+       den = luksan_mxvdot__(n, &xo[1], &xo[1]);
+       if (*met3 <= 4) {
+/* Computing MAX */
+           d__1 = 0., d__2 = 1. - aa / a;
+/* Computing MAX */
+           d__3 = 0., d__4 = 1. - b * b / (den * ah);
+           *sig = sqrt((MAX2(d__1,d__2))) / (sqrt((MAX2(d__3,d__4))) + 1.) * 
+                   pom;
+       } else {
+/* Computing MAX */
+           d__1 = 0., d__2 = *sig * ah / a;
+/* Computing MAX */
+           d__3 = 0., d__4 = 1. - b * b / (den * ah);
+           *sig = sqrt((MAX2(d__1,d__2))) / (sqrt((MAX2(d__3,d__4))) + 1.) * 
+                   pom;
+       }
+/* Computing MAX */
+       d__1 = *sig, d__2 = pom * .2;
+       *sig = MAX2(d__1,d__2);
+/* Computing MIN */
+       d__1 = *sig, d__2 = pom * .8;
+       *sig = MIN2(d__1,d__2);
+    } else {
+       *sig = pom * .25;
+    }
+
+/*     COMPUTATION OF SHIFTED XO AND SHIFTED B */
+
+    b -= ah * *sig;
+    d__1 = -(*sig);
+    luksan_mxvdir__(n, &d__1, &go[1], &xo[1], &xo[1]);
+
+/*     COMPUTATION OF THE PARAMETER RHO (CORRECTION) */
+
+    if (*met2 <= 1) {
+       par = 1.;
+    } else if (*met2 == 2) {
+       par = *sig * ah / b;
+    } else if (*met2 == 3) {
+       par = sqrt(1. - aa / a);
+    } else if (*met2 == 4) {
+       par = sqrt(sqrt(1. - aa / a) * (*sig * ah / b));
+    } else {
+       par = zet / (zet + *sig);
+    }
+
+/*     COMPUTATION OF THE PARAMETER THETA (BFGS) */
+
+    d__1 = sqrt(par * b / cc);
+    pom = copysign(d__1, bb);
+
+/*     COMPUTATION OF Q AND P */
+
+    if (*met5 == 1) {
+
+/*     RANK ONE UPDATE OF XM */
+
+       luksan_mxvdir__(m, &pom, &xr[1], &gr[1], &xr[1]);
+       luksan_mxvlin__(n, &par, &xo[1], &pom, &so[1], &s[1]);
+       d__1 = -1. / (par * b + pom * bb);
+       luksan_mxdcmu__(n, m, &xm[1], &d__1, &s[1], &xr[1]);
+    } else {
+
+/*     RANK TWO UPDATE OF XM */
+
+       d__1 = par / pom - bb / b;
+       luksan_mxvdir__(n, &d__1, &xo[1], &so[1], &s[1]);
+       d__1 = -1. / b;
+       d__2 = -1. / cc;
+       luksan_mxdcmv__(n, m, &xm[1], &d__1, &xo[1], &gr[1], &d__2, &s[1], &xr[1]);
+    }
+L22:
+    *iterh = 0;
+    return;
+} /* luksan_pulvp3__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYADC0                ALL SYSTEMS                98/12/01
+* PURPOSE :
+* NEW SIMPLE BOUNDS ARE ADDED TO THE ACTIVE SET.
+*
+* PARAMETERS :
+*  II  NF  DECLARED NUMBER OF VARIABLES.
+*  II  N  REDUCED NUMBER OF VARIABLES.
+*  RI  X(NF)  VECTOR OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES.
+*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES.
+*  IO  INEW  NUMBER OF ACTIVE CONSTRAINTS.
+*/
+void luksan_pyadc0__(int *nf, int *n, double *x, 
+       int *ix, double *xl, double *xu, int *inew)
+{
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int i__, ii, ixi;
+
+    /* Parameter adjustments */
+    --ix;
+    --x;
+    --xl;
+    --xu;
+
+    /* Function Body */
+    *n = *nf;
+    *inew = 0;
+    i__1 = *nf;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       ii = ix[i__];
+       ixi = iabs(ii);
+       if (ixi >= 5) {
+           ix[i__] = -ixi;
+       } else if ((ixi == 1 || ixi == 3 || ixi == 4) && x[i__] <= xl[i__]) {
+           x[i__] = xl[i__];
+           if (ixi == 4) {
+               ix[i__] = -3;
+           } else {
+               ix[i__] = -ixi;
+           }
+           --(*n);
+           if (ii > 0) {
+               ++(*inew);
+           }
+       } else if ((ixi == 2 || ixi == 3 || ixi == 4) && x[i__] >= xu[i__]) {
+           x[i__] = xu[i__];
+           if (ixi == 3) {
+               ix[i__] = -4;
+           } else {
+               ix[i__] = -ixi;
+           }
+           --(*n);
+           if (ii > 0) {
+               ++(*inew);
+           }
+       }
+/* L1: */
+    }
+    return;
+} /* luksan_pyadc0__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYFUT1                ALL SYSTEMS                98/12/01
+* PURPOSE :
+* TERMINATION CRITERIA AND TEST ON RESTART.
+*
+* PARAMETERS :
+*  II  N  ACTUAL NUMBER OF VARIABLES.
+*  RI  F  NEW VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  FO  OLD VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  UMAX  MAXIMUM ABSOLUTE VALUE OF THE NEGATIVE LAGRANGE MULTIPLIER.
+*  RO  GMAX  NORM OF THE TRANSFORMED GRADIENT.
+*  RI  DMAX  MAXIMUM RELATIVE DIFFERENCE OF VARIABLES.
+*  RI  TOLX  LOWER BOUND FOR STEPLENGTH.
+*  RI  TOLF  LOWER BOUND FOR FUNCTION DECREASE.
+*  RI  TOLB  LOWER BOUND FOR FUNCTION VALUE.
+*  RI  TOLG  LOWER BOUND FOR GRADIENT.
+*  II  KD  DEGREE OF REQUIRED DERIVATIVES.
+*  IU  NIT  ACTUAL NUMBER OF ITERATIONS.
+*  II  KIT  NUMBER OF THE ITERATION AFTER RESTART.
+*  II  MIT  MAXIMUM NUMBER OF ITERATIONS.
+*  IU  NFV  ACTUAL NUMBER OF COMPUTED FUNCTION VALUES.
+*  II  MFV  MAXIMUM NUMBER OF COMPUTED FUNCTION VALUES.
+*  IU  NFG  ACTUAL NUMBER OF COMPUTED GRADIENT VALUES.
+*  II  MFG  MAXIMUM NUMBER OF COMPUTED GRADIENT VALUES.
+*  IU  NTESX  ACTUAL NUMBER OF TESTS ON STEPLENGTH.
+*  II  MTESX  MAXIMUM NUMBER OF TESTS ON STEPLENGTH.
+*  IU  NTESF  ACTUAL NUMBER OF TESTS ON FUNCTION DECREASE.
+*  II  MTESF  MAXIMUM NUMBER OF TESTS ON FUNCTION DECREASE.
+*  II  IRES1  RESTART SPECIFICATION. RESTART IS PERFORMED AFTER
+*         IRES1*N+IRES2 ITERATIONS.
+*  II  IRES2  RESTART SPECIFICATION. RESTART IS PERFORMED AFTER
+*         IRES1*N+IRES2 ITERATIONS.
+*  IU  IREST  RESTART INDICATOR. RESTART IS PERFORMED IF IREST>0.
+*  II  ITERS  TERMINATION INDICATOR FOR STEPLENGTH DETERMINATION.
+*         ITERS=0 FOR ZERO STEP.
+*  IO  ITERM  TERMINATION INDICATOR. ITERM=1-TERMINATION AFTER MTESX
+*         UNSUFFICIENT STEPLENGTHS. ITERM=2-TERMINATION AFTER MTESF
+*         UNSUFFICIENT FUNCTION DECREASES. ITERM=3-TERMINATION ON LOWER
+*         BOUND FOR FUNCTION VALUE. ITERM=4-TERMINATION ON LOWER BOUND
+*         FOR GRADIENT. ITERM=11-TERMINATION AFTER MAXIMUM NUMBER OF
+*         ITERATIONS. ITERM=12-TERMINATION AFTER MAXIMUM NUMBER OF
+*         COMPUTED FUNCTION VALUES.
+*/
+void luksan_pyfut1__(int *n, double *f, double *fo, double *umax, 
+                    double *gmax, int xstop, /* double *dmax__,  */
+                    const nlopt_stopping *stop,
+                    double *tolg, int *kd, int *nit, int *kit, int *mit, 
+                    int *nfg, int *mfg, int *ntesx, 
+       int *mtesx, int *ntesf, int *mtesf, int *ites, 
+       int *ires1, int *ires2, int *irest, int *iters, 
+       int *iterm)
+{
+    /* System generated locals */
+    double d__1, d__2;
+
+    /* Builtin functions */
+
+    if (*iterm < 0) {
+       return;
+    }
+    if (*ites <= 0) {
+       goto L1;
+    }
+    if (*iters == 0) {
+       goto L1;
+    }
+    if (*nit <= 0) {
+/* Computing MIN */
+       d__1 = sqrt((fabs(*f))), d__2 = fabs(*f) / 10.;
+       *fo = *f + MIN2(d__1,d__2);
+    }
+    if (nlopt_stop_forced(stop)) {
+       *iterm = -999;
+       return;
+    }
+    if (*f <= stop->minf_max /* *tolb */) {
+       *iterm = 3;
+       return;
+    }
+    if (*kd > 0) {
+       if (*gmax <= *tolg && *umax <= *tolg) {
+           *iterm = 4;
+           return;
+       }
+    }
+    if (*nit <= 0) {
+       *ntesx = 0;
+       *ntesf = 0;
+    }
+    if (xstop) /* (*dmax__ <= *tolx) */ {
+       *iterm = 1;
+       ++(*ntesx);
+       if (*ntesx >= *mtesx) {
+           return;
+       }
+    } else {
+       *ntesx = 0;
+    }
+    if (nlopt_stop_ftol(stop, *f, *fo)) {
+       *iterm = 2;
+       ++(*ntesf);
+       if (*ntesf >= *mtesf) {
+           return;
+       }
+    } else {
+       *ntesf = 0;
+    }
+L1:
+    if (*nit >= *mit) {
+       *iterm = 11;
+       return;
+    }
+    if (nlopt_stop_evals(stop)) /* (*nfv >= *mfv) */ {
+       *iterm = 12;
+       return;
+    }
+    if (*nfg >= *mfg) {
+       *iterm = 13;
+       return;
+    }
+    *iterm = 0;
+    if (*n > 0 && *nit - *kit >= *ires1 * *n + *ires2) {
+       *irest = MAX2(*irest,1);
+    }
+    ++(*nit);
+    return;
+} /* luksan_pyfut1__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYRMC0                ALL SYSTEMS                98/12/01
+* PURPOSE :
+* OLD SIMPLE BOUND IS REMOVED FROM THE ACTIVE SET. TRANSFORMED
+* GRADIENT OF THE OBJECTIVE FUNCTION IS UPDATED.
+*
+* PARAMETERS :
+*  II  NF  DECLARED NUMBER OF VARIABLES.
+*  II  N  REDUCED NUMBER OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RI  G(NF)  GRADIENT OF THE OBJECTIVE FUNCTION.
+*  RI  EPS8  TOLERANCE FOR CONSTRAINT TO BE REMOVED.
+*  RI  UMAX  MAXIMUM ABSOLUTE VALUE OF THE NEGATIVE LAGRANGE MULTIPLIER.
+*  RI  GMAX  NORM OF THE TRANSFORMED GRADIENT.
+*  RO  RMAX  MAXIMUM VALUE OF THE STEPSIZE PARAMETER.
+*  II  IOLD  NUMBER OF REMOVED CONSTRAINTS.
+*  IU  IREST  RESTART INDICATOR.
+*/
+void luksan_pyrmc0__(int *nf, int *n, int *ix, 
+       double *g, double *eps8, double *umax, double *gmax, 
+       double *rmax, int *iold, int *irest)
+{
+    /* System generated locals */
+    int i__1, i__2, i__3;
+
+    /* Local variables */
+    int i__, ixi;
+
+    /* Parameter adjustments */
+    --g;
+    --ix;
+
+    /* Function Body */
+    if (*n == 0 || *rmax > 0.) {
+       if (*umax > *eps8 * *gmax) {
+           *iold = 0;
+           i__1 = *nf;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ixi = ix[i__];
+               if (ixi >= 0) {
+               } else if (ixi <= -5) {
+               } else if ((ixi == -1 || ixi == -3) && -g[i__] <= 0.) {
+               } else if ((ixi == -2 || ixi == -4) && g[i__] <= 0.) {
+               } else {
+                   ++(*iold);
+/* Computing MIN */
+                   i__3 = (i__2 = ix[i__], iabs(i__2));
+                   ix[i__] = MIN2(i__3,3);
+                   if (*rmax == 0.) {
+                       goto L2;
+                   }
+               }
+/* L1: */
+           }
+L2:
+           if (*iold > 1) {
+               *irest = MAX2(*irest,1);
+           }
+       }
+    }
+    return;
+} /* luksan_pyrmc0__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYTRCD             ALL SYSTEMS                   98/12/01
+* PURPOSE :
+* VECTORS OF VARIABLES DIFFERENCE AND GRADIENTS DIFFERENCE ARE COMPUTED
+* AND SCALED AND REDUCED. TEST VALUE DMAX IS DETERMINED.
+*
+* PARAMETERS :
+*  II  NF DECLARED NUMBER OF VARIABLES.
+*  RI  X(NF)  VECTOR OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RU  XO(NF)  VECTORS OF VARIABLES DIFFERENCE.
+*  RI  G(NF)  GRADIENT OF THE OBJECTIVE FUNCTION.
+*  RU  GO(NF)  GRADIENTS DIFFERENCE.
+*  RO  R  VALUE OF THE STEPSIZE PARAMETER.
+*  RO  F  NEW VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  FO  OLD VALUE OF THE OBJECTIVE FUNCTION.
+*  RO  P  NEW VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RI  PO  OLD VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RO  DMAX  MAXIMUM RELATIVE DIFFERENCE OF VARIABLES.
+*  II  KBF  SPECIFICATION OF SIMPLE BOUNDS. KBF=0-NO SIMPLE BOUNDS.
+*         KBF=1-ONE SIDED SIMPLE BOUNDS. KBF=2=TWO SIDED SIMPLE BOUNDS.
+*  IO  KD  DEGREE OF REQUIRED DERIVATIVES.
+*  IO  LD  DEGREE OF COMPUTED DERIVATIVES.
+*  II  ITERS  TERMINATION INDICATOR FOR STEPLENGTH DETERMINATION.
+*         ITERS=0 FOR ZERO STEP.
+*
+* SUBPROGRAMS USED :
+*  S   MXVDIF  DIFFERENCE OF TWO VECTORS.
+*  S   MXVSAV  DIFFERENCE OF TWO VECTORS WITH COPYING AND SAVING THE
+*         SUBSTRACTED ONE.
+*/
+void luksan_pytrcd__(int *nf, double *x, int *ix, 
+       double *xo, double *g, double *go, double *r__, 
+       double *f, double *fo, double *p, double *po, 
+       double *dmax__, int *kbf, int *kd, int *ld, int *
+       iters)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2, d__3, d__4, d__5;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --go;
+    --g;
+    --xo;
+    --ix;
+    --x;
+
+    /* Function Body */
+    if (*iters > 0) {
+       luksan_mxvdif__(nf, &x[1], &xo[1], &xo[1]);
+       luksan_mxvdif__(nf, &g[1], &go[1], &go[1]);
+       *po = *r__ * *po;
+       *p = *r__ * *p;
+    } else {
+       *f = *fo;
+       *p = *po;
+       luksan_mxvsav__(nf, &x[1], &xo[1]);
+       luksan_mxvsav__(nf, &g[1], &go[1]);
+       *ld = *kd;
+    }
+    *dmax__ = 0.;
+    i__1 = *nf;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       if (*kbf > 0) {
+           if (ix[i__] < 0) {
+               xo[i__] = 0.;
+               go[i__] = 0.;
+               goto L1;
+           }
+       }
+/* Computing MAX */
+/* Computing MAX */
+       d__5 = (d__2 = x[i__], fabs(d__2));
+       d__3 = *dmax__, d__4 = (d__1 = xo[i__], fabs(d__1)) / MAX2(d__5,1.);
+       *dmax__ = MAX2(d__3,d__4);
+L1:
+       ;
+    }
+    return;
+} /* luksan_pytrcd__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYTRCG                ALL SYSTEMS                99/12/01
+* PURPOSE :
+*  GRADIENT OF THE OBJECTIVE FUNCTION IS SCALED AND REDUCED. TEST VALUES
+*  GMAX AND UMAX ARE COMPUTED.
+*
+* PARAMETERS :
+*  II  NF DECLARED NUMBER OF VARIABLES.
+*  II  N  ACTUAL NUMBER OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RI  G(NF)  GRADIENT OF THE OBJECTIVE FUNCTION.
+*  RI  UMAX  MAXIMUM ABSOLUTE VALUE OF THE NEGATIVE LAGRANGE MULTIPLIER.
+*  RI  GMAX  NORM OF THE TRANSFORMED GRADIENT.
+*  II  KBF  SPECIFICATION OF SIMPLE BOUNDS. KBF=0-NO SIMPLE BOUNDS.
+*         KBF=1-ONE SIDED SIMPLE BOUNDS. KBF=2=TWO SIDED SIMPLE BOUNDS.
+*  II  IOLD  INDEX OF THE REMOVED CONSTRAINT.
+*
+* SUBPROGRAMS USED :
+*  RF  MXVMAX  L-INFINITY NORM OF A VECTOR.
+*/
+void luksan_pytrcg__(int *nf, int *n, int *ix, 
+       double *g, double *umax, double *gmax, int *kbf, 
+       int *iold)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__;
+    double temp;
+
+    /* Parameter adjustments */
+    --g;
+    --ix;
+
+    /* Function Body */
+    if (*kbf > 0) {
+       *gmax = 0.;
+       *umax = 0.;
+       *iold = 0;
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           temp = g[i__];
+           if (ix[i__] >= 0) {
+/* Computing MAX */
+               d__1 = *gmax, d__2 = fabs(temp);
+               *gmax = MAX2(d__1,d__2);
+           } else if (ix[i__] <= -5) {
+           } else if ((ix[i__] == -1 || ix[i__] == -3) && *umax + temp >= 0.)
+                    {
+           } else if ((ix[i__] == -2 || ix[i__] == -4) && *umax - temp >= 0.)
+                    {
+           } else {
+               *iold = i__;
+               *umax = fabs(temp);
+           }
+/* L1: */
+       }
+    } else {
+       *umax = 0.;
+       *gmax = luksan_mxvmax__(nf, &g[1]);
+    }
+    *n = *nf;
+    return;
+} /* luksan_pytrcg__ */
+
+/* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */
+/* SUBROUTINE PYTRCS             ALL SYSTEMS                   98/12/01
+* PURPOSE :
+* SCALED AND REDUCED DIRECTION VECTOR IS BACK TRANSFORMED. VECTORS
+* X,G AND VALUES F,P ARE SAVED.
+*
+* PARAMETERS :
+*  II  NF DECLARED NUMBER OF VARIABLES.
+*  RI  X(NF)  VECTOR OF VARIABLES.
+*  II  IX(NF)  VECTOR CONTAINING TYPES OF BOUNDS.
+*  RO  XO(NF)  SAVED VECTOR OF VARIABLES.
+*  RI  XL(NF)  VECTOR CONTAINING LOWER BOUNDS FOR VARIABLES.
+*  RI  XU(NF)  VECTOR CONTAINING UPPER BOUNDS FOR VARIABLES.
+*  RI  G(NF)  GRADIENT OF THE OBJECTIVE FUNCTION.
+*  RO  GO(NF)  SAVED GRADIENT OF THE OBJECTIVE FUNCTION.
+*  RO  S(NF)  DIRECTION VECTOR.
+*  RO  RO  SAVED VALUE OF THE STEPSIZE PARAMETER.
+*  RO  FP  PREVIOUS VALUE OF THE OBJECTIVE FUNCTION.
+*  RU  FO  SAVED VALUE OF THE OBJECTIVE FUNCTION.
+*  RI  F  VALUE OF THE OBJECTIVE FUNCTION.
+*  RO  PO  SAVED VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RI  P  VALUE OF THE DIRECTIONAL DERIVATIVE.
+*  RO  RMAX  MAXIMUM VALUE OF THE STEPSIZE PARAMETER.
+*  RI  ETA9  MAXIMUM FOR REAL NUMBERS.
+*  II  KBF  SPECIFICATION OF SIMPLE BOUNDS. KBF=0-NO SIMPLE BOUNDS.
+*         KBF=1-ONE SIDED SIMPLE BOUNDS. KBF=2=TWO SIDED SIMPLE BOUNDS.
+*
+* SUBPROGRAMS USED :
+*  S   MXVCOP  COPYING OF A VECTOR.
+*/
+void luksan_pytrcs__(int *nf, double *x, int *ix, 
+       double *xo, double *xl, double *xu, double *g, 
+       double *go, double *s, double *ro, double *fp, 
+       double *fo, double *f, double *po, double *p, 
+       double *rmax, double *eta9, int *kbf)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__;
+
+    /* Parameter adjustments */
+    --s;
+    --go;
+    --g;
+    --xu;
+    --xl;
+    --xo;
+    --ix;
+    --x;
+
+    /* Function Body */
+    *fp = *fo;
+    *ro = 0.;
+    *fo = *f;
+    *po = *p;
+    luksan_mxvcop__(nf, &x[1], &xo[1]);
+    luksan_mxvcop__(nf, &g[1], &go[1]);
+    if (*kbf > 0) {
+       i__1 = *nf;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           if (ix[i__] < 0) {
+               s[i__] = 0.;
+           } else {
+               if (ix[i__] == 1 || ix[i__] >= 3) {
+                   if (s[i__] < -1. / *eta9) {
+/* Computing MIN */
+                       d__1 = *rmax, d__2 = (xl[i__] - x[i__]) / s[i__];
+                       *rmax = MIN2(d__1,d__2);
+                   }
+               }
+               if (ix[i__] == 2 || ix[i__] >= 3) {
+                   if (s[i__] > 1. / *eta9) {
+/* Computing MIN */
+                       d__1 = *rmax, d__2 = (xu[i__] - x[i__]) / s[i__];
+                       *rmax = MIN2(d__1,d__2);
+                   }
+               }
+           }
+/* L1: */
+       }
+    }
+    return;
+} /* luksan_pytrcs__ */
+
diff --git a/m4/ax_c_threadlocal.m4 b/m4/ax_c_threadlocal.m4
new file mode 100644 (file)
index 0000000..0fdb30e
--- /dev/null
@@ -0,0 +1,47 @@
+dnl @synopsis AX_C_THREADLOCAL([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl @summary determine C keyword for threadlocal storage
+dnl
+dnl This macro tries to discover a C keyword to declare variables
+dnl as having thread-local storage.  Most commonly, this is either
+dnl __thread [gcc] or __declspec(thread) [Windows].
+dnl
+dnl On success, it #defines the THREADLOCAL preprocessor symbol to
+dnl the appropriate keyword.  You would then use it in C code as, e.g.:
+dnl     THREADLOCAL int myvariable;
+dnl
+dnl ACTION-IF-FOUND is a list of shell commands to run if an thread-local
+dnl keyword is found, and ACTION-IF-NOT-FOUND is a list of commands
+dnl to run it if one is not found.  If ACTION-IF-FOUND is not specified,
+dnl the default action does nothing.
+dnl
+dnl @version 2010-05-28
+dnl @license GPLWithACException
+dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
+AC_DEFUN([AX_C_THREADLOCAL],
+[AC_ARG_WITH(threadlocal,
+  [AC_HELP_STRING([--without-threadlocal], [no thread-local storage keyword])],
+  with_ax_c_threadlocal=$withval, with_ax_c_threadlocal=yes)
+ AC_CACHE_CHECK([for C thread-local keyword], ax_cv_c_threadlocal,
+[if test "x$with_ax_c_threadlocal" = xno; then
+   ax_cv_c_threadlocal=disabled
+ else
+   ax_cv_c_threadlocal=unsupported
+   AC_LANG_SAVE
+   AC_LANG_C
+   for ax_kw in __thread "__declspec(thread)"; do
+     AC_TRY_COMPILE([], [static $ax_kw int x = 0;], 
+                        [ax_cv_c_threadlocal=$ax_kw; break])
+   done
+   AC_LANG_RESTORE
+ fi
+])
+ ax_kw="$ax_cv_c_threadlocal"
+ if test "x$ax_kw" = xunsupported; then ax_kw=""; fi
+ if test "x$ax_kw" = xdisabled; then ax_kw=""; fi
+ AC_DEFINE_UNQUOTED(THREADLOCAL, $ax_kw, [Define to C thread-local keyword, or to nothing if this is not supported in your compiler.])
+ if test "$ax_cv_c_threadlocal" = unsupported; then
+   m4_default([$2],:)
+ else
+   m4_default([$1],:)
+ fi
+])
diff --git a/m4/libtool.m4 b/m4/libtool.m4
new file mode 100644 (file)
index 0000000..44e0ecf
--- /dev/null
@@ -0,0 +1,7982 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 57 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+       [m4_default([$3],
+                  [m4_fatal([Libtool version $1 or higher is required],
+                            63)])],
+       [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+  *\ * | *\    *)
+    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_WITH_SYSROOT])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    _LT_PATH_MAGIC
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME.  Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+       [m4_ifval([$1], [$1], [$2])])
+    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+    m4_ifval([$4],
+       [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+    lt_dict_add_subkey([lt_decl_dict], [$2],
+       [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+  [0], [m4_fatal([$0: too few arguments: $#])],
+  [1], [m4_fatal([$0: too few arguments: $#: $1])],
+  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_if([$2], [],
+          m4_quote(lt_decl_varnames),
+       m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+                       lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'.  VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly.  In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+#    # Some comment about what VAR is for.
+#    visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+                                          [description])))[]dnl
+m4_pushdef([_libtool_name],
+    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+    [0], [_libtool_name=[$]$1],
+    [1], [_libtool_name=$lt_[]$1],
+    [2], [_libtool_name=$lt_[]$1],
+    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'.  Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+       dnl If the libtool generation code has been placed in $CONFIG_LT,
+       dnl instead of duplicating it all over again into config.status,
+       dnl then we will have config.status run $CONFIG_LT later, so it
+       dnl needs to know what name is stored there:
+        [AC_CONFIG_COMMANDS([libtool],
+            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+    dnl If the libtool generation code is destined for config.status,
+    dnl expand the accumulated commands and init code now:
+    [AC_CONFIG_COMMANDS([libtool],
+        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable.  If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins.  After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script.  The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $lt_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+  echo
+  AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2011 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+  case $[1] in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
+
+    -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+    *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+  esac
+  shift
+done
+
+if $lt_cl_silent; then
+  exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+  lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars.  Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+  m4_if(_LT_TAG, [C], [
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+  _LT_PROG_LTMAIN
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" \
+     || (rm -f "$cfgfile"; exit 1)
+
+  _LT_PROG_REPLACE_SHELLFNS
+
+   mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+  [C],                 [_LT_LANG(C)],
+  [C++],               [_LT_LANG(CXX)],
+  [Go],                        [_LT_LANG(GO)],
+  [Java],              [_LT_LANG(GCJ)],
+  [Fortran 77],                [_LT_LANG(F77)],
+  [Fortran],           [_LT_LANG(FC)],
+  [Windows Resource],  [_LT_LANG(RC)],
+  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+    [_LT_LANG($1)],
+    [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+  [LT_SUPPORTED_TAG([$1])dnl
+  m4_append([_LT_TAGS], [$1 ])dnl
+  m4_define([_LT_LANG_]$1[_enabled], [])dnl
+  _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+m4_ifndef([AC_PROG_GO], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_GO.  When it is available in    #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+############################################################
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC],     [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+  fi
+fi
+if test -z "$GOC"; then
+  AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [LT_LANG(CXX)],
+  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+  [LT_LANG(F77)],
+  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+  [LT_LANG(GCJ)],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+    [LT_LANG(GCJ)],
+    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+      [LT_LANG(GCJ)],
+      [m4_ifdef([AC_PROG_GCJ],
+       [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([A][M_PROG_GCJ],
+       [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([LT_PROG_GCJ],
+       [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+  [LT_LANG(GO)],
+  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+  [LT_LANG(RC)],
+  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+    AC_CHECK_TOOL([LIPO], [lipo], [:])
+    AC_CHECK_TOOL([OTOOL], [otool], [:])
+    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+    _LT_DECL([], [DSYMUTIL], [1],
+      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+    _LT_DECL([], [NMEDIT], [1],
+      [Tool to change global to local symbols on Mac OS X])
+    _LT_DECL([], [LIPO], [1],
+      [Tool to manipulate fat objects and archives on Mac OS X])
+    _LT_DECL([], [OTOOL], [1],
+      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+    _LT_DECL([], [OTOOL64], [1],
+      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+       # By default we will add the -single_module flag. You can override
+       # by either setting the environment variable LT_MULTI_MODULE
+       # non-empty at configure time, or by adding -multi_module to the
+       # link flags.
+       rm -rf libconftest.dylib*
+       echo "int foo(void){return 1;}" > conftest.c
+       echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+       $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+         -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+       # If there is a non-empty error log, and "single_module"
+       # appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+         cat conftest.err >&AS_MESSAGE_LOG_FD
+       # Otherwise, if the output was created with a 0 exit code from
+       # the compiler, it worked.
+       elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+         lt_cv_apple_cc_single_mod=yes
+       else
+         cat conftest.err >&AS_MESSAGE_LOG_FD
+       fi
+       rm -rf libconftest.dylib*
+       rm -f conftest.*
+      fi])
+
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+       [lt_cv_ld_exported_symbols_list=yes],
+       [lt_cv_ld_exported_symbols_list=no])
+       LDFLAGS="$save_LDFLAGS"
+    ])
+
+    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+      [lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+       cat conftest.err >&AS_MESSAGE_LOG_FD
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+       lt_cv_ld_force_load=yes
+      else
+       cat conftest.err >&AS_MESSAGE_LOG_FD
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[012]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+       10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+       10.[[012]]*)
+         _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+       10.*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_automatic, $1)=yes
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
+  else
+    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  fi
+  _LT_TAGVAR(link_all_deplibs, $1)=yes
+  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    m4_if([$1], [CXX],
+[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+],[])
+  else
+  _LT_TAGVAR(ld_shlibs, $1)=no
+  fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
+# ----------------------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+# Store the results from the different compilers for each TAGNAME.
+# Allow to override them for all tags through lt_cv_aix_libpath.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
+  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
+  lt_aix_libpath_sed='[
+      /Import File Strings/,/^$/ {
+         /^0/ {
+             s/^0  *\([^ ]*\) *$/\1/
+             p
+         }
+      }]'
+  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi],[])
+  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+  fi
+  ])
+  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
+fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
+
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script which will find a shell with a builtin
+# printf (which we can use as an echo command).
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*" 
+}
+
+case "$ECHO" in
+  printf*) AC_MSG_RESULT([printf]) ;;
+  print*) AC_MSG_RESULT([print -r]) ;;
+  *) AC_MSG_RESULT([cat]) ;;
+esac
+
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test "X`printf %s $ECHO`" = "X$ECHO" \
+      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
+
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_WITH_SYSROOT
+# ----------------
+AC_DEFUN([_LT_WITH_SYSROOT],
+[AC_MSG_CHECKING([for sysroot])
+AC_ARG_WITH([sysroot],
+[  --with-sysroot[=DIR] Search for dependent libraries within DIR
+                        (or the compiler's sysroot if not specified).],
+[], [with_sysroot=no])
+
+dnl lt_sysroot will always be passed unquoted.  We quote it here
+dnl in case the user passed a directory name.
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+   if test "$GCC" = yes; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_ERROR([The sysroot must be an absolute path.])
+   ;;
+esac
+
+ AC_MSG_RESULT([${lt_sysroot:-no}])
+_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
+[dependent libraries, and in which our libraries should be installed.])])
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+  [AS_HELP_STRING([--disable-libtool-lock],
+    [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+       HPUX_IA64_MODE="32"
+       ;;
+      *ELF-64*)
+       HPUX_IA64_MODE="64"
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -melf32bsmip"
+         ;;
+       *N32*)
+         LD="${LD-ld} -melf32bmipn32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -melf64bmip"
+       ;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -32"
+         ;;
+       *N32*)
+         LD="${LD-ld} -n32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -64"
+         ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_i386_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_i386"
+           ;;
+         ppc64-*linux*|powerpc64-*linux*)
+           LD="${LD-ld} -m elf32ppclinux"
+           ;;
+         s390x-*linux*)
+           LD="${LD-ld} -m elf_s390"
+           ;;
+         sparc64-*linux*)
+           LD="${LD-ld} -m elf32_sparc"
+           ;;
+       esac
+       ;;
+      *64-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_x86_64_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_x86_64"
+           ;;
+         ppc*-*linux*|powerpc*-*linux*)
+           LD="${LD-ld} -m elf64ppc"
+           ;;
+         s390*-*linux*|s390*-*tpf*)
+           LD="${LD-ld} -m elf64_s390"
+           ;;
+         sparc*-*linux*)
+           LD="${LD-ld} -m elf64_sparc"
+           ;;
+       esac
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
+      *)
+       if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+         LD="${LD-ld} -64"
+       fi
+       ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar], false)
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+
+AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
+  [lt_cv_ar_at_file=no
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+     [echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
+      AC_TRY_EVAL([lt_ar_try])
+      if test "$ac_status" -eq 0; then
+       # Ensure the archiver fails upon bogus file names.
+       rm -f conftest.$ac_objext libconftest.a
+       AC_TRY_EVAL([lt_ar_try])
+       if test "$ac_status" -ne 0; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
+     ])
+  ])
+
+if test "x$lt_cv_ar_at_file" = xno; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
+_LT_DECL([], [archiver_list_spec], [1],
+  [How to feed a file listing to the archiver])
+])# _LT_PROG_AR
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[_LT_PROG_AR
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+    [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+    [Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+    [Whether to use a lock for old archive extraction])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#              [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$5], , :, [$5])
+else
+    m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                  [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$4], , :, [$4])
+else
+    m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[        ]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+                = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+             test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+    [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+[#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}]
+_LT_EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+    ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+         [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+           [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+       [AC_CHECK_FUNC([dlopen],
+             [lt_cv_dlopen="dlopen"],
+         [AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+           [AC_CHECK_LIB([svld], [dlopen],
+                 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+             [AC_CHECK_LIB([dld], [dld_link],
+                   [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+             ])
+           ])
+         ])
+       ])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+         lt_cv_dlopen_self, [dnl
+         _LT_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+           lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+         lt_cv_dlopen_self_static, [dnl
+         _LT_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+           lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+        [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+        [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+        [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+       [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+         [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+    [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+    fi
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+       [], [
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+       lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
+
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
+
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
+
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
+
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[23]].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux # correct to gnu/linux during the next big refactor
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+    [lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+        LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+        [lt_cv_shlibpath_overrides_runpath=yes])])
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+    ])
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[  ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+       ;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+    [Variables whose values should be saved in libtool wrapper scripts and
+    restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+    [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+    [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+    [[List of archive names.  First name is the real one, the rest are links.
+    The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+    [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+    [Permission mode override for installation of shared libraries])
+_LT_DECL([], [postinstall_cmds], [2],
+    [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+    [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+    [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+    [[As "finish_cmds", except a single script fragment to be evaled but
+    not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+    [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+    [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+    [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="m4_if([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+        [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
+
+AC_ARG_WITH([gnu-ld],
+    [AS_HELP_STRING([--with-gnu-ld],
+       [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test "$GCC" != yes; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_TAGDECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+    fi
+    ;;
+  esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+    [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+    [Command to use when deplibs_check_method = "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+    [How to find potential files when deplibs_check_method = "file_magic"])
+_LT_DECL([], [want_nocaseglob], [1],
+    [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       # Tru64's nm complains that /dev/null is an invalid object file
+       case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+       */dev/null* | *'Invalid file or object type'*)
+         lt_cv_path_NM="$tmp_nm -B"
+         break
+         ;;
+       *)
+         case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+         */dev/null*)
+           lt_cv_path_NM="$tmp_nm -p"
+           break
+           ;;
+         *)
+           lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+           continue # so that we can try to find one that supports BSD flags
+           ;;
+         esac
+         ;;
+       esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
+  AC_SUBST([DUMPBIN])
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+  [lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
+  cat conftest.out >&AS_MESSAGE_LOG_FD
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+# --------------------------------
+# how to determine the name of the shared library
+# associated with a specific link library.
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+m4_require([_LT_DECL_DLLTOOL])
+AC_CACHE_CHECK([how to associate runtime and link libraries],
+lt_cv_sharedlib_from_linklib_cmd,
+[lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh
+  # decide which to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
+  *)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+    ;;
+  esac
+  ;;
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  ;;
+esac
+])
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
+    [Command to associate shared and link libraries])
+])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+
+
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+  [lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
+  fi
+  rm -f conftest*])
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
+  esac
+
+  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+       [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK ['"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx]"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[    ]]\($symcode$symcode*\)[[       ]][[    ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+       if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT@&t@_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT@&t@_DLSYM_CONST
+#else
+# define LT@&t@_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+         cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+LT@&t@_DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+         cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_globsym_save_LIBS=$LIBS
+         lt_globsym_save_CFLAGS=$CFLAGS
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+         if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS=$lt_globsym_save_LIBS
+         CFLAGS=$lt_globsym_save_CFLAGS
+       else
+         echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
+  nm_file_list_spec='@'
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+    [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+    [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+    [lt_cv_sys_global_symbol_to_c_name_address], [1],
+    [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+    [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([], [nm_file_list_spec], [1],
+    [Specify filename containing input files for $NM])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+m4_if([$1], [CXX], [
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+       # All AIX code is PIC.
+       if test "$host_cpu" = ia64; then
+         # AIX 5 now supports IA64 processor
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+       else
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+       fi
+       ;;
+      chorus*)
+       case $cc_basename in
+       cxch68*)
+         # Green Hills C++ Compiler
+         # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+         ;;
+       esac
+       ;;
+      mingw* | cygwin* | os2* | pw32* | cegcc*)
+       # This hack is so that the source file can tell whether it is being
+       # built for inclusion in a dll (and should export symbols for example).
+       m4_if([$1], [GCJ], [],
+         [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+       ;;
+      dgux*)
+       case $cc_basename in
+         ec++*)
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         ghcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      freebsd* | dragonfly*)
+       # FreeBSD uses GNU C++
+       ;;
+      hpux9* | hpux10* | hpux11*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+           if test "$host_cpu" != ia64; then
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+           fi
+           ;;
+         aCC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+           case $host_cpu in
+           hppa*64*|ia64*)
+             # +Z the default
+             ;;
+           *)
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+             ;;
+           esac
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      interix*)
+       # This is c89, which is MS Visual C++ (no shared libs)
+       # Anyone wants to do a port?
+       ;;
+      irix5* | irix6* | nonstopux*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           # CC pic flag -KPIC is the default.
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+       case $cc_basename in
+         KCC*)
+           # KAI C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         ecpc* )
+           # old Intel C++ for x86_64 which still supported -KPIC.
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         icpc* )
+           # Intel C++, used to be incompatible with GCC.
+           # ICC 10 doesn't accept -KPIC any more.
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         pgCC* | pgcpp*)
+           # Portland Group C++ compiler
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         cxx*)
+           # Compaq C++
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
+           # IBM XL 8.0, 9.0 on PPC and BlueGene
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+             _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+             _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+      lynxos*)
+       ;;
+      m88k*)
+       ;;
+      mvs*)
+       case $cc_basename in
+         cxx*)
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      netbsd*)
+       ;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+       case $cc_basename in
+         KCC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           ;;
+         RCC*)
+           # Rational C++ 2.4.1
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         cxx*)
+           # Digital/Compaq C++
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      psos*)
+       ;;
+      solaris*)
+       case $cc_basename in
+         CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+           ;;
+         gcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sunos4*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.x
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         lcc*)
+           # Lucid
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+       esac
+       ;;
+      tandem*)
+       case $cc_basename in
+         NCC*)
+           # NonStop-UX NCC 3.20
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      vxworks*)
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+       ;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)=
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
+      if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
+      fi
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+       ;;
+      nagfor*)
+       # NAG Fortran compiler
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+       ;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+       # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+       ;;
+      *)
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
+         # Sun Fortran 8.3 passes all unrecognized flags to the linker
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+         ;;
+       *Sun\ F* | *Sun*Fortran*)
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+         ;;
+       *Sun\ C*)
+         # Sun C 5.9
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+        *Intel*\ [[CF]]*Compiler*)
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+         ;;
+       *Portland\ Group*)
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         ;;
+       esac
+       ;;
+      esac
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+
+AC_CACHE_CHECK([for $compiler option to produce PIC],
+  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+       [Additional compiler flags for building library objects])
+
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+       [How to pass a linker flag through the compiler])
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+       [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    # Also, AIX nm treats weak defined symbols like other global defined
+    # symbols, whereas GNU nm marks them as "W".
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    ;;
+  cygwin* | mingw* | cegcc*)
+    case $cc_basename in
+    cl*)
+      _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+      ;;
+    *)
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+      ;;
+    esac
+    ;;
+  *)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+    ;;
+  esac
+], [
+  runpath_var=
+  _LT_TAGVAR(allow_undefined_flag, $1)=
+  _LT_TAGVAR(always_export_symbols, $1)=no
+  _LT_TAGVAR(archive_cmds, $1)=
+  _LT_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_TAGVAR(compiler_needs_object, $1)=no
+  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  _LT_TAGVAR(hardcode_automatic, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(inherit_rpath, $1)=no
+  _LT_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_TAGVAR(module_cmds, $1)=
+  _LT_TAGVAR(module_expsym_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_TAGVAR(ld_shlibs, $1)=yes
+
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
+    case $host_os in
+      aix*)
+       # The AIX port of GNU ld has always aspired to compatibility
+       # with the native linker.  However, as the warning in the GNU ld
+       # block says, versions before 2.19.5* couldn't really create working
+       # shared libraries, regardless of the interface used.
+       case `$LD -v 2>&1` in
+         *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+         *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
+         *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
+         *)
+           lt_use_gnu_ld_interface=yes
+           ;;
+       esac
+       ;;
+      *)
+       lt_use_gnu_ld_interface=yes
+       ;;
+    esac
+  fi
+
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=no
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    haiku*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    interix[[3-9]]*)
+      _LT_TAGVAR(hardcode_direct, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+       case $cc_basename in
+         diet\ *) tmp_diet=yes;;       # linux-dietlibc with static linking (!diet-dyn)
+       esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+        && test "$tmp_diet" = no
+      then
+       tmp_addflag=' $pic_flag'
+       tmp_sharedflag='-shared'
+       case $cc_basename,$host_cpu in
+        pgcc*)                         # Portland Group C compiler
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95* | pgfortran*)
+                                       # Portland Group f77 and f90 compilers
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)        # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       lf95*)                          # Lahey Fortran 8.1
+         _LT_TAGVAR(whole_archive_flag_spec, $1)=
+         tmp_sharedflag='--shared' ;;
+       xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+         tmp_sharedflag='-qmkshrobj'
+         tmp_addflag= ;;
+       nvcc*)  # Cuda Compiler Driver 2.2
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         _LT_TAGVAR(compiler_needs_object, $1)=yes
+         ;;
+       esac
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ C*)                       # Sun C 5.9
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         _LT_TAGVAR(compiler_needs_object, $1)=yes
+         tmp_sharedflag='-G' ;;
+       *Sun\ F*)                       # Sun Fortran 8.3
+         tmp_sharedflag='-G' ;;
+       esac
+       _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+           cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+           echo "local: *; };" >> $output_objdir/$libname.ver~
+           $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+       case $cc_basename in
+       xlf* | bgf* | bgxlf* | mpixlf*)
+         # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+         _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+         if test "x$supports_anon_versioning" = xyes; then
+           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+             cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+             echo "local: *; };" >> $output_objdir/$libname.ver~
+             $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+         fi
+         ;;
+       esac
+      else
+        _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+       ;;
+       *)
+         # For security reasons, it is highly recommended that you always
+         # use absolute paths for naming shared libraries, and exclude the
+         # DT_RUNPATH tag from executables and libraries.  But doing so
+         # requires that you compile everything twice, which is a pain.
+         if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         else
+           _LT_TAGVAR(ld_shlibs, $1)=no
+         fi
+       ;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       _LT_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       # Also, AIX nm treats weak defined symbols like other global
+       # defined symbols, whereas GNU nm marks them as "W".
+       if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+         _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       else
+         _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+         ;;
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_TAGVAR(archive_cmds, $1)=''
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[[012]]|aix4.[[012]].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+          strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         :
+         else
+         # We have old collect2
+         _LT_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+         ;;
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+         fi
+       fi
+      fi
+
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX([$1])
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+       if test "$host_cpu" = ia64; then
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+         _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX([$1])
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+         _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+         if test "$with_gnu_ld" = yes; then
+           # We only use this code for GNU lds that support --whole-archive.
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+         else
+           # Exported symbols can be pulled into shared objects from archives
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+         fi
+         _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[[45]]*)
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      case $cc_basename in
+      cl*)
+       # Native MSVC
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+       _LT_TAGVAR(always_export_symbols, $1)=yes
+       _LT_TAGVAR(file_list_spec, $1)='@'
+       # Tell ltmain to make .lib files, not .a files.
+       libext=lib
+       # Tell ltmain to make .dll files, not .so files.
+       shrext_cmds=".dll"
+       # FIXME: Setting linknames here is a bad hack.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+       _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+           sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+         else
+           sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+         fi~
+         $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+         linknames='
+       # The linker will not automatically build a static lib if we build a DLL.
+       # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+       _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+       _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+       # Don't use ranlib
+       _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+       _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+         lt_tool_outputfile="@TOOL_OUTPUT@"~
+         case $lt_outputfile in
+           *.exe|*.EXE) ;;
+           *)
+             lt_outputfile="$lt_outputfile.exe"
+             lt_tool_outputfile="$lt_tool_outputfile.exe"
+             ;;
+         esac~
+         if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+           $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+           $RM "$lt_outputfile.manifest";
+         fi'
+       ;;
+      *)
+       # Assume MSVC wrapper
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+       # Tell ltmain to make .lib files, not .a files.
+       libext=lib
+       # Tell ltmain to make .dll files, not .so files.
+       shrext_cmds=".dll"
+       # FIXME: Setting linknames here is a bad hack.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+       # The linker will automatically build a .lib file if we build a DLL.
+       _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+       # FIXME: Should let the user specify the lib program.
+       _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+       ;;
+      esac
+      ;;
+
+    darwin* | rhapsody*)
+      _LT_DARWIN_LINKER_FEATURES($1)
+      ;;
+
+    dgux*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2.*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_TAGVAR(hardcode_direct, $1)=yes
+       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       # hardcode_minus_L: Not really in the search PATH,
+       # but as the default location of the library.
+       _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+       m4_if($1, [], [
+         # Older versions of the 11.00 compiler do not understand -b yet
+         # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+         _LT_LINKER_OPTION([if $CC understands -b],
+           _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
+           [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+           [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
+         [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_TAGVAR(hardcode_direct, $1)=no
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+         ;;
+       *)
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+         _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       # Try to use the -exported_symbol ld option, if it does not
+       # work, assume that -exports_file does not work either and
+       # implicitly export all symbols.
+       # This should be the same for all languages, so no per-tag cache variable.
+       AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
+         [lt_cv_irix_exported_symbol],
+         [save_LDFLAGS="$LDFLAGS"
+          LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+          AC_LINK_IFELSE(
+            [AC_LANG_SOURCE(
+               [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
+                             [C++], [[int foo (void) { return 0; }]],
+                             [Fortran 77], [[
+      subroutine foo
+      end]],
+                             [Fortran], [[
+      subroutine foo
+      end]])])],
+             [lt_cv_irix_exported_symbol=yes],
+             [lt_cv_irix_exported_symbol=no])
+           LDFLAGS="$save_LDFLAGS"])
+       if test "$lt_cv_irix_exported_symbol" = yes; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+       fi
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(inherit_rpath, $1)=yes
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+       _LT_TAGVAR(hardcode_direct, $1)=yes
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+       if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+         _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       else
+         case $host_os in
+          openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+            _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+            ;;
+          *)
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+            ;;
+         esac
+       fi
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+       _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+       $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+       case `$CC -V 2>&1` in
+       *"Compilers 5.0"*)
+         wlarc=''
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+         ;;
+       *)
+         wlarc='${wl}'
+         _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+         ;;
+       esac
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+       # The compiler driver will combine and reorder linker options,
+       # but understands `-z linker_flag'.  GCC discards it without `$wl',
+       # but is careful enough not to reorder.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       if test "$GCC" = yes; then
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+       else
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+       fi
+       ;;
+      esac
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+         _LT_TAGVAR(hardcode_direct, $1)=no
+        ;;
+       motorola)
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       _LT_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+       ;;
+      esac
+    fi
+  fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+    [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_CACHE_CHECK([whether -lc should be explicitly linked in],
+       [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
+       [$RM conftest*
+       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+       if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+         soname=conftest
+         lib=conftest
+         libobjs=conftest.$ac_objext
+         deplibs=
+         wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+         pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+         compiler_flags=-v
+         linker_flags=-v
+         verstring=
+         output_objdir=.
+         libname=conftest
+         lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+         _LT_TAGVAR(allow_undefined_flag, $1)=
+         if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+         then
+           lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+         else
+           lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+         fi
+         _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+       else
+         cat conftest.err 1>&5
+       fi
+       $RM conftest*
+       ])
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+    [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+    [enable_shared_with_static_runtimes], [0],
+    [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+    [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+    [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+    [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+    [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+    [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+    [Commands used to build a loadable module if different from building
+    a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+    [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+    [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+    [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+    [Flag to hardcode $libdir into a binary during linking.
+    This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+    [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary and the resulting library dependency is
+    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+    [Set to "yes" if building a shared library automatically hardcodes DIR
+    into the library and all subsequent libraries and executables linked
+    against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+    [Set to yes if linker adds runtime paths of dependent libraries
+    to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+    [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [always_export_symbols], [0],
+    [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+    [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+    [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+    [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+    [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+    [Commands necessary for finishing linking programs])
+_LT_TAGDECL([], [file_list_spec], [1],
+    [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl    [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_SYS_DYNAMIC_LINKER($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+  LT_SYS_DLOPEN_SELF
+  _LT_CMD_STRIPLIB
+
+  # Report which library types will actually be built
+  AC_MSG_CHECKING([if libtool supports shared libraries])
+  AC_MSG_RESULT([$can_build_shared])
+
+  AC_MSG_CHECKING([whether to build shared libraries])
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[[4-9]]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  AC_MSG_RESULT([$enable_shared])
+
+  AC_MSG_CHECKING([whether to build static libraries])
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  AC_MSG_RESULT([$enable_static])
+
+  _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+else
+  _lt_caught_CXX_error=yes
+fi
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_CFLAGS=$CFLAGS
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  CFLAGS=$CXXFLAGS
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+    else
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+      LT_PATH_LD
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+         $GREP 'no-whole-archive' > /dev/null; then
+          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+    _LT_TAGVAR(ld_shlibs, $1)=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+      aix[[4-9]]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+           for ld_flag in $LDFLAGS; do
+             case $ld_flag in
+             *-brtl*)
+               aix_use_runtimelinking=yes
+               break
+               ;;
+             esac
+           done
+           ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        _LT_TAGVAR(archive_cmds, $1)=''
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[[012]]|aix4.[[012]].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+            strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+           # We have reworked collect2
+           :
+         else
+           # We have old collect2
+           _LT_TAGVAR(hardcode_direct, $1)=unsupported
+           # It fails to find uninstalled libraries when the uninstalled
+           # path is not listed in the libpath.  Setting hardcode_minus_L
+           # to unsupported forces relinking
+           _LT_TAGVAR(hardcode_minus_L, $1)=yes
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+          esac
+          shared_flag='-shared'
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag="$shared_flag "'${wl}-G'
+         fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+         # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+         # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+          else
+           if test "$aix_use_runtimelinking" = yes; then
+             shared_flag='${wl}-G'
+           else
+             shared_flag='${wl}-bM:SRE'
+           fi
+          fi
+        fi
+
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+       # export.
+        _LT_TAGVAR(always_export_symbols, $1)=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          _LT_SYS_MODULE_PATH_AIX([$1])
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+           _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+           # Determine the default libpath from the value encoded in an
+           # empty executable.
+           _LT_SYS_MODULE_PATH_AIX([$1])
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+           # Warning - without using the other run time loading flags,
+           # -berok will link without error, but may produce a broken library.
+           _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+           _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+           if test "$with_gnu_ld" = yes; then
+             # We only use this code for GNU lds that support --whole-archive.
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           else
+             # Exported symbols can be pulled into shared objects from archives
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+           fi
+           _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+           # This is similar to how AIX traditionally builds its shared
+           # libraries.
+           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+         _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+         # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+         # support --undefined.  This deserves some investigation.  FIXME
+         _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       else
+         _LT_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+         # FIXME: insert proper C++ library support
+         _LT_TAGVAR(ld_shlibs, $1)=no
+         ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32* | cegcc*)
+       case $GXX,$cc_basename in
+       ,cl* | no,cl*)
+         # Native MSVC
+         # hardcode_libdir_flag_spec is actually meaningless, as there is
+         # no search path for DLLs.
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+         _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+         _LT_TAGVAR(always_export_symbols, $1)=yes
+         _LT_TAGVAR(file_list_spec, $1)='@'
+         # Tell ltmain to make .lib files, not .a files.
+         libext=lib
+         # Tell ltmain to make .dll files, not .so files.
+         shrext_cmds=".dll"
+         # FIXME: Setting linknames here is a bad hack.
+         _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+         _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+             $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+           else
+             $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+           fi~
+           $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+           linknames='
+         # The linker will not automatically build a static lib if we build a DLL.
+         # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+         _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+         # Don't use ranlib
+         _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+         _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+           lt_tool_outputfile="@TOOL_OUTPUT@"~
+           case $lt_outputfile in
+             *.exe|*.EXE) ;;
+             *)
+               lt_outputfile="$lt_outputfile.exe"
+               lt_tool_outputfile="$lt_tool_outputfile.exe"
+               ;;
+           esac~
+           func_to_tool_file "$lt_outputfile"~
+           if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+             $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+             $RM "$lt_outputfile.manifest";
+           fi'
+         ;;
+       *)
+         # g++
+         # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+         # as there is no search path for DLLs.
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+         _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+         _LT_TAGVAR(always_export_symbols, $1)=no
+         _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+         if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+           # If the export-symbols file already is a .def file (1st line
+           # is EXPORTS), use it as is; otherwise, prepend...
+           _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+             cp $export_symbols $output_objdir/$soname.def;
+           else
+             echo EXPORTS > $output_objdir/$soname.def;
+             cat $export_symbols >> $output_objdir/$soname.def;
+           fi~
+           $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+         else
+           _LT_TAGVAR(ld_shlibs, $1)=no
+         fi
+         ;;
+       esac
+       ;;
+      darwin* | rhapsody*)
+        _LT_DARWIN_LINKER_FEATURES($1)
+       ;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          ghcx*)
+           # Green Hills C++ Compiler
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      freebsd2.*)
+        # C++ shared libraries reported to be fairly broken before
+       # switch to ELF
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      freebsd-elf*)
+        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      haiku*)
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        ;;
+
+      hpux9*)
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                            # but as the default
+                                            # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            _LT_TAGVAR(ld_shlibs, $1)=no
+            ;;
+          aCC*)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              _LT_TAGVAR(ld_shlibs, $1)=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+             _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            _LT_TAGVAR(hardcode_direct, $1)=no
+            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+            ;;
+          *)
+            _LT_TAGVAR(hardcode_direct, $1)=yes
+            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                                # but as the default
+                                                # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          aCC*)
+           case $host_cpu in
+             hppa*64*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             ia64*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             *)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+           esac
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test $with_gnu_ld = no; then
+               case $host_cpu in
+                 hppa*64*)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 ia64*)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 *)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+               esac
+             fi
+           else
+             # FIXME: insert proper C++ library support
+             _LT_TAGVAR(ld_shlibs, $1)=no
+           fi
+           ;;
+        esac
+        ;;
+
+      interix[[3-9]]*)
+       _LT_TAGVAR(hardcode_direct, $1)=no
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+       # Instead, shared libraries are loaded at an image base (0x10000000 by
+       # default) and relocated if they conflict, which is a slow very memory
+       # consuming and fragmenting process.  To avoid this, we pick a random,
+       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       ;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+           # SGI C++
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+           # Archives containing C++ object files must be created using
+           # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test "$with_gnu_ld" = no; then
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+             else
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+             fi
+           fi
+           _LT_TAGVAR(link_all_deplibs, $1)=yes
+           ;;
+        esac
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(inherit_rpath, $1)=yes
+        ;;
+
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+           # Archives containing C++ object files must be created using
+           # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+           ;;
+         icpc* | ecpc* )
+           # Intel C++
+           with_gnu_ld=yes
+           # version 8.0 and above of icpc choke on multiply defined symbols
+           # if we add $predep_objects and $postdep_objects, however 7.1 and
+           # earlier do not add the objects themselves.
+           case `$CC -V 2>&1` in
+             *"Version 7."*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+             *)  # Version 8.0 or newer
+               tmp_idyn=
+               case $host_cpu in
+                 ia64*) tmp_idyn=' -i_dynamic';;
+               esac
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+           esac
+           _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+           case `$CC -V` in
+           *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
+             _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+             _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+               $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+               $RANLIB $oldlib'
+             _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           *) # Version 6 and above use weak symbols
+             _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           esac
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+         cxx*)
+           # Compaq C++
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+           runpath_var=LD_RUN_PATH
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+           ;;
+         xl* | mpixl* | bgxl*)
+           # IBM XL 8.0 on PPC, with GNU ld
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           if test "x$supports_anon_versioning" = xyes; then
+             _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+               cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+               echo "local: *; };" >> $output_objdir/$libname.ver~
+               $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+           fi
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+             _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+             _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+             # Not sure whether something based on
+             # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+             # would be better.
+             output_verbose_link_cmd='func_echo_all'
+
+             # Archives containing C++ object files must be created using
+             # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+             # necessary to make sure instantiated templates are included
+             # in the archive.
+             _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+         *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+       esac
+       ;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+         _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+         wlarc=
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       fi
+       # Workaround some broken pre-1.5 toolchains
+       output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+       ;;
+
+      *nto* | *qnx*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+       ;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      openbsd*)
+       if test -f /usr/libexec/ld.so; then
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+         if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+         fi
+         output_verbose_link_cmd=func_echo_all
+       else
+         _LT_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Archives containing C++ object files must be created using
+           # the KAI C++ compiler.
+           case $host in
+             osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+             *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+           esac
+           ;;
+          RCC*)
+           # Rational C++ 2.4.1
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          cxx*)
+           case $host in
+             osf3*)
+               _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+               ;;
+             *)
+               _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+                 echo "-hidden">> $lib.exp~
+                 $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+                 $RM $lib.exp'
+               _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+               ;;
+           esac
+
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+         *)
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+             case $host in
+               osf3*)
+                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+               *)
+                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+             esac
+
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+             _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+             # Commands to make compiler produce verbose output that lists
+             # what "hidden" libraries, object files and flags are used when
+             # linking a shared library.
+             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+           else
+             # FIXME: insert proper C++ library support
+             _LT_TAGVAR(ld_shlibs, $1)=no
+           fi
+           ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+           # Sun C++ 4.x
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          lcc*)
+           # Lucid
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+           _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+             $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+           _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+           case $host_os in
+             solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+             *)
+               # The compiler driver will combine and reorder linker options,
+               # but understands `-z linker_flag'.
+               # Supported since Solaris 2.6 (maybe 2.5.1?)
+               _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+               ;;
+           esac
+           _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+           output_verbose_link_cmd='func_echo_all'
+
+           # Archives containing C++ object files must be created using
+           # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+           ;;
+          gcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+           # The C++ compiler must be used to create the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+           ;;
+          *)
+           # GNU C++ compiler with Solaris linker
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+             if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             else
+               # g++ 2.7 appears to require `-G' NOT `-shared' on this
+               # platform.
+               _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             fi
+
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+             case $host_os in
+               solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+               *)
+                 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+                 ;;
+             esac
+           fi
+           ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+       # Note: We can NOT use -z defs as we might desire, because we do not
+       # link with -lc, and that would cause any symbols used from libc to
+       # always be unresolved, which means just about no library would
+       # ever link correctly.  If we're not using GNU ld we use -z text
+       # though, which does catch some bad symbols but isn't as heavy-handed
+       # as -z defs.
+       _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+       _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+       _LT_TAGVAR(link_all_deplibs, $1)=yes
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+       runpath_var='LD_RUN_PATH'
+
+       case $cc_basename in
+          CC*)
+           _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+             '"$_LT_TAGVAR(old_archive_cmds, $1)"
+           _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+             '"$_LT_TAGVAR(reload_cmds, $1)"
+           ;;
+         *)
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           ;;
+       esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+           # NonStop-UX NCC 3.20
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+    esac
+
+    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_FUNC_STRIPNAME_CNF
+# ----------------------
+# func_stripname_cnf prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+#
+# This function is identical to the (non-XSI) version of func_stripname,
+# except this one can be used by m4 code that may be executed by configure,
+# rather than the libtool script.
+m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
+AC_REQUIRE([_LT_DECL_SED])
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
+])# _LT_FUNC_STRIPNAME_CNF
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+_LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
+])
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case ${prev}${p} in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+        prev=$p
+        continue
+       fi
+
+       # Expand the sysroot to ease extracting the directories later.
+       if test -z "$prev"; then
+         case $p in
+         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+         esac
+       fi
+       case $p in
+       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+       esac
+       if test "$pre_test_object_deps_done" = no; then
+        case ${prev} in
+        -L | -R)
+          # Internal compiler library paths should come after those
+          # provided the user.  The postdeps already come after the
+          # user supplied libs so there is no need to process them.
+          if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+            _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+          else
+            _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+          fi
+          ;;
+        # The "-l" case would never come before the object being
+        # linked, so don't bother handling this case.
+        esac
+       else
+        if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+          _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+        else
+          _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+        fi
+       fi
+       prev=
+       ;;
+
+    *.lto.$objext) ;; # Ignore GCC LTO objects
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+        pre_test_object_deps_done=yes
+        continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+          _LT_TAGVAR(predep_objects, $1)="$p"
+        else
+          _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+        fi
+       else
+        if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+          _LT_TAGVAR(postdep_objects, $1)="$p"
+        else
+          _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+        fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_TAGVAR(predep_objects,$1)=
+  _LT_TAGVAR(postdep_objects,$1)=
+  _LT_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC* | sunCC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+    [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+    [Dependencies to place before and after the objects being linked to
+    create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+    [The library search path used internally by the compiler when linking
+    a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  lt_save_CFLAGS=$CFLAGS
+  CC=${F77-"f77"}
+  CFLAGS=$FFLAGS
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+  GCC=$G77
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+       if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+         test "$enable_shared" = yes && enable_static=no
+       fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$G77"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+  CFLAGS="$lt_save_CFLAGS"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_LANG_PUSH(Fortran)
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  lt_save_CFLAGS=$CFLAGS
+  CC=${FC-"f95"}
+  CFLAGS=$FCFLAGS
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
+
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+       if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+         test "$enable_shared" = yes && enable_static=no
+       fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+CFLAGS=$GCJFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+CFLAGS=
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+  :
+  _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+    [AC_CHECK_TOOL(GCJ, gcj,)
+      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+# _LT_DECL_DLLTOOL
+# ----------------
+# Ensure DLLTOOL variable is set.
+m4_defun([_LT_DECL_DLLTOOL],
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
+AC_SUBST([DLLTOOL])
+])
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
+# ------------------------------------------------------
+# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
+# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
+m4_defun([_LT_PROG_FUNCTION_REPLACE],
+[dnl {
+sed -e '/^$1 ()$/,/^} # $1 /c\
+$1 ()\
+{\
+m4_bpatsubsts([$2], [$], [\\], [^\([    ]\)], [\\\1])
+} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+])
+
+
+# _LT_PROG_REPLACE_SHELLFNS
+# -------------------------
+# Replace existing portable implementations of several shell functions with
+# equivalent extended shell implementations where those features are available..
+m4_defun([_LT_PROG_REPLACE_SHELLFNS],
+[if test x"$xsi_shell" = xyes; then
+  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
+    case ${1} in
+      */*) func_dirname_result="${1%/*}${2}" ;;
+      *  ) func_dirname_result="${3}" ;;
+    esac])
+
+  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
+    func_basename_result="${1##*/}"])
+
+  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
+    case ${1} in
+      */*) func_dirname_result="${1%/*}${2}" ;;
+      *  ) func_dirname_result="${3}" ;;
+    esac
+    func_basename_result="${1##*/}"])
+
+  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary parameter first.
+    func_stripname_result=${3}
+    func_stripname_result=${func_stripname_result#"${1}"}
+    func_stripname_result=${func_stripname_result%"${2}"}])
+
+  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
+    func_split_long_opt_name=${1%%=*}
+    func_split_long_opt_arg=${1#*=}])
+
+  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
+    func_split_short_opt_arg=${1#??}
+    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
+
+  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
+    case ${1} in
+      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+      *)    func_lo2o_result=${1} ;;
+    esac])
+
+  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
+
+  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
+
+  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
+fi
+
+if test x"$lt_shell_append" = xyes; then
+  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
+
+  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
+    func_quote_for_eval "${2}"
+dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
+    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
+
+  # Save a `func_append' function call where possible by direct use of '+='
+  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+else
+  # Save a `func_append' function call even when '+=' is not available
+  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
+fi
+])
+
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine which file name conversion functions should be used by
+# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
+# for certain cross-compile configurations and native mingw.
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_MSG_CHECKING([how to convert $build file names to $host format])
+AC_CACHE_VAL(lt_cv_to_host_file_cmd,
+[case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+        ;;
+    esac
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
+])
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
+_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
+         [0], [convert $build file names to $host format])dnl
+
+AC_MSG_CHECKING([how to convert $build file names to toolchain format])
+AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
+[#assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+])
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
+_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
+         [0], [convert $build files to toolchain format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
new file mode 100644 (file)
index 0000000..5d9acd8
--- /dev/null
@@ -0,0 +1,384 @@
+# Helper functions for option handling.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
+#   Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 7 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+        _LT_MANGLE_DEFUN([$1], [$2]),
+    [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+           [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+                     [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME.  If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+    [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+  dnl
+  dnl Simply set some default values (i.e off) if boolean options were not
+  dnl specified:
+  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+  ])
+  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+  ])
+  dnl
+  dnl If no reference was made to various pairs of opposing options, then
+  dnl we run the default mode handler for the pair.  For example, if neither
+  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl archives by default:
+  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+                  [_LT_ENABLE_FAST_INSTALL])
+  ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS],      [1], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+       [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+    _LT_DECL([build_libtool_libs], [enable_shared], [0],
+       [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+       [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+    _LT_DECL([build_old_libs], [enable_static], [0],
+       [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+        [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
+       [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+       IFS="$lt_save_ifs"
+       if test "X$lt_pkg" = "X$lt_p"; then
+         pic_mode=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+                [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+                [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+                [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+                [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+                [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
new file mode 100644 (file)
index 0000000..9000a05
--- /dev/null
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+       [$#], [2], [[$2]],
+       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+       [$#], 1, [],
+       [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+          m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+            [m4_foreach([_Lt_suffix],
+               ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+       [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+         [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+                [lt_append([$1], [$2], [$3])$4],
+                [$5])],
+         [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+       m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+       [$5],
+    [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+  [lt_join(m4_quote(m4_default([$4], [[, ]])),
+           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+                     [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
new file mode 100644 (file)
index 0000000..07a8602
--- /dev/null
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers                      -*- Autoconf -*-
+#
+#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# @configure_input@
+
+# serial 3337 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.4.2])
+m4_define([LT_PACKAGE_REVISION], [1.3337])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.4.2'
+macro_revision='1.3337'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
new file mode 100644 (file)
index 0000000..c573da9
--- /dev/null
@@ -0,0 +1,98 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 5 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],  [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],             [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],        [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],         [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],    [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],           [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],             [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],    [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],           [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],       [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],               [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],        [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],    [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],    [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],         [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],            [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],  [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],             [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],            [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],    [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],   [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],          [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],            [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],           [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],  [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],    [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],          [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],          [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],                [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],     [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],          [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],   [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],           [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],           [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],           [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],  [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],      [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],    [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],    [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],    [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],     [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],         [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],       [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],        [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP],                [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],        [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH],   [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77],              [AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC],               [AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX],              [AC_DEFUN([_LT_PROG_CXX])])
diff --git a/missing b/missing
new file mode 100755 (executable)
index 0000000..cdea514
--- /dev/null
+++ b/missing
@@ -0,0 +1,215 @@
+#! /bin/sh
+# Common wrapper for a few potentially missing GNU programs.
+
+scriptversion=2012-06-26.16; # UTC
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try '$0 --help' for more information"
+  exit 1
+fi
+
+case $1 in
+
+  --is-lightweight)
+    # Used by our autoconf macros to check whether the available missing
+    # script is modern enough.
+    exit 0
+    ;;
+
+  --run)
+    # Back-compat with the calling convention used by older automake.
+    shift
+    ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
+to PROGRAM being missing or too old.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+
+Supported PROGRAM values:
+  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
+  bison     yacc      flex         lex       help2man
+
+Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
+'g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: unknown '$1' option"
+    echo 1>&2 "Try '$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Run the given program, remember its exit status.
+"$@"; st=$?
+
+# If it succeeded, we are done.
+test $st -eq 0 && exit 0
+
+# Also exit now if we it failed (or wasn't found), and '--version' was
+# passed; such an option is passed most likely to detect whether the
+# program is present and works.
+case $2 in --version|--help) exit $st;; esac
+
+# Exit code 63 means version mismatch.  This often happens when the user
+# tries to use an ancient version of a tool on a file that requires a
+# minimum version.
+if test $st -eq 63; then
+  msg="probably too old"
+elif test $st -eq 127; then
+  # Program was missing.
+  msg="missing on your system"
+else
+  # Program was found and executed, but failed.  Give up.
+  exit $st
+fi
+
+perl_URL=http://www.perl.org/
+flex_URL=http://flex.sourceforge.net/
+gnu_software_URL=http://www.gnu.org/software
+
+program_details ()
+{
+  case $1 in
+    aclocal|automake)
+      echo "The '$1' program is part of the GNU Automake package:"
+      echo "<$gnu_software_URL/automake>"
+      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/autoconf>"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+    autoconf|autom4te|autoheader)
+      echo "The '$1' program is part of the GNU Autoconf package:"
+      echo "<$gnu_software_URL/autoconf/>"
+      echo "It also requires GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+  esac
+}
+
+give_advice ()
+{
+  # Normalize program name to check for.
+  normalized_program=`echo "$1" | sed '
+    s/^gnu-//; t
+    s/^gnu//; t
+    s/^g//; t'`
+
+  printf '%s\n' "'$1' is $msg."
+
+  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
+  case $normalized_program in
+    autoconf*)
+      echo "You should only need it if you modified 'configure.ac',"
+      echo "or m4 files included by it."
+      program_details 'autoconf'
+      ;;
+    autoheader*)
+      echo "You should only need it if you modified 'acconfig.h' or"
+      echo "$configure_deps."
+      program_details 'autoheader'
+      ;;
+    automake*)
+      echo "You should only need it if you modified 'Makefile.am' or"
+      echo "$configure_deps."
+      program_details 'automake'
+      ;;
+    aclocal*)
+      echo "You should only need it if you modified 'acinclude.m4' or"
+      echo "$configure_deps."
+      program_details 'aclocal'
+      ;;
+   autom4te*)
+      echo "You might have modified some maintainer files that require"
+      echo "the 'automa4te' program to be rebuilt."
+      program_details 'autom4te'
+      ;;
+    bison*|yacc*)
+      echo "You should only need it if you modified a '.y' file."
+      echo "You may want to install the GNU Bison package:"
+      echo "<$gnu_software_URL/bison/>"
+      ;;
+    lex*|flex*)
+      echo "You should only need it if you modified a '.l' file."
+      echo "You may want to install the Fast Lexical Analyzer package:"
+      echo "<$flex_URL>"
+      ;;
+    help2man*)
+      echo "You should only need it if you modified a dependency" \
+           "of a man page."
+      echo "You may want to install the GNU Help2man package:"
+      echo "<$gnu_software_URL/help2man/>"
+    ;;
+    makeinfo*)
+      echo "You should only need it if you modified a '.texi' file, or"
+      echo "any other file indirectly affecting the aspect of the manual."
+      echo "You might want to install the Texinfo package:"
+      echo "<$gnu_software_URL/texinfo/>"
+      echo "The spurious makeinfo call might also be the consequence of"
+      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
+      echo "want to install GNU make:"
+      echo "<$gnu_software_URL/make/>"
+      ;;
+    *)
+      echo "You might have modified some files without having the proper"
+      echo "tools for further handling them.  Check the 'README' file, it"
+      echo "often tells you about the needed prerequisites for installing"
+      echo "this package.  You may also peek at any GNU archive site, in"
+      echo "case some other package contains this missing '$1' program."
+      ;;
+  esac
+}
+
+give_advice "$1" | sed -e '1s/^/WARNING: /' \
+                       -e '2,$s/^/         /' >&2
+
+# Propagate the correct exit status (expected to be 127 for a program
+# not found, 63 for a program that failed due to version mismatch).
+exit $st
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/mlsl/Makefile.am b/mlsl/Makefile.am
new file mode 100644 (file)
index 0000000..b019c2c
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libmlsl.la
+libmlsl_la_SOURCES = mlsl.c mlsl.h
+
+EXTRA_DIST = README
diff --git a/mlsl/Makefile.in b/mlsl/Makefile.in
new file mode 100644 (file)
index 0000000..cf6fef0
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = mlsl
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libmlsl_la_LIBADD =
+am_libmlsl_la_OBJECTS = mlsl.lo
+libmlsl_la_OBJECTS = $(am_libmlsl_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libmlsl_la_SOURCES)
+DIST_SOURCES = $(libmlsl_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libmlsl.la
+libmlsl_la_SOURCES = mlsl.c mlsl.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu mlsl/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu mlsl/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libmlsl.la: $(libmlsl_la_OBJECTS) $(libmlsl_la_DEPENDENCIES) $(EXTRA_libmlsl_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libmlsl_la_OBJECTS) $(libmlsl_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mlsl.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/mlsl/README b/mlsl/README
new file mode 100644 (file)
index 0000000..18852b0
--- /dev/null
@@ -0,0 +1,22 @@
+This is my implementation of the "Multi-Level Single-Linkage" (MLSL)
+algorithm for global optimization by random local optimizations (a
+multistart algorithm with "clustering" to avoid repeated detection of
+the same local minimum), modified to optionally use a Sobol'
+low-discrepancy sequence (LDS) instead of pseudorandom numbers.  See:
+
+   A. H. G. Rinnooy Kan and G. T. Timmer, "Stochastic global optimization
+   methods," Mathematical Programming, vol. 39, p. 27-78 (1987).
+       [ actually 2 papers -- part I: clustering methods (p. 27), then 
+                              part II: multilevel methods (p. 57) ]
+
+and also:
+
+   Sergei Kucherenko and Yury Sytsko, "Application of deterministic
+   low-discrepancy sequences in global optimization," Computational
+   Optimization and Applications, vol. 30, p. 297-318 (2005).
+
+It is under the same MIT license as the rest of my code in NLopt (see
+../COPYRIGHT).
+
+Steven G. Johnson
+September 2007
diff --git a/mlsl/mlsl.c b/mlsl/mlsl.c
new file mode 100644 (file)
index 0000000..da57c95
--- /dev/null
@@ -0,0 +1,435 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* Multi-Level Single-Linkage (MLSL) algorithm for
+   global optimization by random local optimizations (a multistart algorithm
+   with "clustering" to avoid repeated detection of the same local minimum), 
+   modified to optionally use a Sobol' low-discrepancy sequence (LDS) instead 
+   of pseudorandom numbers.  See:
+
+   A. H. G. Rinnooy Kan and G. T. Timmer, "Stochastic global optimization
+   methods," Mathematical Programming, vol. 39, p. 27-78 (1987).
+       [ actually 2 papers -- part I: clustering methods (p. 27), then 
+                              part II: multilevel methods (p. 57) ]
+
+   and also:
+
+   Sergei Kucherenko and Yury Sytsko, "Application of deterministic
+   low-discrepancy sequences in global optimization," Computational
+   Optimization and Applications, vol. 30, p. 297-318 (2005).
+
+   Compared to the above papers, I made a couple other modifications
+   to the algorithm besides the use of a LDS.
+
+   1) first, the original algorithm suggests discarding points
+      within a *fixed* distance of the boundaries or of previous
+      local minima; I changed this to a distance that decreases with,
+      iteration, proportional to the same threshold radius used
+      for clustering.  (In the case of the boundaries, I make
+      the proportionality constant rather small as well.)
+
+   2) Kan and Timmer suggest using fancy "spiral-search" algorithms
+      to quickly locate nearest-neighbor points, reducing the
+      overall time for N sample points from O(N^2) to O(N log N)
+      However, recent papers seem to show that such schemes (kd trees,
+      etcetera) become inefficient for high-dimensional spaces (d > 20),
+      and finding a better approach seems to be an open question.  Therefore,
+      since I am mainly interested in MLSL for high-dimensional problems
+      (in low dimensions we have DIRECT etc.), I punted on this question
+      for now.  In practice, O(N^2) (which does not count the #points
+      evaluated in local searches) does not seem too bad if the objective
+      function is expensive.
+
+*/
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#include "redblack.h"
+#include "mlsl.h"
+
+/* data structure for each random/quasirandom point in the population */
+typedef struct {
+     double f; /* function value at x */
+     int minimized; /* if we have already minimized starting from x */
+     double closest_pt_d; /* distance^2 to closest pt with smaller f */
+     double closest_lm_d; /* distance^2 to closest lm with smaller f*/
+     double x[1]; /* array of length n (K&R struct hack) */
+} pt;
+
+/* all of the data used by the various mlsl routines...it's
+   not clear in hindsight that we need to put all of this in a data
+   structure since most of the work occurs in a single routine,
+   but it doesn't hurt us */
+typedef struct {
+     int n; /* # dimensions */
+     const double *lb, *ub;
+     nlopt_stopping *stop; /* stopping criteria */
+     nlopt_func f; void *f_data;
+
+     rb_tree pts; /* tree of points (k == pt), sorted by f */
+     rb_tree lms; /* tree of local minimizers, sorted by function value
+                    (k = array of length d+1, [0] = f, [1..d] = x) */
+
+     nlopt_sobol s; /* sobol data for LDS point generation, or NULL
+                      to use pseudo-random numbers */
+
+     double R_prefactor, dlm, dbound, gamma; /* parameters of MLSL */
+     int N; /* number of pts to add per iteration */
+} mlsl_data;
+
+/* comparison routines to sort the red-black trees by function value */
+static int pt_compare(rb_key p1_, rb_key p2_)
+{
+     pt *p1 = (pt *) p1_;
+     pt *p2 = (pt *) p2_;
+     if (p1->f < p2->f) return -1;
+     if (p1->f > p2->f) return +1;
+     return 0;
+}
+static int lm_compare(double *k1, double *k2)
+{
+     if (*k1 < *k2) return -1;
+     if (*k1 > *k2) return +1;
+     return 0;
+}
+
+/* Euclidean distance |x1 - x2|^2 */
+static double distance2(int n, const double *x1, const double *x2)
+{
+     int i;
+     double d = 0.;
+     for (i = 0; i < n; ++i) {
+         double dx = x1[i] - x2[i];
+         d += dx * dx;
+     }
+     return d;
+}
+
+/* find the closest pt to p with a smaller function value;
+   this function is called when p is first added to our tree */
+static void find_closest_pt(int n, rb_tree *pts, pt *p)
+{
+     rb_node *node = rb_tree_find_lt(pts, (rb_key) p);
+     double closest_d = HUGE_VAL;
+     while (node) {
+         double d = distance2(n, p->x, ((pt *) node->k)->x);
+         if (d < closest_d) closest_d = d;
+         node = rb_tree_pred(node);
+     }
+     p->closest_pt_d = closest_d;
+}
+
+/* find the closest local minimizer (lm) to p with a smaller function value;
+   this function is called when p is first added to our tree */
+static void find_closest_lm(int n, rb_tree *lms, pt *p)
+{
+     rb_node *node = rb_tree_find_lt(lms, &p->f);
+     double closest_d = HUGE_VAL;
+     while (node) {
+         double d = distance2(n, p->x, node->k+1);
+         if (d < closest_d) closest_d = d;
+         node = rb_tree_pred(node);
+     }
+     p->closest_lm_d = closest_d;
+}
+
+/* given newpt, which presumably has just been added to our
+   tree, update all pts with a greater function value in case
+   newpt is closer to them than their previous closest_pt ...
+   we can ignore already-minimized points since we never do
+   local minimization from the same point twice */
+static void pts_update_newpt(int n, rb_tree *pts, pt *newpt)
+{
+     rb_node *node = rb_tree_find_gt(pts, (rb_key) newpt);
+     while (node) {
+         pt *p = (pt *) node->k;
+         if (!p->minimized) {
+              double d = distance2(n, newpt->x, p->x);
+              if (d < p->closest_pt_d) p->closest_pt_d = d;
+         }
+         node = rb_tree_succ(node);
+     }
+}
+
+/* given newlm, which presumably has just been added to our
+   tree, update all pts with a greater function value in case
+   newlm is closer to them than their previous closest_lm ...
+   we can ignore already-minimized points since we never do
+   local minimization from the same point twice */
+static void pts_update_newlm(int n, rb_tree *pts, double *newlm)
+{
+     pt tmp_pt;
+     rb_node *node;
+     tmp_pt.f = newlm[0];
+     node = rb_tree_find_gt(pts, (rb_key) &tmp_pt);
+     while (node) {
+         pt *p = (pt *) node->k;
+         if (!p->minimized) {
+              double d = distance2(n, newlm+1, p->x);
+              if (d < p->closest_lm_d) p->closest_lm_d = d;
+         }
+         node = rb_tree_succ(node);
+     }
+}
+
+static int is_potential_minimizer(mlsl_data *mlsl, pt *p,
+                                 double dpt_min,
+                                 double dlm_min,
+                                 double dbound_min)
+{
+     int i, n = mlsl->n;
+     const double *lb = mlsl->lb;
+     const double *ub = mlsl->ub;
+     const double *x = p->x;
+
+     if (p->minimized)
+         return 0;
+
+     if (p->closest_pt_d <= dpt_min*dpt_min)
+         return 0;
+
+     if (p->closest_lm_d <= dlm_min*dlm_min)
+         return 0;
+
+     for (i = 0; i < n; ++i)
+         if ((x[i] - lb[i] <= dbound_min || ub[i] - x[i] <= dbound_min)
+             && ub[i] - lb[i] > dbound_min)
+              return 0;
+
+     return 1;
+}
+
+#define K2PI (6.2831853071795864769252867665590057683943388)
+
+/* compute Gamma(1 + n/2)^{1/n} ... this is a constant factor
+   used in MLSL as part of the minimum-distance cutoff*/
+static double gam(int n)
+{
+     /* use Stirling's approximation:
+       Gamma(1 + z) ~ sqrt(2*pi*z) * z^z / exp(z)
+        ... this is more than accurate enough for our purposes
+            (error in gam < 15% for d=1, < 4% for d=2, < 2% for d=3, ...)
+            and avoids overflow problems because we can combine it with
+           the ^{1/n} exponent */
+     double z = n/2;
+     return sqrt(pow(K2PI * z, 1.0/n) * z) * exp(-0.5);
+}
+
+static pt *alloc_pt(int n)
+{
+     pt *p = (pt *) malloc(sizeof(pt) + (n-1) * sizeof(double));
+     if (p) {
+         p->minimized = 0;
+         p->closest_pt_d = HUGE_VAL;
+         p->closest_lm_d = HUGE_VAL;
+     }
+     return p;
+}
+
+/* wrapper around objective function that increments evaluation count */
+static double fcount(unsigned n, const double *x, double *grad, void *p_)
+{
+     mlsl_data *p = (mlsl_data *) p_;
+     p->stop->nevals++;
+     return p->f(n, x, grad, p->f_data);
+}
+
+static void get_minf(mlsl_data *d, double *minf, double *x)
+{
+     rb_node *node = rb_tree_min(&d->pts);
+     if (node) {
+         *minf = ((pt *) node->k)->f;
+         memcpy(x, ((pt *) node->k)->x, sizeof(double) * d->n);
+     }
+     node = rb_tree_min(&d->lms);
+     if (node && node->k[0] < *minf) {
+         *minf = node->k[0];
+         memcpy(x, node->k + 1, sizeof(double) * d->n);
+     }
+}
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+#define MLSL_SIGMA 2. /* MLSL sigma parameter, using value from the papers */
+#define MLSL_GAMMA 0.3 /* MLSL gamma parameter (FIXME: what should it be?) */
+
+nlopt_result mlsl_minimize(int n, nlopt_func f, void *f_data,
+                          const double *lb, const double *ub, /* bounds */
+                          double *x, /* in: initial guess, out: minimizer */
+                          double *minf,
+                          nlopt_stopping *stop,
+                          nlopt_opt local_opt,
+                          int Nsamples, /* #samples/iteration (0=default) */
+                          int lds) /* random or low-discrepancy seq. (lds) */
+{
+     nlopt_result ret = NLOPT_SUCCESS;
+     mlsl_data d;
+     int i;
+     pt *p;
+
+     if (!Nsamples)
+         d.N = 4; /* FIXME: what is good number of samples per iteration? */
+     else
+         d.N = Nsamples;
+     if (d.N < 1) return NLOPT_INVALID_ARGS;
+
+     d.n = n;
+     d.lb = lb; d.ub = ub;
+     d.stop = stop;
+     d.f = f; d.f_data = f_data;
+     rb_tree_init(&d.pts, pt_compare);
+     rb_tree_init(&d.lms, lm_compare);
+     d.s = lds ? nlopt_sobol_create((unsigned) n) : NULL;
+
+     nlopt_set_min_objective(local_opt, fcount, &d);
+     nlopt_set_lower_bounds(local_opt, lb);
+     nlopt_set_upper_bounds(local_opt, ub);
+     nlopt_set_stopval(local_opt, stop->minf_max);
+
+     d.gamma = MLSL_GAMMA;
+
+     d.R_prefactor = sqrt(2./K2PI) * pow(gam(n) * MLSL_SIGMA, 1.0/n);
+     for (i = 0; i < n; ++i)
+         d.R_prefactor *= pow(ub[i] - lb[i], 1.0/n);
+
+     /* MLSL also suggests setting some minimum distance from points
+       to previous local minimiza and to the boundaries; I don't know
+       how to choose this as a fixed number, so I set it proportional
+       to R; see also the comments at top.  dlm and dbound are the
+       proportionality constants. */
+     d.dlm = 1.0; /* min distance/R to local minima (FIXME: good value?) */
+     d.dbound = 1e-6; /* min distance/R to ub/lb boundaries (good value?) */
+     
+
+     p = alloc_pt(n);
+     if (!p) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+
+     /* FIXME: how many sobol points to skip, if any? */
+     nlopt_sobol_skip(d.s, (unsigned) (10*n+d.N), p->x);
+
+     memcpy(p->x, x, n * sizeof(double));
+     p->f = f(n, x, NULL, f_data);
+     stop->nevals++;
+     if (!rb_tree_insert(&d.pts, (rb_key) p)) { 
+         free(p); ret = NLOPT_OUT_OF_MEMORY; 
+     }
+     if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+     else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+     else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+     else if (p->f < stop->minf_max) ret = NLOPT_MINF_MAX_REACHED;
+
+     while (ret == NLOPT_SUCCESS) {
+         rb_node *node;
+         double R;
+
+         get_minf(&d, minf, x);
+
+         /* sampling phase: add random/quasi-random points */
+         for (i = 0; i < d.N && ret == NLOPT_SUCCESS; ++i) {
+              p = alloc_pt(n);
+              if (!p) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+              if (d.s) nlopt_sobol_next(d.s, p->x, lb, ub);
+              else { /* use random points instead of LDS */
+                   int j;
+                   for (j = 0; j < n; ++j) p->x[j] = nlopt_urand(lb[j],ub[j]);
+              }
+              p->f = f(n, p->x, NULL, f_data);
+              stop->nevals++;
+              if (!rb_tree_insert(&d.pts, (rb_key) p)) { 
+                   free(p); ret = NLOPT_OUT_OF_MEMORY;
+              }
+              if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+              else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+              else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+              else if (p->f < stop->minf_max) ret = NLOPT_MINF_MAX_REACHED;
+              else {
+                   find_closest_pt(n, &d.pts, p);
+                   find_closest_lm(n, &d.lms, p);
+                   pts_update_newpt(n, &d.pts, p);
+              }
+         }
+
+         /* distance threshhold parameter R in MLSL */
+         R = d.R_prefactor 
+              * pow(log((double) d.pts.N) / d.pts.N, 1.0 / n);
+
+         /* local search phase: do local opt. for promising points */
+         node = rb_tree_min(&d.pts);
+         for (i = (int) (ceil(d.gamma * d.pts.N) + 0.5); 
+              node && i > 0 && ret == NLOPT_SUCCESS; --i) {
+              p = (pt *) node->k;
+              if (is_potential_minimizer(&d, p, 
+                                         R, d.dlm*R, d.dbound*R)) {
+                   nlopt_result lret;
+                   double *lm;
+                   double t = nlopt_seconds();
+
+                   if (nlopt_stop_forced(stop)) {
+                        ret = NLOPT_FORCED_STOP; break;
+                   }
+                   if (nlopt_stop_evals(stop)) {
+                         ret = NLOPT_MAXEVAL_REACHED; break;
+                   }
+                   if (stop->maxtime > 0 &&
+                       t - stop->start >= stop->maxtime) {
+                        ret = NLOPT_MAXTIME_REACHED; break;
+                   }
+                   lm = (double *) malloc(sizeof(double) * (n+1));
+                   if (!lm) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+                   memcpy(lm+1, p->x, sizeof(double) * n);
+                   lret = nlopt_optimize_limited(local_opt, lm+1, lm,
+                                                 stop->maxeval - stop->nevals,
+                                                 stop->maxtime -
+                                                 (t - stop->start));
+                   p->minimized = 1;
+                   if (lret < 0) { free(lm); ret = lret; goto done; }
+                   if (!rb_tree_insert(&d.lms, lm)) { 
+                        free(lm); ret = NLOPT_OUT_OF_MEMORY;
+                   }
+                   else if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+                   else if (*lm < stop->minf_max) 
+                        ret = NLOPT_MINF_MAX_REACHED;
+                   else if (nlopt_stop_evals(stop))
+                        ret = NLOPT_MAXEVAL_REACHED;
+                   else if (nlopt_stop_time(stop))
+                        ret = NLOPT_MAXTIME_REACHED;
+                   else
+                        pts_update_newlm(n, &d.pts, lm);
+              }
+
+              /* TODO: additional stopping criteria based
+                 e.g. on improvement in function values, etc? */
+              
+              node = rb_tree_succ(node);
+         }
+     }
+
+     get_minf(&d, minf, x);
+
+ done:
+     nlopt_sobol_destroy(d.s);
+     rb_tree_destroy_with_keys(&d.lms);
+     rb_tree_destroy_with_keys(&d.pts);
+     return ret;
+}
diff --git a/mlsl/mlsl.h b/mlsl/mlsl.h
new file mode 100644 (file)
index 0000000..df79e18
--- /dev/null
@@ -0,0 +1,48 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef MLSL_H
+#define MLSL_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result mlsl_minimize(int n, nlopt_func f, void *f_data,
+                          const double *lb, const double *ub, /* bounds */
+                          double *x, /* in: initial guess, out: minimizer */
+                          double *minf,
+                          nlopt_stopping *stop,
+                           nlopt_opt local_opt,
+                          int Nsamples, /* #samples/iteration (0=default) */
+                           int lds);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/mma/Makefile.am b/mma/Makefile.am
new file mode 100644 (file)
index 0000000..f453b75
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libmma.la
+libmma_la_SOURCES = mma.c ccsa_quadratic.c mma.h
+
+EXTRA_DIST = README
diff --git a/mma/Makefile.in b/mma/Makefile.in
new file mode 100644 (file)
index 0000000..4dede87
--- /dev/null
@@ -0,0 +1,607 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = mma
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libmma_la_LIBADD =
+am_libmma_la_OBJECTS = mma.lo ccsa_quadratic.lo
+libmma_la_OBJECTS = $(am_libmma_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libmma_la_SOURCES)
+DIST_SOURCES = $(libmma_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libmma.la
+libmma_la_SOURCES = mma.c ccsa_quadratic.c mma.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu mma/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu mma/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libmma.la: $(libmma_la_OBJECTS) $(libmma_la_DEPENDENCIES) $(EXTRA_libmma_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libmma_la_OBJECTS) $(libmma_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ccsa_quadratic.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mma.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/mma/README b/mma/README
new file mode 100644 (file)
index 0000000..cb87086
--- /dev/null
@@ -0,0 +1,32 @@
+Implementation of the globally-convergent method-of-moving-asymptotes (MMA)
+algorithm for gradient-based local optimization, as described in:
+
+       Krister Svanberg, "A class of globally convergent optimization
+       methods based on conservative convex separable approximations,"
+       SIAM J. Optim. 12 (2), p. 555-573 (2002).
+
+In fact, this algorithm is much more general than most of the other
+algorithms in NLopt, in that it handles an arbitrary set of nonlinear
+(differentiable) constraints as well, in a very efficient manner.
+I've implemented the full nonlinear-constrained MMA algorithm, and it
+is exported under the nlopt_minimize_constrained API.
+
+I also implemented another CCSA algorithm from the same paper: instead of
+constructing local MMA approximations, it constructs simple quadratic
+approximations (or rather, affine approximations plus a quadratic penalty
+term to stay conservative).  This is the ccsa_quadratic code.  It seems
+to have similar convergence rates to MMA for most problems, which is not
+surprising as they are both essentially similar.  However, for the quadratic
+variant I implemented the possibility of preconditioning: including a
+user-supplied Hessian approximation in the local model.  It is easy to
+incorporate this into the proof in Svanberg's paper, and to show that
+global convergence is still guaranteed as long as the user's "Hessian"
+is positive semidefinite, and it practice it can greatly improve convergence
+if the preconditioner is a good approximation for (at least for the
+largest eigenvectors) the real Hessian.
+
+It is under the same MIT license as the rest of my code in NLopt (see
+../COPYRIGHT).
+
+Steven G. Johnson
+July 2008 - July 2012
diff --git a/mma/ccsa_quadratic.c b/mma/ccsa_quadratic.c
new file mode 100644 (file)
index 0000000..199005e
--- /dev/null
@@ -0,0 +1,550 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* In this file we implement Svanberg's CCSA algorithm with the
+   simple linear approximation + quadratic penalty function.
+
+   We also allow the user to specify an optional "preconditioner": an
+   approximate Hessian (which must be symmetric & positive
+   semidefinite) that can be added into the approximation.  [X. Liang
+   and I went through the convergence proof in Svanberg's paper 
+   and it does not seem to be modified by such preconditioning, as
+   long as the preconditioner eigenvalues are bounded above for all x.]
+
+   For the non-preconditioned case the trust-region subproblem is
+   separable and can be solved by a dual method.  For the preconditioned
+   case the subproblem is still convex but in general is non-separable
+   so we solve by calling the same algorithm recursively, under the
+   assumption that the subproblem objective is cheap to evaluate.
+*/
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "mma.h"
+#include "nlopt-util.h"
+
+unsigned ccsa_verbose = 0; /* > 0 for verbose output */
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+/* magic minimum value for rho in CCSA ... the 2002 paper says it should
+   be a "fixed, strictly positive `small' number, e.g. 1e-5"
+   ... grrr, I hate these magic numbers, which seem like they
+   should depend on the objective function in some way ... in particular,
+   note that rho is dimensionful (= dimensions of objective function) */
+#define CCSA_RHOMIN 1e-5
+
+/***********************************************************************/
+/* function for CCSA's dual solution of the approximate problem */
+
+typedef struct {
+     int count; /* evaluation count, incremented each call */
+     unsigned n; /* must be set on input to dimension of x */
+     const double *x, *lb, *ub, *sigma, *dfdx; /* arrays of length n */
+     const double *dfcdx; /* m-by-n array of fc gradients */
+     double fval, rho; /* must be set on input */
+     const double *fcval, *rhoc; /* arrays of length m */
+     double *xcur; /* array of length n, output each time */
+     double gval, wval, *gcval; /* output each time (array length m) */
+     nlopt_precond pre; void *pre_data;
+     nlopt_precond *prec; void **prec_data; /* length = # constraints */
+     double *scratch; /* length = 2*n */
+} dual_data;
+
+static double sqr(double x) { return x * x; }
+
+static double dual_func(unsigned m, const double *y, double *grad, void *d_)
+{
+     dual_data *d = (dual_data *) d_;
+     unsigned n = d->n;
+     const double *x = d->x, *lb = d->lb, *ub = d->ub, *sigma = d->sigma, 
+         *dfdx = d->dfdx;
+     const double *dfcdx = d->dfcdx;
+     double rho = d->rho, fval = d->fval;
+     const double *rhoc = d->rhoc, *fcval = d->fcval;
+     double *xcur = d->xcur;
+     double *gcval = d->gcval;
+     unsigned i, j;
+     double val;
+
+     d->count++;
+
+     val = d->gval = fval;
+     d->wval = 0;
+     for (i = 0; i < m; ++i) 
+         val += y[i] * (gcval[i] = fcval[i]);
+
+     for (j = 0; j < n; ++j) {
+         double u, v, dx, sigma2, dx2, dx2sig;
+
+         /* first, compute xcur[j] = x+dx for y.  Because this objective is
+            separable, we can minimize over x analytically, and the minimum
+            dx is given by the solution of a linear equation
+                    u dx + v sigma^2 = 0, i.e. dx = -sigma^2 v/u
+            where u and v are defined by the sums below.  However,
+            we also have to check that |dx| <= sigma and that
+            lb <= x+dx <= ub. */
+
+         if (sigma[j] == 0) { /* special case for lb[i] == ub[i] dims, dx=0 */
+              xcur[j] = x[j];
+              continue;
+         }
+
+         u = rho;
+         v = dfdx[j];
+         for (i = 0; i < m; ++i) {
+              u += rhoc[i] * y[i];
+              v += dfcdx[i*n + j] * y[i];
+         }
+         dx = -(sigma2 = sqr(sigma[j])) * v/u;
+
+         /* if dx is out of bounds, we are guaranteed by convexity
+            that the minimum is at the bound on the side of dx */
+         if (fabs(dx) > sigma[j]) dx = copysign(sigma[j], dx);
+         xcur[j] = x[j] + dx;
+         if (xcur[j] > ub[j]) xcur[j] = ub[j];
+         else if (xcur[j] < lb[j]) xcur[j] = lb[j];
+         dx = xcur[j] - x[j];
+         
+         /* function value: */
+         dx2 = dx * dx;
+         val += v * dx + 0.5 * u * dx2 / sigma2;
+
+         /* update gval, wval, gcval (approximant functions) */
+         d->gval += dfdx[j] * dx + rho * (dx2sig = 0.5*dx2/sigma2);
+         d->wval += dx2sig;
+         for (i = 0; i < m; ++i)
+              gcval[i] += dfcdx[i*n+j] * dx + rhoc[i] * dx2sig;
+     }
+
+     /* gradient is easy to compute: since we are at a minimum x (dval/dx=0),
+       we only need the partial derivative with respect to y, and
+       we negate because we are maximizing: */
+     if (grad) for (i = 0; i < m; ++i) grad[i] = -gcval[i];
+     return -val;
+}
+
+/***********************************************************************/
+
+/* compute g(x - x0) and its gradient */
+static double gfunc(unsigned n, double f, const double *dfdx,
+                   double rho, const double *sigma,
+                   const double *x0, 
+                   nlopt_precond pre, void *pre_data, double *scratch,
+                   const double *x, double *grad)
+{
+     double *dx = scratch, *Hdx = scratch + n;
+     double val = f;
+     unsigned j;
+
+     for (j = 0; j < n; ++j) {
+         double sigma2inv = 1.0 / sqr(sigma[j]);
+         dx[j] = x[j] - x0[j];
+         val += dfdx[j] * dx[j] + (0.5*rho) * sqr(dx[j]) * sigma2inv;
+         if (grad) grad[j] = dfdx[j] + rho * dx[j] * sigma2inv;
+     }
+
+     if (pre) {
+         pre(n, x0, dx, Hdx, pre_data);
+         for (j = 0; j < n; ++j)
+              val += 0.5 * dx[j] * Hdx[j];
+         if (grad)
+              for (j = 0; j < n; ++j)
+                   grad[j] += Hdx[j];
+     }
+
+     return val;
+}
+
+static double g0(unsigned n, const double *x, double *grad, void *d_)
+{
+     dual_data *d = (dual_data *) d_;
+     d->count++;
+     return gfunc(n, d->fval, d->dfdx, d->rho, d->sigma,
+                 d->x,
+                 d->pre, d->pre_data, d->scratch,
+                 x, grad);
+}
+
+
+static void gi(unsigned m, double *result,
+              unsigned n, const double *x, double *grad, void *d_)
+{
+     dual_data *d = (dual_data *) d_;
+     unsigned i;
+     for (i = 0; i < m; ++i)
+         result[i] = gfunc(n, d->fcval[i], d->dfcdx + i*n, d->rhoc[i],
+                           d->sigma,
+                           d->x,
+                           d->prec ? d->prec[i] : NULL, 
+                           d->prec_data ? d->prec_data[i] : NULL,
+                           d->scratch,
+                           x, grad);
+}
+
+
+/***********************************************************************/
+
+nlopt_result ccsa_quadratic_minimize(
+     unsigned n, nlopt_func f, void *f_data,
+     unsigned m, nlopt_constraint *fc,
+
+     nlopt_precond pre, 
+
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf,
+     nlopt_stopping *stop,
+     nlopt_opt dual_opt)
+{
+     nlopt_result ret = NLOPT_SUCCESS;
+     double *xcur, rho, *sigma, *dfdx, *dfdx_cur, *xprev, *xprevprev, fcur;
+     double *dfcdx, *dfcdx_cur;
+     double *fcval, *fcval_cur, *rhoc, *gcval, *y, *dual_lb, *dual_ub;
+     double *pre_lb, *pre_ub;
+     unsigned i, ifc, j, k = 0;
+     dual_data dd;
+     int feasible;
+     double infeasibility;
+     unsigned mfc;
+     unsigned no_precond;
+     nlopt_opt pre_opt = NULL;
+
+     m = nlopt_count_constraints(mfc = m, fc);
+     if (nlopt_get_dimension(dual_opt) != m) return NLOPT_INVALID_ARGS;
+     sigma = (double *) malloc(sizeof(double) * (6*n + 2*m*n + m*7));
+     if (!sigma) return NLOPT_OUT_OF_MEMORY;
+     dfdx = sigma + n;
+     dfdx_cur = dfdx + n;
+     xcur = dfdx_cur + n;
+     xprev = xcur + n;
+     xprevprev = xprev + n;
+     fcval = xprevprev + n;
+     fcval_cur = fcval + m;
+     rhoc = fcval_cur + m;
+     gcval = rhoc + m;
+     dual_lb = gcval + m;
+     dual_ub = dual_lb + m;
+     y = dual_ub + m;
+     dfcdx = y + m;
+     dfcdx_cur = dfcdx + m*n;
+
+     dd.n = n;
+     dd.x = x;
+     dd.lb = lb;
+     dd.ub = ub;
+     dd.sigma = sigma;
+     dd.dfdx = dfdx;
+     dd.dfcdx = dfcdx;
+     dd.fcval = fcval;
+     dd.rhoc = rhoc;
+     dd.xcur = xcur;
+     dd.gcval = gcval;
+     dd.pre = pre; dd.pre_data = f_data;
+     dd.prec = NULL; dd.prec_data = NULL;
+     dd.scratch = NULL;
+
+     if (m) {
+         dd.prec = (nlopt_precond *) malloc(sizeof(nlopt_precond) * m);
+         dd.prec_data = (void **) malloc(sizeof(void *) * m);
+         if (!dd.prec || !dd.prec_data) {
+              ret = NLOPT_OUT_OF_MEMORY;
+              goto done;
+         }
+         for (i = ifc = 0; ifc < mfc; ++ifc) {
+              unsigned inext = i + fc[ifc].m;
+              for (; i < inext; ++i) {
+                   dd.prec[i] = fc[ifc].pre;
+                   dd.prec_data[i] = fc[ifc].f_data;
+              }
+         }
+     }
+
+     no_precond = pre == NULL;
+     if (dd.prec)
+         for (i = 0; i < m; ++i)
+              no_precond = no_precond && dd.prec[i] == NULL;
+
+     if (!no_precond) {
+         dd.scratch = (double*) malloc(sizeof(double) * (4*n));
+         if (!dd.scratch) {
+              free(sigma);
+              return NLOPT_OUT_OF_MEMORY;
+         }
+         pre_lb = dd.scratch + 2*n;
+         pre_ub = pre_lb + n;
+
+         pre_opt = nlopt_create(nlopt_get_algorithm(dual_opt), n);
+         if (!pre_opt) { ret = NLOPT_FAILURE; goto done; }
+         ret = nlopt_set_min_objective(pre_opt, g0, &dd);
+         if (ret < 0) goto done;
+         ret = nlopt_add_inequality_mconstraint(pre_opt, m, gi, &dd, NULL);
+         if (ret < 0) goto done;
+         ret = nlopt_set_ftol_rel(pre_opt, nlopt_get_ftol_rel(dual_opt));
+         if (ret < 0) goto done;
+         ret = nlopt_set_ftol_abs(pre_opt, nlopt_get_ftol_abs(dual_opt));
+         if (ret < 0) goto done;
+         ret = nlopt_set_maxeval(pre_opt, nlopt_get_maxeval(dual_opt));
+         if (ret < 0) goto done;
+     }
+     
+     for (j = 0; j < n; ++j) {
+         if (nlopt_isinf(ub[j]) || nlopt_isinf(lb[j]))
+              sigma[j] = 1.0; /* arbitrary default */
+         else
+              sigma[j] = 0.5 * (ub[j] - lb[j]);
+     }
+     rho = 1.0;
+     for (i = 0; i < m; ++i) {
+         rhoc[i] = 1.0;
+         dual_lb[i] = y[i] = 0.0;
+         dual_ub[i] = HUGE_VAL;
+     }
+
+     dd.fval = fcur = *minf = f(n, x, dfdx, f_data);
+     stop->nevals++;
+     memcpy(xcur, x, sizeof(double) * n);
+     if (nlopt_stop_forced(stop)) { ret = NLOPT_FORCED_STOP; goto done; }
+
+     feasible = 1; infeasibility = 0;
+     for (i = ifc = 0; ifc < mfc; ++ifc) {
+         nlopt_eval_constraint(fcval + i, dfcdx + i*n,
+                               fc + ifc, n, x);
+         i += fc[ifc].m;
+         if (nlopt_stop_forced(stop)) { ret = NLOPT_FORCED_STOP; goto done; }
+     }
+     for (i = 0; i < m; ++i) {
+         feasible = feasible && fcval[i] <= 0;
+         if (fcval[i] > infeasibility) infeasibility = fcval[i];
+     }
+     /* For non-feasible initial points, set a finite (large)
+       upper-bound on the dual variables.  What this means is that,
+       if no feasible solution is found from the dual problem, it
+       will minimize the dual objective with the unfeasible
+       constraint weighted by 1e40 -- basically, minimizing the
+       unfeasible constraint until it becomes feasible or until we at
+       least obtain a step towards a feasible point.
+       
+       Svanberg suggested a different approach in his 1987 paper, basically
+       introducing additional penalty variables for unfeasible constraints,
+       but this is easier to implement and at least as efficient. */
+     if (!feasible)
+         for (i = 0; i < m; ++i) dual_ub[i] = 1e40;
+
+     nlopt_set_min_objective(dual_opt, dual_func, &dd);
+     nlopt_set_lower_bounds(dual_opt, dual_lb);
+     nlopt_set_upper_bounds(dual_opt, dual_ub);
+     nlopt_set_stopval(dual_opt, -HUGE_VAL);
+     nlopt_remove_inequality_constraints(dual_opt);
+     nlopt_remove_equality_constraints(dual_opt);
+
+     while (1) { /* outer iterations */
+         double fprev = fcur;
+         if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+         else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+         else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+         else if (feasible && *minf < stop->minf_max) 
+              ret = NLOPT_MINF_MAX_REACHED;
+         if (ret != NLOPT_SUCCESS) goto done;
+         if (++k > 1) memcpy(xprevprev, xprev, sizeof(double) * n);
+         memcpy(xprev, xcur, sizeof(double) * n);
+
+         while (1) { /* inner iterations */
+              double min_dual, infeasibility_cur;
+              int feasible_cur, inner_done;
+              unsigned save_verbose;
+              nlopt_result reti;
+
+              if (no_precond) {
+                   /* solve dual problem */
+                   dd.rho = rho; dd.count = 0;
+                   save_verbose = ccsa_verbose;
+                   ccsa_verbose = 0; /* no recursive verbosity */
+                   reti = nlopt_optimize_limited(dual_opt, y, &min_dual,
+                                                 0,
+                                                 stop->maxtime 
+                                                 - (nlopt_seconds() 
+                                                    - stop->start));
+                   ccsa_verbose = save_verbose;
+                   if (reti < 0 || reti == NLOPT_MAXTIME_REACHED) {
+                        ret = reti;
+                        goto done;
+                   }
+                   
+                   dual_func(m, y, NULL, &dd); /* evaluate final xcur etc. */
+              }
+              else {
+                   double pre_min;
+                   for (j = 0; j < n; ++j) {
+                        pre_lb[j] = MAX(lb[j], x[j] - sigma[j]);
+                        pre_ub[j] = MIN(ub[j], x[j] + sigma[j]);
+                        xcur[j] = x[j];
+                   }
+                   nlopt_set_lower_bounds(pre_opt, pre_lb);
+                   nlopt_set_upper_bounds(pre_opt, pre_ub);
+
+                   dd.rho = rho; dd.count = 0;
+                   save_verbose = ccsa_verbose;
+                   ccsa_verbose = 0; /* no recursive verbosity */
+                   reti = nlopt_optimize_limited(pre_opt, xcur, &pre_min,
+                                                 0, stop->maxtime
+                                                  - (nlopt_seconds()
+                                                     - stop->start));
+                   ccsa_verbose = save_verbose;
+                   if (reti < 0 || reti == NLOPT_MAXTIME_REACHED) {
+                        ret = reti;
+                        goto done;
+                   }
+
+                   /* evaluate final xcur etc */
+                   dd.gval = g0(n, xcur, NULL, &dd);
+                   gi(m, dd.gcval, n, xcur, NULL, &dd);
+              }
+
+              if (ccsa_verbose) {
+                   printf("CCSA dual converged in %d iters to g=%g:\n",
+                          dd.count, dd.gval);
+                   for (i = 0; i < MIN(ccsa_verbose, m); ++i)
+                        printf("    CCSA y[%d]=%g, gc[%d]=%g\n",
+                               i, y[i], i, dd.gcval[i]);
+              }
+
+              fcur = f(n, xcur, dfdx_cur, f_data);
+              stop->nevals++;
+              if (nlopt_stop_forced(stop)) { 
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              feasible_cur = 1; infeasibility_cur = 0;
+              inner_done = dd.gval >= fcur;
+              for (i = ifc = 0; ifc < mfc; ++ifc) {
+                   nlopt_eval_constraint(fcval_cur + i, dfcdx_cur + i*n,
+                                         fc + ifc, n, xcur);
+                   i += fc[ifc].m;
+                   if (nlopt_stop_forced(stop)) { 
+                        ret = NLOPT_FORCED_STOP; goto done; }
+              }
+              for (i = ifc = 0; ifc < mfc; ++ifc) {
+                   unsigned i0 = i, inext = i + fc[ifc].m;
+                   for (; i < inext; ++i) {
+                        feasible_cur = feasible_cur 
+                             && fcval_cur[i] <= fc[ifc].tol[i-i0];
+                        inner_done = inner_done && 
+                             (dd.gcval[i] >= fcval_cur[i]);
+                        if (fcval_cur[i] > infeasibility_cur)
+                             infeasibility_cur = fcval_cur[i];
+                   }
+              }
+
+              if ((fcur < *minf && (inner_done || feasible_cur || !feasible))
+                   || (!feasible && infeasibility_cur < infeasibility)) {
+                   if (ccsa_verbose && !feasible_cur)
+                        printf("CCSA - using infeasible point?\n");
+                   dd.fval = *minf = fcur;
+                   infeasibility = infeasibility_cur;
+                   memcpy(fcval, fcval_cur, sizeof(double)*m);
+                   memcpy(x, xcur, sizeof(double)*n);
+                   memcpy(dfdx, dfdx_cur, sizeof(double)*n);
+                   memcpy(dfcdx, dfcdx_cur, sizeof(double)*n*m);
+                   
+                   /* once we have reached a feasible solution, the
+                      algorithm should never make the solution infeasible
+                      again (if inner_done), although the constraints may
+                      be violated slightly by rounding errors etc. so we
+                      must be a little careful about checking feasibility */
+                   if (infeasibility_cur == 0) {
+                        if (!feasible) { /* reset upper bounds to infin. */
+                             for (i = 0; i < m; ++i) dual_ub[i] = HUGE_VAL;
+                             nlopt_set_upper_bounds(dual_opt, dual_ub);
+                        }
+                        feasible = 1;
+                   }
+
+              }
+              if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+              else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+              else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+              else if (feasible && *minf < stop->minf_max) 
+                   ret = NLOPT_MINF_MAX_REACHED;
+              if (ret != NLOPT_SUCCESS) goto done;
+
+              if (inner_done) break;
+
+              if (fcur > dd.gval)
+                   rho = MIN(10*rho, 1.1 * (rho + (fcur-dd.gval) / dd.wval));
+              for (i = 0; i < m; ++i)
+                   if (fcval_cur[i] > dd.gcval[i])
+                        rhoc[i] = 
+                             MIN(10*rhoc[i], 
+                                 1.1 * (rhoc[i] + (fcval_cur[i]-dd.gcval[i]) 
+                                        / dd.wval));
+              
+              if (ccsa_verbose)
+                   printf("CCSA inner iteration: rho -> %g\n", rho);
+              for (i = 0; i < MIN(ccsa_verbose, m); ++i)
+                   printf("                CCSA rhoc[%d] -> %g\n", i,rhoc[i]);
+         }
+
+         if (nlopt_stop_ftol(stop, fcur, fprev))
+              ret = NLOPT_FTOL_REACHED;
+         if (nlopt_stop_x(stop, xcur, xprev))
+              ret = NLOPT_XTOL_REACHED;
+         if (ret != NLOPT_SUCCESS) goto done;
+              
+         /* update rho and sigma for iteration k+1 */
+         rho = MAX(0.1 * rho, CCSA_RHOMIN);
+         if (ccsa_verbose)
+              printf("CCSA outer iteration: rho -> %g\n", rho);
+         for (i = 0; i < m; ++i)
+              rhoc[i] = MAX(0.1 * rhoc[i], CCSA_RHOMIN);
+         for (i = 0; i < MIN(ccsa_verbose, m); ++i)
+              printf("                 CCSA rhoc[%d] -> %g\n", i, rhoc[i]);
+         if (k > 1) {
+              for (j = 0; j < n; ++j) {
+                   double dx2 = (xcur[j]-xprev[j]) * (xprev[j]-xprevprev[j]);
+                   double gam = dx2 < 0 ? 0.7 : (dx2 > 0 ? 1.2 : 1);
+                   sigma[j] *= gam;
+                   if (!nlopt_isinf(ub[j]) && !nlopt_isinf(lb[j])) {
+                        sigma[j] = MIN(sigma[j], 10*(ub[j]-lb[j]));
+                        /* use a smaller lower bound than Svanberg's
+                           0.01*(ub-lb), which seems unnecessarily large */
+                        sigma[j] = MAX(sigma[j], 1e-8*(ub[j]-lb[j]));
+                   }
+              }
+              for (j = 0; j < MIN(ccsa_verbose, n); ++j)
+                   printf("                 CCSA sigma[%d] -> %g\n", 
+                          j, sigma[j]);
+         }
+     }
+
+ done:
+     nlopt_destroy(pre_opt);
+     if (dd.scratch) free(dd.scratch);
+     if (m) {
+         free(dd.prec_data);
+         free(dd.prec);
+     }
+     free(sigma);
+     return ret;
+}
diff --git a/mma/mma.c b/mma/mma.c
new file mode 100644 (file)
index 0000000..3d03bfd
--- /dev/null
+++ b/mma/mma.c
@@ -0,0 +1,403 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "mma.h"
+#include "nlopt-util.h"
+
+unsigned mma_verbose = 0; /* > 0 for verbose output */
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#ifndef HAVE_ISNAN
+static int my_isnan(double x) { return x != x; }
+#  define isnan my_isnan
+#endif
+
+/* magic minimum value for rho in MMA ... the 2002 paper says it should
+   be a "fixed, strictly positive `small' number, e.g. 1e-5"
+   ... grrr, I hate these magic numbers, which seem like they
+   should depend on the objective function in some way ... in particular,
+   note that rho is dimensionful (= dimensions of objective function) */
+#define MMA_RHOMIN 1e-5
+
+/***********************************************************************/
+/* function for MMA's dual solution of the approximate problem */
+
+typedef struct {
+     int count; /* evaluation count, incremented each call */
+     unsigned n; /* must be set on input to dimension of x */
+     const double *x, *lb, *ub, *sigma, *dfdx; /* arrays of length n */
+     const double *dfcdx; /* m-by-n array of fc gradients */
+     double fval, rho; /* must be set on input */
+     const double *fcval, *rhoc; /* arrays of length m */
+     double *xcur; /* array of length n, output each time */
+     double gval, wval, *gcval; /* output each time (array length m) */
+} dual_data;
+
+static double sqr(double x) { return x * x; }
+
+static double dual_func(unsigned m, const double *y, double *grad, void *d_)
+{
+     dual_data *d = (dual_data *) d_;
+     unsigned n = d->n;
+     const double *x = d->x, *lb = d->lb, *ub = d->ub, *sigma = d->sigma, 
+         *dfdx = d->dfdx;
+     const double *dfcdx = d->dfcdx;
+     double rho = d->rho, fval = d->fval;
+     const double *rhoc = d->rhoc, *fcval = d->fcval;
+     double *xcur = d->xcur;
+     double *gcval = d->gcval;
+     unsigned i, j;
+     double val;
+
+     d->count++;
+
+     val = d->gval = fval;
+     d->wval = 0;
+     for (i = 0; i < m; ++i) 
+         val += y[i] * (gcval[i] = isnan(fcval[i]) ? 0 : fcval[i]);
+
+     for (j = 0; j < n; ++j) {
+         double u, v, dx, denominv, c, sigma2, dx2;
+
+         /* first, compute xcur[j] for y.  Because this objective is
+            separable, we can minimize over x analytically, and the minimum
+            dx is given by the solution of a quadratic equation:
+                    u dx^2 + 2 v sigma^2 dx + u sigma^2 = 0
+            where u and v are defined by the sums below.  Because of
+            the definitions, it is guaranteed that |u/v| <= sigma,
+            and it follows that the only dx solution with |dx| <= sigma
+            is given by:
+                    (v/u) sigma^2 (-1 + sqrt(1 - (u / v sigma)^2))
+                    = (u/v) / (-1 - sqrt(1 - (u / v sigma)^2))
+             (which goes to zero as u -> 0).  The latter expression
+            is less susceptible to roundoff error. */
+
+         if (sigma[j] == 0) { /* special case for lb[i] == ub[i] dims, dx=0 */
+              xcur[j] = x[j];
+              continue;
+         }
+
+         u = dfdx[j];
+         v = fabs(dfdx[j]) * sigma[j] + 0.5 * rho;
+         for (i = 0; i < m; ++i) if (!isnan(fcval[i])) {
+              u += dfcdx[i*n + j] * y[i];
+              v += (fabs(dfcdx[i*n + j]) * sigma[j] + 0.5 * rhoc[i]) * y[i];
+         }
+         u *= (sigma2 = sqr(sigma[j]));
+         dx = (u/v) / (-1 - sqrt(fabs(1 - sqr(u/(v*sigma[j])))));
+         xcur[j] = x[j] + dx;
+         if (xcur[j] > ub[j]) xcur[j] = ub[j];
+         else if (xcur[j] < lb[j]) xcur[j] = lb[j];
+         if (xcur[j] > x[j]+0.9*sigma[j]) xcur[j] = x[j]+0.9*sigma[j];
+         else if (xcur[j] < x[j]-0.9*sigma[j]) xcur[j] = x[j]-0.9*sigma[j];
+         dx = xcur[j] - x[j];
+         
+         /* function value: */
+         dx2 = dx * dx;
+         denominv = 1.0 / (sigma2 - dx2);
+         val += (u * dx + v * dx2) * denominv;
+
+         /* update gval, wval, gcval (approximant functions) */
+         c = sigma2 * dx;
+         d->gval += (dfdx[j] * c + (fabs(dfdx[j])*sigma[j] + 0.5*rho) * dx2)
+              * denominv;
+         d->wval += 0.5 * dx2 * denominv;
+         for (i = 0; i < m; ++i) if (!isnan(fcval[i]))
+              gcval[i] += (dfcdx[i*n+j] * c + (fabs(dfcdx[i*n+j])*sigma[j] 
+                                               + 0.5*rhoc[i]) * dx2)
+                   * denominv;
+     }
+
+     /* gradient is easy to compute: since we are at a minimum x (dval/dx=0),
+       we only need the partial derivative with respect to y, and
+       we negate because we are maximizing: */
+     if (grad) for (i = 0; i < m; ++i) grad[i] = -gcval[i];
+     return -val;
+}
+
+/***********************************************************************/
+
+/* note that we implement a hidden feature not in the standard
+   nlopt_minimize_constrained interface: whenever the constraint
+   function returns NaN, that constraint becomes inactive. */
+
+nlopt_result mma_minimize(unsigned n, nlopt_func f, void *f_data,
+                         unsigned m, nlopt_constraint *fc,
+                         const double *lb, const double *ub, /* bounds */
+                         double *x, /* in: initial guess, out: minimizer */
+                         double *minf,
+                         nlopt_stopping *stop,
+                         nlopt_opt dual_opt)
+{
+     nlopt_result ret = NLOPT_SUCCESS;
+     double *xcur, rho, *sigma, *dfdx, *dfdx_cur, *xprev, *xprevprev, fcur;
+     double *dfcdx, *dfcdx_cur;
+     double *fcval, *fcval_cur, *rhoc, *gcval, *y, *dual_lb, *dual_ub;
+     unsigned i, ifc, j, k = 0;
+     dual_data dd;
+     int feasible;
+     double infeasibility;
+     unsigned mfc;
+
+     m = nlopt_count_constraints(mfc = m, fc);
+     if (nlopt_get_dimension(dual_opt) != m) return NLOPT_INVALID_ARGS;
+     sigma = (double *) malloc(sizeof(double) * (6*n + 2*m*n + m*7));
+     if (!sigma) return NLOPT_OUT_OF_MEMORY;
+     dfdx = sigma + n;
+     dfdx_cur = dfdx + n;
+     xcur = dfdx_cur + n;
+     xprev = xcur + n;
+     xprevprev = xprev + n;
+     fcval = xprevprev + n;
+     fcval_cur = fcval + m;
+     rhoc = fcval_cur + m;
+     gcval = rhoc + m;
+     dual_lb = gcval + m;
+     dual_ub = dual_lb + m;
+     y = dual_ub + m;
+     dfcdx = y + m;
+     dfcdx_cur = dfcdx + m*n;
+
+     dd.n = n;
+     dd.x = x;
+     dd.lb = lb;
+     dd.ub = ub;
+     dd.sigma = sigma;
+     dd.dfdx = dfdx;
+     dd.dfcdx = dfcdx;
+     dd.fcval = fcval;
+     dd.rhoc = rhoc;
+     dd.xcur = xcur;
+     dd.gcval = gcval;
+
+     for (j = 0; j < n; ++j) {
+         if (nlopt_isinf(ub[j]) || nlopt_isinf(lb[j]))
+              sigma[j] = 1.0; /* arbitrary default */
+         else
+              sigma[j] = 0.5 * (ub[j] - lb[j]);
+     }
+     rho = 1.0;
+     for (i = 0; i < m; ++i) {
+         rhoc[i] = 1.0;
+         dual_lb[i] = y[i] = 0.0;
+         dual_ub[i] = HUGE_VAL;
+     }
+
+     dd.fval = fcur = *minf = f(n, x, dfdx, f_data);
+     stop->nevals++;
+     memcpy(xcur, x, sizeof(double) * n);
+     if (nlopt_stop_forced(stop)) { ret = NLOPT_FORCED_STOP; goto done; }
+
+     feasible = 1; infeasibility = 0;
+     for (i = ifc = 0; ifc < mfc; ++ifc) {
+         nlopt_eval_constraint(fcval + i, dfcdx + i*n,
+                               fc + ifc, n, x);
+         i += fc[ifc].m;
+         if (nlopt_stop_forced(stop)) { ret = NLOPT_FORCED_STOP; goto done; }
+     }
+     for (i = 0; i < m; ++i) {
+         feasible = feasible && (fcval[i] <= 0 || isnan(fcval[i]));
+         if (fcval[i] > infeasibility) infeasibility = fcval[i];
+     }
+     /* For non-feasible initial points, set a finite (large)
+       upper-bound on the dual variables.  What this means is that,
+       if no feasible solution is found from the dual problem, it
+       will minimize the dual objective with the unfeasible
+       constraint weighted by 1e40 -- basically, minimizing the
+       unfeasible constraint until it becomes feasible or until we at
+       least obtain a step towards a feasible point.
+       
+       Svanberg suggested a different approach in his 1987 paper, basically
+       introducing additional penalty variables for unfeasible constraints,
+       but this is easier to implement and at least as efficient. */
+     if (!feasible)
+         for (i = 0; i < m; ++i) dual_ub[i] = 1e40;
+
+     nlopt_set_min_objective(dual_opt, dual_func, &dd);
+     nlopt_set_lower_bounds(dual_opt, dual_lb);
+     nlopt_set_upper_bounds(dual_opt, dual_ub);
+     nlopt_set_stopval(dual_opt, -HUGE_VAL);
+     nlopt_remove_inequality_constraints(dual_opt);
+     nlopt_remove_equality_constraints(dual_opt);
+
+     while (1) { /* outer iterations */
+         double fprev = fcur;
+         if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+         else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+         else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+         else if (feasible && *minf < stop->minf_max) 
+              ret = NLOPT_MINF_MAX_REACHED;
+         if (ret != NLOPT_SUCCESS) goto done;
+         if (++k > 1) memcpy(xprevprev, xprev, sizeof(double) * n);
+         memcpy(xprev, xcur, sizeof(double) * n);
+
+         while (1) { /* inner iterations */
+              double min_dual, infeasibility_cur;
+              int feasible_cur, inner_done;
+              unsigned save_verbose;
+              int new_infeasible_constraint;
+              nlopt_result reti;
+
+              /* solve dual problem */
+              dd.rho = rho; dd.count = 0;
+              save_verbose = mma_verbose;
+              mma_verbose = 0; /* no recursive verbosity */
+              reti = nlopt_optimize_limited(dual_opt, y, &min_dual,
+                                            0,
+                                            stop->maxtime - (nlopt_seconds() 
+                                                             - stop->start));
+              mma_verbose = save_verbose;
+              if (reti < 0 || reti == NLOPT_MAXTIME_REACHED) {
+                   ret = reti;
+                   goto done;
+              }
+
+              dual_func(m, y, NULL, &dd); /* evaluate final xcur etc. */
+              if (mma_verbose) {
+                   printf("MMA dual converged in %d iterations to g=%g:\n",
+                          dd.count, dd.gval);
+                   for (i = 0; i < MIN(mma_verbose, m); ++i)
+                        printf("    MMA y[%d]=%g, gc[%d]=%g\n",
+                               i, y[i], i, dd.gcval[i]);
+              }
+
+              fcur = f(n, xcur, dfdx_cur, f_data);
+              stop->nevals++;
+              if (nlopt_stop_forced(stop)) { 
+                   ret = NLOPT_FORCED_STOP; goto done; }
+              feasible_cur = 1; infeasibility_cur = 0;
+              new_infeasible_constraint = 0;
+              inner_done = dd.gval >= fcur;
+              for (i = ifc = 0; ifc < mfc; ++ifc) {
+                   nlopt_eval_constraint(fcval_cur + i, dfcdx_cur + i*n,
+                                         fc + ifc, n, xcur);
+                   i += fc[ifc].m;
+                   if (nlopt_stop_forced(stop)) { 
+                        ret = NLOPT_FORCED_STOP; goto done; }
+              }
+              for (i = ifc = 0; ifc < mfc; ++ifc) {
+                   unsigned i0 = i, inext = i + fc[ifc].m;
+                   for (; i < inext; ++i)
+                        if (!isnan(fcval_cur[i])) {
+                             feasible_cur = feasible_cur 
+                                  && (fcval_cur[i] <= fc[ifc].tol[i-i0]);
+                             if (!isnan(fcval[i]))
+                                  inner_done = inner_done && 
+                                       (dd.gcval[i] >= fcval_cur[i]);
+                             else if (fcval_cur[i] > 0)
+                                  new_infeasible_constraint = 1;
+                             if (fcval_cur[i] > infeasibility_cur)
+                                  infeasibility_cur = fcval_cur[i];
+                        }
+              }
+
+              if ((fcur < *minf && (inner_done || feasible_cur || !feasible))
+                   || (!feasible && infeasibility_cur < infeasibility)) {
+                   if (mma_verbose && !feasible_cur)
+                        printf("MMA - using infeasible point?\n");
+                   dd.fval = *minf = fcur;
+                   infeasibility = infeasibility_cur;
+                   memcpy(fcval, fcval_cur, sizeof(double)*m);
+                   memcpy(x, xcur, sizeof(double)*n);
+                   memcpy(dfdx, dfdx_cur, sizeof(double)*n);
+                   memcpy(dfcdx, dfcdx_cur, sizeof(double)*n*m);
+                   
+                   /* once we have reached a feasible solution, the
+                      algorithm should never make the solution infeasible
+                      again (if inner_done), although the constraints may
+                      be violated slightly by rounding errors etc. so we
+                      must be a little careful about checking feasibility */
+                   if (infeasibility_cur == 0) {
+                        if (!feasible) { /* reset upper bounds to infin. */
+                             for (i = 0; i < m; ++i) dual_ub[i] = HUGE_VAL;
+                             nlopt_set_upper_bounds(dual_opt, dual_ub);
+                        }
+                        feasible = 1;
+                   }
+                   else if (new_infeasible_constraint) feasible = 0;
+
+              }
+              if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
+              else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+              else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+              else if (feasible && *minf < stop->minf_max) 
+                   ret = NLOPT_MINF_MAX_REACHED;
+              if (ret != NLOPT_SUCCESS) goto done;
+
+              if (inner_done) break;
+
+              if (fcur > dd.gval)
+                   rho = MIN(10*rho, 1.1 * (rho + (fcur-dd.gval) / dd.wval));
+              for (i = 0; i < m; ++i)
+                   if (!isnan(fcval_cur[i]) && fcval_cur[i] > dd.gcval[i])
+                        rhoc[i] = 
+                             MIN(10*rhoc[i], 
+                                 1.1 * (rhoc[i] + (fcval_cur[i]-dd.gcval[i]) 
+                                        / dd.wval));
+              
+              if (mma_verbose)
+                   printf("MMA inner iteration: rho -> %g\n", rho);
+              for (i = 0; i < MIN(mma_verbose, m); ++i)
+                   printf("                 MMA rhoc[%d] -> %g\n", i,rhoc[i]);
+         }
+
+         if (nlopt_stop_ftol(stop, fcur, fprev))
+              ret = NLOPT_FTOL_REACHED;
+         if (nlopt_stop_x(stop, xcur, xprev))
+              ret = NLOPT_XTOL_REACHED;
+         if (ret != NLOPT_SUCCESS) goto done;
+              
+         /* update rho and sigma for iteration k+1 */
+         rho = MAX(0.1 * rho, MMA_RHOMIN);
+         if (mma_verbose)
+              printf("MMA outer iteration: rho -> %g\n", rho);
+         for (i = 0; i < m; ++i)
+              rhoc[i] = MAX(0.1 * rhoc[i], MMA_RHOMIN);
+         for (i = 0; i < MIN(mma_verbose, m); ++i)
+              printf("                 MMA rhoc[%d] -> %g\n", i, rhoc[i]);
+         if (k > 1) {
+              for (j = 0; j < n; ++j) {
+                   double dx2 = (xcur[j]-xprev[j]) * (xprev[j]-xprevprev[j]);
+                   double gam = dx2 < 0 ? 0.7 : (dx2 > 0 ? 1.2 : 1);
+                   sigma[j] *= gam;
+                   if (!nlopt_isinf(ub[j]) && !nlopt_isinf(lb[j])) {
+                        sigma[j] = MIN(sigma[j], 10*(ub[j]-lb[j]));
+                        sigma[j] = MAX(sigma[j], 0.01*(ub[j]-lb[j]));
+                   }
+              }
+              for (j = 0; j < MIN(mma_verbose, n); ++j)
+                   printf("                 MMA sigma[%d] -> %g\n", 
+                          j, sigma[j]);
+         }
+     }
+
+ done:
+     free(sigma);
+     return ret;
+}
diff --git a/mma/mma.h b/mma/mma.h
new file mode 100644 (file)
index 0000000..dd17067
--- /dev/null
+++ b/mma/mma.h
@@ -0,0 +1,61 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef MMA_H
+#define MMA_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+extern unsigned mma_verbose;
+
+nlopt_result mma_minimize(unsigned n, nlopt_func f, void *f_data,
+                         unsigned m, nlopt_constraint *fc,
+                         const double *lb, const double *ub, /* bounds */
+                         double *x, /* in: initial guess, out: minimizer */
+                         double *minf,
+                         nlopt_stopping *stop,
+                         nlopt_opt dual_opt);
+
+nlopt_result ccsa_quadratic_minimize(
+     unsigned n, nlopt_func f, void *f_data,
+     unsigned m, nlopt_constraint *fc,
+
+     nlopt_precond pre,
+
+     const double *lb, const double *ub, /* bounds */
+     double *x, /* in: initial guess, out: minimizer */
+     double *minf,
+     nlopt_stopping *stop,
+     nlopt_opt dual_opt);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/neldermead/Makefile.am b/neldermead/Makefile.am
new file mode 100644 (file)
index 0000000..1c9ed8a
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libneldermead.la
+libneldermead_la_SOURCES = nldrmd.c neldermead.h sbplx.c
+
+EXTRA_DIST = README
diff --git a/neldermead/Makefile.in b/neldermead/Makefile.in
new file mode 100644 (file)
index 0000000..20b320e
--- /dev/null
@@ -0,0 +1,607 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = neldermead
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libneldermead_la_LIBADD =
+am_libneldermead_la_OBJECTS = nldrmd.lo sbplx.lo
+libneldermead_la_OBJECTS = $(am_libneldermead_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libneldermead_la_SOURCES)
+DIST_SOURCES = $(libneldermead_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libneldermead.la
+libneldermead_la_SOURCES = nldrmd.c neldermead.h sbplx.c
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu neldermead/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu neldermead/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libneldermead.la: $(libneldermead_la_OBJECTS) $(libneldermead_la_DEPENDENCIES) $(EXTRA_libneldermead_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libneldermead_la_OBJECTS) $(libneldermead_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nldrmd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sbplx.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/neldermead/README b/neldermead/README
new file mode 100644 (file)
index 0000000..1d02088
--- /dev/null
@@ -0,0 +1,107 @@
+This directory contains Nelder-Mead and variations thereof.  
+
+Currently, I have implemented two algorithms, described below.
+
+The code in this directory is under the same MIT license as the rest
+of my code in NLopt (see ../COPYRIGHT).
+
+Steven G. Johnson
+November 2008
+
+-----------------------------------------------------------------------
+
+First, (almost) the original Nelder-Mead simplex algorithm
+(NLOPT_LN_NELDERMEAD), as described in:
+
+       J. A. Nelder and R. Mead, "A simplex method for function
+       minimization," The Computer Journal 7, p. 308-313 (1965).
+
+This method is simple and has demonstrated enduring popularity,
+despite the later discovery that it fails to converge at all for some
+functions.  Anecdotal evidence suggests that it often performs well
+even for noisy and/or discontinuous objective functions.  I would tend
+to recommend the Subplex method (below) instead, however.
+
+The main variation is that I implemented explicit support for bound
+constraints, using essentially the method described in:
+
+       J. A. Richardson and J. L. Kuester, "The complex method for
+       constrained optimization," Commun. ACM 16(8), 487-489 (1973).
+
+       implementing the method described by:
+
+       M. J. Box, "A new method of constrained optimization and a
+       comparison with other methods," Computer J. 8 (1), 42-52 (1965).
+
+Whenever a new point would lie outside the bound constraints, Box
+advocates moving it "just inside" the constraints.  I couldn't see any
+advantage to using a fixed distance inside the constraints, especially
+if the optimum is on the constraint, so instead I move the point
+exactly onto the constraint in that case.
+
+The danger with implementing bound constraints in this way (or by
+Box's method) is that you may collapse the simplex into a
+lower-dimensional subspace.  I'm not aware of a better way, however.
+In any case, this collapse of the simplex is ameliorated by
+restarting, such as when Nelder-Mead is used within the Subplex
+algorithm below.
+
+-----------------------------------------------------------------------
+
+Second, I re-implemented Tom Rowan's "Subplex" algorithm.  As Rowan
+expressed a preference that other implementations of his algorithm use
+a different name, I called my implementation "Sbplx" (NLOPT_LN_SBPLX).
+Subplex (a variant of Nelder-Mead that uses Nelder-Mead on a sequence
+of subspaces) is claimed to be much more efficient and robust than the
+original Nelder-Mead, while retaining the latter's facility with
+discontinuous objectives, and in my experience these claims seem to be
+true.  (However, I'm not aware of any proof that Subplex is globally
+convergent, and may fail for some objectives like Nelder-Mead; YMMV.)
+
+I used the description of Rowan's algorithm in his PhD thesis:
+
+     T. Rowan, "Functional Stability Analysis of Numerical Algorithms",
+     Ph.D. thesis, Department of Computer Sciences, University of Texas
+     at Austin, 1990.
+
+I would have preferred to use Rowan's original implementation, posted
+by him on Netlib:
+
+     http://www.netlib.org/opt/subplex.tgz
+
+Unfortunately, the legality of redistributing or modifying this code
+is unclear.  Rowan didn't include any license statement at all with
+the original code, which makes it technically illegal to redistribute.
+I contacted Rowan about getting a clear open-source/free-software
+license for it, and he was very agreeable, but he said he had to think
+about the specific license choice and would get back to me.
+Unfortunately, a year later I still haven't heard from him, and his
+old email address no longer seems to work, so I don't know how to
+contact him for permission.
+
+Since the algorithm is not too complicated, however, I just rewrote
+it.  There seem to be slight differences between the behavior of my
+implementation and his (probably due to different choices of initial
+subspace and other slight variations, where his paper was ambiguous),
+but the number of iterations to converge on my test problems seems to
+be quite close (within 10% for most problems).
+
+The only major difference between my implementation and Rowan's, as
+far as I can tell, is that I implemented explicit support for bound
+constraints (via the method in the Box paper as described above).
+This seems to be a big improvement in the case where the optimum lies
+against one of the constraints.
+
+-----------------------------------------------------------------------
+
+Future possibilities:
+
+       C. J. Price, I. D. Coope, and D. Byatt, "A convergent variant
+       of the Nelder-Mead algorithm," J. Optim. Theory Appl. 113 (1),
+       p. 5-19 (2002).
+
+       A. Burmen, J. Puhan, and T. Tuma, "Grid restrained Nelder-Mead
+       algorithm," Computational Optim. Appl. 34(3), 359-375 (2006).
+
+Both of these are provably convergent variations of Nelder-Mead; the
+latter authors claim that theirs is superior.
diff --git a/neldermead/neldermead.h b/neldermead/neldermead.h
new file mode 100644 (file)
index 0000000..5041c5a
--- /dev/null
@@ -0,0 +1,61 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef NELDERMEAD_H
+#define NELDERMEAD_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result nldrmd_minimize(int n, nlopt_func f, void *f_data,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            const double *xstep, /* initial step sizes */
+                            nlopt_stopping *stop);
+
+nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
+                             const double *lb, const double *ub, /* bounds */
+                             double *x,/* in: initial guess, out: minimizer */
+                             double *minf,
+                             const double *xstep, /* initial step sizes */
+                             nlopt_stopping *stop,
+                             double psi, double *scratch, double *fdiff);
+
+nlopt_result sbplx_minimize(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub, /* bounds */
+                           double *x, /* in: initial guess, out: minimizer */
+                           double *minf,
+                           const double *xstep0, /* initial step sizes */
+                           nlopt_stopping *stop);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/neldermead/nldrmd.c b/neldermead/nldrmd.c
new file mode 100644 (file)
index 0000000..5bdc1f3
--- /dev/null
@@ -0,0 +1,306 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "neldermead.h"
+#include "redblack.h"
+
+/* Nelder-Mead simplex algorithm, used as a subroutine for the Rowan's
+   subplex algorithm.  Modified to handle bound constraints ala
+   Richardson and Kuester (1973), as mentioned below. */
+
+/* heuristic "strategy" constants: */
+static const double alpha = 1, beta = 0.5, gamm = 2, delta = 0.5;
+
+/* sort order in red-black tree: keys [f(x), x] are sorted by f(x) */
+static int simplex_compare(double *k1, double *k2)
+{
+     if (*k1 < *k2) return -1;
+     if (*k1 > *k2) return +1;
+     return k1 - k2; /* tie-breaker */
+}
+
+/* return 1 if a and b are approximately equal relative to floating-point
+   precision, 0 otherwise */
+static int close(double a, double b)
+{
+     return (fabs(a - b) <= 1e-13 * (fabs(a) + fabs(b)));
+}
+
+/* Perform the reflection xnew = c + scale * (c - xold),
+   returning 0 if xnew == c or xnew == xold (coincident points), 1 otherwise.
+
+   The reflected point xnew is "pinned" to the lower and upper bounds
+   (lb and ub), as suggested by J. A. Richardson and J. L. Kuester,
+   "The complex method for constrained optimization," Commun. ACM
+   16(8), 487-489 (1973).  This is probably a suboptimal way to handle
+   bound constraints, but I don't know a better way.  The main danger
+   with this is that the simplex might collapse into a
+   lower-dimensional hyperplane; this danger can be ameliorated by
+   restarting (as in subplex), however. */
+static int reflectpt(int n, double *xnew, 
+                    const double *c, double scale, const double *xold,
+                    const double *lb, const double *ub)
+{
+     int equalc = 1, equalold = 1, i;
+     for (i = 0; i < n; ++i) {
+         double newx = c[i] + scale * (c[i] - xold[i]);
+         if (newx < lb[i]) newx = lb[i];
+         if (newx > ub[i]) newx = ub[i];
+         equalc = equalc && close(newx, c[i]);
+         equalold = equalold && close(newx, xold[i]);
+         xnew[i] = newx;
+     }
+     return !(equalc || equalold);
+}
+
+#define CHECK_EVAL(xc,fc)                                                \
+ stop->nevals++;                                                         \
+ if (nlopt_stop_forced(stop)) { ret=NLOPT_FORCED_STOP; goto done; }        \
+ if ((fc) <= *minf) {                                                    \
+   *minf = (fc); memcpy(x, (xc), n * sizeof(double));                    \
+   if (*minf < stop->minf_max) { ret=NLOPT_MINF_MAX_REACHED; goto done; } \
+ }                                                                       \
+ if (nlopt_stop_evals(stop)) { ret=NLOPT_MAXEVAL_REACHED; goto done; }   \
+ if (nlopt_stop_time(stop)) { ret=NLOPT_MAXTIME_REACHED; goto done; }
+
+/* Internal version of nldrmd_minimize, intended to be used as
+   a subroutine for the subplex method.  Three differences compared
+   to nldrmd_minimize:
+
+   *minf should contain the value of f(x)  (so that we don't have to
+   re-evaluate f at the starting x).
+
+   if psi > 0, then it *replaces* xtol and ftol in stop with the condition
+   that the simplex diameter |xl - xh| must be reduced by a factor of psi 
+   ... this is for when nldrmd is used within the subplex method; for
+   ordinary termination tests, set psi = 0. 
+
+   scratch should contain an array of length >= (n+1)*(n+1) + 2*n,
+   used as scratch workspace. 
+
+   On output, *fdiff will contain the difference between the high
+   and low function values of the last simplex. */
+nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            const double *xstep, /* initial step sizes */
+                            nlopt_stopping *stop,
+                            double psi, double *scratch,
+                            double *fdiff)
+{
+     double *pts; /* (n+1) x (n+1) array of n+1 points plus function val [0] */
+     double *c; /* centroid * n */
+     double *xcur; /* current point */
+     rb_tree t; /* red-black tree of simplex, sorted by f(x) */
+     int i, j;
+     double ninv = 1.0 / n;
+     nlopt_result ret = NLOPT_SUCCESS;
+     double init_diam = 0;
+
+     pts = scratch;
+     c = scratch + (n+1)*(n+1);
+     xcur = c + n;
+
+     rb_tree_init(&t, simplex_compare);
+
+     *fdiff = HUGE_VAL;
+
+     /* initialize the simplex based on the starting xstep */
+     memcpy(pts+1, x, sizeof(double)*n);
+     pts[0] = *minf;
+     if (*minf < stop->minf_max) { ret=NLOPT_MINF_MAX_REACHED; goto done; }
+     for (i = 0; i < n; ++i) {
+         double *pt = pts + (i+1)*(n+1);
+         memcpy(pt+1, x, sizeof(double)*n);
+         pt[1+i] += xstep[i];
+         if (pt[1+i] > ub[i]) {
+              if (ub[i] - x[i] > fabs(xstep[i]) * 0.1)
+                   pt[1+i] = ub[i];
+              else /* ub is too close to pt, go in other direction */
+                   pt[1+i] = x[i] - fabs(xstep[i]);
+         }
+         if (pt[1+i] < lb[i]) {
+              if (x[i] - lb[i] > fabs(xstep[i]) * 0.1)
+                   pt[1+i] = lb[i];
+              else {/* lb is too close to pt, go in other direction */
+                   pt[1+i] = x[i] + fabs(xstep[i]);
+                   if (pt[1+i] > ub[i]) /* go towards further of lb, ub */
+                        pt[1+i] = 0.5 * ((ub[i] - x[i] > x[i] - lb[i] ?
+                                          ub[i] : lb[i]) + x[i]);
+              }
+         }
+         if (close(pt[1+i], x[i])) { ret=NLOPT_FAILURE; goto done; }
+         pt[0] = f(n, pt+1, NULL, f_data);
+         CHECK_EVAL(pt+1, pt[0]);
+     }
+
+ restart:
+     for (i = 0; i < n + 1; ++i)
+         if (!rb_tree_insert(&t, pts + i*(n+1))) {
+              ret = NLOPT_OUT_OF_MEMORY;
+              goto done;
+         }
+
+     while (1) {
+         rb_node *low = rb_tree_min(&t);
+         rb_node *high = rb_tree_max(&t);
+         double fl = low->k[0], *xl = low->k + 1;
+         double fh = high->k[0], *xh = high->k + 1;
+         double fr;
+
+         *fdiff = fh - fl;
+
+         if (init_diam == 0) /* initialize diam. for psi convergence test */
+              for (i = 0; i < n; ++i) init_diam += fabs(xl[i] - xh[i]);
+
+         if (psi <= 0 && nlopt_stop_ftol(stop, fl, fh)) {
+              ret = NLOPT_FTOL_REACHED;
+              goto done;
+         }
+
+         /* compute centroid ... if we cared about the perfomance of this,
+            we could do it iteratively by updating the centroid on
+            each step, but then we would have to be more careful about
+            accumulation of rounding errors... anyway n is unlikely to
+            be very large for Nelder-Mead in practical cases */
+         memset(c, 0, sizeof(double)*n);
+         for (i = 0; i < n + 1; ++i) {
+              double *xi = pts + i*(n+1) + 1;
+              if (xi != xh)
+                   for (j = 0; j < n; ++j)
+                        c[j] += xi[j];
+         }
+         for (i = 0; i < n; ++i) c[i] *= ninv;
+
+         /* x convergence check: find xcur = max radius from centroid */
+         memset(xcur, 0, sizeof(double)*n);
+         for (i = 0; i < n + 1; ++i) {
+               double *xi = pts + i*(n+1) + 1;
+              for (j = 0; j < n; ++j) {
+                   double dx = fabs(xi[j] - c[j]);
+                   if (dx > xcur[j]) xcur[j] = dx;
+              }
+         }
+         for (i = 0; i < n; ++i) xcur[i] += c[i];
+         if (psi > 0) {
+              double diam = 0;
+              for (i = 0; i < n; ++i) diam += fabs(xl[i] - xh[i]);
+              if (diam < psi * init_diam) {
+                   ret = NLOPT_XTOL_REACHED;
+                   goto done;
+              }
+         }
+         else if (nlopt_stop_x(stop, c, xcur)) {
+              ret = NLOPT_XTOL_REACHED;
+              goto done;
+         }
+
+         /* reflection */
+         if (!reflectpt(n, xcur, c, alpha, xh, lb, ub)) { 
+              ret=NLOPT_XTOL_REACHED; goto done; 
+         }
+         fr = f(n, xcur, NULL, f_data);
+         CHECK_EVAL(xcur, fr);
+
+         if (fr < fl) { /* new best point, expand simplex */
+              if (!reflectpt(n, xh, c, gamm, xh, lb, ub)) {
+                   ret=NLOPT_XTOL_REACHED; goto done; 
+              }
+              fh = f(n, xh, NULL, f_data);
+              CHECK_EVAL(xh, fh);
+              if (fh >= fr) { /* expanding didn't improve */
+                   fh = fr;
+                   memcpy(xh, xcur, sizeof(double)*n);
+              }
+         }
+         else if (fr < rb_tree_pred(high)->k[0]) { /* accept new point */
+              memcpy(xh, xcur, sizeof(double)*n);
+              fh = fr;
+         }
+         else { /* new worst point, contract */
+              double fc;
+              if (!reflectpt(n,xcur,c, fh <= fr ? -beta : beta, xh, lb,ub)) {
+                   ret=NLOPT_XTOL_REACHED; goto done; 
+              }
+              fc = f(n, xcur, NULL, f_data);
+              CHECK_EVAL(xcur, fc);
+              if (fc < fr && fc < fh) { /* successful contraction */
+                   memcpy(xh, xcur, sizeof(double)*n);
+                   fh = fc;
+              }
+              else { /* failed contraction, shrink simplex */
+                   rb_tree_destroy(&t);
+                   rb_tree_init(&t, simplex_compare);
+                   for (i = 0; i < n+1; ++i) {
+                        double *pt = pts + i * (n+1);
+                        if (pt+1 != xl) {
+                             if (!reflectpt(n,pt+1, xl,-delta,pt+1, lb,ub)) {
+                                  ret = NLOPT_XTOL_REACHED;
+                                  goto done;
+                             }
+                             pt[0] = f(n, pt+1, NULL, f_data);
+                             CHECK_EVAL(pt+1, pt[0]);
+                        }
+                   }
+                   goto restart;
+              }
+         }
+
+         high->k[0] = fh;
+         rb_tree_resort(&t, high);
+     }
+     
+done:
+     rb_tree_destroy(&t);
+     return ret;
+}
+
+nlopt_result nldrmd_minimize(int n, nlopt_func f, void *f_data,
+                            const double *lb, const double *ub, /* bounds */
+                            double *x, /* in: initial guess, out: minimizer */
+                            double *minf,
+                            const double *xstep, /* initial step sizes */
+                            nlopt_stopping *stop)
+{
+     nlopt_result ret;
+     double *scratch, fdiff;
+
+     *minf = f(n, x, NULL, f_data);
+     stop->nevals++;
+     if (nlopt_stop_forced(stop)) return NLOPT_FORCED_STOP;
+     if (*minf < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+     if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+     if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+
+     scratch = (double*) malloc(sizeof(double) * ((n+1)*(n+1) + 2*n));
+     if (!scratch) return NLOPT_OUT_OF_MEMORY;
+
+     ret = nldrmd_minimize_(n, f, f_data, lb, ub, x, minf, xstep, stop,
+                           0.0, scratch, &fdiff);
+     free(scratch);
+     return ret;
+}
diff --git a/neldermead/sbplx.c b/neldermead/sbplx.c
new file mode 100644 (file)
index 0000000..f2ad6f3
--- /dev/null
@@ -0,0 +1,239 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "neldermead.h"
+
+/* subplex strategy constants: */
+static const double psi = 0.25, omega = 0.1;
+static const int nsmin = 2, nsmax = 5;
+
+int sbplx_verbose = 0; /* for debugging */
+
+/* qsort_r comparison function for sorting indices into delta-x array */
+static int p_compare(void *dx_, const void *i_, const void *j_)
+{
+     const double *dx = (const double *) dx_;
+     int i = *((const int *) i_), j = *((const int *) j_);
+     double dxi = fabs(dx[i]), dxj = fabs(dx[j]);
+     return (dxi > dxj ? -1 : (dxi < dxj ? +1 : 0));
+}
+
+typedef struct {
+     const int *p; /* subspace index permutation */
+     int is; /* starting index for this subspace */
+     int n; /* dimension of underlying space */
+     double *x; /* current x vector */
+     nlopt_func f; void *f_data; /* the "actual" underlying function */
+} subspace_data;
+
+/* wrapper around objective function for subspace optimization */
+static double subspace_func(unsigned ns, const double *xs, double *grad, void *data)
+{
+     subspace_data *d = (subspace_data *) data;
+     int i, is = d->is;
+     const int *p = d->p;
+     double *x = d->x;
+
+     (void) grad; /* should always be NULL here */
+     for (i = is; i < is + ((int) ns); ++i) x[p[i]] = xs[i-is];
+     return d->f(d->n, x, NULL, d->f_data);
+}
+
+nlopt_result sbplx_minimize(int n, nlopt_func f, void *f_data,
+                           const double *lb, const double *ub, /* bounds */
+                           double *x, /* in: initial guess, out: minimizer */
+                           double *minf,
+                           const double *xstep0, /* initial step sizes */
+                           nlopt_stopping *stop)
+{
+     nlopt_result ret = NLOPT_SUCCESS;
+     double *xstep, *xprev, *dx, *xs, *lbs, *ubs, *xsstep, *scratch;
+     int *p; /* permuted indices of x sorted by decreasing magnitude |dx| */
+     int i;
+     subspace_data sd;
+     double fprev;
+
+     *minf = f(n, x, NULL, f_data);
+     stop->nevals++;
+     if (nlopt_stop_forced(stop)) return NLOPT_FORCED_STOP;
+     if (*minf < stop->minf_max) return NLOPT_MINF_MAX_REACHED;
+     if (nlopt_stop_evals(stop)) return NLOPT_MAXEVAL_REACHED;
+     if (nlopt_stop_time(stop)) return NLOPT_MAXTIME_REACHED;
+
+     xstep = (double*)malloc(sizeof(double) * (n*3 + nsmax*4
+                                              + (nsmax+1)*(nsmax+1)+2*nsmax));
+     if (!xstep) return NLOPT_OUT_OF_MEMORY;
+     xprev = xstep + n; dx = xprev + n;
+     xs = dx + n; xsstep = xs + nsmax; 
+     lbs = xsstep + nsmax; ubs = lbs + nsmax;
+     scratch = ubs + nsmax;
+     p = (int *) malloc(sizeof(int) * n);
+     if (!p) { free(xstep); return NLOPT_OUT_OF_MEMORY; }
+
+     memcpy(xstep, xstep0, n * sizeof(double));
+     memset(dx, 0, n * sizeof(double));
+
+     sd.p = p;
+     sd.n = n;
+     sd.x = x;
+     sd.f = f;
+     sd.f_data = f_data;
+
+     while (1) {
+         double normi = 0;
+         double normdx = 0;
+         int ns, nsubs = 0;
+         int nevals = stop->nevals;
+         double fdiff, fdiff_max = 0;
+
+         memcpy(xprev, x, n * sizeof(double));
+         fprev = *minf;
+
+         /* sort indices into the progress vector dx by decreasing
+            order of magnitude |dx| */
+         for (i = 0; i < n; ++i) p[i] = i;
+         nlopt_qsort_r(p, (size_t) n, sizeof(int), dx, p_compare);
+
+         /* find the subspaces, and perform nelder-mead on each one */
+         for (i = 0; i < n; ++i) normdx += fabs(dx[i]); /* L1 norm */
+         for (i = 0; i + nsmin < n; i += ns) {
+              /* find subspace starting at index i */
+              int k, nk;
+              double ns_goodness = -HUGE_VAL, norm = normi;
+              nk = i+nsmax > n ? n : i+nsmax; /* max k for this subspace */
+              for (k = i; k < i+nsmin-1; ++k) norm += fabs(dx[p[k]]);
+              ns = nsmin;
+              for (k = i+nsmin-1; k < nk; ++k) {
+                   double goodness;
+                   norm += fabs(dx[p[k]]);
+                   /* remaining subspaces must be big enough to partition */
+                   if (n-(k+1) < nsmin) continue;
+                   /* maximize figure of merit defined by Rowan thesis:
+                      look for sudden drops in average |dx| */
+                   if (k+1 < n)
+                        goodness = norm/(k+1) - (normdx-norm)/(n-(k+1));
+                   else
+                        goodness = normdx/n;
+                   if (goodness > ns_goodness) {
+                        ns_goodness = goodness;
+                        ns = (k+1)-i;
+                   }
+              }
+              for (k = i; k < i+ns; ++k) normi += fabs(dx[p[k]]);
+              /* do nelder-mead on subspace of dimension ns starting w/i */
+              sd.is = i;
+              for (k = i; k < i+ns; ++k) {
+                   xs[k-i] = x[p[k]];
+                   xsstep[k-i] = xstep[p[k]];
+                   lbs[k-i] = lb[p[k]];
+                   ubs[k-i] = ub[p[k]];
+              }
+              ++nsubs;
+              nevals = stop->nevals;
+              ret = nldrmd_minimize_(ns, subspace_func, &sd, lbs,ubs,xs, minf,
+                                     xsstep, stop, psi, scratch, &fdiff);
+              if (fdiff > fdiff_max) fdiff_max = fdiff;
+              if (sbplx_verbose)
+                   printf("%d NM iterations for (%d,%d) subspace\n",
+                          stop->nevals - nevals, sd.is, ns);
+              for (k = i; k < i+ns; ++k) x[p[k]] = xs[k-i];
+              if (ret == NLOPT_FAILURE) { ret=NLOPT_XTOL_REACHED; goto done; }
+              if (ret != NLOPT_XTOL_REACHED) goto done;
+         }
+         /* nelder-mead on last subspace */
+         ns = n - i;
+         sd.is = i;
+         for (; i < n; ++i) {
+              xs[i-sd.is] = x[p[i]];
+              xsstep[i-sd.is] = xstep[p[i]];
+              lbs[i-sd.is] = lb[p[i]];
+              ubs[i-sd.is] = ub[p[i]];
+         }
+         ++nsubs;
+         nevals = stop->nevals;
+         ret = nldrmd_minimize_(ns, subspace_func, &sd, lbs,ubs,xs, minf,
+                                xsstep, stop, psi, scratch, &fdiff);
+         if (fdiff > fdiff_max) fdiff_max = fdiff;
+         if (sbplx_verbose)
+              printf("sbplx: %d NM iterations for (%d,%d) subspace\n",
+                     stop->nevals - nevals, sd.is, ns);
+         for (i = sd.is; i < n; ++i) x[p[i]] = xs[i-sd.is];
+         if (ret == NLOPT_FAILURE) { ret=NLOPT_XTOL_REACHED; goto done; }
+         if (ret != NLOPT_XTOL_REACHED) goto done;
+
+         /* termination tests: */
+         if (nlopt_stop_ftol(stop, *minf, *minf + fdiff_max)) {
+               ret = NLOPT_FTOL_REACHED;
+               goto done;
+         }
+         if (nlopt_stop_x(stop, x, xprev)) {
+              int j;
+              /* as explained in Rowan's thesis, it is important
+                 to check |xstep| as well as |x-xprev|, since if
+                 the step size is too large (in early iterations),
+                 the inner Nelder-Mead may not make much progress */
+              for (j = 0; j < n; ++j)
+                   if (fabs(xstep[j]) * psi > stop->xtol_abs[j]
+                       && fabs(xstep[j]) * psi > stop->xtol_rel * fabs(x[j]))
+                        break;
+              if (j == n) {
+                   ret = NLOPT_XTOL_REACHED;
+                   goto done;
+              }
+         }
+
+         /* compute change in optimal point */
+         for (i = 0; i < n; ++i) dx[i] = x[i] - xprev[i];
+
+         /* setting stepsizes */
+         {
+              double scale;
+              if (nsubs == 1)
+                   scale = psi;
+              else {
+                   double stepnorm = 0, dxnorm = 0;
+                   for (i = 0; i < n; ++i) {
+                        stepnorm += fabs(xstep[i]);
+                        dxnorm += fabs(dx[i]);
+                   }
+                   scale = dxnorm / stepnorm;
+                   if (scale < omega) scale = omega;
+                   if (scale > 1/omega) scale = 1/omega;
+              }
+              if (sbplx_verbose)
+                   printf("sbplx: stepsize scale factor = %g\n", scale);
+              for (i = 0; i < n; ++i) 
+                   xstep[i] = (dx[i] == 0) ? -(xstep[i] * scale)
+                         : copysign(xstep[i] * scale, dx[i]);
+         }
+     }
+
+ done:
+     free(p);
+     free(xstep);
+     return ret;
+}
diff --git a/newuoa/COPYRIGHT b/newuoa/COPYRIGHT
new file mode 100644 (file)
index 0000000..af4e0b8
--- /dev/null
@@ -0,0 +1,23 @@
+/* Copyright (c) 2004 M. J. D. Powell (mjdp@cam.ac.uk)
+ * Copyright (c) 2007-2011 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
diff --git a/newuoa/Makefile.am b/newuoa/Makefile.am
new file mode 100644 (file)
index 0000000..74abf1a
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libnewuoa.la
+libnewuoa_la_SOURCES = newuoa.c newuoa.h
+
+EXTRA_DIST = README README.orig COPYRIGHT
diff --git a/newuoa/Makefile.in b/newuoa/Makefile.in
new file mode 100644 (file)
index 0000000..e0f694e
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = newuoa
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libnewuoa_la_LIBADD =
+am_libnewuoa_la_OBJECTS = newuoa.lo
+libnewuoa_la_OBJECTS = $(am_libnewuoa_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libnewuoa_la_SOURCES)
+DIST_SOURCES = $(libnewuoa_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libnewuoa.la
+libnewuoa_la_SOURCES = newuoa.c newuoa.h
+EXTRA_DIST = README README.orig COPYRIGHT
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu newuoa/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu newuoa/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libnewuoa.la: $(libnewuoa_la_OBJECTS) $(libnewuoa_la_DEPENDENCIES) $(EXTRA_libnewuoa_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libnewuoa_la_OBJECTS) $(libnewuoa_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newuoa.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/newuoa/README b/newuoa/README
new file mode 100644 (file)
index 0000000..8055e8c
--- /dev/null
@@ -0,0 +1,29 @@
+This is the NEWUOA software by M. J. D. Powell, which performs
+derivative-free unconstrained optimization using an iteratively
+constructred quadratic approximation for the objective function.  See:
+
+       M. J. D. Powell, "The NEWUOA software for unconstrained
+       optimization without derivatives," Proc. 40th Workshop
+       on Large Scale Nonlinear Optimization (Erice, Italy, 2004).
+
+The C translation by S. G. Johnson (2008) includes a few minor
+modifications, mainly to use the NLopt stopping criteria (and to
+take the objective function as an argument rather than a global).
+
+The C translation also includes a variant (NEWUOA_BOUND, when the lb
+and ub parameters to newuoa are non-NULL) that is substantially
+modified in order to support bound constraints on the input variables.
+In the original NEWUOA algorithm, Powell solved the quadratic
+subproblems (in routines TRSAPP and BIGLAG) in a spherical trust
+region via a truncated conjugate-gradient algorithm.  In the new
+variant, we use the MMA algorithm for these subproblems to solve them
+with both bound constraints and a spherical trust region.  In principle,
+we should also change the BIGDEN subroutine in a similar way (since
+BIGDEN also approximately solves a trust-region subproblem), but instead
+I just truncated its result to the bounds (which probably gives suboptimal
+convergence, but BIGDEN is called only very rarely in practice).
+
+The original Fortran code was released by Powell with "no restrictions
+or charges", and the C translation by S. G. Johnson is released in a
+similar spirit under the MIT License (see the COPYRIGHT file in this
+directory).
diff --git a/newuoa/README.orig b/newuoa/README.orig
new file mode 100644 (file)
index 0000000..23f7354
--- /dev/null
@@ -0,0 +1,40 @@
+     This is the Fortran version of NEWUOA. Its purpose is to seek
+the least value of a function F of several variables, when derivatives
+are not available, where F is specified by the user through a subroutine
+called CALFUN. The algorithm is intended to change the variables to values
+that are close to a local minimum of F. The user, however, should assume
+responsibility for finding out if the calculations are satisfactory, by
+considering carefully the values of F that occur. The method is described
+in the report "The NEWUOA software for unconstrained optimization without
+derivatives", which is available on the web at www.damtp.cam.ac.uk, where
+you have to click on Numerical Analysis and then on Reports, the number
+of the report being NA2004/08. Let N be the number of variables. The main
+new feature of the method is that quadratic models are updated using only
+about NPT=2N+1 interpolation conditions, the remaining freedom being taken
+up by minimizing the Frobenius norm of the change to the second derivative
+matrix of the model.
+
+     The new software was developed from UOBYQA, which also forms quadratic
+models from interpolation conditions. That method requires NPT=(N+1)(N+2)/2
+conditions, however, because they have to define all the parameters of the
+model. The least Frobenius norm updating procedure with NPT=2N+1 is usually
+much more efficient when N is large, because the work of each iteration is
+much less than before, and in some experiments the number of calculations
+of the objective function seems to be only of magnitude N.
+
+     The attachments in sequence are a suitable Makefile, followed by a main
+program and a CALFUN routine for the Chebyquad problems, in order to provide
+an example for testing. Then NEWUOA and its five auxiliary routines, namely
+NEWUOB, BIGDEN, BIGLAG, TRSAPP and UPDATE, are given. Finally, the computed
+output that the author obtained for the Chebyquad problems is listed.
+
+     The way of calling NEWUOA should be clear from the Chebyquad example
+and from the comments of that subroutine. It is hoped that the software will
+be helpful to much future research and to many applications. There are no
+restrictions on or charges for its use. If you wish to refer to it, please
+cite the DAMTP report that is mentioned above, which has been submitted for
+publication in the proceedings of the 40th Workshop on Large Scale Nonlinear
+Optimization (Erice, Italy, 2004).
+
+December 16th, 2004                    M.J.D. Powell (mjdp@cam.ac.uk)
+
diff --git a/newuoa/newuoa.c b/newuoa/newuoa.c
new file mode 100644 (file)
index 0000000..711cf4f
--- /dev/null
@@ -0,0 +1,2560 @@
+/* Copyright (c) 2004 M. J. D. Powell (mjdp@cam.ac.uk)
+ * Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* NEWUOA derivative-free optimization algorithm by M. J. D. Powell.
+   Original Fortran code by Powell (2004).  Converted via f2c, cleaned up,
+   and incorporated into NLopt by S. G. Johnson (2008).  See README. */
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "newuoa.h"
+
+#define MIN2(a,b) ((a) <= (b) ? (a) : (b))
+#define MAX2(a,b) ((a) >= (b) ? (a) : (b))
+
+/*************************************************************************/
+/* trsapp.f */
+
+typedef struct {
+     int npt;
+     double *xpt, *pq, *hq, *gq, *xopt;
+     double *hd;
+     int iter;
+} quad_model_data;
+
+static double quad_model(int n, const double *x, double *grad, void *data)
+{
+     quad_model_data *d = (quad_model_data *) data;
+     const double *xpt = d->xpt, *pq = d->pq, *hq = d->hq, *gq = d->gq, *xopt = d->xopt;
+     double *hd = d->hd;
+     int npt = d->npt;
+     int i, j, k;
+     double val = 0;
+
+     /* first, set hd to be Hessian matrix times x */
+     memset(hd, 0, sizeof(double) * n);
+     /* implicit Hessian terms (a sum of outer products of xpt vectors) */
+     for (k = 0; k < npt; ++k) {
+         double temp = 0;
+         for (j = 0; j < n; ++j)
+              temp += xpt[k + j * npt] * (xopt[j] + x[j]);
+         temp *= pq[k];
+         for (i = 0; i < n; ++i)
+              hd[i] += temp * xpt[k + i * npt];
+     }
+     /* explicit Hessian terms (stored as compressed lower triangle hq) */
+     k = 0;
+     for (j = 0; j < n; ++j) {
+         for (i = 0; i < j; ++i) {
+              hd[j] += hq[k] * (xopt[i] + x[i]);
+              hd[i] += hq[k] * (xopt[j] + x[j]);
+              ++k;
+         }
+         hd[j] += hq[k++] * (xopt[j] + x[j]);
+     }
+
+     for (i = 0; i < n; ++i) {
+         val += (gq[i] + 0.5 * hd[i]) * (xopt[i] + x[i]);
+         if (grad) grad[i] = gq[i] + hd[i];
+     }
+     d->iter++;
+     return val;
+}
+
+/* constraint function to enforce |x|^2 <= rho*rho */
+static double rho_constraint(int n, const double *x, double *grad, void *data)
+{
+     double rho = *((double *) data);
+     double val = - rho*rho;
+     int i;
+     for (i = 0; i < n; ++i)
+         val += x[i] * x[i];
+     if (grad) for (i = 0; i < n; ++i) grad[i] = 2*x[i];
+     return val;
+}
+
+static nlopt_result trsapp_(int *n, int *npt, double *xopt, 
+       double *xpt, double *gq, double *hq, double *pq, 
+       double *delta, double *step, double *d__, double *g, 
+       double *hd, double *hs, double *crvmin,
+                   const double *xbase, const double *lb, const double *ub)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, i__1, i__2;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__, j, k;
+    double dd, cf, dg, gg;
+    int ih;
+    double ds, sg;
+    int iu;
+    double ss, dhd, dhs, cth, sgk, shs, sth, qadd, half, qbeg, qred, qmin,
+            temp, qsav, qnew, zero, ggbeg, alpha, angle, reduc;
+    int iterc;
+    double ggsav, delsq, tempa, tempb;
+    int isave;
+    double bstep, ratio, twopi;
+    int itersw;
+    double angtest;
+    int itermax;
+
+
+/* N is the number of variables of a quadratic objective function, Q say. */
+/* The arguments NPT, XOPT, XPT, GQ, HQ and PQ have their usual meanings, */
+/*   in order to define the current quadratic model Q. */
+/* DELTA is the trust region radius, and has to be positive. */
+/* STEP will be set to the calculated trial step. */
+/* The arrays D, G, HD and HS will be used for working space. */
+/* CRVMIN will be set to the least curvature of H along the conjugate */
+/*   directions that occur, except that it is set to zero if STEP goes */
+/*   all the way to the trust region boundary. */
+
+/* The calculation of STEP begins with the truncated conjugate gradient */
+/* method. If the boundary of the trust region is reached, then further */
+/* changes to STEP may be made, each one being in the 2D space spanned */
+/* by the current STEP and the corresponding gradient of Q. Thus STEP */
+/* should provide a substantial reduction to Q within the trust region. */
+
+/* Initialization, which includes setting HD to H times XOPT. */
+
+    /* Parameter adjustments */
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xopt;
+    --gq;
+    --hq;
+    --pq;
+    --step;
+    --d__;
+    --g;
+    --hd;
+    --hs;
+
+    if (lb && ub) {
+        double *slb, *sub, *xtol, minf, crv;
+        nlopt_result ret;
+        quad_model_data qmd;
+        qmd.npt = *npt;
+        qmd.xpt = &xpt[1 + 1 * xpt_dim1];
+        qmd.pq = &pq[1];
+        qmd.hq = &hq[1];
+        qmd.gq = &gq[1];
+        qmd.xopt = &xopt[1];
+        qmd.hd = &hd[1];
+        qmd.iter = 0;
+        slb = &g[1];
+        sub = &hs[1];
+        xtol = &d__[1];
+        for (j = 0; j < *n; ++j) {
+             slb[j] = -(sub[j] = *delta);
+             if (slb[j] < lb[j] - xbase[j] - xopt[j+1])
+                  slb[j] = lb[j] - xbase[j] - xopt[j+1];
+             if (sub[j] > ub[j] - xbase[j] - xopt[j+1])
+                  sub[j] = ub[j] - xbase[j] - xopt[j+1];
+             if (slb[j] > 0) slb[j] = 0;
+             if (sub[j] < 0) sub[j] = 0;
+             xtol[j] = 1e-7 * *delta; /* absolute x tolerance */
+        }
+        memset(&step[1], 0, sizeof(double) * *n);
+        ret = nlopt_minimize_constrained(NLOPT_LD_MMA, *n, quad_model, &qmd,
+                                   1, rho_constraint, delta, sizeof(double),
+                                   slb, sub, &step[1], &minf, -HUGE_VAL,
+                                   0., 0., 0., xtol, 1000, 0.);
+        if (rho_constraint(*n, &step[1], 0, delta) > -1e-6*(*delta)*(*delta))
+             crv = 0;
+        else {
+             for (j = 1; j <= *n; ++j) d__[j] = step[j] - xopt[j];
+             quad_model(*n, &d__[1], &g[1], &qmd);
+             crv = gg = 0; 
+             for (j = 1; j <= *n; ++j) { 
+                  crv += step[j] * (g[j] - gq[j]);
+                  gg += step[j] * step[j];
+             }
+             if (gg <= 1e-16 * crv)
+                  crv = 1e16;
+             else
+                  crv = crv / gg;
+        }
+        *crvmin = crv;
+        return ret;
+    }
+    
+    /* Function Body */
+    half = .5;
+    zero = 0.;
+    twopi = atan(1.) * 8.;
+    delsq = *delta * *delta;
+    iterc = 0;
+    itermax = *n;
+    itersw = itermax;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L10: */
+       d__[i__] = xopt[i__];
+    }
+    goto L170;
+
+/* Prepare for the first line search. */
+
+L20:
+    qred = zero;
+    dd = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       step[i__] = zero;
+       hs[i__] = zero;
+       g[i__] = gq[i__] + hd[i__];
+       d__[i__] = -g[i__];
+/* L30: */
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dd += d__1 * d__1;
+    }
+    *crvmin = zero;
+    if (dd == zero) {
+       goto L160;
+    }
+    ds = zero;
+    ss = zero;
+    gg = dd;
+    ggbeg = gg;
+
+/* Calculate the step to the trust region boundary and the product HD. */
+
+L40:
+    ++iterc;
+    temp = delsq - ss;
+    bstep = temp / (ds + sqrt(ds * ds + dd * temp));
+    goto L170;
+L50:
+    dhd = zero;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* L60: */
+       dhd += d__[j] * hd[j];
+    }
+
+/* Update CRVMIN and set the step-length ALPHA. */
+
+    alpha = bstep;
+    if (dhd > zero) {
+       temp = dhd / dd;
+       if (iterc == 1) {
+           *crvmin = temp;
+       }
+       *crvmin = MIN2(*crvmin,temp);
+/* Computing MIN */
+       d__1 = alpha, d__2 = gg / dhd;
+       alpha = MIN2(d__1,d__2);
+    }
+    qadd = alpha * (gg - half * alpha * dhd);
+    qred += qadd;
+
+/* Update STEP and HS. */
+
+    ggsav = gg;
+    gg = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       step[i__] += alpha * d__[i__];
+       hs[i__] += alpha * hd[i__];
+/* L70: */
+/* Computing 2nd power */
+       d__1 = g[i__] + hs[i__];
+       gg += d__1 * d__1;
+    }
+
+/* Begin another conjugate direction iteration if required. */
+
+    if (alpha < bstep) {
+       if (qadd <= qred * .01) {
+           goto L160;
+       }
+       if (gg <= ggbeg * 1e-4) {
+           goto L160;
+       }
+       if (iterc == itermax) {
+           goto L160;
+       }
+       temp = gg / ggsav;
+       dd = zero;
+       ds = zero;
+       ss = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           d__[i__] = temp * d__[i__] - g[i__] - hs[i__];
+/* Computing 2nd power */
+           d__1 = d__[i__];
+           dd += d__1 * d__1;
+           ds += d__[i__] * step[i__];
+/* L80: */
+/* Computing 2nd power */
+           d__1 = step[i__];
+           ss += d__1 * d__1;
+       }
+       if (ds <= zero) {
+           goto L160;
+       }
+       if (ss < delsq) {
+           goto L40;
+       }
+    }
+    *crvmin = zero;
+    itersw = iterc;
+
+/* Test whether an alternative iteration is required. */
+
+L90:
+    if (gg <= ggbeg * 1e-4) {
+       goto L160;
+    }
+    sg = zero;
+    shs = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       sg += step[i__] * g[i__];
+/* L100: */
+       shs += step[i__] * hs[i__];
+    }
+    sgk = sg + shs;
+    angtest = sgk / sqrt(gg * delsq);
+    if (angtest <= -.99) {
+       goto L160;
+    }
+
+/* Begin the alternative iteration by calculating D and HD and some */
+/* scalar products. */
+
+    ++iterc;
+    temp = sqrt(delsq * gg - sgk * sgk);
+    tempa = delsq / temp;
+    tempb = sgk / temp;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L110: */
+       d__[i__] = tempa * (g[i__] + hs[i__]) - tempb * step[i__];
+    }
+    goto L170;
+L120:
+    dg = zero;
+    dhd = zero;
+    dhs = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       dg += d__[i__] * g[i__];
+       dhd += hd[i__] * d__[i__];
+/* L130: */
+       dhs += hd[i__] * step[i__];
+    }
+
+/* Seek the value of the angle that minimizes Q. */
+
+    cf = half * (shs - dhd);
+    qbeg = sg + cf;
+    qsav = qbeg;
+    qmin = qbeg;
+    isave = 0;
+    iu = 49;
+    temp = twopi / (double) (iu + 1);
+    i__1 = iu;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       angle = (double) i__ * temp;
+       cth = cos(angle);
+       sth = sin(angle);
+       qnew = (sg + cf * cth) * cth + (dg + dhs * cth) * sth;
+       if (qnew < qmin) {
+           qmin = qnew;
+           isave = i__;
+           tempa = qsav;
+       } else if (i__ == isave + 1) {
+           tempb = qnew;
+       }
+/* L140: */
+       qsav = qnew;
+    }
+    if ((double) isave == zero) {
+       tempa = qnew;
+    }
+    if (isave == iu) {
+       tempb = qbeg;
+    }
+    angle = zero;
+    if (tempa != tempb) {
+       tempa -= qmin;
+       tempb -= qmin;
+       angle = half * (tempa - tempb) / (tempa + tempb);
+    }
+    angle = temp * ((double) isave + angle);
+
+/* Calculate the new STEP and HS. Then test for convergence. */
+
+    cth = cos(angle);
+    sth = sin(angle);
+    reduc = qbeg - (sg + cf * cth) * cth - (dg + dhs * cth) * sth;
+    gg = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       step[i__] = cth * step[i__] + sth * d__[i__];
+       hs[i__] = cth * hs[i__] + sth * hd[i__];
+/* L150: */
+/* Computing 2nd power */
+       d__1 = g[i__] + hs[i__];
+       gg += d__1 * d__1;
+    }
+    qred += reduc;
+    ratio = reduc / qred;
+    if (iterc < itermax && ratio > .01) {
+       goto L90;
+    }
+L160:
+    return NLOPT_SUCCESS;
+
+/* The following instructions act as a subroutine for setting the vector */
+/* HD to the vector D multiplied by the second derivative matrix of Q. */
+/* They are called from three different places, which are distinguished */
+/* by the value of ITERC. */
+
+L170:
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L180: */
+       hd[i__] = zero;
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       temp = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L190: */
+           temp += xpt[k + j * xpt_dim1] * d__[j];
+       }
+       temp *= pq[k];
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L200: */
+           hd[i__] += temp * xpt[k + i__ * xpt_dim1];
+       }
+    }
+    ih = 0;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       i__1 = j;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           ++ih;
+           if (i__ < j) {
+               hd[j] += hq[ih] * d__[i__];
+           }
+/* L210: */
+           hd[i__] += hq[ih] * d__[j];
+       }
+    }
+    if (iterc == 0) {
+       goto L20;
+    }
+    if (iterc <= itersw) {
+       goto L50;
+    }
+    goto L120;
+} /* trsapp_ */
+
+
+/*************************************************************************/
+/* bigden.f */
+
+static nlopt_result bigden_(int *n, int *npt, double *xopt, 
+                   double *xpt, double *bmat, double *zmat, int *idz, 
+                   int *ndim, int *kopt, int *knew, double *d__, 
+                   double *w, double *vlag, double *beta, double *s, 
+                   double *wvec, double *prod,
+                   const double *xbase, const double *lb, const double *ub)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, wvec_dim1, wvec_offset, prod_dim1, prod_offset, i__1,
+            i__2;
+    double d__1;
+
+    /* Local variables */
+    int i__, j, k;
+    double dd;
+    int jc;
+    double ds;
+    int ip, iu, nw;
+    double ss, den[9], one, par[9], tau, sum, two, diff, half, temp;
+    int ksav;
+    double step;
+    int nptm;
+    double zero, alpha, angle, denex[9];
+    int iterc;
+    double tempa, tempb, tempc;
+    int isave;
+    double ssden, dtest, quart, xoptd, twopi, xopts, denold, denmax, 
+           densav, dstemp, sumold, sstemp, xoptsq;
+
+
+/* N is the number of variables. */
+/* NPT is the number of interpolation equations. */
+/* XOPT is the best interpolation point so far. */
+/* XPT contains the coordinates of the current interpolation points. */
+/* BMAT provides the last N columns of H. */
+/* ZMAT and IDZ give a factorization of the first NPT by NPT submatrix of H. */
+/* NDIM is the first dimension of BMAT and has the value NPT+N. */
+/* KOPT is the index of the optimal interpolation point. */
+/* KNEW is the index of the interpolation point that is going to be moved. */
+/* D will be set to the step from XOPT to the new point, and on entry it */
+/*   should be the D that was calculated by the last call of BIGLAG. The */
+/*   length of the initial D provides a trust region bound on the final D. */
+/* W will be set to Wcheck for the final choice of D. */
+/* VLAG will be set to Theta*Wcheck+e_b for the final choice of D. */
+/* BETA will be set to the value that will occur in the updating formula */
+/*   when the KNEW-th interpolation point is moved to its new position. */
+/* S, WVEC, PROD and the private arrays DEN, DENEX and PAR will be used */
+/*   for working space. */
+
+/* D is calculated in a way that should provide a denominator with a large */
+/* modulus in the updating formula when the KNEW-th interpolation point is */
+/* shifted to the new position XOPT+D. */
+
+/* Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xopt;
+    prod_dim1 = *ndim;
+    prod_offset = 1 + prod_dim1;
+    prod -= prod_offset;
+    wvec_dim1 = *ndim;
+    wvec_offset = 1 + wvec_dim1;
+    wvec -= wvec_offset;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --d__;
+    --w;
+    --vlag;
+    --s;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    quart = .25;
+    two = 2.;
+    zero = 0.;
+    twopi = atan(one) * 8.;
+    nptm = *npt - *n - 1;
+
+/* Store the first NPT elements of the KNEW-th column of H in W(N+1) */
+/* to W(N+NPT). */
+
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+/* L10: */
+       w[*n + k] = zero;
+    }
+    i__1 = nptm;
+    for (j = 1; j <= i__1; ++j) {
+       temp = zmat[*knew + j * zmat_dim1];
+       if (j < *idz) {
+           temp = -temp;
+       }
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L20: */
+           w[*n + k] += temp * zmat[k + j * zmat_dim1];
+       }
+    }
+    alpha = w[*n + *knew];
+
+/* The initial search direction D is taken from the last call of BIGLAG, */
+/* and the initial S is set below, usually to the direction from X_OPT */
+/* to X_KNEW, but a different direction to an interpolation point may */
+/* be chosen, in order to prevent S from being nearly parallel to D. */
+
+    dd = zero;
+    ds = zero;
+    ss = zero;
+    xoptsq = zero;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dd += d__1 * d__1;
+       s[i__] = xpt[*knew + i__ * xpt_dim1] - xopt[i__];
+       ds += d__[i__] * s[i__];
+/* Computing 2nd power */
+       d__1 = s[i__];
+       ss += d__1 * d__1;
+/* L30: */
+/* Computing 2nd power */
+       d__1 = xopt[i__];
+       xoptsq += d__1 * d__1;
+    }
+    if (ds * ds > dd * .99 * ss) {
+       ksav = *knew;
+       dtest = ds * ds / ss;
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+           if (k != *kopt) {
+               dstemp = zero;
+               sstemp = zero;
+               i__1 = *n;
+               for (i__ = 1; i__ <= i__1; ++i__) {
+                   diff = xpt[k + i__ * xpt_dim1] - xopt[i__];
+                   dstemp += d__[i__] * diff;
+/* L40: */
+                   sstemp += diff * diff;
+               }
+               if (sstemp == 0) return NLOPT_ROUNDOFF_LIMITED;
+               if (dstemp * dstemp / sstemp < dtest) {
+                   ksav = k;
+                   dtest = dstemp * dstemp / sstemp;
+                   ds = dstemp;
+                   ss = sstemp;
+               }
+           }
+/* L50: */
+       }
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L60: */
+           s[i__] = xpt[ksav + i__ * xpt_dim1] - xopt[i__];
+       }
+    }
+    ssden = dd * ss - ds * ds;
+    iterc = 0;
+    densav = zero;
+
+/* Begin the iteration by overwriting S with a vector that has the */
+/* required length and direction. */
+
+L70:
+    ++iterc;
+    if (ssden < 0) return NLOPT_ROUNDOFF_LIMITED;
+    temp = one / sqrt(ssden);
+    xoptd = zero;
+    xopts = zero;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       s[i__] = temp * (dd * s[i__] - ds * d__[i__]);
+       xoptd += xopt[i__] * d__[i__];
+/* L80: */
+       if (nlopt_isinf(s[i__])) return NLOPT_ROUNDOFF_LIMITED;
+       xopts += xopt[i__] * s[i__];
+    }
+
+/* Set the coefficients of the first two terms of BETA. */
+
+    tempa = half * xoptd * xoptd;
+    tempb = half * xopts * xopts;
+    den[0] = dd * (xoptsq + half * dd) + tempa + tempb;
+    den[1] = two * xoptd * dd;
+    den[2] = two * xopts * dd;
+    den[3] = tempa - tempb;
+    den[4] = xoptd * xopts;
+    for (i__ = 6; i__ <= 9; ++i__) {
+/* L90: */
+       den[i__ - 1] = zero;
+    }
+
+/* Put the coefficients of Wcheck in WVEC. */
+
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       tempa = zero;
+       tempb = zero;
+       tempc = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           tempa += xpt[k + i__ * xpt_dim1] * d__[i__];
+           tempb += xpt[k + i__ * xpt_dim1] * s[i__];
+/* L100: */
+           tempc += xpt[k + i__ * xpt_dim1] * xopt[i__];
+       }
+       wvec[k + wvec_dim1] = quart * (tempa * tempa + tempb * tempb);
+       wvec[k + (wvec_dim1 << 1)] = tempa * tempc;
+       wvec[k + wvec_dim1 * 3] = tempb * tempc;
+       wvec[k + (wvec_dim1 << 2)] = quart * (tempa * tempa - tempb * tempb);
+/* L110: */
+       wvec[k + wvec_dim1 * 5] = half * tempa * tempb;
+    }
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       ip = i__ + *npt;
+       wvec[ip + wvec_dim1] = zero;
+       wvec[ip + (wvec_dim1 << 1)] = d__[i__];
+       wvec[ip + wvec_dim1 * 3] = s[i__];
+       wvec[ip + (wvec_dim1 << 2)] = zero;
+/* L120: */
+       wvec[ip + wvec_dim1 * 5] = zero;
+    }
+
+/* Put the coefficents of THETA*Wcheck in PROD. */
+
+    for (jc = 1; jc <= 5; ++jc) {
+       nw = *npt;
+       if (jc == 2 || jc == 3) {
+           nw = *ndim;
+       }
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L130: */
+           prod[k + jc * prod_dim1] = zero;
+       }
+       i__2 = nptm;
+       for (j = 1; j <= i__2; ++j) {
+           sum = zero;
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+/* L140: */
+               sum += zmat[k + j * zmat_dim1] * wvec[k + jc * wvec_dim1];
+           }
+           if (j < *idz) {
+               sum = -sum;
+           }
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+/* L150: */
+               prod[k + jc * prod_dim1] += sum * zmat[k + j * zmat_dim1];
+           }
+       }
+       if (nw == *ndim) {
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+               sum = zero;
+               i__2 = *n;
+               for (j = 1; j <= i__2; ++j) {
+/* L160: */
+                   sum += bmat[k + j * bmat_dim1] * wvec[*npt + j + jc * 
+                           wvec_dim1];
+               }
+/* L170: */
+               prod[k + jc * prod_dim1] += sum;
+           }
+       }
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           sum = zero;
+           i__2 = nw;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+/* L180: */
+               sum += bmat[i__ + j * bmat_dim1] * wvec[i__ + jc * wvec_dim1];
+           }
+/* L190: */
+           prod[*npt + j + jc * prod_dim1] = sum;
+       }
+    }
+
+/* Include in DEN the part of BETA that depends on THETA. */
+
+    i__1 = *ndim;
+    for (k = 1; k <= i__1; ++k) {
+       sum = zero;
+       for (i__ = 1; i__ <= 5; ++i__) {
+           par[i__ - 1] = half * prod[k + i__ * prod_dim1] * wvec[k + i__ * 
+                   wvec_dim1];
+/* L200: */
+           sum += par[i__ - 1];
+       }
+       den[0] = den[0] - par[0] - sum;
+       tempa = prod[k + prod_dim1] * wvec[k + (wvec_dim1 << 1)] + prod[k + (
+               prod_dim1 << 1)] * wvec[k + wvec_dim1];
+       tempb = prod[k + (prod_dim1 << 1)] * wvec[k + (wvec_dim1 << 2)] + 
+               prod[k + (prod_dim1 << 2)] * wvec[k + (wvec_dim1 << 1)];
+       tempc = prod[k + prod_dim1 * 3] * wvec[k + wvec_dim1 * 5] + prod[k + 
+               prod_dim1 * 5] * wvec[k + wvec_dim1 * 3];
+       den[1] = den[1] - tempa - half * (tempb + tempc);
+       den[5] -= half * (tempb - tempc);
+       tempa = prod[k + prod_dim1] * wvec[k + wvec_dim1 * 3] + prod[k + 
+               prod_dim1 * 3] * wvec[k + wvec_dim1];
+       tempb = prod[k + (prod_dim1 << 1)] * wvec[k + wvec_dim1 * 5] + prod[k 
+               + prod_dim1 * 5] * wvec[k + (wvec_dim1 << 1)];
+       tempc = prod[k + prod_dim1 * 3] * wvec[k + (wvec_dim1 << 2)] + prod[k 
+               + (prod_dim1 << 2)] * wvec[k + wvec_dim1 * 3];
+       den[2] = den[2] - tempa - half * (tempb - tempc);
+       den[6] -= half * (tempb + tempc);
+       tempa = prod[k + prod_dim1] * wvec[k + (wvec_dim1 << 2)] + prod[k + (
+               prod_dim1 << 2)] * wvec[k + wvec_dim1];
+       den[3] = den[3] - tempa - par[1] + par[2];
+       tempa = prod[k + prod_dim1] * wvec[k + wvec_dim1 * 5] + prod[k + 
+               prod_dim1 * 5] * wvec[k + wvec_dim1];
+       tempb = prod[k + (prod_dim1 << 1)] * wvec[k + wvec_dim1 * 3] + prod[k 
+               + prod_dim1 * 3] * wvec[k + (wvec_dim1 << 1)];
+       den[4] = den[4] - tempa - half * tempb;
+       den[7] = den[7] - par[3] + par[4];
+       tempa = prod[k + (prod_dim1 << 2)] * wvec[k + wvec_dim1 * 5] + prod[k 
+               + prod_dim1 * 5] * wvec[k + (wvec_dim1 << 2)];
+/* L210: */
+       den[8] -= half * tempa;
+    }
+
+/* Extend DEN so that it holds all the coefficients of DENOM. */
+
+    sum = zero;
+    for (i__ = 1; i__ <= 5; ++i__) {
+/* Computing 2nd power */
+       d__1 = prod[*knew + i__ * prod_dim1];
+       par[i__ - 1] = half * (d__1 * d__1);
+/* L220: */
+       sum += par[i__ - 1];
+    }
+    denex[0] = alpha * den[0] + par[0] + sum;
+    tempa = two * prod[*knew + prod_dim1] * prod[*knew + (prod_dim1 << 1)];
+    tempb = prod[*knew + (prod_dim1 << 1)] * prod[*knew + (prod_dim1 << 2)];
+    tempc = prod[*knew + prod_dim1 * 3] * prod[*knew + prod_dim1 * 5];
+    denex[1] = alpha * den[1] + tempa + tempb + tempc;
+    denex[5] = alpha * den[5] + tempb - tempc;
+    tempa = two * prod[*knew + prod_dim1] * prod[*knew + prod_dim1 * 3];
+    tempb = prod[*knew + (prod_dim1 << 1)] * prod[*knew + prod_dim1 * 5];
+    tempc = prod[*knew + prod_dim1 * 3] * prod[*knew + (prod_dim1 << 2)];
+    denex[2] = alpha * den[2] + tempa + tempb - tempc;
+    denex[6] = alpha * den[6] + tempb + tempc;
+    tempa = two * prod[*knew + prod_dim1] * prod[*knew + (prod_dim1 << 2)];
+    denex[3] = alpha * den[3] + tempa + par[1] - par[2];
+    tempa = two * prod[*knew + prod_dim1] * prod[*knew + prod_dim1 * 5];
+    denex[4] = alpha * den[4] + tempa + prod[*knew + (prod_dim1 << 1)] * prod[
+           *knew + prod_dim1 * 3];
+    denex[7] = alpha * den[7] + par[3] - par[4];
+    denex[8] = alpha * den[8] + prod[*knew + (prod_dim1 << 2)] * prod[*knew + 
+           prod_dim1 * 5];
+
+/* Seek the value of the angle that maximizes the modulus of DENOM. */
+
+    sum = denex[0] + denex[1] + denex[3] + denex[5] + denex[7];
+    denold = sum;
+    denmax = sum;
+    isave = 0;
+    iu = 49;
+    temp = twopi / (double) (iu + 1);
+    par[0] = one;
+    i__1 = iu;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       angle = (double) i__ * temp;
+       par[1] = cos(angle);
+       par[2] = sin(angle);
+       for (j = 4; j <= 8; j += 2) {
+           par[j - 1] = par[1] * par[j - 3] - par[2] * par[j - 2];
+/* L230: */
+           par[j] = par[1] * par[j - 2] + par[2] * par[j - 3];
+       }
+       sumold = sum;
+       sum = zero;
+       for (j = 1; j <= 9; ++j) {
+/* L240: */
+           sum += denex[j - 1] * par[j - 1];
+       }
+       if (fabs(sum) > fabs(denmax)) {
+           denmax = sum;
+           isave = i__;
+           tempa = sumold;
+       } else if (i__ == isave + 1) {
+           tempb = sum;
+       }
+/* L250: */
+    }
+    if (isave == 0) {
+       tempa = sum;
+    }
+    if (isave == iu) {
+       tempb = denold;
+    }
+    step = zero;
+    if (tempa != tempb) {
+       tempa -= denmax;
+       tempb -= denmax;
+       step = half * (tempa - tempb) / (tempa + tempb);
+    }
+    angle = temp * ((double) isave + step);
+
+/* Calculate the new parameters of the denominator, the new VLAG vector */
+/* and the new D. Then test for convergence. */
+
+    par[1] = cos(angle);
+    par[2] = sin(angle);
+    for (j = 4; j <= 8; j += 2) {
+       par[j - 1] = par[1] * par[j - 3] - par[2] * par[j - 2];
+/* L260: */
+       par[j] = par[1] * par[j - 2] + par[2] * par[j - 3];
+    }
+    *beta = zero;
+    denmax = zero;
+    for (j = 1; j <= 9; ++j) {
+       *beta += den[j - 1] * par[j - 1];
+/* L270: */
+       denmax += denex[j - 1] * par[j - 1];
+    }
+    i__1 = *ndim;
+    for (k = 1; k <= i__1; ++k) {
+       vlag[k] = zero;
+       for (j = 1; j <= 5; ++j) {
+/* L280: */
+           vlag[k] += prod[k + j * prod_dim1] * par[j - 1];
+       }
+    }
+    tau = vlag[*knew];
+    dd = zero;
+    tempa = zero;
+    tempb = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       d__[i__] = par[1] * d__[i__] + par[2] * s[i__];
+       w[i__] = xopt[i__] + d__[i__];
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dd += d__1 * d__1;
+       tempa += d__[i__] * w[i__];
+/* L290: */
+       tempb += w[i__] * w[i__];
+    }
+    if (iterc >= *n) {
+       goto L340;
+    }
+    if (iterc > 1) {
+       densav = MAX2(densav,denold);
+    }
+    if (fabs(denmax) <= fabs(densav) * 1.1) {
+       goto L340;
+    }
+    densav = denmax;
+
+/* Set S to half the gradient of the denominator with respect to D. */
+/* Then branch for the next iteration. */
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp = tempa * xopt[i__] + tempb * d__[i__] - vlag[*npt + i__];
+/* L300: */
+       s[i__] = tau * bmat[*knew + i__ * bmat_dim1] + alpha * temp;
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       sum = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L310: */
+           sum += xpt[k + j * xpt_dim1] * w[j];
+       }
+       if (nlopt_isinf(tau * w[*n + k]) ||
+           nlopt_isinf(alpha * vlag[k])) return NLOPT_ROUNDOFF_LIMITED;
+       temp = (tau * w[*n + k] - alpha * vlag[k]) * sum;
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L320: */
+           s[i__] += temp * xpt[k + i__ * xpt_dim1];
+       }
+    }
+    ss = zero;
+    ds = zero;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* Computing 2nd power */
+       d__1 = s[i__];
+       ss += d__1 * d__1;
+/* L330: */
+       ds += d__[i__] * s[i__];
+    }
+    ssden = dd * ss - ds * ds;
+    if (ssden >= dd * 1e-8 * ss) {
+       goto L70;
+    }
+
+/* Set the vector W before the RETURN from the subroutine. */
+
+L340:
+    /* SGJ, 2008: crude hack: truncate d to [lb,ub] bounds if given */
+    if (lb && ub) {
+        for (k = 1; k <= *n; ++k) {
+             if (d__[k] > ub[k-1] - xbase[k-1] - xopt[k])
+                  d__[k] = ub[k-1] - xbase[k-1] - xopt[k];
+             else if (d__[k] < lb[k-1] - xbase[k-1] - xopt[k])
+                  d__[k] = lb[k-1] - xbase[k-1] - xopt[k];
+        }
+    }
+
+    i__2 = *ndim;
+    for (k = 1; k <= i__2; ++k) {
+       w[k] = zero;
+       for (j = 1; j <= 5; ++j) {
+/* L350: */
+           w[k] += wvec[k + j * wvec_dim1] * par[j - 1];
+       }
+    }
+    vlag[*kopt] += one;
+    return NLOPT_SUCCESS;
+} /* bigden_ */
+
+/*************************************************************************/
+/* biglag.f */
+
+typedef struct {
+     int npt, ndim, iter;
+     double *hcol, *xpt, *bmat, *xopt;
+     int flipsign;
+} lag_data;
+
+/* the Lagrange function, whose absolute value biglag maximizes */
+static double lag(int n, const double *dx, double *grad, void *data)
+{
+     lag_data *d = (lag_data *) data;
+     int i, j, npt = d->npt, ndim = d->ndim;
+     const double *hcol = d->hcol, *xpt = d->xpt, *bmat = d->bmat, *xopt = d->xopt;
+     double val = 0;
+     for (j = 0; j < n; ++j) {
+         val += bmat[j * ndim] * (xopt[j] + dx[j]);
+         if (grad) grad[j] = bmat[j * ndim];
+     }
+     for (i = 0; i < npt; ++i) {
+         double dot = 0;
+         for (j = 0; j < n; ++j)
+              dot += xpt[i + j * npt] * (xopt[j] + dx[j]);
+         val += 0.5 * hcol[i] * (dot * dot);
+         dot *= hcol[i];
+         if (grad) for (j = 0; j < n; ++j)
+                        grad[j] += dot * xpt[i + j * npt];
+     }
+     if (d->flipsign) {
+         val = -val;
+         if (grad) for (j = 0; j < n; ++j) grad[j] = -grad[j];
+     }
+     d->iter++;
+     return val;
+}
+
+static nlopt_result biglag_(int *n, int *npt, double *xopt, 
+                   double *xpt, double *bmat, double *zmat, int *idz, 
+                   int *ndim, int *knew, double *delta, double *d__, 
+                   double *alpha, double *hcol, double *gc, double *gd, 
+                   double *s, double *w,
+                   const double *xbase, const double *lb, const double *ub)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2;
+    double d__1;
+
+    /* Local variables */
+    int i__, j, k;
+    double dd, gg;
+    int iu;
+    double sp, ss, cf1, cf2, cf3, cf4, cf5, dhd, cth, one, tau, sth, sum, 
+           half, temp, step;
+    int nptm;
+    double zero, angle, scale, denom;
+    int iterc, isave;
+    double delsq, tempa, tempb, twopi, taubeg, tauold, taumax;
+
+
+/* N is the number of variables. */
+/* NPT is the number of interpolation equations. */
+/* XOPT is the best interpolation point so far. */
+/* XPT contains the coordinates of the current interpolation points. */
+/* BMAT provides the last N columns of H. */
+/* ZMAT and IDZ give a factorization of the first NPT by NPT submatrix of H. */
+/* NDIM is the first dimension of BMAT and has the value NPT+N. */
+/* KNEW is the index of the interpolation point that is going to be moved. */
+/* DELTA is the current trust region bound. */
+/* D will be set to the step from XOPT to the new point. */
+/* ALPHA will be set to the KNEW-th diagonal element of the H matrix. */
+/* HCOL, GC, GD, S and W will be used for working space. */
+
+/* The step D is calculated in a way that attempts to maximize the modulus */
+/* of LFUNC(XOPT+D), subject to the bound ||D|| .LE. DELTA, where LFUNC is */
+/* the KNEW-th Lagrange function. */
+
+/* Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --xopt;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --d__;
+    --hcol;
+    --gc;
+    --gd;
+    --s;
+    --w;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    zero = 0.;
+    twopi = atan(one) * 8.;
+    delsq = *delta * *delta;
+    nptm = *npt - *n - 1;
+
+/* Set the first NPT components of HCOL to the leading elements of the */
+/* KNEW-th column of H. */
+
+    iterc = 0;
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+/* L10: */
+       hcol[k] = zero;
+    }
+    i__1 = nptm;
+    for (j = 1; j <= i__1; ++j) {
+       temp = zmat[*knew + j * zmat_dim1];
+       if (j < *idz) {
+           temp = -temp;
+       }
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L20: */
+           hcol[k] += temp * zmat[k + j * zmat_dim1];
+           if (nlopt_isinf(hcol[k])) return NLOPT_ROUNDOFF_LIMITED;
+       }
+    }
+    *alpha = hcol[*knew];
+
+/* Set the unscaled initial direction D. Form the gradient of LFUNC at */
+/* XOPT, and multiply D by the second derivative matrix of LFUNC. */
+
+    dd = zero;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       d__[i__] = xpt[*knew + i__ * xpt_dim1] - xopt[i__];
+       gc[i__] = bmat[*knew + i__ * bmat_dim1];
+       gd[i__] = zero;
+/* L30: */
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dd += d__1 * d__1;
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       temp = zero;
+       sum = zero;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           temp += xpt[k + j * xpt_dim1] * xopt[j];
+/* L40: */
+           sum += xpt[k + j * xpt_dim1] * d__[j];
+       }
+       temp = hcol[k] * temp;
+       sum = hcol[k] * sum;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           gc[i__] += temp * xpt[k + i__ * xpt_dim1];
+/* L50: */
+           gd[i__] += sum * xpt[k + i__ * xpt_dim1];
+       }
+    }
+
+/* Scale D and GD, with a sign change if required. Set S to another */
+/* vector in the initial two dimensional subspace. */
+
+    gg = zero;
+    sp = zero;
+    dhd = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing 2nd power */
+       d__1 = gc[i__];
+       gg += d__1 * d__1;
+       sp += d__[i__] * gc[i__];
+/* L60: */
+       dhd += d__[i__] * gd[i__];
+    }
+    scale = *delta / sqrt(dd);
+    if (sp * dhd < zero) {
+       scale = -scale;
+    }
+    temp = zero;
+    if (sp * sp > dd * .99 * gg) {
+       temp = one;
+    }
+    tau = scale * (fabs(sp) + half * scale * fabs(dhd));
+    if (gg * delsq < tau * .01 * tau) {
+       temp = one;
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       d__[i__] = scale * d__[i__];
+       gd[i__] = scale * gd[i__];
+/* L70: */
+       s[i__] = gc[i__] + temp * gd[i__];
+    }
+
+    if (lb && ub) {
+        double minf, *dlb, *dub, *xtol;
+        lag_data ld;
+        ld.npt = *npt;
+        ld.ndim = *ndim;
+        ld.iter = 0;
+        ld.hcol = &hcol[1];
+        ld.xpt = &xpt[1 + 1 * xpt_dim1];
+        ld.bmat = &bmat[*knew + 1 * bmat_dim1];
+        ld.xopt = &xopt[1];
+        ld.flipsign = 0;
+        dlb = &gc[1]; dub = &gd[1]; xtol = &s[1];
+        /* make sure rounding errors don't push initial |d| > delta */
+        for (j = 1; j <= *n; ++j) d__[j] *= 0.99999;
+        for (j = 0; j < *n; ++j) {
+             dlb[j] = -(dub[j] = *delta);
+             if (dlb[j] < lb[j] - xbase[j] - xopt[j+1])
+                  dlb[j] = lb[j] - xbase[j] - xopt[j+1];
+             if (dub[j] > ub[j] - xbase[j] - xopt[j+1])
+                  dub[j] = ub[j] - xbase[j] - xopt[j+1];
+             if (dlb[j] > 0) dlb[j] = 0;
+             if (dub[j] < 0) dub[j] = 0;
+             if (d__[j+1] < dlb[j]) d__[j+1] = dlb[j];
+             else if (d__[j+1] > dub[j]) d__[j+1] = dub[j];
+             xtol[j] = 1e-5 * *delta;
+        }
+        ld.flipsign = lag(*n, &d__[1], 0, &ld) > 0; /* maximize if > 0 */
+        return nlopt_minimize_constrained(NLOPT_LD_MMA, *n, lag, &ld,
+                                   1, rho_constraint, delta, sizeof(double),
+                                   dlb, dub, &d__[1], &minf, -HUGE_VAL,
+                                   0., 0., 0., xtol, 1000, 0.);
+    }
+
+/* Begin the iteration by overwriting S with a vector that has the */
+/* required length and direction, except that termination occurs if */
+/* the given D and S are nearly parallel. */
+
+L80:
+    ++iterc;
+    dd = zero;
+    sp = zero;
+    ss = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dd += d__1 * d__1;
+       sp += d__[i__] * s[i__];
+/* L90: */
+/* Computing 2nd power */
+       d__1 = s[i__];
+       ss += d__1 * d__1;
+    }
+    temp = dd * ss - sp * sp;
+    if (temp <= dd * 1e-8 * ss) {
+       goto L160;
+    }
+    denom = sqrt(temp);
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       s[i__] = (dd * s[i__] - sp * d__[i__]) / denom;
+/* L100: */
+       w[i__] = zero;
+    }
+
+/* Calculate the coefficients of the objective function on the circle, */
+/* beginning with the multiplication of S by the second derivative matrix. */
+
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       sum = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L110: */
+           sum += xpt[k + j * xpt_dim1] * s[j];
+       }
+       sum = hcol[k] * sum;
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L120: */
+           w[i__] += sum * xpt[k + i__ * xpt_dim1];
+       }
+    }
+    cf1 = zero;
+    cf2 = zero;
+    cf3 = zero;
+    cf4 = zero;
+    cf5 = zero;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       cf1 += s[i__] * w[i__];
+       cf2 += d__[i__] * gc[i__];
+       cf3 += s[i__] * gc[i__];
+       cf4 += d__[i__] * gd[i__];
+/* L130: */
+       cf5 += s[i__] * gd[i__];
+    }
+    cf1 = half * cf1;
+    cf4 = half * cf4 - cf1;
+
+/* Seek the value of the angle that maximizes the modulus of TAU. */
+
+    taubeg = cf1 + cf2 + cf4;
+    taumax = taubeg;
+    tauold = taubeg;
+    isave = 0;
+    iu = 49;
+    temp = twopi / (double) (iu + 1);
+    i__2 = iu;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       angle = (double) i__ * temp;
+       cth = cos(angle);
+       sth = sin(angle);
+       tau = cf1 + (cf2 + cf4 * cth) * cth + (cf3 + cf5 * cth) * sth;
+       if (fabs(tau) > fabs(taumax)) {
+           taumax = tau;
+           isave = i__;
+           tempa = tauold;
+       } else if (i__ == isave + 1) {
+           tempb = tau;
+       }
+/* L140: */
+       tauold = tau;
+    }
+    if (isave == 0) {
+       tempa = tau;
+    }
+    if (isave == iu) {
+       tempb = taubeg;
+    }
+    step = zero;
+    if (tempa != tempb) {
+       tempa -= taumax;
+       tempb -= taumax;
+       step = half * (tempa - tempb) / (tempa + tempb);
+    }
+    angle = temp * ((double) isave + step);
+
+/* Calculate the new D and GD. Then test for convergence. */
+
+    cth = cos(angle);
+    sth = sin(angle);
+    tau = cf1 + (cf2 + cf4 * cth) * cth + (cf3 + cf5 * cth) * sth;
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       d__[i__] = cth * d__[i__] + sth * s[i__];
+       gd[i__] = cth * gd[i__] + sth * w[i__];
+/* L150: */
+       s[i__] = gc[i__] + gd[i__];
+    }
+    if (fabs(tau) <= fabs(taubeg) * 1.1) {
+       goto L160;
+    }
+    if (iterc < *n) {
+       goto L80;
+    }
+L160:
+    return NLOPT_SUCCESS;
+} /* biglag_ */
+
+
+
+/*************************************************************************/
+/* update.f */
+
+static void update_(int *n, int *npt, double *bmat, 
+       double *zmat, int *idz, int *ndim, double *vlag, 
+       double *beta, int *knew, double *w)
+{
+    /* System generated locals */
+    int bmat_dim1, bmat_offset, zmat_dim1, zmat_offset, i__1, i__2;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__, j, ja, jb, jl, jp;
+    double one, tau, temp;
+    int nptm;
+    double zero;
+    int iflag;
+    double scala, scalb_, alpha, denom, tempa, tempb, tausq;
+
+
+/* The arrays BMAT and ZMAT with IDZ are updated, in order to shift the */
+/* interpolation point that has index KNEW. On entry, VLAG contains the */
+/* components of the vector Theta*Wcheck+e_b of the updating formula */
+/* (6.11), and BETA holds the value of the parameter that has this name. */
+/* The vector W is used for working space. */
+
+/* Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --vlag;
+    --w;
+
+    /* Function Body */
+    one = 1.;
+    zero = 0.;
+    nptm = *npt - *n - 1;
+
+/* Apply the rotations that put zeros in the KNEW-th row of ZMAT. */
+
+    jl = 1;
+    i__1 = nptm;
+    for (j = 2; j <= i__1; ++j) {
+       if (j == *idz) {
+           jl = *idz;
+       } else if (zmat[*knew + j * zmat_dim1] != zero) {
+/* Computing 2nd power */
+           d__1 = zmat[*knew + jl * zmat_dim1];
+/* Computing 2nd power */
+           d__2 = zmat[*knew + j * zmat_dim1];
+           temp = sqrt(d__1 * d__1 + d__2 * d__2);
+           tempa = zmat[*knew + jl * zmat_dim1] / temp;
+           tempb = zmat[*knew + j * zmat_dim1] / temp;
+           i__2 = *npt;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               temp = tempa * zmat[i__ + jl * zmat_dim1] + tempb * zmat[i__ 
+                       + j * zmat_dim1];
+               zmat[i__ + j * zmat_dim1] = tempa * zmat[i__ + j * zmat_dim1] 
+                       - tempb * zmat[i__ + jl * zmat_dim1];
+/* L10: */
+               zmat[i__ + jl * zmat_dim1] = temp;
+           }
+           zmat[*knew + j * zmat_dim1] = zero;
+       }
+/* L20: */
+    }
+
+/* Put the first NPT components of the KNEW-th column of HLAG into W, */
+/* and calculate the parameters of the updating formula. */
+
+    tempa = zmat[*knew + zmat_dim1];
+    if (*idz >= 2) {
+       tempa = -tempa;
+    }
+    if (jl > 1) {
+       tempb = zmat[*knew + jl * zmat_dim1];
+    }
+    i__1 = *npt;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       w[i__] = tempa * zmat[i__ + zmat_dim1];
+       if (jl > 1) {
+           w[i__] += tempb * zmat[i__ + jl * zmat_dim1];
+       }
+/* L30: */
+    }
+    alpha = w[*knew];
+    tau = vlag[*knew];
+    tausq = tau * tau;
+    denom = alpha * *beta + tausq;
+    vlag[*knew] -= one;
+
+/* Complete the updating of ZMAT when there is only one nonzero element */
+/* in the KNEW-th row of the new matrix ZMAT, but, if IFLAG is set to one, */
+/* then the first column of ZMAT will be exchanged with another one later. */
+
+    iflag = 0;
+    if (jl == 1) {
+       temp = sqrt((fabs(denom)));
+       tempb = tempa / temp;
+       tempa = tau / temp;
+       i__1 = *npt;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L40: */
+           zmat[i__ + zmat_dim1] = tempa * zmat[i__ + zmat_dim1] - tempb * 
+                   vlag[i__];
+       }
+       if (*idz == 1 && temp < zero) {
+           *idz = 2;
+       }
+       if (*idz >= 2 && temp >= zero) {
+           iflag = 1;
+       }
+    } else {
+
+/* Complete the updating of ZMAT in the alternative case. */
+
+       ja = 1;
+       if (*beta >= zero) {
+           ja = jl;
+       }
+       jb = jl + 1 - ja;
+       temp = zmat[*knew + jb * zmat_dim1] / denom;
+       tempa = temp * *beta;
+       tempb = temp * tau;
+       temp = zmat[*knew + ja * zmat_dim1];
+       scala = one / sqrt(fabs(*beta) * temp * temp + tausq);
+       scalb_ = scala * sqrt((fabs(denom)));
+       i__1 = *npt;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           zmat[i__ + ja * zmat_dim1] = scala * (tau * zmat[i__ + ja * 
+                   zmat_dim1] - temp * vlag[i__]);
+/* L50: */
+           zmat[i__ + jb * zmat_dim1] = scalb_ * (zmat[i__ + jb * zmat_dim1] 
+                   - tempa * w[i__] - tempb * vlag[i__]);
+       }
+       if (denom <= zero) {
+           if (*beta < zero) {
+               ++(*idz);
+           }
+           if (*beta >= zero) {
+               iflag = 1;
+           }
+       }
+    }
+
+/* IDZ is reduced in the following case, and usually the first column */
+/* of ZMAT is exchanged with a later one. */
+
+    if (iflag == 1) {
+       --(*idz);
+       i__1 = *npt;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           temp = zmat[i__ + zmat_dim1];
+           zmat[i__ + zmat_dim1] = zmat[i__ + *idz * zmat_dim1];
+/* L60: */
+           zmat[i__ + *idz * zmat_dim1] = temp;
+       }
+    }
+
+/* Finally, update the matrix BMAT. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       jp = *npt + j;
+       w[jp] = bmat[*knew + j * bmat_dim1];
+       tempa = (alpha * vlag[jp] - tau * w[jp]) / denom;
+       tempb = (-(*beta) * w[jp] - tau * vlag[jp]) / denom;
+       i__2 = jp;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           bmat[i__ + j * bmat_dim1] = bmat[i__ + j * bmat_dim1] + tempa * 
+                   vlag[i__] + tempb * w[i__];
+           if (i__ > *npt) {
+               bmat[jp + (i__ - *npt) * bmat_dim1] = bmat[i__ + j * 
+                       bmat_dim1];
+           }
+/* L70: */
+       }
+    }
+    return;
+} /* update_ */
+
+
+/*************************************************************************/
+/* newuob.f */
+
+static nlopt_result newuob_(int *n, int *npt, double *x, 
+                           double *rhobeg, 
+                           const double *lb, const double *ub,
+                           nlopt_stopping *stop, double *minf,
+                           newuoa_func calfun, void *calfun_data,
+                   double *xbase, double *xopt, double *xnew, 
+                   double *xpt, double *fval, double *gq, double *hq, 
+                   double *pq, double *bmat, double *zmat, int *ndim, 
+                   double *d__, double *vlag, double *w)
+{
+    /* System generated locals */
+    int xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, 
+           zmat_offset, i__1, i__2, i__3;
+    double d__1, d__2, d__3;
+
+    /* Local variables */
+    double f;
+    int i__, j, k, ih, nf, nh, ip, jp;
+    double dx;
+    int np, nfm;
+    double one;
+    int idz;
+    double dsq, rho;
+    int ipt, jpt;
+    double sum, fbeg, diff, half, beta;
+    int nfmm;
+    double gisq;
+    int knew;
+    double temp, suma, sumb, fopt = HUGE_VAL, bsum, gqsq;
+    int kopt, nptm;
+    double zero, xipt, xjpt, sumz, diffa, diffb, diffc, hdiag, alpha, 
+           delta, recip, reciq, fsave;
+    int ksave, nfsav, itemp;
+    double dnorm, ratio, dstep, tenth, vquad;
+    int ktemp;
+    double tempq;
+    int itest;
+    double rhosq;
+    double detrat, crvmin;
+    double distsq;
+    double xoptsq;
+    double rhoend;
+    nlopt_result rc = NLOPT_SUCCESS, rc2;
+
+/* SGJ, 2008: compute rhoend from NLopt stop info */
+    rhoend = stop->xtol_rel * (*rhobeg);
+    for (j = 0; j < *n; ++j)
+        if (rhoend < stop->xtol_abs[j])
+             rhoend = stop->xtol_abs[j];
+
+/* The arguments N, NPT, X, RHOBEG, RHOEND, IPRINT and MAXFUN are identical */
+/*   to the corresponding arguments in SUBROUTINE NEWUOA. */
+/* XBASE will hold a shift of origin that should reduce the contributions */
+/*   from rounding errors to values of the model and Lagrange functions. */
+/* XOPT will be set to the displacement from XBASE of the vector of */
+/*   variables that provides the least calculated F so far. */
+/* XNEW will be set to the displacement from XBASE of the vector of */
+/*   variables for the current calculation of F. */
+/* XPT will contain the interpolation point coordinates relative to XBASE. */
+/* FVAL will hold the values of F at the interpolation points. */
+/* GQ will hold the gradient of the quadratic model at XBASE. */
+/* HQ will hold the explicit second derivatives of the quadratic model. */
+/* PQ will contain the parameters of the implicit second derivatives of */
+/*   the quadratic model. */
+/* BMAT will hold the last N columns of H. */
+/* ZMAT will hold the factorization of the leading NPT by NPT submatrix of */
+/*   H, this factorization being ZMAT times Diag(DZ) times ZMAT^T, where */
+/*   the elements of DZ are plus or minus one, as specified by IDZ. */
+/* NDIM is the first dimension of BMAT and has the value NPT+N. */
+/* D is reserved for trial steps from XOPT. */
+/* VLAG will contain the values of the Lagrange functions at a new point X. */
+/*   They are part of a product that requires VLAG to be of length NDIM. */
+/* The array W will be used for working space. Its length must be at least */
+/*   10*NDIM = 10*(NPT+N). */
+
+/* Set some constants. */
+
+    /* Parameter adjustments */
+    zmat_dim1 = *npt;
+    zmat_offset = 1 + zmat_dim1;
+    zmat -= zmat_offset;
+    xpt_dim1 = *npt;
+    xpt_offset = 1 + xpt_dim1;
+    xpt -= xpt_offset;
+    --x;
+    --xbase;
+    --xopt;
+    --xnew;
+    --fval;
+    --gq;
+    --hq;
+    --pq;
+    bmat_dim1 = *ndim;
+    bmat_offset = 1 + bmat_dim1;
+    bmat -= bmat_offset;
+    --d__;
+    --vlag;
+    --w;
+
+    /* Function Body */
+    half = .5;
+    one = 1.;
+    tenth = .1;
+    zero = 0.;
+    np = *n + 1;
+    nh = *n * np / 2;
+    nptm = *npt - np;
+
+/* Set the initial elements of XPT, BMAT, HQ, PQ and ZMAT to zero. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+       xbase[j] = x[j];
+       i__2 = *npt;
+       for (k = 1; k <= i__2; ++k) {
+/* L10: */
+           xpt[k + j * xpt_dim1] = zero;
+       }
+       i__2 = *ndim;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L20: */
+           bmat[i__ + j * bmat_dim1] = zero;
+       }
+    }
+    i__2 = nh;
+    for (ih = 1; ih <= i__2; ++ih) {
+/* L30: */
+       hq[ih] = zero;
+    }
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       pq[k] = zero;
+       i__1 = nptm;
+       for (j = 1; j <= i__1; ++j) {
+/* L40: */
+           zmat[k + j * zmat_dim1] = zero;
+       }
+    }
+
+/* Begin the initialization procedure. NF becomes one more than the number */
+/* of function values so far. The coordinates of the displacement of the */
+/* next initial interpolation point from XBASE are set in XPT(NF,.). */
+
+    rhosq = *rhobeg * *rhobeg;
+    recip = one / rhosq;
+    reciq = sqrt(half) / rhosq;
+    nf = 0;
+L50:
+    nfm = nf;
+    nfmm = nf - *n;
+    ++nf;
+    if (nfm <= *n << 1) {
+       if (nfm >= 1 && nfm <= *n) {
+           xpt[nf + nfm * xpt_dim1] = *rhobeg;
+       } else if (nfm > *n) {
+           xpt[nf + nfmm * xpt_dim1] = -(*rhobeg);
+       }
+    } else {
+       itemp = (nfmm - 1) / *n;
+       jpt = nfm - itemp * *n - *n;
+       ipt = jpt + itemp;
+       if (ipt > *n) {
+           itemp = jpt;
+           jpt = ipt - *n;
+           ipt = itemp;
+       }
+       xipt = *rhobeg;
+       if (fval[ipt + np] < fval[ipt + 1]) {
+           xipt = -xipt;
+       }
+       xjpt = *rhobeg;
+       if (fval[jpt + np] < fval[jpt + 1]) {
+           xjpt = -xjpt;
+       }
+       xpt[nf + ipt * xpt_dim1] = xipt;
+       xpt[nf + jpt * xpt_dim1] = xjpt;
+    }
+
+/* Calculate the next value of F, label 70 being reached immediately */
+/* after this calculation. The least function value so far and its index */
+/* are required. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* L60: */
+       x[j] = xpt[nf + j * xpt_dim1] + xbase[j];
+    }
+    if (lb && ub) { /* SGJ, 2008: make sure we are within bounds */
+        for (j = 1; j <= i__1; ++j) {
+             if (x[j] < lb[j-1]) x[j] = lb[j-1];
+             else if (x[j] > ub[j-1]) x[j] = ub[j-1];
+        }
+    }
+    goto L310;
+L70:
+    fval[nf] = f;
+    if (nf == 1) {
+       fbeg = f;
+       fopt = f;
+       kopt = 1;
+    } else if (f < fopt) {
+       fopt = f;
+       kopt = nf;
+    }
+
+/* Set the nonzero initial elements of BMAT and the quadratic model in */
+/* the cases when NF is at most 2*N+1. */
+
+    if (nfm <= *n << 1) {
+       if (nfm >= 1 && nfm <= *n) {
+           gq[nfm] = (f - fbeg) / *rhobeg;
+           if (*npt < nf + *n) {
+               bmat[nfm * bmat_dim1 + 1] = -one / *rhobeg;
+               bmat[nf + nfm * bmat_dim1] = one / *rhobeg;
+               bmat[*npt + nfm + nfm * bmat_dim1] = -half * rhosq;
+           }
+       } else if (nfm > *n) {
+           bmat[nf - *n + nfmm * bmat_dim1] = half / *rhobeg;
+           bmat[nf + nfmm * bmat_dim1] = -half / *rhobeg;
+           zmat[nfmm * zmat_dim1 + 1] = -reciq - reciq;
+           zmat[nf - *n + nfmm * zmat_dim1] = reciq;
+           zmat[nf + nfmm * zmat_dim1] = reciq;
+           ih = nfmm * (nfmm + 1) / 2;
+           temp = (fbeg - f) / *rhobeg;
+           hq[ih] = (gq[nfmm] - temp) / *rhobeg;
+           gq[nfmm] = half * (gq[nfmm] + temp);
+       }
+
+/* Set the off-diagonal second derivatives of the Lagrange functions and */
+/* the initial quadratic model. */
+
+    } else {
+       ih = ipt * (ipt - 1) / 2 + jpt;
+       if (xipt < zero) {
+           ipt += *n;
+       }
+       if (xjpt < zero) {
+           jpt += *n;
+       }
+       zmat[nfmm * zmat_dim1 + 1] = recip;
+       zmat[nf + nfmm * zmat_dim1] = recip;
+       zmat[ipt + 1 + nfmm * zmat_dim1] = -recip;
+       zmat[jpt + 1 + nfmm * zmat_dim1] = -recip;
+       hq[ih] = (fbeg - fval[ipt + 1] - fval[jpt + 1] + f) / (xipt * xjpt);
+    }
+    if (nf < *npt) {
+       goto L50;
+    }
+
+/* Begin the iterative procedure, because the initial model is complete. */
+
+    rho = *rhobeg;
+    delta = rho;
+    idz = 1;
+    diffa = zero;
+    diffb = zero;
+    itest = 0;
+    xoptsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       xopt[i__] = xpt[kopt + i__ * xpt_dim1];
+/* L80: */
+/* Computing 2nd power */
+       d__1 = xopt[i__];
+       xoptsq += d__1 * d__1;
+    }
+L90:
+    nfsav = nf;
+
+/* Generate the next trust region step and test its length. Set KNEW */
+/* to -1 if the purpose of the next F will be to improve the model. */
+
+L100:
+    knew = 0;
+    rc2 = trsapp_(n, npt, &xopt[1], &xpt[xpt_offset], &gq[1], &hq[1], &pq[1], &
+           delta, &d__[1], &w[1], &w[np], &w[np + *n], &w[np + (*n << 1)], &
+           crvmin, &xbase[1], lb, ub);
+    if (rc2 < 0) { rc = rc2; goto L530; }
+    dsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L110: */
+/* Computing 2nd power */
+       d__1 = d__[i__];
+       dsq += d__1 * d__1;
+    }
+/* Computing MIN */
+    d__1 = delta, d__2 = sqrt(dsq);
+    dnorm = MIN2(d__1,d__2);
+    if (dnorm < half * rho) {
+       knew = -1;
+       delta = tenth * delta;
+       ratio = -1.;
+       if (delta <= rho * 1.5) {
+           delta = rho;
+       }
+       if (nf <= nfsav + 2) {
+           goto L460;
+       }
+       temp = crvmin * .125 * rho * rho;
+/* Computing MAX */
+       d__1 = MAX2(diffa,diffb);
+       if (temp <= MAX2(d__1,diffc)) {
+           goto L460;
+       }
+       goto L490;
+    }
+
+/* Shift XBASE if XOPT may be too far from XBASE. First make the changes */
+/* to BMAT that do not depend on ZMAT. */
+
+L120:
+    if (dsq <= xoptsq * .001) {
+       tempq = xoptsq * .25;
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+           sum = zero;
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+/* L130: */
+               sum += xpt[k + i__ * xpt_dim1] * xopt[i__];
+           }
+           temp = pq[k] * sum;
+           sum -= half * xoptsq;
+           w[*npt + k] = sum;
+           i__2 = *n;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               gq[i__] += temp * xpt[k + i__ * xpt_dim1];
+               xpt[k + i__ * xpt_dim1] -= half * xopt[i__];
+               vlag[i__] = bmat[k + i__ * bmat_dim1];
+               w[i__] = sum * xpt[k + i__ * xpt_dim1] + tempq * xopt[i__];
+               ip = *npt + i__;
+               i__3 = i__;
+               for (j = 1; j <= i__3; ++j) {
+/* L140: */
+                   bmat[ip + j * bmat_dim1] = bmat[ip + j * bmat_dim1] + 
+                           vlag[i__] * w[j] + w[i__] * vlag[j];
+               }
+           }
+       }
+
+/* Then the revisions of BMAT that depend on ZMAT are calculated. */
+
+       i__3 = nptm;
+       for (k = 1; k <= i__3; ++k) {
+           sumz = zero;
+           i__2 = *npt;
+           for (i__ = 1; i__ <= i__2; ++i__) {
+               sumz += zmat[i__ + k * zmat_dim1];
+/* L150: */
+               w[i__] = w[*npt + i__] * zmat[i__ + k * zmat_dim1];
+           }
+           i__2 = *n;
+           for (j = 1; j <= i__2; ++j) {
+               sum = tempq * sumz * xopt[j];
+               i__1 = *npt;
+               for (i__ = 1; i__ <= i__1; ++i__) {
+/* L160: */
+                   sum += w[i__] * xpt[i__ + j * xpt_dim1];
+               }
+               vlag[j] = sum;
+               if (k < idz) {
+                   sum = -sum;
+               }
+               i__1 = *npt;
+               for (i__ = 1; i__ <= i__1; ++i__) {
+/* L170: */
+                   bmat[i__ + j * bmat_dim1] += sum * zmat[i__ + k * 
+                           zmat_dim1];
+               }
+           }
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ip = i__ + *npt;
+               temp = vlag[i__];
+               if (k < idz) {
+                   temp = -temp;
+               }
+               i__2 = i__;
+               for (j = 1; j <= i__2; ++j) {
+/* L180: */
+                   bmat[ip + j * bmat_dim1] += temp * vlag[j];
+               }
+           }
+       }
+
+/* The following instructions complete the shift of XBASE, including */
+/* the changes to the parameters of the quadratic model. */
+
+       ih = 0;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           w[j] = zero;
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+               w[j] += pq[k] * xpt[k + j * xpt_dim1];
+/* L190: */
+               xpt[k + j * xpt_dim1] -= half * xopt[j];
+           }
+           i__1 = j;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               ++ih;
+               if (i__ < j) {
+                   gq[j] += hq[ih] * xopt[i__];
+               }
+               gq[i__] += hq[ih] * xopt[j];
+               hq[ih] = hq[ih] + w[i__] * xopt[j] + xopt[i__] * w[j];
+/* L200: */
+               bmat[*npt + i__ + j * bmat_dim1] = bmat[*npt + j + i__ * 
+                       bmat_dim1];
+           }
+       }
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           xbase[j] += xopt[j];
+/* L210: */
+           xopt[j] = zero;
+       }
+       xoptsq = zero;
+    }
+
+/* Pick the model step if KNEW is positive. A different choice of D */
+/* may be made later, if the choice of D by BIGLAG causes substantial */
+/* cancellation in DENOM. */
+
+    if (knew > 0) {
+       rc2 = 
+        biglag_(n, npt, &xopt[1], &xpt[xpt_offset], &bmat[bmat_offset], &zmat[
+               zmat_offset], &idz, ndim, &knew, &dstep, &d__[1], &alpha, &
+               vlag[1], &vlag[*npt + 1], &w[1], &w[np], &w[np + *n], 
+               &xbase[1], lb, ub);
+       if (rc2 < 0) { rc = rc2; goto L530; }
+    }
+
+/* Calculate VLAG and BETA for the current choice of D. The first NPT */
+/* components of W_check will be held in W. */
+
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       suma = zero;
+       sumb = zero;
+       sum = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+           suma += xpt[k + j * xpt_dim1] * d__[j];
+           sumb += xpt[k + j * xpt_dim1] * xopt[j];
+/* L220: */
+           sum += bmat[k + j * bmat_dim1] * d__[j];
+       }
+       w[k] = suma * (half * suma + sumb);
+/* L230: */
+       vlag[k] = sum;
+    }
+    beta = zero;
+    i__1 = nptm;
+    for (k = 1; k <= i__1; ++k) {
+       sum = zero;
+       i__2 = *npt;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L240: */
+           sum += zmat[i__ + k * zmat_dim1] * w[i__];
+       }
+       if (k < idz) {
+           beta += sum * sum;
+           sum = -sum;
+       } else {
+           beta -= sum * sum;
+       }
+       i__2 = *npt;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L250: */
+           vlag[i__] += sum * zmat[i__ + k * zmat_dim1];
+       }
+    }
+    bsum = zero;
+    dx = zero;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       sum = zero;
+       i__1 = *npt;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L260: */
+           sum += w[i__] * bmat[i__ + j * bmat_dim1];
+       }
+       bsum += sum * d__[j];
+       jp = *npt + j;
+       i__1 = *n;
+       for (k = 1; k <= i__1; ++k) {
+/* L270: */
+           sum += bmat[jp + k * bmat_dim1] * d__[k];
+       }
+       vlag[jp] = sum;
+       bsum += sum * d__[j];
+/* L280: */
+       dx += d__[j] * xopt[j];
+    }
+    beta = dx * dx + dsq * (xoptsq + dx + dx + half * dsq) + beta - bsum;
+    vlag[kopt] += one;
+
+/* If KNEW is positive and if the cancellation in DENOM is unacceptable, */
+/* then BIGDEN calculates an alternative model step, XNEW being used for */
+/* working space. */
+
+    if (knew > 0) {
+/* Computing 2nd power */
+       d__1 = vlag[knew];
+       if (d__1 == 0) { rc = NLOPT_ROUNDOFF_LIMITED; goto L530; }
+       temp = one + alpha * beta / (d__1 * d__1);
+       if (fabs(temp) <= .8) {
+         rc2 = 
+           bigden_(n, npt, &xopt[1], &xpt[xpt_offset], &bmat[bmat_offset], &
+                   zmat[zmat_offset], &idz, ndim, &kopt, &knew, &d__[1], &w[
+                   1], &vlag[1], &beta, &xnew[1], &w[*ndim + 1], &w[*ndim * 
+                   6 + 1], &xbase[1], lb, ub);
+         if (rc2 < 0) { rc = rc2; goto L530; }
+       }
+    }
+
+/* Calculate the next value of the objective function. */
+
+L290:
+    i__2 = *n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       xnew[i__] = xopt[i__] + d__[i__];
+/* L300: */
+       x[i__] = xbase[i__] + xnew[i__];
+    }
+    if (lb && ub) { /* SGJ, 2008: make sure we are within bounds,
+                      since roundoff errors can push us slightly outside */
+        for (j = 1; j <= i__1; ++j) {
+             if (x[j] < lb[j-1]) x[j] = lb[j-1];
+             else if (x[j] > ub[j-1]) x[j] = ub[j-1];
+        }
+    }
+    ++nf;
+L310:
+    if (nlopt_stop_forced(stop)) rc = NLOPT_FORCED_STOP;
+    else if (stop->nevals > 0) {
+        if (nlopt_stop_evals(stop)) rc = NLOPT_MAXEVAL_REACHED;
+        else if (nlopt_stop_time(stop)) rc = NLOPT_MAXTIME_REACHED;
+    }
+    if (rc != NLOPT_SUCCESS) goto L530;
+
+    stop->nevals++;
+    f = calfun(*n, &x[1], calfun_data);
+    if (f < stop->minf_max) {
+       rc = NLOPT_MINF_MAX_REACHED;
+       goto L530;
+    }
+    
+    if (nf <= *npt) {
+       goto L70;
+    }
+    if (knew == -1) {
+       goto L530;
+    }
+
+/* Use the quadratic model to predict the change in F due to the step D, */
+/* and set DIFF to the error of this prediction. */
+
+    vquad = zero;
+    ih = 0;
+    i__2 = *n;
+    for (j = 1; j <= i__2; ++j) {
+       vquad += d__[j] * gq[j];
+       i__1 = j;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           ++ih;
+           temp = d__[i__] * xnew[j] + d__[j] * xopt[i__];
+           if (i__ == j) {
+               temp = half * temp;
+           }
+/* L340: */
+           vquad += temp * hq[ih];
+       }
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+/* L350: */
+       vquad += pq[k] * w[k];
+    }
+    diff = f - fopt - vquad;
+    diffc = diffb;
+    diffb = diffa;
+    diffa = fabs(diff);
+    if (dnorm > rho) {
+       nfsav = nf;
+    }
+
+/* Update FOPT and XOPT if the new F is the least value of the objective */
+/* function so far. The branch when KNEW is positive occurs if D is not */
+/* a trust region step. */
+
+    fsave = fopt;
+    if (f < fopt) {
+       fopt = f;
+       xoptsq = zero;
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           xopt[i__] = xnew[i__];
+/* L360: */
+/* Computing 2nd power */
+           d__1 = xopt[i__];
+           xoptsq += d__1 * d__1;
+       }
+       if (nlopt_stop_ftol(stop, fopt, fsave)) {
+            rc = NLOPT_FTOL_REACHED;
+            goto L530;
+       }
+
+    }
+    ksave = knew;
+    if (knew > 0) {
+       goto L410;
+    }
+
+/* Pick the next value of DELTA after a trust region step. */
+
+    if (vquad >= zero) {
+       goto L530;
+    }
+    ratio = (f - fsave) / vquad;
+    if (ratio <= tenth) {
+       delta = half * dnorm;
+    } else if (ratio <= .7) {
+/* Computing MAX */
+       d__1 = half * delta;
+       delta = MAX2(d__1,dnorm);
+    } else {
+/* Computing MAX */
+       d__1 = half * delta, d__2 = dnorm + dnorm;
+       delta = MAX2(d__1,d__2);
+    }
+    if (delta <= rho * 1.5) {
+       delta = rho;
+    }
+
+/* Set KNEW to the index of the next interpolation point to be deleted. */
+
+/* Computing MAX */
+    d__2 = tenth * delta;
+/* Computing 2nd power */
+    d__1 = MAX2(d__2,rho);
+    rhosq = d__1 * d__1;
+    ktemp = 0;
+    detrat = zero;
+    if (f >= fsave) {
+       ktemp = kopt;
+       detrat = one;
+    }
+    i__1 = *npt;
+    for (k = 1; k <= i__1; ++k) {
+       hdiag = zero;
+       i__2 = nptm;
+       for (j = 1; j <= i__2; ++j) {
+           temp = one;
+           if (j < idz) {
+               temp = -one;
+           }
+/* L380: */
+/* Computing 2nd power */
+           d__1 = zmat[k + j * zmat_dim1];
+           hdiag += temp * (d__1 * d__1);
+       }
+/* Computing 2nd power */
+       d__2 = vlag[k];
+       temp = (d__1 = beta * hdiag + d__2 * d__2, fabs(d__1));
+       distsq = zero;
+       i__2 = *n;
+       for (j = 1; j <= i__2; ++j) {
+/* L390: */
+/* Computing 2nd power */
+           d__1 = xpt[k + j * xpt_dim1] - xopt[j];
+           distsq += d__1 * d__1;
+       }
+       if (distsq > rhosq) {
+/* Computing 3rd power */
+           d__1 = distsq / rhosq;
+           temp *= d__1 * (d__1 * d__1);
+       }
+       if (temp > detrat && k != ktemp) {
+           detrat = temp;
+           knew = k;
+       }
+/* L400: */
+    }
+    if (knew == 0) {
+       goto L460;
+    }
+
+/* Update BMAT, ZMAT and IDZ, so that the KNEW-th interpolation point */
+/* can be moved. Begin the updating of the quadratic model, starting */
+/* with the explicit second derivative term. */
+
+L410:
+    update_(n, npt, &bmat[bmat_offset], &zmat[zmat_offset], &idz, ndim, &vlag[
+           1], &beta, &knew, &w[1]);
+    fval[knew] = f;
+    ih = 0;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       temp = pq[knew] * xpt[knew + i__ * xpt_dim1];
+       i__2 = i__;
+       for (j = 1; j <= i__2; ++j) {
+           ++ih;
+/* L420: */
+           hq[ih] += temp * xpt[knew + j * xpt_dim1];
+       }
+    }
+    pq[knew] = zero;
+
+/* Update the other second derivative parameters, and then the gradient */
+/* vector of the model. Also include the new interpolation point. */
+
+    i__2 = nptm;
+    for (j = 1; j <= i__2; ++j) {
+       temp = diff * zmat[knew + j * zmat_dim1];
+       if (j < idz) {
+           temp = -temp;
+       }
+       i__1 = *npt;
+       for (k = 1; k <= i__1; ++k) {
+/* L440: */
+           pq[k] += temp * zmat[k + j * zmat_dim1];
+       }
+    }
+    gqsq = zero;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       gq[i__] += diff * bmat[knew + i__ * bmat_dim1];
+/* Computing 2nd power */
+       d__1 = gq[i__];
+       gqsq += d__1 * d__1;
+/* L450: */
+       xpt[knew + i__ * xpt_dim1] = xnew[i__];
+    }
+
+/* If a trust region step makes a small change to the objective function, */
+/* then calculate the gradient of the least Frobenius norm interpolant at */
+/* XBASE, and store it in W, using VLAG for a vector of right hand sides. */
+
+    if (ksave == 0 && delta == rho) {
+       if (fabs(ratio) > .01) {
+           itest = 0;
+       } else {
+           i__1 = *npt;
+           for (k = 1; k <= i__1; ++k) {
+/* L700: */
+               vlag[k] = fval[k] - fval[kopt];
+           }
+           gisq = zero;
+           i__1 = *n;
+           for (i__ = 1; i__ <= i__1; ++i__) {
+               sum = zero;
+               i__2 = *npt;
+               for (k = 1; k <= i__2; ++k) {
+/* L710: */
+                   sum += bmat[k + i__ * bmat_dim1] * vlag[k];
+               }
+               gisq += sum * sum;
+/* L720: */
+               w[i__] = sum;
+           }
+
+/* Test whether to replace the new quadratic model by the least Frobenius */
+/* norm interpolant, making the replacement if the test is satisfied. */
+
+           ++itest;
+           if (gqsq < gisq * 100.) {
+               itest = 0;
+           }
+           if (itest >= 3) {
+               i__1 = *n;
+               for (i__ = 1; i__ <= i__1; ++i__) {
+/* L730: */
+                   gq[i__] = w[i__];
+               }
+               i__1 = nh;
+               for (ih = 1; ih <= i__1; ++ih) {
+/* L740: */
+                   hq[ih] = zero;
+               }
+               i__1 = nptm;
+               for (j = 1; j <= i__1; ++j) {
+                   w[j] = zero;
+                   i__2 = *npt;
+                   for (k = 1; k <= i__2; ++k) {
+/* L750: */
+                       w[j] += vlag[k] * zmat[k + j * zmat_dim1];
+                   }
+/* L760: */
+                   if (j < idz) {
+                       w[j] = -w[j];
+                   }
+               }
+               i__1 = *npt;
+               for (k = 1; k <= i__1; ++k) {
+                   pq[k] = zero;
+                   i__2 = nptm;
+                   for (j = 1; j <= i__2; ++j) {
+/* L770: */
+                       pq[k] += zmat[k + j * zmat_dim1] * w[j];
+                   }
+               }
+               itest = 0;
+           }
+       }
+    }
+    if (f < fsave) {
+       kopt = knew;
+    }
+
+/* If a trust region step has provided a sufficient decrease in F, then */
+/* branch for another trust region calculation. The case KSAVE>0 occurs */
+/* when the new function value was calculated by a model step. */
+
+    if (f <= fsave + tenth * vquad) {
+       goto L100;
+    }
+    if (ksave > 0) {
+       goto L100;
+    }
+
+/* Alternatively, find out if the interpolation points are close enough */
+/* to the best point so far. */
+
+    knew = 0;
+L460:
+    distsq = delta * 4. * delta;
+    i__2 = *npt;
+    for (k = 1; k <= i__2; ++k) {
+       sum = zero;
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+/* L470: */
+/* Computing 2nd power */
+           d__1 = xpt[k + j * xpt_dim1] - xopt[j];
+           sum += d__1 * d__1;
+       }
+       if (sum > distsq) {
+           knew = k;
+           distsq = sum;
+       }
+/* L480: */
+    }
+
+/* If KNEW is positive, then set DSTEP, and branch back for the next */
+/* iteration, which will generate a "model step". */
+
+    if (knew > 0) {
+/* Computing MAX */
+/* Computing MIN */
+       d__2 = tenth * sqrt(distsq), d__3 = half * delta;
+       d__1 = MIN2(d__2,d__3);
+       dstep = MAX2(d__1,rho);
+       dsq = dstep * dstep;
+       goto L120;
+    }
+    if (ratio > zero) {
+       goto L100;
+    }
+    if (MAX2(delta,dnorm) > rho) {
+       goto L100;
+    }
+
+/* The calculations with the current value of RHO are complete. Pick the */
+/* next values of RHO and DELTA. */
+
+L490:
+    if (rho > rhoend) {
+       delta = half * rho;
+       ratio = rho / rhoend;
+       if (ratio <= 16.) {
+           rho = rhoend;
+       } else if (ratio <= 250.) {
+           rho = sqrt(ratio) * rhoend;
+       } else {
+           rho = tenth * rho;
+       }
+       delta = MAX2(delta,rho);
+       goto L90;
+    }
+
+/* Return from the calculation, after another Newton-Raphson step, if */
+/* it is too short to have been tried before. */
+
+    if (knew == -1) {
+       goto L290;
+    }
+    rc = NLOPT_XTOL_REACHED;
+L530:
+    if (fopt <= f) {
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L540: */
+           x[i__] = xbase[i__] + xopt[i__];
+       }
+       f = fopt;
+    }
+    *minf = f;
+    return rc;
+} /* newuob_ */
+
+/*************************************************************************/
+/* newuoa.f */
+
+nlopt_result newuoa(int n, int npt, double *x,
+                   const double *lb, const double *ub,
+                   double rhobeg, nlopt_stopping *stop, double *minf,
+                   newuoa_func calfun, void *calfun_data)
+{
+    /* Local variables */
+    int id, np, iw, igq, ihq, ixb, ifv, ipq, ivl, ixn, ixo, ixp, ndim, 
+           nptm, ibmat, izmat;
+    nlopt_result ret;
+    double *w;
+
+/* This subroutine seeks the least value of a function of many variables, */
+/* by a trust region method that forms quadratic models by interpolation. */
+/* There can be some freedom in the interpolation conditions, which is */
+/* taken up by minimizing the Frobenius norm of the change to the second */
+/* derivative of the quadratic model, beginning with a zero matrix. The */
+/* arguments of the subroutine are as follows. */
+
+/* N must be set to the number of variables and must be at least two. */
+/* NPT is the number of interpolation conditions. Its value must be in the */
+/*   interval [N+2,(N+1)(N+2)/2]. */
+/* Initial values of the variables must be set in X(1),X(2),...,X(N). They */
+/*   will be changed to the values that give the least calculated F. */
+/* RHOBEG and RHOEND must be set to the initial and final values of a trust */
+/*   region radius, so both must be positive with RHOEND<=RHOBEG. Typically */
+/*   RHOBEG should be about one tenth of the greatest expected change to a */
+/*   variable, and RHOEND should indicate the accuracy that is required in */
+/*   the final values of the variables. */
+/* The value of IPRINT should be set to 0, 1, 2 or 3, which controls the */
+/*   amount of printing. Specifically, there is no output if IPRINT=0 and */
+/*   there is output only at the return if IPRINT=1. Otherwise, each new */
+/*   value of RHO is printed, with the best vector of variables so far and */
+/*   the corresponding value of the objective function. Further, each new */
+/*   value of F with its variables are output if IPRINT=3. */
+/* MAXFUN must be set to an upper bound on the number of calls of CALFUN. */
+/* The array W will be used for working space. Its length must be at least */
+/* (NPT+13)*(NPT+N)+3*N*(N+3)/2. */
+
+/* SUBROUTINE CALFUN (N,X,F) must be provided by the user. It must set F to */
+/* the value of the objective function for the variables X(1),X(2),...,X(N). */
+
+/* Partition the working space array, so that different parts of it can be */
+/* treated separately by the subroutine that performs the main calculation. */
+
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    np = n + 1;
+    nptm = npt - np;
+    if (n < 2 || npt < n + 2 || npt > (n + 2) * np / 2) {
+        return NLOPT_INVALID_ARGS;
+    }
+    ndim = npt + n;
+    ixb = 1;
+    ixo = ixb + n;
+    ixn = ixo + n;
+    ixp = ixn + n;
+    ifv = ixp + n * npt;
+    igq = ifv + npt;
+    ihq = igq + n;
+    ipq = ihq + n * np / 2;
+    ibmat = ipq + npt;
+    izmat = ibmat + ndim * n;
+    id = izmat + npt * nptm;
+    ivl = id + n;
+    iw = ivl + ndim;
+
+    w = (double *) malloc(sizeof(double) * ((npt+13)*(npt+n) + 3*(n*(n+3))/2));
+    if (!w) return NLOPT_OUT_OF_MEMORY;
+    --w;
+
+/* The above settings provide a partition of W for subroutine NEWUOB. */
+/* The partition requires the first NPT*(NPT+N)+5*N*(N+3)/2 elements of */
+/* W plus the space that is needed by the last array of NEWUOB. */
+
+    ret = newuob_(&n, &npt, &x[1], &rhobeg, 
+                 lb, ub, stop, minf, calfun, calfun_data, 
+                 &w[ixb], &w[ixo], &w[ixn], &w[ixp], &w[ifv],
+                 &w[igq], &w[ihq], &w[ipq], &w[ibmat], &w[izmat],
+                 &ndim, &w[id], &w[ivl], &w[iw]);
+
+    ++w;
+    free(w);
+    return ret;
+} /* newuoa_ */
+
+/*************************************************************************/
+/*************************************************************************/
diff --git a/newuoa/newuoa.h b/newuoa/newuoa.h
new file mode 100644 (file)
index 0000000..b270069
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef NEWUOA_H
+#define NEWUOA_H 1
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+
+typedef double (*newuoa_func)(int n, const double *x, void *func_data);
+
+extern nlopt_result newuoa(int n, int npt, double *x, 
+                          const double *lb, const double *ub,
+                          double rhobeg, nlopt_stopping *stop, double *minf,
+                          newuoa_func calfun, void *calfun_data);
+
+#endif /* NEWUOA_H */
diff --git a/nlopt.pc.in b/nlopt.pc.in
new file mode 100644 (file)
index 0000000..a5cecf8
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: NLopt
+Description: nonlinear optimization libary
+Version: @VERSION@
+Libs: -L${libdir} -lnlopt -lm
+Cflags: -I${includedir}
diff --git a/octave/Makefile.am b/octave/Makefile.am
new file mode 100644 (file)
index 0000000..695491c
--- /dev/null
@@ -0,0 +1,43 @@
+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 NLOPT_LN_AUGLAG.m NLOPT_LD_AUGLAG.m NLOPT_LN_AUGLAG_EQ.m NLOPT_LD_AUGLAG_EQ.m NLOPT_LN_BOBYQA.m NLOPT_GN_ISRES.m NLOPT_AUGLAG.m NLOPT_AUGLAG_EQ.m NLOPT_G_MLSL.m NLOPT_G_MLSL_LDS.m NLOPT_LD_SLSQP.m NLOPT_LD_CCSAQ.m NLOPT_GN_ESCH.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)
+if WITH_OCTAVE
+oct_DATA = nlopt_optimize.oct
+m_DATA = $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m
+endif
+
+nlopt_optimize.oct: nlopt_optimize-oct.cc nlopt_optimize_usage.h $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la
+       $(MKOCTFILE) -o $@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-oct.cc $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@
+
+BUILT_SOURCES = nlopt_optimize_usage.h
+MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+
+nlopt_optimize_usage.h: $(srcdir)/nlopt_optimize.m
+       echo "#define NLOPT_OPTIMIZE_USAGE \\" > $@
+       sed 's/\"/\\"/g' $(srcdir)/nlopt_optimize.m | sed 's,^% ,\",;s,^%,\",;s,$$,\\n\" \\,' >> $@
+       echo "" >> $@
+
+#######################################################################
+mexdir = $(MEX_INSTALL_DIR)
+if WITH_MATLAB
+mex_DATA = nlopt_optimize.$(MEXSUFF) $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m
+endif
+
+nlopt_optimize.$(MEXSUFF): nlopt_optimize-mex.c $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la
+       $(MEX) -output nlopt_optimize -O $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-mex.c $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@
+
+#######################################################################
+
+EXTRA_DIST = nlopt_optimize-oct.cc nlopt_optimize-mex.c $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m nlopt_optimize_usage.h
+
+CLEANFILES = nlopt_optimize.oct nlopt_optimize.h nlopt_optimize.$(MEXSUFF) nlopt_optimize-oct.o
diff --git a/octave/Makefile.in b/octave/Makefile.in
new file mode 100644 (file)
index 0000000..c72d59c
--- /dev/null
@@ -0,0 +1,737 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+noinst_PROGRAMS = dummy$(EXEEXT)
+subdir = octave
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_dummy_OBJECTS = dummy.$(OBJEXT)
+dummy_OBJECTS = $(am_dummy_OBJECTS)
+dummy_LDADD = $(LDADD)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(dummy_SOURCES)
+DIST_SOURCES = $(dummy_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(mdir)" "$(DESTDIR)$(mexdir)" \
+       "$(DESTDIR)$(octdir)"
+DATA = $(m_DATA) $(mex_DATA) $(oct_DATA)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+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 NLOPT_LN_AUGLAG.m NLOPT_LD_AUGLAG.m NLOPT_LN_AUGLAG_EQ.m NLOPT_LD_AUGLAG_EQ.m NLOPT_LN_BOBYQA.m NLOPT_GN_ISRES.m NLOPT_AUGLAG.m NLOPT_AUGLAG_EQ.m NLOPT_G_MLSL.m NLOPT_G_MLSL_LDS.m NLOPT_LD_SLSQP.m NLOPT_LD_CCSAQ.m NLOPT_GN_ESCH.m 
+dummy_SOURCES = dummy.c
+
+#######################################################################
+octdir = $(OCT_INSTALL_DIR)
+mdir = $(M_INSTALL_DIR)
+@WITH_OCTAVE_TRUE@oct_DATA = nlopt_optimize.oct
+@WITH_OCTAVE_TRUE@m_DATA = $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m
+BUILT_SOURCES = nlopt_optimize_usage.h
+MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+
+#######################################################################
+mexdir = $(MEX_INSTALL_DIR)
+@WITH_MATLAB_TRUE@mex_DATA = nlopt_optimize.$(MEXSUFF) $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m
+
+#######################################################################
+EXTRA_DIST = nlopt_optimize-oct.cc nlopt_optimize-mex.c $(MFILES) nlopt_minimize.m nlopt_minimize_constrained.m nlopt_optimize.m nlopt_optimize_usage.h
+CLEANFILES = nlopt_optimize.oct nlopt_optimize.h nlopt_optimize.$(MEXSUFF) nlopt_optimize-oct.o
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu octave/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu octave/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+
+dummy$(EXEEXT): $(dummy_OBJECTS) $(dummy_DEPENDENCIES) $(EXTRA_dummy_DEPENDENCIES) 
+       @rm -f dummy$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(dummy_OBJECTS) $(dummy_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-mDATA: $(m_DATA)
+       @$(NORMAL_INSTALL)
+       @list='$(m_DATA)'; test -n "$(mdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(mdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(mdir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(mdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(mdir)" || exit $$?; \
+       done
+
+uninstall-mDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(m_DATA)'; test -n "$(mdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(mdir)'; $(am__uninstall_files_from_dir)
+install-mexDATA: $(mex_DATA)
+       @$(NORMAL_INSTALL)
+       @list='$(mex_DATA)'; test -n "$(mexdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(mexdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(mexdir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(mexdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(mexdir)" || exit $$?; \
+       done
+
+uninstall-mexDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(mex_DATA)'; test -n "$(mexdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(mexdir)'; $(am__uninstall_files_from_dir)
+install-octDATA: $(oct_DATA)
+       @$(NORMAL_INSTALL)
+       @list='$(oct_DATA)'; test -n "$(octdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(octdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(octdir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(octdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(octdir)" || exit $$?; \
+       done
+
+uninstall-octDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(oct_DATA)'; test -n "$(octdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(octdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(DATA)
+installdirs:
+       for dir in "$(DESTDIR)$(mdir)" "$(DESTDIR)$(mexdir)" "$(DESTDIR)$(octdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-mDATA install-mexDATA install-octDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-mDATA uninstall-mexDATA uninstall-octDATA
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-mDATA install-man install-mexDATA \
+       install-octDATA install-pdf install-pdf-am install-ps \
+       install-ps-am install-strip installcheck installcheck-am \
+       installdirs maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+       uninstall-am uninstall-mDATA uninstall-mexDATA \
+       uninstall-octDATA
+
+
+nlopt_optimize.oct: nlopt_optimize-oct.cc nlopt_optimize_usage.h $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la
+       $(MKOCTFILE) -o $@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-oct.cc $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@
+
+nlopt_optimize_usage.h: $(srcdir)/nlopt_optimize.m
+       echo "#define NLOPT_OPTIMIZE_USAGE \\" > $@
+       sed 's/\"/\\"/g' $(srcdir)/nlopt_optimize.m | sed 's,^% ,\",;s,^%,\",;s,$$,\\n\" \\,' >> $@
+       echo "" >> $@
+
+nlopt_optimize.$(MEXSUFF): nlopt_optimize-mex.c $(top_builddir)/.libs/libnlopt@NLOPT_SUFFIX@.la
+       $(MEX) -output nlopt_optimize -O $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(srcdir)/nlopt_optimize-mex.c $(LDFLAGS) -L$(top_builddir)/.libs -lnlopt@NLOPT_SUFFIX@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/octave/NLOPT_AUGLAG.m b/octave/NLOPT_AUGLAG.m
new file mode 100644 (file)
index 0000000..cd51cb1
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_AUGLAG: Augmented Lagrangian method (needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_AUGLAG
+  val = 36;
diff --git a/octave/NLOPT_AUGLAG_EQ.m b/octave/NLOPT_AUGLAG_EQ.m
new file mode 100644 (file)
index 0000000..2177c65
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_AUGLAG_EQ
+  val = 37;
diff --git a/octave/NLOPT_GD_MLSL.m b/octave/NLOPT_GD_MLSL.m
new file mode 100644 (file)
index 0000000..9cc25ea
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GD_MLSL: Multi-level single-linkage (MLSL), random (global, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GD_MLSL
+  val = 21;
diff --git a/octave/NLOPT_GD_MLSL_LDS.m b/octave/NLOPT_GD_MLSL_LDS.m
new file mode 100644 (file)
index 0000000..73c1ef1
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GD_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GD_MLSL_LDS
+  val = 23;
diff --git a/octave/NLOPT_GD_STOGO.m b/octave/NLOPT_GD_STOGO.m
new file mode 100644 (file)
index 0000000..22ce83c
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GD_STOGO: StoGO (global, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GD_STOGO
+  val = 8;
diff --git a/octave/NLOPT_GD_STOGO_RAND.m b/octave/NLOPT_GD_STOGO_RAND.m
new file mode 100644 (file)
index 0000000..12e8a37
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GD_STOGO_RAND: StoGO with randomized search (global, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GD_STOGO_RAND
+  val = 9;
diff --git a/octave/NLOPT_GN_CRS2_LM.m b/octave/NLOPT_GN_CRS2_LM.m
new file mode 100644 (file)
index 0000000..bde02d1
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_CRS2_LM: Controlled random search (CRS2) with local mutation (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_CRS2_LM
+  val = 19;
diff --git a/octave/NLOPT_GN_DIRECT.m b/octave/NLOPT_GN_DIRECT.m
new file mode 100644 (file)
index 0000000..e6d9b81
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT: DIRECT (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT
+  val = 0;
diff --git a/octave/NLOPT_GN_DIRECT_L.m b/octave/NLOPT_GN_DIRECT_L.m
new file mode 100644 (file)
index 0000000..f2e7c61
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT_L: DIRECT-L (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT_L
+  val = 1;
diff --git a/octave/NLOPT_GN_DIRECT_L_NOSCAL.m b/octave/NLOPT_GN_DIRECT_L_NOSCAL.m
new file mode 100644 (file)
index 0000000..9fd8330
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT_L_NOSCAL: Unscaled DIRECT-L (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT_L_NOSCAL
+  val = 4;
diff --git a/octave/NLOPT_GN_DIRECT_L_RAND.m b/octave/NLOPT_GN_DIRECT_L_RAND.m
new file mode 100644 (file)
index 0000000..2af256e
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT_L_RAND: Randomized DIRECT-L (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT_L_RAND
+  val = 2;
diff --git a/octave/NLOPT_GN_DIRECT_L_RAND_NOSCAL.m b/octave/NLOPT_GN_DIRECT_L_RAND_NOSCAL.m
new file mode 100644 (file)
index 0000000..58bbf60
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT_L_RAND_NOSCAL: Unscaled Randomized DIRECT-L (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT_L_RAND_NOSCAL
+  val = 5;
diff --git a/octave/NLOPT_GN_DIRECT_NOSCAL.m b/octave/NLOPT_GN_DIRECT_NOSCAL.m
new file mode 100644 (file)
index 0000000..285a1b4
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_DIRECT_NOSCAL: Unscaled DIRECT (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_DIRECT_NOSCAL
+  val = 3;
diff --git a/octave/NLOPT_GN_ESCH.m b/octave/NLOPT_GN_ESCH.m
new file mode 100644 (file)
index 0000000..5d8f636
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_ESCH: ESCH evolutionary strategy
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_ESCH
+  val = 42;
diff --git a/octave/NLOPT_GN_ISRES.m b/octave/NLOPT_GN_ISRES.m
new file mode 100644 (file)
index 0000000..9eaaa07
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_ISRES: ISRES evolutionary constrained optimization (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_ISRES
+  val = 35;
diff --git a/octave/NLOPT_GN_MLSL.m b/octave/NLOPT_GN_MLSL.m
new file mode 100644 (file)
index 0000000..4642de0
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_MLSL: Multi-level single-linkage (MLSL), random (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_MLSL
+  val = 20;
diff --git a/octave/NLOPT_GN_MLSL_LDS.m b/octave/NLOPT_GN_MLSL_LDS.m
new file mode 100644 (file)
index 0000000..bdde5ba
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_MLSL_LDS
+  val = 22;
diff --git a/octave/NLOPT_GN_ORIG_DIRECT.m b/octave/NLOPT_GN_ORIG_DIRECT.m
new file mode 100644 (file)
index 0000000..59e7c2b
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_ORIG_DIRECT: Original DIRECT version (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_ORIG_DIRECT
+  val = 6;
diff --git a/octave/NLOPT_GN_ORIG_DIRECT_L.m b/octave/NLOPT_GN_ORIG_DIRECT_L.m
new file mode 100644 (file)
index 0000000..90e3c75
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_GN_ORIG_DIRECT_L: Original DIRECT-L version (global, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_GN_ORIG_DIRECT_L
+  val = 7;
diff --git a/octave/NLOPT_G_MLSL.m b/octave/NLOPT_G_MLSL.m
new file mode 100644 (file)
index 0000000..f0c0abc
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_G_MLSL: Multi-level single-linkage (MLSL), random (global, needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_G_MLSL
+  val = 38;
diff --git a/octave/NLOPT_G_MLSL_LDS.m b/octave/NLOPT_G_MLSL_LDS.m
new file mode 100644 (file)
index 0000000..254023e
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_G_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_G_MLSL_LDS
+  val = 39;
diff --git a/octave/NLOPT_LD_AUGLAG.m b/octave/NLOPT_LD_AUGLAG.m
new file mode 100644 (file)
index 0000000..704520b
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_AUGLAG: Augmented Lagrangian method (local, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_AUGLAG
+  val = 31;
diff --git a/octave/NLOPT_LD_AUGLAG_EQ.m b/octave/NLOPT_LD_AUGLAG_EQ.m
new file mode 100644 (file)
index 0000000..e327ddb
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (local, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_AUGLAG_EQ
+  val = 33;
diff --git a/octave/NLOPT_LD_CCSAQ.m b/octave/NLOPT_LD_CCSAQ.m
new file mode 100644 (file)
index 0000000..f72335c
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_CCSAQ: CCSA (Conservative Convex Separable Approximations) with simple quadratic approximations (local, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_CCSAQ
+  val = 41;
diff --git a/octave/NLOPT_LD_LBFGS.m b/octave/NLOPT_LD_LBFGS.m
new file mode 100644 (file)
index 0000000..5c52378
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_LBFGS: Limited-memory BFGS (L-BFGS) (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_LBFGS
+  val = 11;
diff --git a/octave/NLOPT_LD_LBFGS_NOCEDAL.m b/octave/NLOPT_LD_LBFGS_NOCEDAL.m
new file mode 100644 (file)
index 0000000..f20c00a
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_LBFGS_NOCEDAL: original NON-FREE L-BFGS code by Nocedal et al. (NOT COMPILED)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_LBFGS_NOCEDAL
+  val = 10;
diff --git a/octave/NLOPT_LD_MMA.m b/octave/NLOPT_LD_MMA.m
new file mode 100644 (file)
index 0000000..a7b3ca6
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_MMA: Method of Moving Asymptotes (MMA) (local, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_MMA
+  val = 24;
diff --git a/octave/NLOPT_LD_SLSQP.m b/octave/NLOPT_LD_SLSQP.m
new file mode 100644 (file)
index 0000000..be949c0
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_SLSQP: Sequential Quadratic Programming (SQP) (local, derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_SLSQP
+  val = 40;
diff --git a/octave/NLOPT_LD_TNEWTON.m b/octave/NLOPT_LD_TNEWTON.m
new file mode 100644 (file)
index 0000000..60fb2d7
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_TNEWTON: Truncated Newton (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_TNEWTON
+  val = 15;
diff --git a/octave/NLOPT_LD_TNEWTON_PRECOND.m b/octave/NLOPT_LD_TNEWTON_PRECOND.m
new file mode 100644 (file)
index 0000000..ab42479
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_TNEWTON_PRECOND: Preconditioned truncated Newton (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_TNEWTON_PRECOND
+  val = 17;
diff --git a/octave/NLOPT_LD_TNEWTON_PRECOND_RESTART.m b/octave/NLOPT_LD_TNEWTON_PRECOND_RESTART.m
new file mode 100644 (file)
index 0000000..d1e42f7
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_TNEWTON_PRECOND_RESTART: Preconditioned truncated Newton with restarting (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_TNEWTON_PRECOND_RESTART
+  val = 18;
diff --git a/octave/NLOPT_LD_TNEWTON_RESTART.m b/octave/NLOPT_LD_TNEWTON_RESTART.m
new file mode 100644 (file)
index 0000000..7ef9d75
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_TNEWTON_RESTART: Truncated Newton with restarting (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_TNEWTON_RESTART
+  val = 16;
diff --git a/octave/NLOPT_LD_VAR1.m b/octave/NLOPT_LD_VAR1.m
new file mode 100644 (file)
index 0000000..0385562
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_VAR1: Limited-memory variable-metric, rank 1 (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_VAR1
+  val = 13;
diff --git a/octave/NLOPT_LD_VAR2.m b/octave/NLOPT_LD_VAR2.m
new file mode 100644 (file)
index 0000000..fd9c229
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LD_VAR2: Limited-memory variable-metric, rank 2 (local, derivative-based)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LD_VAR2
+  val = 14;
diff --git a/octave/NLOPT_LN_AUGLAG.m b/octave/NLOPT_LN_AUGLAG.m
new file mode 100644 (file)
index 0000000..b204237
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_AUGLAG: Augmented Lagrangian method (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_AUGLAG
+  val = 30;
diff --git a/octave/NLOPT_LN_AUGLAG_EQ.m b/octave/NLOPT_LN_AUGLAG_EQ.m
new file mode 100644 (file)
index 0000000..5cc7e00
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_AUGLAG_EQ
+  val = 32;
diff --git a/octave/NLOPT_LN_BOBYQA.m b/octave/NLOPT_LN_BOBYQA.m
new file mode 100644 (file)
index 0000000..738946e
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_BOBYQA: BOBYQA bound-constrained optimization via quadratic models (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_BOBYQA
+  val = 34;
diff --git a/octave/NLOPT_LN_COBYLA.m b/octave/NLOPT_LN_COBYLA.m
new file mode 100644 (file)
index 0000000..418f0e6
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_COBYLA: COBYLA (Constrained Optimization BY Linear Approximations) (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_COBYLA
+  val = 25;
diff --git a/octave/NLOPT_LN_NELDERMEAD.m b/octave/NLOPT_LN_NELDERMEAD.m
new file mode 100644 (file)
index 0000000..9297a9c
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_NELDERMEAD: Nelder-Mead simplex algorithm (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_NELDERMEAD
+  val = 28;
diff --git a/octave/NLOPT_LN_NEWUOA.m b/octave/NLOPT_LN_NEWUOA.m
new file mode 100644 (file)
index 0000000..a4b2b9e
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_NEWUOA: NEWUOA unconstrained optimization via quadratic models (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_NEWUOA
+  val = 26;
diff --git a/octave/NLOPT_LN_NEWUOA_BOUND.m b/octave/NLOPT_LN_NEWUOA_BOUND.m
new file mode 100644 (file)
index 0000000..44591f1
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_NEWUOA_BOUND: Bound-constrained optimization via NEWUOA-based quadratic models (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_NEWUOA_BOUND
+  val = 27;
diff --git a/octave/NLOPT_LN_PRAXIS.m b/octave/NLOPT_LN_PRAXIS.m
new file mode 100644 (file)
index 0000000..c768cae
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_PRAXIS: Principal-axis, praxis (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_PRAXIS
+  val = 12;
diff --git a/octave/NLOPT_LN_SBPLX.m b/octave/NLOPT_LN_SBPLX.m
new file mode 100644 (file)
index 0000000..a1f04df
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_LN_SBPLX: Sbplx variant of Nelder-Mead (re-implementation of Rowan's Subplex) (local, no-derivative)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_LN_SBPLX
+  val = 29;
diff --git a/octave/dummy.c b/octave/dummy.c
new file mode 100644 (file)
index 0000000..dc34341
--- /dev/null
@@ -0,0 +1,2 @@
+#include <stdio.h>
+int main(void) { printf("Hello world.\n"); return 0; }
diff --git a/octave/nlopt_minimize.m b/octave/nlopt_minimize.m
new file mode 100644 (file)
index 0000000..ea2b100
--- /dev/null
@@ -0,0 +1,72 @@
+% Usage: [xopt, fmin, retcode] = nlopt_minimize(algorithm, f, f_data, lb, ub,
+%                                               xinit, stop)
+%
+% Minimizes a nonlinear multivariable function f(x, f_data{:}), where
+% x is a row vector, returning the optimal x found (xopt) along with
+% the minimum function value (fmin = f(xopt)) and a return code (retcode).
+% A variety of local and global optimization algorithms can be used,
+% as specified by the algorithm parameter described below.  lb and ub
+% are row vectors giving the upper and lower bounds on x, xinit is
+% a row vector giving the initial guess for x, and stop is a struct
+% containing termination conditions (see below).
+%
+% This function is a front-end for the external routine nlopt_minimize
+% in the free NLopt nonlinear-optimization library, which is a wrapper
+% around a number of free/open-source optimization subroutines.  More
+% details can be found on the NLopt web page (ab-initio.mit.edu/nlopt)
+% and also under 'man nlopt_minimize' on Unix.
+%
+% f should be a handle (@) to a function of the form:
+%
+%    [val, gradient] = f(x, ...)
+%
+% where x is a row vector, val is the function value f(x), and gradient
+% is a row vector giving the gradient of the function with respect to x.
+% The gradient is only used for gradient-based optimization algorithms;
+% some of the algorithms (below) are derivative-free and only require
+% f to return val (its value).  f can take additional arguments (...)
+% which are passed via the argument f_data: f_data is a cell array
+% of the additional arguments to pass to f.  (Recall that cell arrays
+% are specified by curly brackets { ... }.  For example, pass f_data={}
+% for functions that require no additional arguments.)
+%
+% stop describes the termination criteria, and is a struct with a
+% number of optional fields:
+%     stop.ftol_rel = fractional tolerance on function value
+%     stop.ftol_abs = absolute tolerance on function value
+%     stop.xtol_rel = fractional tolerance on x
+%     stop.xtol_abs = row vector of absolute tolerances on x components
+%     stop.fmin_max = stop when f < fmin_max is found
+%     stop.maxeval = maximum number of function evaluations
+%     stop.maxtime = maximum run time in seconds
+%     stop.verbose = > 0 indicates verbose output
+% Minimization stops when any one of these conditions is met; any
+% condition that is omitted from stop will be ignored.  WARNING:
+% not all algorithms interpret the stopping criteria in exactly the
+% same way, and in any case ftol/xtol specify only a crude estimate
+% for the accuracy of the minimum function value/x.
+%
+% The algorithm should be one of the following constants (name and
+% interpretation are the same as for the C function).  Names with
+% _G*_ are global optimization, and names with _L*_ are local
+% optimization.  Names with _*N_ are derivative-free, while names
+% with _*D_ are gradient-based algorithms.  Algorithms:
+%
+% NLOPT_GD_MLSL_LDS, NLOPT_GD_MLSL, NLOPT_GD_STOGO, NLOPT_GD_STOGO_RAND, 
+% NLOPT_GN_CRS2_LM, NLOPT_GN_DIRECT_L, NLOPT_GN_DIRECT_L_NOSCAL, 
+% NLOPT_GN_DIRECT_L_RAND, NLOPT_GN_DIRECT_L_RAND_NOSCAL, NLOPT_GN_DIRECT, 
+% NLOPT_GN_DIRECT_NOSCAL, NLOPT_GN_ISRES, NLOPT_GN_MLSL_LDS, NLOPT_GN_MLSL, 
+% NLOPT_GN_ORIG_DIRECT_L, NLOPT_GN_ORIG_DIRECT, NLOPT_LD_AUGLAG_EQ, 
+% NLOPT_LD_AUGLAG, NLOPT_LD_LBFGS, NLOPT_LD_LBFGS_NOCEDAL, NLOPT_LD_MMA, 
+% NLOPT_LD_TNEWTON, NLOPT_LD_TNEWTON_PRECOND, 
+% NLOPT_LD_TNEWTON_PRECOND_RESTART, NLOPT_LD_TNEWTON_RESTART, 
+% NLOPT_LD_VAR1, NLOPT_LD_VAR2, NLOPT_LN_AUGLAG_EQ, NLOPT_LN_AUGLAG, 
+% NLOPT_LN_BOBYQA, NLOPT_LN_COBYLA, NLOPT_LN_NELDERMEAD, 
+% NLOPT_LN_NEWUOA_BOUND, NLOPT_LN_NEWUOA, NLOPT_LN_PRAXIS, NLOPT_LN_SBPLX
+%
+% For more information on individual algorithms, see their individual
+% help pages (e.g. "help NLOPT_LN_SBPLX").
+function [xopt, fmin, retcode] = nlopt_minimize(algorithm, f, f_data, lb, ub, xinit, stop)
+  
+  [xopt, fmin, retcode] = nlopt_minimize_constrained(algorithm, f, f_data, {}, {}, lb, ub, xinit, stop);
+  
diff --git a/octave/nlopt_minimize_constrained.m b/octave/nlopt_minimize_constrained.m
new file mode 100644 (file)
index 0000000..8d3cee6
--- /dev/null
@@ -0,0 +1,103 @@
+% Usage: [xopt, fmin, retcode] = nlopt_minimize_constrained
+%                                          (algorithm, f, f_data,
+%                                           fc, fc_data, lb, ub,
+%                                           xinit, stop)
+%
+% Minimizes a nonlinear multivariable function f(x, f_data{:}), subject
+% to nonlinear constraints described by fc and fc_data (see below), where
+% x is a row vector, returning the optimal x found (xopt) along with
+% the minimum function value (fmin = f(xopt)) and a return code (retcode).
+% A variety of local and global optimization algorithms can be used,
+% as specified by the algorithm parameter described below.  lb and ub
+% are row vectors giving the upper and lower bounds on x, xinit is
+% a row vector giving the initial guess for x, and stop is a struct
+% containing termination conditions (see below).
+%
+% This function is a front-end for the external routine
+% nlopt_minimize_constrained in the free NLopt nonlinear-optimization
+% library, which is a wrapper around a number of free/open-source
+% optimization subroutines.  More details can be found on the NLopt
+% web page (ab-initio.mit.edu/nlopt) and also under
+% 'man nlopt_minimize_constrained' on Unix.
+%
+% f should be a handle (@) to a function of the form:
+%
+%    [val, gradient] = f(x, ...)
+%
+% where x is a row vector, val is the function value f(x), and gradient
+% is a row vector giving the gradient of the function with respect to x.
+% The gradient is only used for gradient-based optimization algorithms;
+% some of the algorithms (below) are derivative-free and only require
+% f to return val (its value).  f can take additional arguments (...)
+% which are passed via the argument f_data: f_data is a cell array
+% of the additional arguments to pass to f.  (Recall that cell arrays
+% are specified by curly brackets { ... }.  For example, pass f_data={}
+% for functions that require no additional arguments.)
+%
+% A few of the algorithms (below) support nonlinear constraints,
+% in particular NLOPT_LD_MMA and NLOPT_LN_COBYLA.  These (if any)
+% are specified by fc and fc_data.  fc is a cell array of
+% function handles, and fc_data is a cell array of cell arrays of the
+% corresponding arguments.  Both must have the same length m, the
+% number of nonlinear constraints.  That is, fc{i} is a handle
+% to a function of the form:
+%
+%   [val, gradient] = fc(x, ...)
+%
+% (where the gradient is only used for gradient-based algorithms),
+% and the ... arguments are given by fc_data{i}{:}.
+%
+% If you have no nonlinear constraints, i.e. fc = fc_data = {}, then
+% it is equivalent to calling the the nlopt_minimize() function, 
+% which omits the fc and fc_data arguments.
+%
+% stop describes the termination criteria, and is a struct with a
+% number of optional fields:
+%     stop.ftol_rel = fractional tolerance on function value
+%     stop.ftol_abs = absolute tolerance on function value
+%     stop.xtol_rel = fractional tolerance on x
+%     stop.xtol_abs = row vector of absolute tolerances on x components
+%     stop.fmin_max = stop when f < fmin_max is found
+%     stop.maxeval = maximum number of function evaluations
+%     stop.maxtime = maximum run time in seconds
+%     stop.verbose = > 0 indicates verbose output
+% Minimization stops when any one of these conditions is met; any
+% condition that is omitted from stop will be ignored.  WARNING:
+% not all algorithms interpret the stopping criteria in exactly the
+% same way, and in any case ftol/xtol specify only a crude estimate
+% for the accuracy of the minimum function value/x.
+%
+% The algorithm should be one of the following constants (name and
+% interpretation are the same as for the C function).  Names with
+% _G*_ are global optimization, and names with _L*_ are local
+% optimization.  Names with _*N_ are derivative-free, while names
+% with _*D_ are gradient-based algorithms.  Algorithms:
+%
+% NLOPT_GD_MLSL_LDS, NLOPT_GD_MLSL, NLOPT_GD_STOGO, NLOPT_GD_STOGO_RAND, 
+% NLOPT_GN_CRS2_LM, NLOPT_GN_DIRECT_L, NLOPT_GN_DIRECT_L_NOSCAL, 
+% NLOPT_GN_DIRECT_L_RAND, NLOPT_GN_DIRECT_L_RAND_NOSCAL, NLOPT_GN_DIRECT, 
+% NLOPT_GN_DIRECT_NOSCAL, NLOPT_GN_ISRES, NLOPT_GN_MLSL_LDS, NLOPT_GN_MLSL, 
+% NLOPT_GN_ORIG_DIRECT_L, NLOPT_GN_ORIG_DIRECT, NLOPT_LD_AUGLAG_EQ, 
+% NLOPT_LD_AUGLAG, NLOPT_LD_LBFGS, NLOPT_LD_LBFGS_NOCEDAL, NLOPT_LD_MMA, 
+% NLOPT_LD_TNEWTON, NLOPT_LD_TNEWTON_PRECOND, 
+% NLOPT_LD_TNEWTON_PRECOND_RESTART, NLOPT_LD_TNEWTON_RESTART, 
+% NLOPT_LD_VAR1, NLOPT_LD_VAR2, NLOPT_LN_AUGLAG_EQ, NLOPT_LN_AUGLAG, 
+% NLOPT_LN_BOBYQA, NLOPT_LN_COBYLA, NLOPT_LN_NELDERMEAD, 
+% NLOPT_LN_NEWUOA_BOUND, NLOPT_LN_NEWUOA, NLOPT_LN_PRAXIS, NLOPT_LN_SBPLX
+%
+% For more information on individual algorithms, see their individual
+% help pages (e.g. "help NLOPT_LN_SBPLX").
+function [xopt, fmin, retcode] = nlopt_minimize_constrained(algorithm, f, f_data, fc, fc_data, lb, ub, xinit, stop)
+
+opt = stop;
+if (isfield(stop, 'minf_max'))
+  opt.stopval = stop.minf_max;
+end
+opt.algorithm = algorithm;
+opt.min_objective = @(x) f(x, f_data{:});
+opt.lower_bounds = lb;
+opt.upper_bounds = ub;
+for i = 1:length(fc)
+  opt.fc{i} = @(x) fc{i}(x, fc_data{i}{:});
+end
+[xopt, fmin, retcode] = nlopt_optimize(opt, xinit);
diff --git a/octave/nlopt_optimize-mex.c b/octave/nlopt_optimize-mex.c
new file mode 100644 (file)
index 0000000..eb37461
--- /dev/null
@@ -0,0 +1,377 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* Matlab MEX interface to NLopt, and in particular to nlopt_optimize */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <mex.h>
+
+#include "nlopt.h"
+
+#define CHECK0(cond, msg) if (!(cond)) mexErrMsgTxt(msg);
+
+static double struct_val_default(const mxArray *s, const char *name, double dflt)
+{
+     mxArray *val = mxGetField(s, 0, name);
+     if (val) {
+         CHECK0(mxIsNumeric(val) && !mxIsComplex(val) 
+               && mxGetM(val) * mxGetN(val) == 1,
+               "opt fields, other than xtol_abs, must be real scalars");
+         return mxGetScalar(val);
+     }
+     return dflt;
+}
+
+static double *struct_arrval(const mxArray *s, const char *name, unsigned n,
+                            double *dflt)
+{
+     mxArray *val = mxGetField(s, 0, name);
+     if (val) {
+         CHECK0(mxIsNumeric(val) && !mxIsComplex(val) 
+               && mxGetM(val) * mxGetN(val) == n,
+               "opt vector field is not of length n");
+         return mxGetPr(val);
+     }
+     return dflt;
+}
+
+static mxArray *struct_funcval(const mxArray *s, const char *name)
+{
+     mxArray *val = mxGetField(s, 0, name);
+     if (val) {
+         CHECK0(mxIsChar(val) || mxIsFunctionHandle(val),
+                "opt function field is not a function handle/name");
+         return val;
+     }
+     return NULL;
+}
+
+static double *fill(double *arr, unsigned n, double val)
+{
+     unsigned i;
+     for (i = 0; i < n; ++i) arr[i] = val;
+     return arr;
+}
+
+#define FLEN 128 /* max length of user function name */
+#define MAXRHS 3 /* max nrhs for user function */
+typedef struct user_function_data_s {
+     char f[FLEN];
+     mxArray *plhs[2];
+     mxArray *prhs[MAXRHS];
+     int xrhs, nrhs;
+     int verbose, neval;
+     struct user_function_data_s *dpre;
+     nlopt_opt opt;
+} user_function_data;
+
+static double user_function(unsigned n, const double *x,
+                           double *gradient, /* NULL if not needed */
+                           void *d_)
+{
+  user_function_data *d = (user_function_data *) d_;
+  double f;
+
+  d->plhs[0] = d->plhs[1] = NULL;
+  memcpy(mxGetPr(d->prhs[d->xrhs]), x, n * sizeof(double));
+
+  CHECK0(0 == mexCallMATLAB(gradient ? 2 : 1, d->plhs, 
+                          d->nrhs, d->prhs, d->f),
+       "error calling user function");
+
+  CHECK0(mxIsNumeric(d->plhs[0]) && !mxIsComplex(d->plhs[0]) 
+       && mxGetM(d->plhs[0]) * mxGetN(d->plhs[0]) == 1,
+       "user function must return real scalar");
+  f = mxGetScalar(d->plhs[0]);
+  mxDestroyArray(d->plhs[0]);
+  if (gradient) {
+     CHECK0(mxIsDouble(d->plhs[1]) && !mxIsComplex(d->plhs[1])
+          && (mxGetM(d->plhs[1]) == 1 || mxGetN(d->plhs[1]) == 1)
+          && mxGetM(d->plhs[1]) * mxGetN(d->plhs[1]) == n,
+          "gradient vector from user function is the wrong size");
+     memcpy(gradient, mxGetPr(d->plhs[1]), n * sizeof(double));
+     mxDestroyArray(d->plhs[1]);
+  }
+  d->neval++;
+  if (d->verbose) mexPrintf("nlopt_optimize eval #%d: %g\n", d->neval, f);
+  if (mxIsNaN(f)) nlopt_force_stop(d->opt);
+  return f;
+}
+
+static void user_pre(unsigned n, const double *x, const double *v,
+                      double *vpre, void *d_)
+{
+  user_function_data *d = ((user_function_data *) d_)->dpre;
+  d->plhs[0] = d->plhs[1] = NULL;
+  memcpy(mxGetPr(d->prhs[d->xrhs]), x, n * sizeof(double));
+  memcpy(mxGetPr(d->prhs[d->xrhs + 1]), v, n * sizeof(double));
+
+  CHECK0(0 == mexCallMATLAB(1, d->plhs, 
+                           d->nrhs, d->prhs, d->f),
+        "error calling user function");
+
+  CHECK0(mxIsDouble(d->plhs[0]) && !mxIsComplex(d->plhs[0])
+        && (mxGetM(d->plhs[0]) == 1 || mxGetN(d->plhs[0]) == 1)
+        && mxGetM(d->plhs[0]) * mxGetN(d->plhs[0]) == n,
+        "vpre vector from user function is the wrong size");
+  memcpy(vpre, mxGetPr(d->plhs[0]), n * sizeof(double));
+  mxDestroyArray(d->plhs[0]);
+  d->neval++;
+  if (d->verbose) mexPrintf("nlopt_optimize precond eval #%d\n", d->neval);
+}
+
+#define CHECK1(cond, msg) if (!(cond)) { mxFree(tmp); nlopt_destroy(opt); nlopt_destroy(local_opt); mexWarnMsgTxt(msg); return NULL; };
+
+nlopt_opt make_opt(const mxArray *opts, unsigned n)
+{
+     nlopt_opt opt = NULL, local_opt = NULL;
+     nlopt_algorithm algorithm;
+     double *tmp = NULL;
+     unsigned i;
+
+     algorithm = (nlopt_algorithm)
+         struct_val_default(opts, "algorithm", NLOPT_NUM_ALGORITHMS);
+     CHECK1(((int)algorithm) >= 0 && algorithm < NLOPT_NUM_ALGORITHMS,
+           "invalid opt.algorithm");
+
+     tmp = (double *) mxCalloc(n, sizeof(double));
+     opt = nlopt_create(algorithm, n);
+     CHECK1(opt, "nlopt: out of memory");
+
+     nlopt_set_lower_bounds(opt, struct_arrval(opts, "lower_bounds", n,
+                                              fill(tmp, n, -HUGE_VAL)));
+     nlopt_set_upper_bounds(opt, struct_arrval(opts, "upper_bounds", n,
+                                              fill(tmp, n, +HUGE_VAL)));
+
+     nlopt_set_stopval(opt, struct_val_default(opts, "stopval", -HUGE_VAL));
+     nlopt_set_ftol_rel(opt, struct_val_default(opts, "ftol_rel", 0.0));
+     nlopt_set_ftol_abs(opt, struct_val_default(opts, "ftol_abs", 0.0));
+     nlopt_set_xtol_rel(opt, struct_val_default(opts, "xtol_rel", 0.0));
+     nlopt_set_xtol_abs(opt, struct_arrval(opts, "xtol_abs", n,
+                                          fill(tmp, n, 0.0)));
+     nlopt_set_maxeval(opt, struct_val_default(opts, "maxeval", 0.0) < 0 ?
+                      0 : struct_val_default(opts, "maxeval", 0.0));
+     nlopt_set_maxtime(opt, struct_val_default(opts, "maxtime", 0.0));
+
+     nlopt_set_population(opt, struct_val_default(opts, "population", 0));
+     nlopt_set_vector_storage(opt, struct_val_default(opts, "vector_storage", 0));
+
+     if (struct_arrval(opts, "initial_step", n, NULL))
+         nlopt_set_initial_step(opt,
+                                struct_arrval(opts, "initial_step", n, NULL));
+     
+     if (mxGetField(opts, 0, "local_optimizer")) {
+         const mxArray *local_opts = mxGetField(opts, 0, "local_optimizer");
+         CHECK1(mxIsStruct(local_opts),
+                "opt.local_optimizer must be a structure");
+         CHECK1(local_opt = make_opt(local_opts, n),
+                "error initializing local optimizer");
+         nlopt_set_local_optimizer(opt, local_opt);
+         nlopt_destroy(local_opt); local_opt = NULL;
+     }
+
+     mxFree(tmp);
+     return opt;
+}
+
+#define CHECK(cond, msg) if (!(cond)) { mxFree(dh); mxFree(dfc); nlopt_destroy(opt); mexErrMsgTxt(msg); }
+
+void mexFunction(int nlhs, mxArray *plhs[],
+                 int nrhs, const mxArray *prhs[])
+{
+     unsigned n;
+     double *x, *x0, opt_f;
+     nlopt_result ret;
+     mxArray *x_mx, *mx;
+     user_function_data d, dpre, *dfc = NULL, *dh = NULL;
+     nlopt_opt opt = NULL;
+
+     CHECK(nrhs == 2 && nlhs <= 3, "wrong number of arguments");
+
+     /* options = prhs[0] */
+     CHECK(mxIsStruct(prhs[0]), "opt must be a struct");
+     
+     /* x0 = prhs[1] */
+     CHECK(mxIsDouble(prhs[1]) && !mxIsComplex(prhs[1])
+          && (mxGetM(prhs[1]) == 1 || mxGetN(prhs[1]) == 1),
+          "x must be real row or column vector");
+     n = mxGetM(prhs[1]) * mxGetN(prhs[1]),
+     x0 = mxGetPr(prhs[1]);
+
+     CHECK(opt = make_opt(prhs[0], n), "error initializing nlopt options");
+
+     d.neval = 0;
+     d.verbose = (int) struct_val_default(prhs[0], "verbose", 0);
+     d.opt = opt;
+
+     /* function f = prhs[1] */
+     mx = struct_funcval(prhs[0], "min_objective");
+     if (!mx) mx = struct_funcval(prhs[0], "max_objective");
+     CHECK(mx, "either opt.min_objective or opt.max_objective must exist");
+     if (mxIsChar(mx)) {
+         CHECK(mxGetString(mx, d.f, FLEN) == 0,
+               "error reading function name string (too long?)");
+         d.nrhs = 1;
+         d.xrhs = 0;
+     }
+     else {
+         d.prhs[0] = mx;
+         strcpy(d.f, "feval");
+         d.nrhs = 2;
+         d.xrhs = 1;
+     }
+     d.prhs[d.xrhs] = mxCreateDoubleMatrix(1, n, mxREAL);
+
+     if ((mx = struct_funcval(prhs[0], "pre"))) {
+         CHECK(mxIsChar(mx) || mxIsFunctionHandle(mx),
+               "pre must contain function handles or function names");
+         if (mxIsChar(mx)) {
+              CHECK(mxGetString(mx, dpre.f, FLEN) == 0,
+                     "error reading function name string (too long?)");
+              dpre.nrhs = 2;
+              dpre.xrhs = 0;
+         }
+         else {
+              dpre.prhs[0] = mx;
+              strcpy(dpre.f, "feval");
+              dpre.nrhs = 3;
+              dpre.xrhs = 1;
+         }
+         dpre.verbose = d.verbose > 2;
+         dpre.opt = opt;
+         dpre.neval = 0;
+         dpre.prhs[dpre.xrhs] = d.prhs[d.xrhs];
+         dpre.prhs[d.xrhs+1] = mxCreateDoubleMatrix(1, n, mxREAL);
+         d.dpre = &dpre;
+
+         if (struct_funcval(prhs[0], "min_objective"))
+              nlopt_set_precond_min_objective(opt, user_function,user_pre,&d);
+         else
+              nlopt_set_precond_max_objective(opt, user_function,user_pre,&d);
+     }
+     else {
+         dpre.nrhs = 0;
+         if (struct_funcval(prhs[0], "min_objective"))
+              nlopt_set_min_objective(opt, user_function, &d);
+         else
+              nlopt_set_max_objective(opt, user_function, &d);
+     }
+
+     if ((mx = mxGetField(prhs[0], 0, "fc"))) {
+         int j, m;
+         double *fc_tol;
+         
+         CHECK(mxIsCell(mx), "fc must be a Cell array");
+         m = mxGetM(mx) * mxGetN(mx);;
+         dfc = (user_function_data *) mxCalloc(m, sizeof(user_function_data));
+         fc_tol = struct_arrval(prhs[0], "fc_tol", m, NULL);
+
+         for (j = 0; j < m; ++j) {
+              mxArray *fc = mxGetCell(mx, j);
+              CHECK(mxIsChar(fc) || mxIsFunctionHandle(fc),
+                    "fc must contain function handles or function names");
+              if (mxIsChar(fc)) {
+                   CHECK(mxGetString(fc, dfc[j].f, FLEN) == 0,
+                    "error reading function name string (too long?)");
+                   dfc[j].nrhs = 1;
+                   dfc[j].xrhs = 0;
+              }
+              else {
+                   dfc[j].prhs[0] = fc;
+                   strcpy(dfc[j].f, "feval");
+                   dfc[j].nrhs = 2;
+                   dfc[j].xrhs = 1;
+              }
+              dfc[j].verbose = d.verbose > 1;
+              dfc[j].opt = opt;
+              dfc[j].neval = 0;
+              dfc[j].prhs[dfc[j].xrhs] = d.prhs[d.xrhs];
+              CHECK(nlopt_add_inequality_constraint(opt, user_function,
+                                                    dfc + j,
+                                                    fc_tol ? fc_tol[j] : 0)
+                    > 0, "nlopt error adding inequality constraint");
+         }
+     }
+
+
+     if ((mx = mxGetField(prhs[0], 0, "h"))) {
+         int j, m;
+         double *h_tol;
+         
+         CHECK(mxIsCell(mx), "h must be a Cell array");
+         m = mxGetM(mx) * mxGetN(mx);;
+         dh = (user_function_data *) mxCalloc(m, sizeof(user_function_data));
+         h_tol = struct_arrval(prhs[0], "h_tol", m, NULL);
+
+         for (j = 0; j < m; ++j) {
+              mxArray *h = mxGetCell(mx, j);
+              CHECK(mxIsChar(h) || mxIsFunctionHandle(h),
+                    "h must contain function handles or function names");
+              if (mxIsChar(h)) {
+                   CHECK(mxGetString(h, dh[j].f, FLEN) == 0,
+                    "error reading function name string (too long?)");
+                   dh[j].nrhs = 1;
+                   dh[j].xrhs = 0;
+              }
+              else {
+                   dh[j].prhs[0] = h;
+                   strcpy(dh[j].f, "feval");
+                   dh[j].nrhs = 2;
+                   dh[j].xrhs = 1;
+              }
+              dh[j].verbose = d.verbose > 1;
+              dh[j].opt = opt;
+              dh[j].neval = 0;
+              dh[j].prhs[dh[j].xrhs] = d.prhs[d.xrhs];
+              CHECK(nlopt_add_equality_constraint(opt, user_function,
+                                                    dh + j,
+                                                  h_tol ? h_tol[j] : 0)
+                    > 0, "nlopt error adding equality constraint");
+         }
+     }
+
+
+     x_mx = mxCreateDoubleMatrix(mxGetM(prhs[1]), mxGetN(prhs[1]), mxREAL);
+     x = mxGetPr(x_mx);
+     memcpy(x, x0, sizeof(double) * n);
+
+     ret = nlopt_optimize(opt, x, &opt_f);
+
+     mxFree(dh);
+     mxFree(dfc);
+     mxDestroyArray(d.prhs[d.xrhs]);
+     if (dpre.nrhs > 0) mxDestroyArray(dpre.prhs[d.xrhs+1]);
+     nlopt_destroy(opt);
+
+     plhs[0] = x_mx;
+     if (nlhs > 1) {
+         plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
+         *(mxGetPr(plhs[1])) = opt_f;
+     }
+     if (nlhs > 2) {
+         plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
+         *(mxGetPr(plhs[2])) = (int) ret;
+     }
+}
diff --git a/octave/nlopt_optimize-oct.cc b/octave/nlopt_optimize-oct.cc
new file mode 100644 (file)
index 0000000..4e08421
--- /dev/null
@@ -0,0 +1,298 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <octave/oct.h>
+#include <octave/oct-map.h>
+#include <octave/ov.h>
+#include <math.h>
+#include <stdio.h>
+
+#include "nlopt.h"
+#include "nlopt_optimize_usage.h"
+
+static int struct_val_default(Octave_map &m, const std::string& k,
+                                int dflt)
+{
+  if (m.contains(k)) {
+    if (m.contents(k).length() == 1 && (m.contents(k))(0).is_real_scalar())
+      return (m.contents(k))(0).int_value();
+  }
+  return dflt;
+}
+
+static double struct_val_default(Octave_map &m, const std::string& k,
+                                double dflt)
+{
+  if (m.contains(k)) {
+    if (m.contents(k).length() == 1 && (m.contents(k))(0).is_real_scalar())
+      return (m.contents(k))(0).double_value();
+  }
+  return dflt;
+}
+
+static Matrix struct_val_default(Octave_map &m, const std::string& k,
+                                Matrix &dflt)
+{
+  if (m.contains(k)) {
+    if ((m.contents(k)).length() == 1) {
+      if ((m.contents(k))(0).is_real_scalar())
+       return Matrix(1, dflt.length(), (m.contents(k))(0).double_value());
+      else if ((m.contents(k))(0).is_real_matrix())
+       return (m.contents(k))(0).matrix_value();
+    }
+  }
+  return dflt;
+}
+
+typedef struct {
+  octave_function *f;
+  int neval, verbose;
+  nlopt_opt opt;
+} user_function_data;
+
+static double user_function(unsigned n, const double *x,
+                           double *gradient, /* NULL if not needed */
+                           void *data_)
+{
+  user_function_data *data = (user_function_data *) data_;
+  octave_value_list args(1, 0);
+  Matrix xm(1,n);
+  for (unsigned i = 0; i < n; ++i)
+    xm(i) = x[i];
+  args(0) = xm;
+  octave_value_list res = data->f->do_multi_index_op(gradient ? 2 : 1, args); 
+  if (res.length() < (gradient ? 2 : 1))
+    gripe_user_supplied_eval("nlopt_optimize");
+  else if (!res(0).is_real_scalar()
+          || (gradient && !res(1).is_real_matrix()
+              && !(n == 1 && res(1).is_real_scalar())))
+    gripe_user_returned_invalid("nlopt_optimize");
+  else {
+    if (gradient) {
+      if (n == 1 && res(1).is_real_scalar())
+       gradient[0] = res(1).double_value();
+      else {
+       Matrix grad = res(1).matrix_value();
+       for (unsigned i = 0; i < n; ++i)
+         gradient[i] = grad(i);
+      }
+    }
+    data->neval++;
+    if (data->verbose) printf("nlopt_optimize eval #%d: %g\n", 
+                             data->neval, res(0).double_value());
+    double f = res(0).double_value();
+    if (f != f /* isnan(f) */) nlopt_force_stop(data->opt);
+    return f;
+  }
+  return 0;
+}                               
+
+static double user_function1(unsigned n, const double *x,
+                           double *gradient, /* NULL if not needed */
+                           void *data_)
+{
+  octave_function *f = (octave_function *) data_;
+  octave_value_list args(1, 0);
+  Matrix xm(1,n);
+  for (unsigned i = 0; i < n; ++i)
+    xm(i) = x[i];
+  args(0) = xm;
+  octave_value_list res = f->do_multi_index_op(gradient ? 2 : 1, args); 
+  if (res.length() < (gradient ? 2 : 1))
+    gripe_user_supplied_eval("nlopt_optimize");
+  else if (!res(0).is_real_scalar()
+          || (gradient && !res(1).is_real_matrix()
+              && !(n == 1 && res(1).is_real_scalar())))
+    gripe_user_returned_invalid("nlopt_optimize");
+  else {
+    if (gradient) {
+      if (n == 1 && res(1).is_real_scalar())
+       gradient[0] = res(1).double_value();
+      else {
+       Matrix grad = res(1).matrix_value();
+       for (unsigned i = 0; i < n; ++i)
+         gradient[i] = grad(i);
+      }
+    }
+    return res(0).double_value();
+  }
+  return 0;
+}                               
+
+#define CHECK1(cond, msg) if (!(cond)) { fprintf(stderr, msg "\n\n"); nlopt_destroy(opt); nlopt_destroy(local_opt); return NULL; }
+
+nlopt_opt make_opt(Octave_map &opts, int n)
+{
+  nlopt_opt opt = NULL, local_opt = NULL;
+
+  nlopt_algorithm algorithm = 
+    nlopt_algorithm(struct_val_default(opts, "algorithm", 
+                                      NLOPT_NUM_ALGORITHMS));
+  CHECK1(((int)algorithm) >= 0 && algorithm < NLOPT_NUM_ALGORITHMS,
+       "invalid opt.algorithm");
+
+  opt = nlopt_create(algorithm, n);
+  CHECK1(opt, "nlopt: out of memory");
+
+  Matrix m_inf(1, n, -HUGE_VAL);
+  Matrix lb = struct_val_default(opts, "lower_bounds", m_inf);
+  CHECK1(n == lb.length(), "wrong length of opt.lower_bounds");
+  CHECK1(nlopt_set_lower_bounds(opt, lb.data()) > 0, "nlopt: out of memory");
+
+  Matrix p_inf(1, n, +HUGE_VAL);
+  Matrix ub = struct_val_default(opts, "upper_bounds", p_inf);
+  CHECK1(n == ub.length(), "wrong length of opt.upper_bounds");
+  CHECK1(nlopt_set_upper_bounds(opt, ub.data()) > 0, "nlopt: out of memory");
+
+  nlopt_set_stopval(opt, struct_val_default(opts, "stopval", -HUGE_VAL));
+  nlopt_set_ftol_rel(opt, struct_val_default(opts, "ftol_rel", 0.0));
+  nlopt_set_ftol_abs(opt, struct_val_default(opts, "ftol_abs", 0.0));
+  nlopt_set_xtol_rel(opt, struct_val_default(opts, "xtol_rel", 0.0));
+
+  {
+    Matrix zeros(1, n, 0.0);
+    Matrix xtol_abs = struct_val_default(opts, "xtol_abs", zeros);
+    CHECK1(n == xtol_abs.length(), "stop.xtol_abs must have same length as x");
+    CHECK1(nlopt_set_xtol_abs(opt, xtol_abs.data())>0, "nlopt: out of memory");
+  }
+
+  nlopt_set_maxeval(opt, struct_val_default(opts, "maxeval", 0) < 0 ?
+                   0 : struct_val_default(opts, "maxeval", 0));
+  nlopt_set_maxtime(opt, struct_val_default(opts, "maxtime", 0.0));
+
+  nlopt_set_population(opt, struct_val_default(opts, "population", 0));
+  nlopt_set_vector_storage(opt, struct_val_default(opts, "vector_storage", 0));
+
+  if (opts.contains("initial_step")) {
+    Matrix zeros(1, n, 0.0);
+    Matrix initial_step = struct_val_default(opts, "initial_step", zeros);
+    CHECK1(n == initial_step.length(),
+         "stop.initial_step must have same length as x");
+    CHECK1(nlopt_set_initial_step(opt, initial_step.data()) > 0,
+         "nlopt: out of memory");
+  }
+
+  if (opts.contains("local_optimizer")) {
+    CHECK1(opts.contents("local_optimizer").length() == 1 
+         && (opts.contents("local_optimizer"))(0).is_map(),
+         "opt.local_optimizer must be a structure");
+    Octave_map local_opts = (opts.contents("local_optimizer"))(0).map_value();
+    CHECK1((local_opt = make_opt(local_opts, n)), 
+         "error initializing local optimizer");
+    nlopt_set_local_optimizer(opt, local_opt);
+    nlopt_destroy(local_opt); local_opt = NULL;
+  }
+
+  return opt;
+}
+
+#define CHECK(cond, msg) if (!(cond)) { fprintf(stderr, msg "\n\n"); nlopt_destroy(opt); return retval; }
+
+DEFUN_DLD(nlopt_optimize, args, nargout, NLOPT_OPTIMIZE_USAGE)
+{
+  octave_value_list retval;
+  double A;
+  nlopt_opt opt = NULL;
+
+  CHECK(args.length() == 2 && nargout <= 3, "wrong number of args");
+
+  CHECK(args(0).is_map(), "opt must be structure")
+  Octave_map opts = args(0).map_value();
+
+  CHECK(args(1).is_real_matrix() || args(1).is_real_scalar(),
+       "x must be real vector");
+  Matrix x = args(1).is_real_scalar() ?
+    Matrix(1, 1, args(1).double_value()) : args(1).matrix_value();
+  int n = x.length();
+
+  CHECK((opt = make_opt(opts, n)), "error initializing nlopt options");
+
+  user_function_data d;
+  d.neval = 0;
+  d.verbose = struct_val_default(opts, "verbose", 0);
+  d.opt = opt;
+  if (opts.contains("min_objective")) {
+    CHECK(opts.contents("min_objective").length() == 1 
+         && (opts.contents("min_objective"))(0).is_function_handle(),
+         "opt.min_objective must be a function");
+      d.f = (opts.contents("min_objective"))(0).function_value();
+      nlopt_set_min_objective(opt, user_function, &d);
+  }
+  else if (opts.contains("max_objective")) {
+    CHECK(opts.contents("max_objective").length() == 1 
+         && (opts.contents("max_objective"))(0).is_function_handle(),
+         "opt.max_objective must be a function");
+      d.f = (opts.contents("max_objective"))(0).function_value();
+      nlopt_set_max_objective(opt, user_function, &d);
+  }
+  else {
+    CHECK(0,"either opt.min_objective or opt.max_objective must exist");
+  }
+
+  if (opts.contains("fc") && opts.contents("fc").length() == 1) {
+    CHECK((opts.contents("fc"))(0).is_cell(), "opt.fc must be cell array");
+    Cell fc = (opts.contents("fc"))(0).cell_value();
+    Matrix zeros(1, fc.length(), 0.0);
+    Matrix fc_tol = struct_val_default(opts, "fc_tol", zeros);
+    CHECK(fc_tol.length() == fc.length(), 
+         "opt.fc must have same length as opt.fc_tol");
+    for (int i = 0; i < fc.length(); ++i) {
+      CHECK(fc(i).is_function() || fc(i).is_function_handle(),
+           "opt.fc must be a cell array of function handles");
+      CHECK(nlopt_add_inequality_constraint(opt, user_function1,
+                                           fc(i).function_value(),
+                                           fc_tol(i)) > 0,
+           "nlopt error adding inequality constraint");
+    }
+  }
+
+  if (opts.contains("h") && opts.contents("h").length() == 1) {
+    CHECK((opts.contents("h"))(0).is_cell(), "opt.h must be cell array");
+    Cell h = (opts.contents("h"))(0).cell_value();
+    Matrix zeros(1, h.length(), 0.0);
+    Matrix h_tol = struct_val_default(opts, "h_tol", zeros);
+    CHECK(h_tol.length() == h.length(), 
+         "opt.h must have same length as opt.h_tol");
+    for (int i = 0; i < h.length(); ++i) {
+      CHECK(h(i).is_function() || h(i).is_function_handle(),
+           "opt.h must be a cell array of function handles");
+      CHECK(nlopt_add_equality_constraint(opt, user_function1,
+                                           h(i).function_value(),
+                                           h_tol(i)) > 0,
+           "nlopt error adding equality constraint");
+    }
+  }
+
+
+  double opt_f;
+  nlopt_result ret = nlopt_optimize(opt, x.fortran_vec(), &opt_f);
+                                   
+  retval(0) = x;
+  if (nargout > 1)
+    retval(1) = opt_f;
+  if (nargout > 2)
+    retval(2) = int(ret);
+
+  nlopt_destroy(opt);
+
+  return retval;
+}
diff --git a/octave/nlopt_optimize.m b/octave/nlopt_optimize.m
new file mode 100644 (file)
index 0000000..1377689
--- /dev/null
@@ -0,0 +1,190 @@
+% Usage: [xopt, fopt, retcode] = nlopt_optimize(opt, xinit)
+%
+% Optimizes (minimizes or maximizes) a nonlinear function under
+% nonlinear constraints from the starting guess xinit, where the
+% objective, constraints, stopping criteria, and other options are 
+% specified in the structure opt described below.  A variety of local
+% and global optimization algorithms can be used, as specified by the 
+% opt.algorithm parameter described below.  Returns the optimum
+% function value fopt, the location xopt of the optimum, and a
+% return code retcode described below (> 0 on success).
+%
+% The dimension (n) of the problem, i.e. the number of design variables,
+% is specified implicitly via the length of xinit.
+%
+% This function is a front-end for the external routine nlopt_optimize
+% in the free NLopt nonlinear-optimization library, which is a wrapper
+% around a number of free/open-source optimization subroutines.  More
+% details can be found on the NLopt web page (ab-initio.mit.edu/nlopt)
+% and also under 'man nlopt_minimize' on Unix.
+%
+% OBJECTIVE FUNCTION:
+%
+% The objective function f is specified via opt.min_objective or
+% opt.max_objective for minimization or maximization, respectively.
+% opt.min/max_objective should be a handle (@) to a function of the form:
+%
+%    [val, gradient] = f(x)
+%
+% where x is a row vector, val is the function value f(x), and gradient
+% is a row vector giving the gradient of the function with respect to x.
+% The gradient is only used for gradient-based optimization algorithms;
+% some of the algorithms (below) are derivative-free and only require
+% f to return val (its value).
+%
+% BOUND CONSTRAINTS:
+%
+% Lower and/or upper bounds for the design variables x are specified
+% via opt.lower_bounds and/or opt.upper_bounds, respectively: these
+% are vectors (of the same length as xinit, above) giving the bounds
+% in each component. An unbounded component may be specified by a
+% lower/upper bound of -inf/+inf, respectively.  If opt.lower_bounds
+% and/or opt.upper_bounds are not specified, the default bounds are
+% -inf/+inf (i.e. unbounded), respectively.
+%
+% NONLINEAR CONSTRAINTS:
+%
+% Several of the algorithms in NLopt (MMA, COBYLA, and ORIG_DIRECT) also
+% support arbitrary nonlinear inequality constraints, and some also allow
+% nonlinear equality constraints (ISRES and AUGLAG). For these 
+% algorithms, you can specify as many nonlinear constraints as you wish.
+% (The default is no nonlinear constraints.)
+%
+% Inequality constraints of the form fc{i}(x) <= 0 are specified via opt.fc,
+% which is a cell array of function handles (@) of the same form as
+% the objective function above (i.e., returning the value and optionally
+% the gradient of the constraint function fc{i}, where the gradient is
+% only needed for gradient-based algorithms).
+%
+% Equality constraints of the form h{i}(x) = 0 are specified via opt.h,
+% which is a cell array of function handles (@) of the same form as
+% the objective function above (i.e., returning the value and optionally
+% the gradient of the constraint function h{i}, where the gradient is
+% only needed for gradient-based algorithms).
+%
+% For both inequality and equality constraints, you can supply a
+% "tolerance" for each constraint: this tolerance is used for convergence
+% tests only, and a point x is considered feasible for purposes of
+% convergence if the constraint is violated by the given tolerance.
+% The tolerances are specified via opt.fc_tol and opt.h_tol, respectively,
+% which must be vectors of the same length as opt.fc and opt.h, so
+% that opt.fc_tol(i) is the tolerance for opt.fc{i} and opt.h_tol(i)
+% is the tolerance for opt.h{i}.  These tolerances default to zero; a
+% small nonzero tolerance is recommended, however, especially for h_tol.
+%
+% ALGORITHMS
+%
+% The optimization algorithm must be specified via opt.algorithm.
+%
+% The algorithm should be one of the following constants (name and
+% interpretation are the same as for the C language interface).  Names
+% with _G*_ are global optimization, and names with _L*_ are local
+% optimization.  Names with _*N_ are derivative-free, while names
+% with _*D_ are gradient-based algorithms.  Algorithms:
+%
+% NLOPT_GD_MLSL_LDS, NLOPT_GD_MLSL, NLOPT_GD_STOGO, NLOPT_GD_STOGO_RAND, 
+% NLOPT_GN_CRS2_LM, NLOPT_GN_DIRECT_L, NLOPT_GN_DIRECT_L_NOSCAL, 
+% NLOPT_GN_DIRECT_L_RAND, NLOPT_GN_DIRECT_L_RAND_NOSCAL, NLOPT_GN_DIRECT, 
+% NLOPT_GN_DIRECT_NOSCAL, NLOPT_GN_ISRES, NLOPT_GN_MLSL_LDS, NLOPT_GN_MLSL, 
+% NLOPT_GN_ORIG_DIRECT_L, NLOPT_GN_ORIG_DIRECT, NLOPT_LD_AUGLAG_EQ, 
+% NLOPT_LD_AUGLAG, NLOPT_LD_LBFGS, NLOPT_LD_LBFGS_NOCEDAL, NLOPT_LD_MMA, 
+% NLOPT_LD_TNEWTON, NLOPT_LD_TNEWTON_PRECOND, 
+% NLOPT_LD_TNEWTON_PRECOND_RESTART, NLOPT_LD_TNEWTON_RESTART, 
+% NLOPT_LD_VAR1, NLOPT_LD_VAR2, NLOPT_LN_AUGLAG_EQ, NLOPT_LN_AUGLAG, 
+% NLOPT_LN_BOBYQA, NLOPT_LN_COBYLA, NLOPT_LN_NELDERMEAD, 
+% NLOPT_LN_NEWUOA_BOUND, NLOPT_LN_NEWUOA, NLOPT_LN_PRAXIS, NLOPT_LN_SBPLX
+%
+% For more information on individual algorithms, see their individual
+% help pages (e.g. "help NLOPT_LN_SBPLX").
+%
+% STOPPING CRITERIA:
+%
+% Multiple stopping criteria can be specified by setting one or more of
+% the following fields of opt.  The optimization halts whenever any
+% one of the given criteria is satisfied.
+%
+% opt.stopval: Stop when an objective value of at least stopval is found.
+%    That is, stop minimizing when a value <= stopval is found, or stop
+%    maximizing when a value >= stopval is found.
+%
+% opt.ftol_rel: Relative tolerance on function value, to stop when
+%    an optimization step (or an estimate of the optimum) changes
+%    the function value by less than opt.ftol_rel multiplied by
+%    the absolute value of the function.
+%
+% opt.ftol_abs: Absolute tolerance on function value, to stop when
+%    an optimization step (or an estimate of the optimum) changes
+%    the function value by less than opt.ftol_abs.
+%
+% opt.xtol_rel: Relative tolerance on function value, to stop when
+%    an optimization step (or an estimate of the optimum) changes
+%    every component of x by less than opt.xtol_rel multiplied by
+%    the absolute value of that component of x.
+%
+% opt.xtol_abs: Absolute tolerance on function value, to stop when
+%    an optimization step (or an estimate of the optimum) changes
+%    every component of x by less than that component of opt.xtol_abs
+%    -- should be a vector of same length as x.
+%
+% opt.maxeval: Maximum number of function evaluations.
+%
+% opt.maxtime: Maximum runtime (in seconds) for the optimization.
+%
+% RETURN CODE:
+%
+% The retcode result is positive upon successful completion, and
+% negative for an error.  The specific values are:
+%
+% generic success code: +1
+%      stopval reached: +2
+%         ftol reached: +3
+%         xtol reached: +4
+%      maxeval reached: +5
+%      maxtime reached: +6
+% generic failure code: -1
+%    invalid arguments: -2
+%        out of memory: -3
+%     roundoff-limited: -4
+%
+% LOCAL OPTIMIZER:
+%
+% Some of the algorithms, especially MLSL and AUGLAG, use a different
+% optimization algorithm as a subroutine, typically for local optimization.
+% By default, they use MMA or COBYLA for gradient-based or derivative-free
+% searching, respectively.  However, you can change this by specifying
+% opt.local_optimizer: this is a structure with the same types of fields as opt
+% (stopping criteria, algorithm, etcetera).  The objective function
+% and nonlinear constraint parameters of opt.local_optimizer are ignored.
+%
+% INITIAL STEP SIZE:
+%
+% For derivative-free local-optimization algorithms, the optimizer must
+% somehow decide on some initial step size to perturb x by when it begins
+% the optimization. This step size should be big enough that the value
+% of the objective changes significantly, but not too big if you want to
+% find the local optimum nearest to x. By default, NLopt chooses this
+% initial step size heuristically from the bounds, tolerances, and other
+% information, but this may not always be the best choice.
+%
+% You can modify the initial step by setting opt.initial_step, which
+% is a vector of the same length as x containing the (nonzero) initial
+% step size for each component of x.
+%
+% STOCHASTIC POPULATION:
+%
+% Several of the stochastic search algorithms (e.g., CRS, MLSL, and
+% ISRES) start by generating some initial "population" of random points
+% x. By default, this initial population size is chosen heuristically in
+% some algorithm-specific way, but the initial population can by changed
+% by setting opt.population to the desired initial population size.
+%
+% VERBOSE OUTPUT:
+%
+% If opt.verbose is set to a nonzero value, then nlopt_optimize
+% will print out verbose output; for example, it will print the
+% value of the objective function after each evaluation.
+%
+% MORE INFORMATION:
+%
+% For more documentation, such as a detailed description of all the
+% algorithms, see the NLopt home page: http://ab-initio.mit.edu/nlopt
diff --git a/octave/nlopt_optimize_usage.h b/octave/nlopt_optimize_usage.h
new file mode 100644 (file)
index 0000000..8449e79
--- /dev/null
@@ -0,0 +1,192 @@
+#define NLOPT_OPTIMIZE_USAGE \
+"Usage: [xopt, fopt, retcode] = nlopt_optimize(opt, xinit)\n" \
+"\n" \
+"Optimizes (minimizes or maximizes) a nonlinear function under\n" \
+"nonlinear constraints from the starting guess xinit, where the\n" \
+"objective, constraints, stopping criteria, and other options are \n" \
+"specified in the structure opt described below.  A variety of local\n" \
+"and global optimization algorithms can be used, as specified by the \n" \
+"opt.algorithm parameter described below.  Returns the optimum\n" \
+"function value fopt, the location xopt of the optimum, and a\n" \
+"return code retcode described below (> 0 on success).\n" \
+"\n" \
+"The dimension (n) of the problem, i.e. the number of design variables,\n" \
+"is specified implicitly via the length of xinit.\n" \
+"\n" \
+"This function is a front-end for the external routine nlopt_optimize\n" \
+"in the free NLopt nonlinear-optimization library, which is a wrapper\n" \
+"around a number of free/open-source optimization subroutines.  More\n" \
+"details can be found on the NLopt web page (ab-initio.mit.edu/nlopt)\n" \
+"and also under 'man nlopt_minimize' on Unix.\n" \
+"\n" \
+"OBJECTIVE FUNCTION:\n" \
+"\n" \
+"The objective function f is specified via opt.min_objective or\n" \
+"opt.max_objective for minimization or maximization, respectively.\n" \
+"opt.min/max_objective should be a handle (@) to a function of the form:\n" \
+"\n" \
+"   [val, gradient] = f(x)\n" \
+"\n" \
+"where x is a row vector, val is the function value f(x), and gradient\n" \
+"is a row vector giving the gradient of the function with respect to x.\n" \
+"The gradient is only used for gradient-based optimization algorithms;\n" \
+"some of the algorithms (below) are derivative-free and only require\n" \
+"f to return val (its value).\n" \
+"\n" \
+"BOUND CONSTRAINTS:\n" \
+"\n" \
+"Lower and/or upper bounds for the design variables x are specified\n" \
+"via opt.lower_bounds and/or opt.upper_bounds, respectively: these\n" \
+"are vectors (of the same length as xinit, above) giving the bounds\n" \
+"in each component. An unbounded component may be specified by a\n" \
+"lower/upper bound of -inf/+inf, respectively.  If opt.lower_bounds\n" \
+"and/or opt.upper_bounds are not specified, the default bounds are\n" \
+"-inf/+inf (i.e. unbounded), respectively.\n" \
+"\n" \
+"NONLINEAR CONSTRAINTS:\n" \
+"\n" \
+"Several of the algorithms in NLopt (MMA, COBYLA, and ORIG_DIRECT) also\n" \
+"support arbitrary nonlinear inequality constraints, and some also allow\n" \
+"nonlinear equality constraints (ISRES and AUGLAG). For these \n" \
+"algorithms, you can specify as many nonlinear constraints as you wish.\n" \
+"(The default is no nonlinear constraints.)\n" \
+"\n" \
+"Inequality constraints of the form fc{i}(x) <= 0 are specified via opt.fc,\n" \
+"which is a cell array of function handles (@) of the same form as\n" \
+"the objective function above (i.e., returning the value and optionally\n" \
+"the gradient of the constraint function fc{i}, where the gradient is\n" \
+"only needed for gradient-based algorithms).\n" \
+"\n" \
+"Equality constraints of the form h{i}(x) = 0 are specified via opt.h,\n" \
+"which is a cell array of function handles (@) of the same form as\n" \
+"the objective function above (i.e., returning the value and optionally\n" \
+"the gradient of the constraint function h{i}, where the gradient is\n" \
+"only needed for gradient-based algorithms).\n" \
+"\n" \
+"For both inequality and equality constraints, you can supply a\n" \
+"\"tolerance\" for each constraint: this tolerance is used for convergence\n" \
+"tests only, and a point x is considered feasible for purposes of\n" \
+"convergence if the constraint is violated by the given tolerance.\n" \
+"The tolerances are specified via opt.fc_tol and opt.h_tol, respectively,\n" \
+"which must be vectors of the same length as opt.fc and opt.h, so\n" \
+"that opt.fc_tol(i) is the tolerance for opt.fc{i} and opt.h_tol(i)\n" \
+"is the tolerance for opt.h{i}.  These tolerances default to zero; a\n" \
+"small nonzero tolerance is recommended, however, especially for h_tol.\n" \
+"\n" \
+"ALGORITHMS\n" \
+"\n" \
+"The optimization algorithm must be specified via opt.algorithm.\n" \
+"\n" \
+"The algorithm should be one of the following constants (name and\n" \
+"interpretation are the same as for the C language interface).  Names\n" \
+"with _G*_ are global optimization, and names with _L*_ are local\n" \
+"optimization.  Names with _*N_ are derivative-free, while names\n" \
+"with _*D_ are gradient-based algorithms.  Algorithms:\n" \
+"\n" \
+"NLOPT_GD_MLSL_LDS, NLOPT_GD_MLSL, NLOPT_GD_STOGO, NLOPT_GD_STOGO_RAND, \n" \
+"NLOPT_GN_CRS2_LM, NLOPT_GN_DIRECT_L, NLOPT_GN_DIRECT_L_NOSCAL, \n" \
+"NLOPT_GN_DIRECT_L_RAND, NLOPT_GN_DIRECT_L_RAND_NOSCAL, NLOPT_GN_DIRECT, \n" \
+"NLOPT_GN_DIRECT_NOSCAL, NLOPT_GN_ISRES, NLOPT_GN_MLSL_LDS, NLOPT_GN_MLSL, \n" \
+"NLOPT_GN_ORIG_DIRECT_L, NLOPT_GN_ORIG_DIRECT, NLOPT_LD_AUGLAG_EQ, \n" \
+"NLOPT_LD_AUGLAG, NLOPT_LD_LBFGS, NLOPT_LD_LBFGS_NOCEDAL, NLOPT_LD_MMA, \n" \
+"NLOPT_LD_TNEWTON, NLOPT_LD_TNEWTON_PRECOND, \n" \
+"NLOPT_LD_TNEWTON_PRECOND_RESTART, NLOPT_LD_TNEWTON_RESTART, \n" \
+"NLOPT_LD_VAR1, NLOPT_LD_VAR2, NLOPT_LN_AUGLAG_EQ, NLOPT_LN_AUGLAG, \n" \
+"NLOPT_LN_BOBYQA, NLOPT_LN_COBYLA, NLOPT_LN_NELDERMEAD, \n" \
+"NLOPT_LN_NEWUOA_BOUND, NLOPT_LN_NEWUOA, NLOPT_LN_PRAXIS, NLOPT_LN_SBPLX\n" \
+"\n" \
+"For more information on individual algorithms, see their individual\n" \
+"help pages (e.g. \"help NLOPT_LN_SBPLX\").\n" \
+"\n" \
+"STOPPING CRITERIA:\n" \
+"\n" \
+"Multiple stopping criteria can be specified by setting one or more of\n" \
+"the following fields of opt.  The optimization halts whenever any\n" \
+"one of the given criteria is satisfied.\n" \
+"\n" \
+"opt.stopval: Stop when an objective value of at least stopval is found.\n" \
+"   That is, stop minimizing when a value <= stopval is found, or stop\n" \
+"   maximizing when a value >= stopval is found.\n" \
+"\n" \
+"opt.ftol_rel: Relative tolerance on function value, to stop when\n" \
+"   an optimization step (or an estimate of the optimum) changes\n" \
+"   the function value by less than opt.ftol_rel multiplied by\n" \
+"   the absolute value of the function.\n" \
+"\n" \
+"opt.ftol_abs: Absolute tolerance on function value, to stop when\n" \
+"   an optimization step (or an estimate of the optimum) changes\n" \
+"   the function value by less than opt.ftol_abs.\n" \
+"\n" \
+"opt.xtol_rel: Relative tolerance on function value, to stop when\n" \
+"   an optimization step (or an estimate of the optimum) changes\n" \
+"   every component of x by less than opt.xtol_rel multiplied by\n" \
+"   the absolute value of that component of x.\n" \
+"\n" \
+"opt.xtol_abs: Absolute tolerance on function value, to stop when\n" \
+"   an optimization step (or an estimate of the optimum) changes\n" \
+"   every component of x by less than that component of opt.xtol_abs\n" \
+"   -- should be a vector of same length as x.\n" \
+"\n" \
+"opt.maxeval: Maximum number of function evaluations.\n" \
+"\n" \
+"opt.maxtime: Maximum runtime (in seconds) for the optimization.\n" \
+"\n" \
+"RETURN CODE:\n" \
+"\n" \
+"The retcode result is positive upon successful completion, and\n" \
+"negative for an error.  The specific values are:\n" \
+"\n" \
+"generic success code: +1\n" \
+"     stopval reached: +2\n" \
+"        ftol reached: +3\n" \
+"        xtol reached: +4\n" \
+"     maxeval reached: +5\n" \
+"     maxtime reached: +6\n" \
+"generic failure code: -1\n" \
+"   invalid arguments: -2\n" \
+"       out of memory: -3\n" \
+"    roundoff-limited: -4\n" \
+"\n" \
+"LOCAL OPTIMIZER:\n" \
+"\n" \
+"Some of the algorithms, especially MLSL and AUGLAG, use a different\n" \
+"optimization algorithm as a subroutine, typically for local optimization.\n" \
+"By default, they use MMA or COBYLA for gradient-based or derivative-free\n" \
+"searching, respectively.  However, you can change this by specifying\n" \
+"opt.local_optimizer: this is a structure with the same types of fields as opt\n" \
+"(stopping criteria, algorithm, etcetera).  The objective function\n" \
+"and nonlinear constraint parameters of opt.local_optimizer are ignored.\n" \
+"\n" \
+"INITIAL STEP SIZE:\n" \
+"\n" \
+"For derivative-free local-optimization algorithms, the optimizer must\n" \
+"somehow decide on some initial step size to perturb x by when it begins\n" \
+"the optimization. This step size should be big enough that the value\n" \
+"of the objective changes significantly, but not too big if you want to\n" \
+"find the local optimum nearest to x. By default, NLopt chooses this\n" \
+"initial step size heuristically from the bounds, tolerances, and other\n" \
+"information, but this may not always be the best choice.\n" \
+"\n" \
+"You can modify the initial step by setting opt.initial_step, which\n" \
+"is a vector of the same length as x containing the (nonzero) initial\n" \
+"step size for each component of x.\n" \
+"\n" \
+"STOCHASTIC POPULATION:\n" \
+"\n" \
+"Several of the stochastic search algorithms (e.g., CRS, MLSL, and\n" \
+"ISRES) start by generating some initial \"population\" of random points\n" \
+"x. By default, this initial population size is chosen heuristically in\n" \
+"some algorithm-specific way, but the initial population can by changed\n" \
+"by setting opt.population to the desired initial population size.\n" \
+"\n" \
+"VERBOSE OUTPUT:\n" \
+"\n" \
+"If opt.verbose is set to a nonzero value, then nlopt_optimize\n" \
+"will print out verbose output; for example, it will print the\n" \
+"value of the objective function after each evaluation.\n" \
+"\n" \
+"MORE INFORMATION:\n" \
+"\n" \
+"For more documentation, such as a detailed description of all the\n" \
+"algorithms, see the NLopt home page: http://ab-initio.mit.edu/nlopt\n" \
+
diff --git a/praxis/Makefile.am b/praxis/Makefile.am
new file mode 100644 (file)
index 0000000..c6c1e21
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libpraxis.la
+libpraxis_la_SOURCES = praxis.c praxis.h
+
+EXTRA_DIST = README
diff --git a/praxis/Makefile.in b/praxis/Makefile.in
new file mode 100644 (file)
index 0000000..56f1d09
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = praxis
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libpraxis_la_LIBADD =
+am_libpraxis_la_OBJECTS = praxis.lo
+libpraxis_la_OBJECTS = $(am_libpraxis_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libpraxis_la_SOURCES)
+DIST_SOURCES = $(libpraxis_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libpraxis.la
+libpraxis_la_SOURCES = praxis.c praxis.h
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu praxis/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu praxis/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libpraxis.la: $(libpraxis_la_OBJECTS) $(libpraxis_la_DEPENDENCIES) $(EXTRA_libpraxis_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libpraxis_la_OBJECTS) $(libpraxis_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/praxis.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/praxis/README b/praxis/README
new file mode 100644 (file)
index 0000000..c51dd42
--- /dev/null
@@ -0,0 +1,15 @@
+praxis gradient-free local optimization via the "principal-axis method",
+downloaded from Netlib:
+
+       http://netlib.org/opt/praxis
+
+The original Fortran code was written by Richard Brent and made
+available by the Stanford Linear Accelerator Center, dated 3/1/73.
+Since this code contains no copyright statements and is dated prior to
+1977, under US copyright law it is in the public domain (not copyrighted).
+
+Converted to C via f2c and cleaned up by Steven G. Johnson
+(stevenj@alum.mit.edu).  C version is licensed under the MIT license
+(which is in the same spirit as public domain, but disclaims warranty
+and is clearer legally).
+
diff --git a/praxis/praxis.c b/praxis/praxis.c
new file mode 100644 (file)
index 0000000..d6636a9
--- /dev/null
@@ -0,0 +1,1366 @@
+/* See README */
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "nlopt-util.h"
+#include "praxis.h"
+
+/* Common Block Declarations */
+
+struct global_s {
+    double fx, ldt, dmin__;
+    int nf, nl;
+};
+
+struct q_s {
+     double *v; /* size n x n */
+     double *q0, *q1, *t_flin; /* size n */
+     double qa, qb, qc, qd0, qd1, qf1;
+
+     double fbest, *xbest; /* size n */
+     nlopt_stopping *stop;
+};
+
+/* Table of constant values */
+
+static int pow_ii(int x, int n) /* compute x^n, n >= 0 */
+{
+     int p = 1;
+     while (n > 0) {
+         if (n & 1) { n--; p *= x; }
+         else { n >>= 1; x *= x; }
+     }
+     return p;
+}
+
+static void minfit_(int m, int n, double machep, 
+            double *tol, double *ab, double *q, double *ework);
+static nlopt_result min_(int n, int j, int nits, double *d2, double *x1, double *f1, int fk, praxis_func f, void *f_data, double *x, double *t_old, double machep, double *h__, struct global_s *global_1, struct q_s *q_1);
+static double flin_(int n, int j, double *l, praxis_func f, void *f_data, double *x, int *nf, struct q_s *q_1, nlopt_result *ret);
+static void sort_(int m, int n, double *d__, double *v);
+static void quad_(int n, praxis_func f, void *f_data, double *x, 
+                 double *t_old, double machep, double *h__, struct global_s *global_1, struct q_s *q_1);
+
+nlopt_result praxis_(double t0, double machep, double h0, 
+                    int n, double *x, praxis_func f, void *f_data,
+                    nlopt_stopping *stop, double *minf)
+{
+    /* System generated locals */
+    int i__1, i__2, i__3;
+    nlopt_result ret = NLOPT_SUCCESS;
+    double d__1;
+
+    /* Global */
+    struct global_s global_1;
+    struct q_s q_1;
+
+    /* Local variables */
+    double *d__, *y, *z__, *e_minfit, *prev_xbest; /* size n */
+    double prev_fbest;
+    double h__;
+    int i__, j, k;
+    double s, t_old, f1;
+    int k2;
+    double m2, m4, t2_old, df, dn;
+    int kl, ii;
+    double sf;
+    int kt;
+    double sl;
+    int im1, km1;
+    double dni, lds;
+    int ktm;
+    double scbd;
+    int illc;
+    int klmk;
+    double ldfac, large, small, value;
+    double vlarge;
+    double vsmall;
+    double *work;
+
+/*                             LAST MODIFIED 3/1/73 */
+/*            Modified August 2007 by S. G. Johnson:
+                 after conversion to C via f2c and some manual cleanup,
+                 eliminating write statements, I additionally:
+                    - modified the routine to use NLopt stop criteria
+                    - allocate arrays dynamically to allow n > 20
+                    - return the NLopt return code, where the min.
+                      function value is now given by the parameter minf
+*/
+/*     PRAXIS RETURNS THE MINIMUM OF THE FUNCTION F(N,X) OF N VARIABLES */
+/*     USING THE PRINCIPAL AXIS METHOD.  THE GRADIENT OF THE FUNCTION IS */
+/*     NOT REQUIRED. */
+
+/*     FOR A DESCRIPTION OF THE ALGORITHM, SEE CHAPTER SEVEN OF */
+/*     "ALGORITHMS FOR FINDING ZEROS AND EXTREMA OF FUNCTIONS WITHOUT */
+/*     CALCULATING DERIVATIVES" BY RICHARD P BRENT. */
+
+/*     THE PARAMETERS ARE: */
+/*     T0       IS A TOLERANCE.  PRAXIS ATTEMPTS TO RETURN PRAXIS=F(X) */
+/*              SUCH THAT IF X0 IS THE TRUE LOCAL MINIMUM NEAR X, THEN */
+/*              NORM(X-X0) < T0 + SQUAREROOT(MACHEP)*NORM(X). */
+/*     MACHEP   IS THE MACHINE PRECISION, THE SMALLEST NUMBER SUCH THAT */
+/*              1 + MACHEP > 1.  MACHEP SHOULD BE 16.**-13 (ABOUT */
+/*              2.22D-16) FOR REAL*8 ARITHMETIC ON THE IBM 360. */
+/*     H0       IS THE MAXIMUM STEP SIZE.  H0 SHOULD BE SET TO ABOUT THE */
+/*              MAXIMUM DISTANCE FROM THE INITIAL GUESS TO THE MINIMUM. */
+/*              (IF H0 IS SET TOO LARGE OR TOO SMALL, THE INITIAL RATE OF */
+/*              CONVERGENCE MAY BE SLOW.) */
+/*     N        (AT LEAST TWO) IS THE NUMBER OF VARIABLES UPON WHICH */
+/*              THE FUNCTION DEPENDS. */
+/*     X        IS AN ARRAY CONTAINING ON ENTRY A GUESS OF THE POINT OF */
+/*              MINIMUM, ON RETURN THE ESTIMATED POINT OF MINIMUM. */
+/*     F(N,X)   IS THE FUNCTION TO BE MINIMIZED.  F SHOULD BE A REAL*8 */
+/*              FUNCTION DECLARED EXTERNAL IN THE CALLING PROGRAM. */
+/*     THE APPROXIMATING QUADRATIC FORM IS */
+/*              Q(X') = F(N,X) + (1/2) * (X'-X)-TRANSPOSE * A * (X'-X) */
+/*     WHERE X IS THE BEST ESTIMATE OF THE MINIMUM AND A IS */
+/*              INVERSE(V-TRANSPOSE) * D * INVERSE(V) */
+/*     (V(*,*) IS THE MATRIX OF SEARCH DIRECTIONS; D(*) IS THE ARRAY */
+/*     OF SECOND DIFFERENCES).  IF F HAS CONTINUOUS SECOND DERIVATIVES */
+/*     NEAR X0, A WILL TEND TO THE HESSIAN OF F AT X0 AS X APPROACHES X0. */
+
+/*     IT IS ASSUMED THAT ON FLOATING-POINT UNDERFLOW THE RESULT IS SET */
+/*     TO ZERO. */
+/*     THE USER SHOULD OBSERVE THE COMMENT ON HEURISTIC NUMBERS AFTER */
+/*     THE INITIALIZATION OF MACHINE DEPENDENT NUMBERS. */
+
+
+/* .....IF N>20 OR IF N<20 AND YOU NEED MORE SPACE, CHANGE '20' TO THE */
+/*     LARGEST VALUE OF N IN THE NEXT CARD, IN THE CARD 'IDIM=20', AND */
+/*     IN THE DIMENSION STATEMENTS IN SUBROUTINES MINFIT,MIN,FLIN,QUAD. */
+    /* ...changed by S. G. Johnson, 2007, to use malloc */
+
+/* .....INITIALIZATION..... */
+/*     MACHINE DEPENDENT NUMBERS: */
+
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    small = machep * machep;
+    vsmall = small * small;
+    large = 1. / small;
+    vlarge = 1. / vsmall;
+    m2 = sqrt(machep);
+    m4 = sqrt(m2);
+
+    /* new: dynamic allocation of temporary arrays */
+    work = (double *) malloc(sizeof(double) * (n*n + n*9));
+    if (!work) return NLOPT_OUT_OF_MEMORY;
+    q_1.v = work;
+    q_1.q0 = q_1.v + n*n;
+    q_1.q1 = q_1.q0 + n;
+    q_1.t_flin = q_1.q1 + n;
+    q_1.xbest = q_1.t_flin + n;
+    d__ = q_1.xbest + n;
+    y = d__ + n;
+    z__ = y + n;
+    e_minfit = y + n;
+    prev_xbest = e_minfit + n;
+
+/*     HEURISTIC NUMBERS: */
+/*     IF THE AXES MAY BE BADLY SCALED (WHICH IS TO BE AVOIDED IF */
+/*     POSSIBLE), THEN SET SCBD=10.  OTHERWISE SET SCBD=1. */
+/*     IF THE PROBLEM IS KNOWN TO BE ILL-CONDITIONED, SET ILLC=TRUE. */
+/*     OTHERWISE SET ILLC=FALSE. */
+/*     KTM IS THE NUMBER OF ITERATIONS WITHOUT IMPROVEMENT BEFORE THE */
+/*     ALGORITHM TERMINATES.  KTM=4 IS VERY CAUTIOUS; USUALLY KTM=1 */
+/*     IS SATISFACTORY. */
+
+    scbd = 1.;
+    illc = 0 /* false */;
+    ktm = 1;
+
+    ldfac = .01;
+    if (illc) {
+       ldfac = .1;
+    }
+    kt = 0;
+    global_1.nl = 0;
+    global_1.nf = 1;
+    prev_fbest = q_1.fbest = global_1.fx = f(n, &x[1], f_data);
+    memcpy(q_1.xbest, &x[1], n*sizeof(double));
+    memcpy(prev_xbest, &x[1], n*sizeof(double));
+    stop->nevals++;
+    q_1.stop = stop;
+    q_1.qf1 = global_1.fx;
+    if (t0 > 0)
+        t_old = small + t0;
+    else {
+        t_old = 0;
+        for (i__ = 0; i__ < n; ++i__)
+             if (stop->xtol_abs[i__] > t_old)
+                  t_old = stop->xtol_abs[i__];
+        t_old += small;
+    }
+    t2_old = t_old;
+    global_1.dmin__ = small;
+    h__ = h0;
+    if (h__ < t_old * 100) {
+       h__ = t_old * 100;
+    }
+    global_1.ldt = h__;
+/* .....THE FIRST SET OF SEARCH DIRECTIONS V IS THE IDENTITY MATRIX..... */
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       i__2 = n;
+       for (j = 1; j <= i__2; ++j) {
+/* L10: */
+           q_1.v[i__ + j * n - (n+1)] = 0.;
+       }
+/* L20: */
+       q_1.v[i__ + i__ * n - (n+1)] = 1.;
+    }
+    d__[0] = 0.;
+    q_1.qd0 = 0.;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       q_1.q0[i__ - 1] = x[i__];
+/* L30: */
+       q_1.q1[i__ - 1] = x[i__];
+    }
+
+/* .....THE MAIN LOOP STARTS HERE..... */
+L40:
+    sf = d__[0];
+    d__[0] = 0.;
+    s = 0.;
+
+/* .....MINIMIZE ALONG THE FIRST DIRECTION V(*,1). */
+/*     FX MUST BE PASSED TO MIN BY VALUE. */
+    value = global_1.fx;
+    ret = min_(n, 1, 2, d__, &s, &value, 0, f,f_data, &x[1], 
+           &t_old, machep, &h__, &global_1, &q_1);
+    if (ret != NLOPT_SUCCESS) goto done;
+    if (s > 0.) {
+       goto L50;
+    }
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L45: */
+       q_1.v[i__ - 1] = -q_1.v[i__ - 1];
+    }
+L50:
+    if (sf > d__[0] * .9 && sf * .9 < d__[0]) {
+       goto L70;
+    }
+    i__1 = n;
+    for (i__ = 2; i__ <= i__1; ++i__) {
+/* L60: */
+       d__[i__ - 1] = 0.;
+    }
+
+/* .....THE INNER LOOP STARTS HERE..... */
+L70:
+    i__1 = n;
+    for (k = 2; k <= i__1; ++k) {
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L75: */
+           y[i__ - 1] = x[i__];
+       }
+       sf = global_1.fx;
+       if (kt > 0) {
+           illc = 1 /* true */;
+       }
+L80:
+       kl = k;
+       df = 0.;
+
+/* .....A RANDOM STEP FOLLOWS (TO AVOID RESOLUTION VALLEYS). */
+/*     PRAXIS ASSUMES THAT RANDOM RETURNS A RANDOM NUMBER UNIFORMLY */
+/*     DISTRIBUTED IN (0,1). */
+
+       if (! illc) {
+           goto L95;
+       }
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+            s = (global_1.ldt * .1 + t2_old * pow_ii(10, kt)) 
+                 * nlopt_urand(-.5,.5);
+            /* was: (random_(n) - .5); */
+           z__[i__ - 1] = s;
+           i__3 = n;
+           for (j = 1; j <= i__3; ++j) {
+/* L85: */
+               x[j] += s * q_1.v[j + i__ * n - (n+1)];
+           }
+/* L90: */
+       }
+       global_1.fx = (*f)(n, &x[1], f_data);
+       ++global_1.nf;
+
+/* .....MINIMIZE ALONG THE "NON-CONJUGATE" DIRECTIONS V(*,K),...,V(*,N) */
+
+L95:
+       i__2 = n;
+       for (k2 = k; k2 <= i__2; ++k2) {
+           sl = global_1.fx;
+           s = 0.;
+           value = global_1.fx;
+           ret = min_(n, k2, 2, &d__[k2 - 1], &s, &value, 0, f,f_data, &
+                      x[1], &t_old, machep, &h__, &global_1, &q_1);
+           if (ret != NLOPT_SUCCESS) goto done;
+           if (illc) {
+               goto L97;
+           }
+           s = sl - global_1.fx;
+           goto L99;
+L97:
+/* Computing 2nd power */
+           d__1 = s + z__[k2 - 1];
+           s = d__[k2 - 1] * (d__1 * d__1);
+L99:
+           if (df > s) {
+               goto L105;
+           }
+           df = s;
+           kl = k2;
+L105:
+           ;
+       }
+       if (illc || df >= (d__1 = machep * 100 * global_1.fx, fabs(d__1))) {
+           goto L110;
+       }
+
+/* .....IF THERE WAS NOT MUCH IMPROVEMENT ON THE FIRST TRY, SET */
+/*     ILLC=TRUE AND START THE INNER LOOP AGAIN..... */
+
+       illc = 1 /* true */;
+       goto L80;
+L110:
+
+/* .....MINIMIZE ALONG THE "CONJUGATE" DIRECTIONS V(*,1),...,V(*,K-1) */
+
+       km1 = k - 1;
+       i__2 = km1;
+       for (k2 = 1; k2 <= i__2; ++k2) {
+           s = 0.;
+           value = global_1.fx;
+           ret = min_(n, k2, 2, &d__[k2 - 1], &s, &value, 0, f,f_data, &
+                      x[1], &t_old, machep, &h__, &global_1, &q_1);
+           if (ret != NLOPT_SUCCESS) goto done;
+/* L120: */
+       }
+       f1 = global_1.fx;
+       global_1.fx = sf;
+       lds = 0.;
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           sl = x[i__];
+           x[i__] = y[i__ - 1];
+           sl -= y[i__ - 1];
+           y[i__ - 1] = sl;
+/* L130: */
+           lds += sl * sl;
+       }
+       lds = sqrt(lds);
+       if (lds <= small) {
+           goto L160;
+       }
+
+/* .....DISCARD DIRECTION V(*,KL). */
+/*     IF NO RANDOM STEP WAS TAKEN, V(*,KL) IS THE "NON-CONJUGATE" */
+/*     DIRECTION ALONG WHICH THE GREATEST IMPROVEMENT WAS MADE..... */
+
+       klmk = kl - k;
+       if (klmk < 1) {
+           goto L141;
+       }
+       i__2 = klmk;
+       for (ii = 1; ii <= i__2; ++ii) {
+           i__ = kl - ii;
+           i__3 = n;
+           for (j = 1; j <= i__3; ++j) {
+/* L135: */
+               q_1.v[j + (i__ + 1) * n - (n+1)] = q_1.v[j + i__ * n - (n+1)];
+           }
+/* L140: */
+           d__[i__] = d__[i__ - 1];
+       }
+L141:
+       d__[k - 1] = 0.;
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L145: */
+           q_1.v[i__ + k * n - (n+1)] = y[i__ - 1] / lds;
+       }
+
+/* .....MINIMIZE ALONG THE NEW "CONJUGATE" DIRECTION V(*,K), WHICH IS */
+/*     THE NORMALIZED VECTOR:  (NEW X) - (0LD X)..... */
+
+       value = f1;
+       ret = min_(n, k, 4, &d__[k - 1], &lds, &value, 1, f,f_data, &x[1],
+                  &t_old, machep, &h__, &global_1, &q_1);
+       if (ret != NLOPT_SUCCESS) goto done;
+       if (lds > 0.) {
+           goto L160;
+       }
+       lds = -lds;
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L150: */
+           q_1.v[i__ + k * n - (n+1)] = -q_1.v[i__ + k * n - (n+1)];
+       }
+L160:
+       global_1.ldt = ldfac * global_1.ldt;
+       if (global_1.ldt < lds) {
+           global_1.ldt = lds;
+       }
+       t2_old = 0.;
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L165: */
+/* Computing 2nd power */
+           d__1 = x[i__];
+           t2_old += d__1 * d__1;
+       }
+       t2_old = m2 * sqrt(t2_old) + t_old;
+
+/* .....SEE WHETHER THE LENGTH OF THE STEP TAKEN SINCE STARTING THE */
+/*     INNER LOOP EXCEEDS HALF THE TOLERANCE..... */
+
+       if (global_1.ldt > t2_old * .5f
+           && !nlopt_stop_f(stop, q_1.fbest, prev_fbest)
+           && !nlopt_stop_x(stop, q_1.xbest, prev_xbest)) {
+           kt = -1;
+       }
+       ++kt;
+       if (kt > ktm) {
+            if (nlopt_stop_f(stop, q_1.fbest, prev_fbest))
+                 ret = NLOPT_FTOL_REACHED;
+            else if (nlopt_stop_x(stop, q_1.xbest, prev_xbest))
+                 ret = NLOPT_XTOL_REACHED;
+            goto done;
+       }
+       prev_fbest = q_1.fbest;
+       memcpy(prev_xbest, q_1.xbest, n * sizeof(double));
+/* L170: */
+    }
+/* .....THE INNER LOOP ENDS HERE. */
+
+/*     TRY QUADRATIC EXTRAPOLATION IN CASE WE ARE IN A CURVED VALLEY. */
+
+/* L171: */
+    quad_(n, f,f_data, &x[1], &t_old, machep, &h__, &global_1, &q_1);
+    dn = 0.;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       d__[i__ - 1] = 1. / sqrt(d__[i__ - 1]);
+       if (dn < d__[i__ - 1]) {
+           dn = d__[i__ - 1];
+       }
+/* L175: */
+    }
+    i__1 = n;
+    for (j = 1; j <= i__1; ++j) {
+       s = d__[j - 1] / dn;
+       i__2 = n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L180: */
+           q_1.v[i__ + j * n - (n+1)] = s * q_1.v[i__ + j * n - (n+1)];
+       }
+    }
+
+/* .....SCALE THE AXES TO TRY TO REDUCE THE CONDITION NUMBER..... */
+
+    if (scbd <= 1.) {
+       goto L200;
+    }
+    s = vlarge;
+    i__2 = n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       sl = 0.;
+       i__1 = n;
+       for (j = 1; j <= i__1; ++j) {
+/* L182: */
+           sl += q_1.v[i__ + j * n - (n+1)] * q_1.v[i__ + j * n - (n+1)];
+       }
+       z__[i__ - 1] = sqrt(sl);
+       if (z__[i__ - 1] < m4) {
+           z__[i__ - 1] = m4;
+       }
+       if (s > z__[i__ - 1]) {
+           s = z__[i__ - 1];
+       }
+/* L185: */
+    }
+    i__2 = n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       sl = s / z__[i__ - 1];
+       z__[i__ - 1] = 1. / sl;
+       if (z__[i__ - 1] <= scbd) {
+           goto L189;
+       }
+       sl = 1. / scbd;
+       z__[i__ - 1] = scbd;
+L189:
+       i__1 = n;
+       for (j = 1; j <= i__1; ++j) {
+/* L190: */
+           q_1.v[i__ + j * n - (n+1)] = sl * q_1.v[i__ + j * n - (n+1)];
+       }
+/* L195: */
+    }
+
+/* .....CALCULATE A NEW SET OF ORTHOGONAL DIRECTIONS BEFORE REPEATING */
+/*     THE MAIN LOOP. */
+/*     FIRST TRANSPOSE V FOR MINFIT: */
+
+L200:
+    i__2 = n;
+    for (i__ = 2; i__ <= i__2; ++i__) {
+       im1 = i__ - 1;
+       i__1 = im1;
+       for (j = 1; j <= i__1; ++j) {
+           s = q_1.v[i__ + j * n - (n+1)];
+           q_1.v[i__ + j * n - (n+1)] = q_1.v[j + i__ * n - (n+1)];
+/* L210: */
+           q_1.v[j + i__ * n - (n+1)] = s;
+       }
+/* L220: */
+    }
+
+/* .....CALL MINFIT TO FIND THE SINGULAR VALUE DECOMPOSITION OF V. */
+/*     THIS GIVES THE PRINCIPAL VALUES AND PRINCIPAL DIRECTIONS OF THE */
+/*     APPROXIMATING QUADRATIC FORM WITHOUT SQUARING THE CONDITION */
+/*     NUMBER..... */
+
+    minfit_(n, n, machep, &vsmall, q_1.v, d__, e_minfit);
+
+/* .....UNSCALE THE AXES..... */
+
+    if (scbd <= 1.) {
+       goto L250;
+    }
+    i__2 = n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       s = z__[i__ - 1];
+       i__1 = n;
+       for (j = 1; j <= i__1; ++j) {
+/* L225: */
+           q_1.v[i__ + j * n - (n+1)] = s * q_1.v[i__ + j * n - (n+1)];
+       }
+/* L230: */
+    }
+    i__2 = n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       s = 0.;
+       i__1 = n;
+       for (j = 1; j <= i__1; ++j) {
+/* L235: */
+/* Computing 2nd power */
+           d__1 = q_1.v[j + i__ * n - (n+1)];
+           s += d__1 * d__1;
+       }
+       s = sqrt(s);
+       d__[i__ - 1] = s * d__[i__ - 1];
+       s = 1 / s;
+       i__1 = n;
+       for (j = 1; j <= i__1; ++j) {
+/* L240: */
+           q_1.v[j + i__ * n - (n+1)] = s * q_1.v[j + i__ * n - (n+1)];
+       }
+/* L245: */
+    }
+
+L250:
+    i__2 = n;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       dni = dn * d__[i__ - 1];
+       if (dni > large) {
+           goto L265;
+       }
+       if (dni < small) {
+           goto L260;
+       }
+       d__[i__ - 1] = 1 / (dni * dni);
+       goto L270;
+L260:
+       d__[i__ - 1] = vlarge;
+       goto L270;
+L265:
+       d__[i__ - 1] = vsmall;
+L270:
+       ;
+    }
+
+/* .....SORT THE EIGENVALUES AND EIGENVECTORS..... */
+
+    sort_(n, n, d__, q_1.v);
+    global_1.dmin__ = d__[n - 1];
+    if (global_1.dmin__ < small) {
+       global_1.dmin__ = small;
+    }
+    illc = 0 /* false */;
+    if (m2 * d__[0] > global_1.dmin__) {
+       illc = 1 /* true */;
+    }
+
+/* .....THE MAIN LOOP ENDS HERE..... */
+
+    goto L40;
+
+/* .....RETURN..... */
+
+done:
+    if (ret != NLOPT_OUT_OF_MEMORY) {
+        *minf = q_1.fbest;
+        memcpy(&x[1], q_1.xbest, n * sizeof(double));
+    }
+    free(work);
+    return ret;
+} /* praxis_ */
+
+static void minfit_(int m, int n, double machep, 
+       double *tol, double *ab, double *q, double *ework)
+{
+    /* System generated locals */
+    int ab_dim1, ab_offset, i__1, i__2, i__3;
+    double d__1, d__2;
+
+    /* Local variables */
+    double *e; /* size n */
+    double c__, f, g, h__;
+    int i__, j, k, l;
+    double s, x, y, z__;
+    int l2, ii, kk, kt, ll2, lp1;
+    double eps, temp;
+    
+    e = ework;
+
+/* ...AN IMPROVED VERSION OF MINFIT (SEE GOLUB AND REINSCH, 1969) */
+/*   RESTRICTED TO M=N,P=0. */
+/*   THE SINGULAR VALUES OF THE ARRAY AB ARE RETURNED IN Q AND AB IS */
+/*   OVERWRITTEN WITH THE ORTHOGONAL MATRIX V SUCH THAT U.DIAG(Q) = AB.V, */
+/*   WHERE U IS ANOTHER ORTHOGONAL MATRIX. */
+/* ...HOUSEHOLDER'S REDUCTION TO BIDIAGONAL FORM... */
+    /* Parameter adjustments */
+    --q;
+    ab_dim1 = m;
+    ab_offset = 1 + ab_dim1;
+    ab -= ab_offset;
+
+    /* Function Body */
+    if (n == 1) {
+       goto L200;
+    }
+    eps = machep;
+    g = 0.;
+    x = 0.;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       e[i__ - 1] = g;
+       s = 0.;
+       l = i__ + 1;
+       i__2 = n;
+       for (j = i__; j <= i__2; ++j) {
+/* L1: */
+/* Computing 2nd power */
+           d__1 = ab[j + i__ * ab_dim1];
+           s += d__1 * d__1;
+       }
+       g = 0.;
+       if (s < *tol) {
+           goto L4;
+       }
+       f = ab[i__ + i__ * ab_dim1];
+       g = sqrt(s);
+       if (f >= 0.) {
+           g = -g;
+       }
+       h__ = f * g - s;
+       ab[i__ + i__ * ab_dim1] = f - g;
+       if (l > n) {
+           goto L4;
+       }
+       i__2 = n;
+       for (j = l; j <= i__2; ++j) {
+           f = 0.;
+           i__3 = n;
+           for (k = i__; k <= i__3; ++k) {
+/* L2: */
+               f += ab[k + i__ * ab_dim1] * ab[k + j * ab_dim1];
+           }
+           f /= h__;
+           i__3 = n;
+           for (k = i__; k <= i__3; ++k) {
+/* L3: */
+               ab[k + j * ab_dim1] += f * ab[k + i__ * ab_dim1];
+           }
+       }
+L4:
+       q[i__] = g;
+       s = 0.;
+       if (i__ == n) {
+           goto L6;
+       }
+       i__3 = n;
+       for (j = l; j <= i__3; ++j) {
+/* L5: */
+           s += ab[i__ + j * ab_dim1] * ab[i__ + j * ab_dim1];
+       }
+L6:
+       g = 0.;
+       if (s < *tol) {
+           goto L10;
+       }
+       if (i__ == n) {
+           goto L16;
+       }
+       f = ab[i__ + (i__ + 1) * ab_dim1];
+L16:
+       g = sqrt(s);
+       if (f >= 0.) {
+           g = -g;
+       }
+       h__ = f * g - s;
+       if (i__ == n) {
+           goto L10;
+       }
+       ab[i__ + (i__ + 1) * ab_dim1] = f - g;
+       i__3 = n;
+       for (j = l; j <= i__3; ++j) {
+/* L7: */
+           e[j - 1] = ab[i__ + j * ab_dim1] / h__;
+       }
+       i__3 = n;
+       for (j = l; j <= i__3; ++j) {
+           s = 0.;
+           i__2 = n;
+           for (k = l; k <= i__2; ++k) {
+/* L8: */
+               s += ab[j + k * ab_dim1] * ab[i__ + k * ab_dim1];
+           }
+           i__2 = n;
+           for (k = l; k <= i__2; ++k) {
+/* L9: */
+               ab[j + k * ab_dim1] += s * e[k - 1];
+           }
+       }
+L10:
+       y = (d__1 = q[i__], fabs(d__1)) + (d__2 = e[i__ - 1], fabs(d__2));
+/* L11: */
+       if (y > x) {
+           x = y;
+       }
+    }
+/* ...ACCUMULATION OF RIGHT-HAND TRANSFORMATIONS... */
+    ab[n + n * ab_dim1] = 1.;
+    g = e[n - 1];
+    l = n;
+    i__1 = n;
+    for (ii = 2; ii <= i__1; ++ii) {
+       i__ = n - ii + 1;
+       if (g == 0.) {
+           goto L23;
+       }
+       h__ = ab[i__ + (i__ + 1) * ab_dim1] * g;
+       i__2 = n;
+       for (j = l; j <= i__2; ++j) {
+/* L20: */
+           ab[j + i__ * ab_dim1] = ab[i__ + j * ab_dim1] / h__;
+       }
+       i__2 = n;
+       for (j = l; j <= i__2; ++j) {
+           s = 0.;
+           i__3 = n;
+           for (k = l; k <= i__3; ++k) {
+/* L21: */
+               s += ab[i__ + k * ab_dim1] * ab[k + j * ab_dim1];
+           }
+           i__3 = n;
+           for (k = l; k <= i__3; ++k) {
+/* L22: */
+               ab[k + j * ab_dim1] += s * ab[k + i__ * ab_dim1];
+           }
+       }
+L23:
+       i__3 = n;
+       for (j = l; j <= i__3; ++j) {
+           ab[i__ + j * ab_dim1] = 0.;
+/* L24: */
+           ab[j + i__ * ab_dim1] = 0.;
+       }
+       ab[i__ + i__ * ab_dim1] = 1.;
+       g = e[i__ - 1];
+/* L25: */
+       l = i__;
+    }
+/* ...DIAGONALIZATION OF THE BIDIAGONAL FORM... */
+/* L100: */
+    eps *= x;
+    i__1 = n;
+    for (kk = 1; kk <= i__1; ++kk) {
+       k = n - kk + 1;
+       kt = 0;
+L101:
+       ++kt;
+       if (kt <= 30) {
+           goto L102;
+       }
+       e[k - 1] = 0.;
+       /* fprintf(stderr, "QR failed\n"); */
+L102:
+       i__3 = k;
+       for (ll2 = 1; ll2 <= i__3; ++ll2) {
+           l2 = k - ll2 + 1;
+           l = l2;
+           if ((d__1 = e[l - 1], fabs(d__1)) <= eps) {
+               goto L120;
+           }
+           if (l == 1) {
+               goto L103;
+           }
+           if ((d__1 = q[l - 1], fabs(d__1)) <= eps) {
+               goto L110;
+           }
+L103:
+           ;
+       }
+/* ...CANCELLATION OF E(L) IF L>1... */
+L110:
+       c__ = 0.;
+       s = 1.;
+       i__3 = k;
+       for (i__ = l; i__ <= i__3; ++i__) {
+           f = s * e[i__ - 1];
+           e[i__ - 1] = c__ * e[i__ - 1];
+           if (fabs(f) <= eps) {
+               goto L120;
+           }
+           g = q[i__];
+/* ...Q(I) = H = DSQRT(G*G + F*F)... */
+           if (fabs(f) < fabs(g)) {
+               goto L113;
+           }
+           if (f != 0.) {
+               goto L112;
+           } else {
+               goto L111;
+           }
+L111:
+           h__ = 0.;
+           goto L114;
+L112:
+/* Computing 2nd power */
+           d__1 = g / f;
+           h__ = fabs(f) * sqrt(d__1 * d__1 + 1);
+           goto L114;
+L113:
+/* Computing 2nd power */
+           d__1 = f / g;
+           h__ = fabs(g) * sqrt(d__1 * d__1 + 1);
+L114:
+           q[i__] = h__;
+           if (h__ != 0.) {
+               goto L115;
+           }
+           g = 1.;
+           h__ = 1.;
+L115:
+           c__ = g / h__;
+/* L116: */
+           s = -f / h__;
+       }
+/* ...TEST FOR CONVERGENCE... */
+L120:
+       z__ = q[k];
+       if (l == k) {
+           goto L140;
+       }
+/* ...SHIFT FROM BOTTOM 2*2 MINOR... */
+       x = q[l];
+       y = q[k - 1];
+       g = e[k - 2];
+       h__ = e[k - 1];
+       f = ((y - z__) * (y + z__) + (g - h__) * (g + h__)) / (h__ * 2 * y);
+       g = sqrt(f * f + 1.);
+       temp = f - g;
+       if (f >= 0.) {
+           temp = f + g;
+       }
+       f = ((x - z__) * (x + z__) + h__ * (y / temp - h__)) / x;
+/* ...NEXT QR TRANSFORMATION... */
+       c__ = 1.;
+       s = 1.;
+       lp1 = l + 1;
+       if (lp1 > k) {
+           goto L133;
+       }
+       i__3 = k;
+       for (i__ = lp1; i__ <= i__3; ++i__) {
+           g = e[i__ - 1];
+           y = q[i__];
+           h__ = s * g;
+           g *= c__;
+           if (fabs(f) < fabs(h__)) {
+               goto L123;
+           }
+           if (f != 0.) {
+               goto L122;
+           } else {
+               goto L121;
+           }
+L121:
+           z__ = 0.;
+           goto L124;
+L122:
+/* Computing 2nd power */
+           d__1 = h__ / f;
+           z__ = fabs(f) * sqrt(d__1 * d__1 + 1);
+           goto L124;
+L123:
+/* Computing 2nd power */
+           d__1 = f / h__;
+           z__ = fabs(h__) * sqrt(d__1 * d__1 + 1);
+L124:
+           e[i__ - 2] = z__;
+           if (z__ != 0.) {
+               goto L125;
+           }
+           f = 1.;
+           z__ = 1.;
+L125:
+           c__ = f / z__;
+           s = h__ / z__;
+           f = x * c__ + g * s;
+           g = -x * s + g * c__;
+           h__ = y * s;
+           y *= c__;
+           i__2 = n;
+           for (j = 1; j <= i__2; ++j) {
+               x = ab[j + (i__ - 1) * ab_dim1];
+               z__ = ab[j + i__ * ab_dim1];
+               ab[j + (i__ - 1) * ab_dim1] = x * c__ + z__ * s;
+/* L126: */
+               ab[j + i__ * ab_dim1] = -x * s + z__ * c__;
+           }
+           if (fabs(f) < fabs(h__)) {
+               goto L129;
+           }
+           if (f != 0.) {
+               goto L128;
+           } else {
+               goto L127;
+           }
+L127:
+           z__ = 0.;
+           goto L130;
+L128:
+/* Computing 2nd power */
+           d__1 = h__ / f;
+           z__ = fabs(f) * sqrt(d__1 * d__1 + 1);
+           goto L130;
+L129:
+/* Computing 2nd power */
+           d__1 = f / h__;
+           z__ = fabs(h__) * sqrt(d__1 * d__1 + 1);
+L130:
+           q[i__ - 1] = z__;
+           if (z__ != 0.) {
+               goto L131;
+           }
+           f = 1.;
+           z__ = 1.;
+L131:
+           c__ = f / z__;
+           s = h__ / z__;
+           f = c__ * g + s * y;
+/* L132: */
+           x = -s * g + c__ * y;
+       }
+L133:
+       e[l - 1] = 0.;
+       e[k - 1] = f;
+       q[k] = x;
+       goto L101;
+/* ...CONVERGENCE:  Q(K) IS MADE NON-NEGATIVE... */
+L140:
+       if (z__ >= 0.) {
+           goto L150;
+       }
+       q[k] = -z__;
+       i__3 = n;
+       for (j = 1; j <= i__3; ++j) {
+/* L141: */
+           ab[j + k * ab_dim1] = -ab[j + k * ab_dim1];
+       }
+L150:
+       ;
+    }
+    return;
+L200:
+    q[1] = ab[ab_dim1 + 1];
+    ab[ab_dim1 + 1] = 1.;
+} /* minfit_ */
+
+static nlopt_result min_(int n, int j, int nits, double *
+       d2, double *x1, double *f1, int fk, praxis_func f, void *f_data, double *
+       x, double *t_old, double machep, double *h__, struct global_s *global_1, struct q_s *q_1)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__, k;
+    double s, d1, f0, f2, m2, m4, t2, x2, fm;
+    int dz;
+    double xm, sf1, sx1;
+    double temp, small;
+    nlopt_result ret = NLOPT_SUCCESS;
+
+/* ...THE SUBROUTINE MIN MINIMIZES F FROM X IN THE DIRECTION V(*,J) UNLESS */
+/*   J IS LESS THAN 1, WHEN A QUADRATIC SEARCH IS MADE IN THE PLANE */
+/*   DEFINED BY Q0,Q1,X. */
+/*   D2 IS EITHER ZERO OR AN APPROXIMATION TO HALF F". */
+/*   ON ENTRY, X1 IS AN ESTIMATE OF THE DISTANCE FROM X TO THE MINIMUM */
+/*   ALONG V(*,J) (OR, IF J=0, A CURVE).  ON RETURN, X1 IS THE DISTANCE */
+/*   FOUND. */
+/*   IF FK=.TRUE., THEN F1 IS FLIN(X1).  OTHERWISE X1 AND F1 ARE IGNORED */
+/*   ON ENTRY UNLESS FINAL FX IS GREATER THAN F1. */
+/*   NITS CONTROLS THE NUMBER OF TIMES AN ATTEMPT WILL BE MADE TO HALVE */
+/*   THE INTERVAL. */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+/* Computing 2nd power */
+    d__1 = machep;
+    small = d__1 * d__1;
+    m2 = sqrt(machep);
+    m4 = sqrt(m2);
+    sf1 = *f1;
+    sx1 = *x1;
+    k = 0;
+    xm = 0.;
+    fm = global_1->fx;
+    f0 = global_1->fx;
+    dz = *d2 < machep;
+/* ...FIND THE STEP SIZE... */
+    s = 0.;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L1: */
+/* Computing 2nd power */
+       d__1 = x[i__];
+       s += d__1 * d__1;
+    }
+    s = sqrt(s);
+    temp = *d2;
+    if (dz) {
+       temp = global_1->dmin__;
+    }
+    t2 = m4 * sqrt(fabs(global_1->fx) / temp + s * global_1->ldt) + m2 * 
+           global_1->ldt;
+    s = m4 * s + *t_old;
+    if (dz && t2 > s) {
+       t2 = s;
+    }
+    t2 = t2 > small ? t2 : small;
+/* Computing MIN */
+    d__1 = t2, d__2 = *h__ * .01;
+    t2 = d__1 < d__2 ? d__1 : d__2;
+    if (! (fk) || *f1 > fm) {
+       goto L2;
+    }
+    xm = *x1;
+    fm = *f1;
+L2:
+    if (fk && fabs(*x1) >= t2) {
+       goto L3;
+    }
+    temp = 1.;
+    if (*x1 < 0.) {
+       temp = -1.;
+    }
+    *x1 = temp * t2;
+    *f1 = flin_(n, j, x1, f,f_data, &x[1], &global_1->nf, q_1, &ret);
+    if (ret != NLOPT_SUCCESS) return ret;
+L3:
+    if (*f1 > fm) {
+       goto L4;
+    }
+    xm = *x1;
+    fm = *f1;
+L4:
+    if (! dz) {
+       goto L6;
+    }
+/* ...EVALUATE FLIN AT ANOTHER POINT AND ESTIMATE THE SECOND DERIVATIVE... */
+    x2 = -(*x1);
+    if (f0 >= *f1) {
+       x2 = *x1 * 2.;
+    }
+    f2 = flin_(n, j, &x2, f,f_data, &x[1], &global_1->nf, q_1, &ret);
+    if (ret != NLOPT_SUCCESS) return ret;
+    if (f2 > fm) {
+       goto L5;
+    }
+    xm = x2;
+    fm = f2;
+L5:
+    *d2 = (x2 * (*f1 - f0) - *x1 * (f2 - f0)) / (*x1 * x2 * (*x1 - x2));
+/* ...ESTIMATE THE FIRST DERIVATIVE AT 0... */
+L6:
+    d1 = (*f1 - f0) / *x1 - *x1 * *d2;
+    dz = 1 /* true */;
+/* ...PREDICT THE MINIMUM... */
+    if (*d2 > small) {
+       goto L7;
+    }
+    x2 = *h__;
+    if (d1 >= 0.) {
+       x2 = -x2;
+    }
+    goto L8;
+L7:
+    x2 = d1 * -.5 / *d2;
+L8:
+    if (fabs(x2) <= *h__) {
+       goto L11;
+    }
+    if (x2 <= 0.) {
+       goto L9;
+    } else {
+       goto L10;
+    }
+L9:
+    x2 = -(*h__);
+    goto L11;
+L10:
+    x2 = *h__;
+/* ...EVALUATE F AT THE PREDICTED MINIMUM... */
+L11:
+    f2 = flin_(n, j, &x2, f,f_data, &x[1], &global_1->nf, q_1, &ret);
+    if (ret != NLOPT_SUCCESS) return ret;
+    if (k >= nits || f2 <= f0) {
+       goto L12;
+    }
+/* ...NO SUCCESS, SO TRY AGAIN... */
+    ++k;
+    if (f0 < *f1 && *x1 * x2 > 0.) {
+       goto L4;
+    }
+    x2 *= .5;
+    goto L11;
+/* ...INCREMENT THE ONE-DIMENSIONAL SEARCH COUNTER... */
+L12:
+    ++global_1->nl;
+    if (f2 <= fm) {
+       goto L13;
+    }
+    x2 = xm;
+    goto L14;
+L13:
+    fm = f2;
+/* ...GET A NEW ESTIMATE OF THE SECOND DERIVATIVE... */
+L14:
+    if ((d__1 = x2 * (x2 - *x1), fabs(d__1)) <= small) {
+       goto L15;
+    }
+    *d2 = (x2 * (*f1 - f0) - *x1 * (fm - f0)) / (*x1 * x2 * (*x1 - x2));
+    goto L16;
+L15:
+    if (k > 0) {
+       *d2 = 0.;
+    }
+L16:
+    if (*d2 <= small) {
+       *d2 = small;
+    }
+    *x1 = x2;
+    global_1->fx = fm;
+    if (sf1 >= global_1->fx) {
+       goto L17;
+    }
+    global_1->fx = sf1;
+    *x1 = sx1;
+/* ...UPDATE X FOR LINEAR BUT NOT PARABOLIC SEARCH... */
+L17:
+    if (j == 0) {
+       return NLOPT_SUCCESS;
+    }
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L18: */
+       x[i__] += *x1 * q_1->v[i__ + j * n - (n+1)];
+    }
+    return NLOPT_SUCCESS;
+} /* min_ */
+
+static double flin_(int n, int j, double *l, praxis_func f, void *f_data, double *x,
+        int *nf, struct q_s *q_1, nlopt_result *ret)
+{
+    /* System generated locals */
+    int i__1;
+    double ret_val;
+
+    /* Local variables */
+    nlopt_stopping *stop = q_1->stop;
+    int i__;
+    double *t; /* size n */
+
+    t = q_1->t_flin;
+
+/* ...FLIN IS THE FUNCTION OF ONE REAL VARIABLE L THAT IS MINIMIZED */
+/*   BY THE SUBROUTINE MIN... */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    if (j == 0) {
+       goto L2;
+    }
+/* ...THE SEARCH IS LINEAR... */
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L1: */
+       t[i__ - 1] = x[i__] + *l * q_1->v[i__ + j * n - (n+1)];
+    }
+    goto L4;
+/* ...THE SEARCH IS ALONG A PARABOLIC SPACE CURVE... */
+L2:
+    q_1->qa = *l * (*l - q_1->qd1) / (q_1->qd0 * (q_1->qd0 + q_1->qd1));
+    q_1->qb = (*l + q_1->qd0) * (q_1->qd1 - *l) / (q_1->qd0 * q_1->qd1);
+    q_1->qc = *l * (*l + q_1->qd0) / (q_1->qd1 * (q_1->qd0 + q_1->qd1));
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L3: */
+       t[i__ - 1] = q_1->qa * q_1->q0[i__ - 1] + q_1->qb * x[i__] + q_1->qc * 
+               q_1->q1[i__ - 1];
+    }
+/* ...THE FUNCTION EVALUATION COUNTER NF IS INCREMENTED... */
+L4:
+    ++(*nf);
+    ret_val = f(n, t, f_data);
+    stop->nevals++;
+    if (ret_val < q_1->fbest) {
+        q_1->fbest = ret_val;
+        memcpy(q_1->xbest, t, n * sizeof(double));
+    }
+    if (nlopt_stop_forced(stop)) *ret = NLOPT_FORCED_STOP;
+    else if (nlopt_stop_evals(stop)) *ret = NLOPT_MAXEVAL_REACHED;
+    else if (nlopt_stop_time(stop)) *ret = NLOPT_MAXTIME_REACHED;
+    else if (ret_val <= stop->minf_max) *ret = NLOPT_MINF_MAX_REACHED;
+    return ret_val;
+} /* flin_ */
+
+static void sort_(int m, int n, double *d__, double *v)
+{
+    /* System generated locals */
+    int v_dim1, v_offset, i__1, i__2;
+
+    /* Local variables */
+    int i__, j, k;
+    double s;
+    int ip1, nm1;
+
+/* ...SORTS THE ELEMENTS OF D(N) INTO DESCENDING ORDER AND MOVES THE */
+/*   CORRESPONDING COLUMNS OF V(N,N). */
+/*   M IS THE ROW DIMENSION OF V AS DECLARED IN THE CALLING PROGRAM. */
+    /* Parameter adjustments */
+    v_dim1 = m;
+    v_offset = 1 + v_dim1;
+    v -= v_offset;
+    --d__;
+
+    /* Function Body */
+    if (n == 1) {
+       return;
+    }
+    nm1 = n - 1;
+    i__1 = nm1;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       k = i__;
+       s = d__[i__];
+       ip1 = i__ + 1;
+       i__2 = n;
+       for (j = ip1; j <= i__2; ++j) {
+           if (d__[j] <= s) {
+               goto L1;
+           }
+           k = j;
+           s = d__[j];
+L1:
+           ;
+       }
+       if (k <= i__) {
+           goto L3;
+       }
+       d__[k] = d__[i__];
+       d__[i__] = s;
+       i__2 = n;
+       for (j = 1; j <= i__2; ++j) {
+           s = v[j + i__ * v_dim1];
+           v[j + i__ * v_dim1] = v[j + k * v_dim1];
+/* L2: */
+           v[j + k * v_dim1] = s;
+       }
+L3:
+       ;
+    }
+} /* sort_ */
+
+static void quad_(int n, praxis_func f, void *f_data, double *x, double *t_old, 
+                 double machep, double *h__, struct global_s *global_1, struct q_s *q_1)
+{
+    /* System generated locals */
+    int i__1;
+    double d__1;
+
+    /* Local variables */
+    int i__;
+    double l, s;
+    double value;
+
+/* ...QUAD LOOKS FOR THE MINIMUM OF F ALONG A CURVE DEFINED BY Q0,Q1,X... */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    s = global_1->fx;
+    global_1->fx = q_1->qf1;
+    q_1->qf1 = s;
+    q_1->qd1 = 0.;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       s = x[i__];
+       l = q_1->q1[i__ - 1];
+       x[i__] = l;
+       q_1->q1[i__ - 1] = s;
+/* L1: */
+/* Computing 2nd power */
+       d__1 = s - l;
+       q_1->qd1 += d__1 * d__1;
+    }
+    q_1->qd1 = sqrt(q_1->qd1);
+    l = q_1->qd1;
+    s = 0.;
+    if (q_1->qd0 <= 0. || q_1->qd1 <= 0. || global_1->nl < n * 3 * n) {
+       goto L2;
+    }
+    value = q_1->qf1;
+    min_(n, 0, 2, &s, &l, &value, 1, f,f_data, &x[1], t_old, machep, 
+           h__, global_1, q_1);
+    q_1->qa = l * (l - q_1->qd1) / (q_1->qd0 * (q_1->qd0 + q_1->qd1));
+    q_1->qb = (l + q_1->qd0) * (q_1->qd1 - l) / (q_1->qd0 * q_1->qd1);
+    q_1->qc = l * (l + q_1->qd0) / (q_1->qd1 * (q_1->qd0 + q_1->qd1));
+    goto L3;
+L2:
+    global_1->fx = q_1->qf1;
+    q_1->qa = 0.;
+    q_1->qb = q_1->qa;
+    q_1->qc = 1.;
+L3:
+    q_1->qd0 = q_1->qd1;
+    i__1 = n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       s = q_1->q0[i__ - 1];
+       q_1->q0[i__ - 1] = x[i__];
+/* L4: */
+       x[i__] = q_1->qa * s + q_1->qb * x[i__] + q_1->qc * q_1->q1[i__ - 1];
+    }
+} /* quad_ */
diff --git a/praxis/praxis.h b/praxis/praxis.h
new file mode 100644 (file)
index 0000000..59ad0bd
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef PRAXIS_H
+#define PRAXIS_H
+
+#include "nlopt-util.h"
+#include "nlopt.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef double (*praxis_func)(int n, const double *x, void *f_data);
+
+nlopt_result praxis_(double t0, double machep, double h0,
+                    int n, double *x, praxis_func f, void *f_data, 
+                    nlopt_stopping *stop, double *minf);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* PRAXIS_H */
diff --git a/py-compile b/py-compile
new file mode 100755 (executable)
index 0000000..46ea866
--- /dev/null
@@ -0,0 +1,170 @@
+#!/bin/sh
+# py-compile - Compile a Python program
+
+scriptversion=2011-06-08.12; # UTC
+
+# Copyright (C) 2000-2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+if [ -z "$PYTHON" ]; then
+  PYTHON=python
+fi
+
+me=py-compile
+
+usage_error ()
+{
+  echo "$me: $*" >&2
+  echo "Try '$me --help' for more information." >&2
+  exit 1
+}
+
+basedir=
+destdir=
+while test $# -ne 0; do
+  case "$1" in
+    --basedir)
+      if test $# -lt 2; then
+        usage_error "option '--basedir' requires an argument"
+      else
+        basedir=$2
+      fi
+      shift
+      ;;
+    --destdir)
+      if test $# -lt 2; then
+        usage_error "option '--destdir' requires an argument"
+      else
+        destdir=$2
+      fi
+      shift
+      ;;
+    -h|--help)
+      cat <<\EOF
+Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
+
+Byte compile some python scripts FILES.  Use --destdir to specify any
+leading directory path to the FILES that you don't want to include in the
+byte compiled file.  Specify --basedir for any additional path information you
+do want to be shown in the byte compiled file.
+
+Example:
+  py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+      exit $?
+      ;;
+    -v|--version)
+      echo "$me $scriptversion"
+      exit $?
+      ;;
+    --)
+      shift
+      break
+      ;;
+    -*)
+      usage_error "unrecognized option '$1'"
+      ;;
+    *)
+      break
+      ;;
+  esac
+  shift
+done
+
+files=$*
+if test -z "$files"; then
+    usage_error "no files given"
+fi
+
+# if basedir was given, then it should be prepended to filenames before
+# byte compilation.
+if [ -z "$basedir" ]; then
+    pathtrans="path = file"
+else
+    pathtrans="path = os.path.join('$basedir', file)"
+fi
+
+# if destdir was given, then it needs to be prepended to the filename to
+# byte compile but not go into the compiled file.
+if [ -z "$destdir" ]; then
+    filetrans="filepath = path"
+else
+    filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
+fi
+
+$PYTHON -c "
+import sys, os, py_compile, imp
+
+files = '''$files'''
+
+sys.stdout.write('Byte-compiling python modules...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+           continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    if hasattr(imp, 'get_tag'):
+        py_compile.compile(filepath, imp.cache_from_source(filepath), path)
+    else:
+        py_compile.compile(filepath, filepath + 'c', path)
+sys.stdout.write('\n')" || exit $?
+
+# this will fail for python < 1.5, but that doesn't matter ...
+$PYTHON -O -c "
+import sys, os, py_compile, imp
+
+# pypy does not use .pyo optimization
+if hasattr(sys, 'pypy_translation_info'):
+    sys.exit(0)
+
+files = '''$files'''
+sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+           continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    if hasattr(imp, 'get_tag'):
+        py_compile.compile(filepath, imp.cache_from_source(filepath, False), path)
+    else:
+        py_compile.compile(filepath, filepath + 'o', path)
+sys.stdout.write('\n')" 2>/dev/null || :
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/slsqp/COPYRIGHT b/slsqp/COPYRIGHT
new file mode 100644 (file)
index 0000000..dbdb062
--- /dev/null
@@ -0,0 +1,60 @@
+Copyright (c) 1988 Dieter Kraft
+
+Copyright (c) 1994 Association for Computing Machinery
+
+Copyright (c) 2001, 2002 Enthought, Inc.
+All rights reserved.
+
+Copyright (c) 2003-2009 SciPy Developers.
+All rights reserved.
+
+Copyright (c) 2010 Massachusetts Institute of Technology
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  a. Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+  b. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  c. Neither the name of the Enthought nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+C      http://permalink.gmane.org/gmane.comp.python.scientific.devel/6725
+C      ------
+C      From: Deborah Cotton <cotton@hq.acm.org>
+C      Date: Fri, 14 Sep 2007 12:35:55 -0500
+C      Subject: RE: Algorithm License requested
+C      To: Alan Isaac
+C
+C      Prof. Issac,
+C
+C      In that case, then because the author consents to [the ACM] releasing
+C      the code currently archived at http://www.netlib.org/toms/733 under the
+C      BSD license, the ACM hereby releases this code under the BSD license.
+C
+C      Regards,
+C
+C      Deborah Cotton, Copyright & Permissions
+C      ACM Publications
+C      2 Penn Plaza, Suite 701**
+C      New York, NY 10121-0701
+C      permissions@acm.org
+C      212.869.7440 ext. 652
+C      Fax. 212.869.0481
+C      ------
diff --git a/slsqp/Makefile.am b/slsqp/Makefile.am
new file mode 100644 (file)
index 0000000..ff7e813
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libslsqp.la
+libslsqp_la_SOURCES = slsqp.c slsqp.h
+
+EXTRA_DIST = README COPYRIGHT
diff --git a/slsqp/Makefile.in b/slsqp/Makefile.in
new file mode 100644 (file)
index 0000000..2b7abd5
--- /dev/null
@@ -0,0 +1,606 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = slsqp
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libslsqp_la_LIBADD =
+am_libslsqp_la_OBJECTS = slsqp.lo
+libslsqp_la_OBJECTS = $(am_libslsqp_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libslsqp_la_SOURCES)
+DIST_SOURCES = $(libslsqp_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libslsqp.la
+libslsqp_la_SOURCES = slsqp.c slsqp.h
+EXTRA_DIST = README COPYRIGHT
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu slsqp/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu slsqp/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libslsqp.la: $(libslsqp_la_OBJECTS) $(libslsqp_la_DEPENDENCIES) $(EXTRA_libslsqp_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libslsqp_la_OBJECTS) $(libslsqp_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slsqp.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/slsqp/README b/slsqp/README
new file mode 100644 (file)
index 0000000..6da5fe4
--- /dev/null
@@ -0,0 +1,47 @@
+This code implements a sequential quadratic programming (SQP)
+algorithm for nonlinearly constrained gradient-based optimization, and
+was originally written by Dieter Kraft and described in:
+
+    Dieter Kraft, "A software package for sequential quadratic
+    programming", Technical Report DFVLR-FB 88-28, Institut für
+    Dynamik der Flugsysteme, Oberpfaffenhofen, July 1988.
+
+    Dieter Kraft, "Algorithm 733: TOMP–Fortran modules for optimal
+    control calculations," ACM Transactions on Mathematical Software,
+    vol. 20, no. 3, pp. 262-281 (1994).
+
+(I believe that SLSQP stands for something like Sequential
+Least-Squares Quadratic Programming, because the problem is treated as
+a sequence of constrained least-squared problems, but such a
+least-squares problem is equivalent to a QP.)
+
+The actual Fortran file was obtained from the SciPy project, who are
+responsible for obtaining permission to distribute it under a
+free-software (3-clause BSD) license (see the permission email from
+ACM at the top of slsqp.c, and also projects.scipy.org/scipy/ticket/1056).
+
+The code was modified for inclusion in NLopt by S. G. Johnson in 2010,
+with the following changes.  The code was converted to C and manually
+cleaned up.  It was modified to be re-entrant, preserving the
+reverse-communication interface but explicitly saving the state in a
+data structure.  The reverse-communication interface was wrapped with
+an NLopt-style inteface, with NLopt stopping conditions.  The inexact
+line search was modified to evaluate the functions including gradients
+for the first step, since this removes the need to evaluate the
+function+gradient a second time for the same point in the common case
+when the inexact line search concludes after a single step, since
+NLopt's interface combines the function and gradient computations.
+Since roundoff errors sometimes pushed SLSQP's parameters slightly
+outside the bound constraints (not allowed by NLopt), we added checks
+to force the parameters within the bounds.  Fixed a bug in LSEI (use
+of uninitialized variables) for the case where the number of equality
+constraints equals the dimension of the problem.  The LSQ subroutine
+was modified to handle infinite lower/upper bounds (in which case
+those constraints are omitted).
+
+The exact line-search option is currently disabled; if we want to
+re-enable this (although exact line-search is usually overkill in
+these kinds of algorithms), we plan to do so using a recursive call to
+NLopt.  (This will allow a user-specified line-search algorithm to be
+used, and will allow the gradient to be exploited in the exact line
+search, in contrast to the routine provided with SLSQP.)
\ No newline at end of file
diff --git a/slsqp/slsqp.c b/slsqp/slsqp.c
new file mode 100644 (file)
index 0000000..1be33a3
--- /dev/null
@@ -0,0 +1,2647 @@
+/* SLSQP: Sequentional Least Squares Programming (aka sequential quadratic programming SQP)
+   method for nonlinearly constrained nonlinear optimization, by Dieter Kraft (1991).
+   Fortran released under a free (BSD) license by ACM to the SciPy project and used there.
+   C translation via f2c + hand-cleanup and incorporation into NLopt by S. G. Johnson (2009). */
+
+/* Table of constant values */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "slsqp.h"
+
+/*      ALGORITHM 733, COLLECTED ALGORITHMS FROM ACM. */
+/*      TRANSACTIONS ON MATHEMATICAL SOFTWARE, */
+/*      VOL. 20, NO. 3, SEPTEMBER, 1994, PP. 262-281. */
+/*      http://doi.acm.org/10.1145/192115.192124 */
+
+
+/*      http://permalink.gmane.org/gmane.comp.python.scientific.devel/6725 */
+/*      ------ */
+/*      From: Deborah Cotton <cotton@hq.acm.org> */
+/*      Date: Fri, 14 Sep 2007 12:35:55 -0500 */
+/*      Subject: RE: Algorithm License requested */
+/*      To: Alan Isaac */
+
+/*      Prof. Issac, */
+
+/*      In that case, then because the author consents to [the ACM] releasing */
+/*      the code currently archived at http://www.netlib.org/toms/733 under the */
+/*      BSD license, the ACM hereby releases this code under the BSD license. */
+
+/*      Regards, */
+
+/*      Deborah Cotton, Copyright & Permissions */
+/*      ACM Publications */
+/*      2 Penn Plaza, Suite 701** */
+/*      New York, NY 10121-0701 */
+/*      permissions@acm.org */
+/*      212.869.7440 ext. 652 */
+/*      Fax. 212.869.0481 */
+/*      ------ */
+
+/********************************* BLAS1 routines *************************/
+
+/*     COPIES A VECTOR, X, TO A VECTOR, Y, with the given increments */
+static void dcopy___(int *n_, const double *dx, int incx, 
+                    double *dy, int incy)
+{
+     int i, n = *n_;
+     
+     if (n <= 0) return;
+     if (incx == 1 && incy == 1)
+         memcpy(dy, dx, sizeof(double) * ((unsigned) n));
+     else if (incx == 0 && incy == 1) {
+         double x = dx[0];
+         for (i = 0; i < n; ++i) dy[i] = x;
+     }
+     else {
+         for (i = 0; i < n; ++i) dy[i*incy] = dx[i*incx];
+     }
+} /* dcopy___ */
+
+/* CONSTANT TIMES A VECTOR PLUS A VECTOR. */
+static void daxpy_sl__(int *n_, const double *da_, const double *dx, 
+                      int incx, double *dy, int incy)
+{
+     int n = *n_, i;  
+     double da = *da_;
+
+     if (n <= 0 || da == 0) return;
+     for (i = 0; i < n; ++i) dy[i*incy] += da * dx[i*incx];
+}
+
+/* dot product dx dot dy. */
+static double ddot_sl__(int *n_, double *dx, int incx, double *dy, int incy)
+{
+     int n = *n_, i;
+     long double sum = 0;
+     if (n <= 0) return 0;
+     for (i = 0; i < n; ++i) sum += dx[i*incx] * dy[i*incy];
+     return (double) sum;
+}
+
+/* compute the L2 norm of array DX of length N, stride INCX */
+static double dnrm2___(int *n_, double *dx, int incx)
+{
+     int i, n = *n_;
+     double xmax = 0, scale;
+     long double sum = 0;
+     for (i = 0; i < n; ++i) {
+          double xabs = fabs(dx[incx*i]);
+          if (xmax < xabs) xmax = xabs;
+     }
+     if (xmax == 0) return 0;
+     scale = 1.0 / xmax;
+     for (i = 0; i < n; ++i) {
+          double xs = scale * dx[incx*i];
+          sum += xs * xs;
+     }
+     return xmax * sqrt((double) sum);
+}
+
+/* apply Givens rotation */
+static void dsrot_(int n, double *dx, int incx, 
+                  double *dy, int incy, double *c__, double *s_)
+{
+     int i;
+     double c = *c__, s = *s_;
+
+     for (i = 0; i < n; ++i) {
+         double x = dx[incx*i], y = dy[incy*i];
+         dx[incx*i] = c * x + s * y;
+         dy[incy*i] = c * y - s * x;
+     }
+}
+
+/* construct Givens rotation */
+static void dsrotg_(double *da, double *db, double *c, double *s)
+{
+     double absa, absb, roe, scale;
+
+     absa = fabs(*da); absb = fabs(*db);
+     if (absa > absb) {
+         roe = *da;
+         scale = absa;
+     }
+     else {
+         roe = *db;
+         scale = absb;
+     }
+
+     if (scale != 0) {
+         double r, iscale = 1 / scale;
+         double tmpa = (*da) * iscale, tmpb = (*db) * iscale;
+         r = (roe < 0 ? -scale : scale) * sqrt((tmpa * tmpa) + (tmpb * tmpb)); 
+         *c = *da / r; *s = *db / r; 
+         *da = r;
+         if (*c != 0 && fabs(*c) <= *s) *db = 1 / *c;
+         else *db = *s;
+     }
+     else { 
+         *c = 1; 
+         *s = *da = *db = 0;
+     }
+}
+
+/* scales vector X(n) by constant da */
+static void dscal_sl__(int *n_, const double *da, double *dx, int incx)
+{
+     int i, n = *n_;
+     double alpha = *da;
+     for (i = 0; i < n; ++i) dx[i*incx] *= alpha;
+}
+
+/**************************************************************************/
+
+static const int c__0 = 0;
+static const int c__1 = 1;
+static const int c__2 = 2;
+
+#define MIN2(a,b) ((a) <= (b) ? (a) : (b))
+#define MAX2(a,b) ((a) >= (b) ? (a) : (b))
+
+static void h12_(const int *mode, int *lpivot, int *l1, 
+                int *m, double *u, const int *iue, double *up, 
+                double *c__, const int *ice, const int *icv, const int *ncv)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+
+    /* System generated locals */
+    int u_dim1, u_offset, i__1, i__2;
+    double d__1;
+
+    /* Local variables */
+    double b;
+    int i__, j, i2, i3, i4;
+    double cl, sm;
+    int incr;
+    double clinv;
+
+/*     C.L.LAWSON AND R.J.HANSON, JET PROPULSION LABORATORY, 1973 JUN 12 */
+/*     TO APPEAR IN 'SOLVING LEAST SQUARES PROBLEMS', PRENTICE-HALL, 1974 */
+/*     CONSTRUCTION AND/OR APPLICATION OF A SINGLE */
+/*     HOUSEHOLDER TRANSFORMATION  Q = I + U*(U**T)/B */
+/*     MODE    = 1 OR 2   TO SELECT ALGORITHM  H1  OR  H2 . */
+/*     LPIVOT IS THE INDEX OF THE PIVOT ELEMENT. */
+/*     L1,M   IF L1 <= M   THE TRANSFORMATION WILL BE CONSTRUCTED TO */
+/*            ZERO ELEMENTS INDEXED FROM L1 THROUGH M. */
+/*            IF L1 > M THE SUBROUTINE DOES AN IDENTITY TRANSFORMATION. */
+/*     U(),IUE,UP */
+/*            ON ENTRY TO H1 U() STORES THE PIVOT VECTOR. */
+/*            IUE IS THE STORAGE INCREMENT BETWEEN ELEMENTS. */
+/*            ON EXIT FROM H1 U() AND UP STORE QUANTITIES DEFINING */
+/*            THE VECTOR U OF THE HOUSEHOLDER TRANSFORMATION. */
+/*            ON ENTRY TO H2 U() AND UP */
+/*            SHOULD STORE QUANTITIES PREVIOUSLY COMPUTED BY H1. */
+/*            THESE WILL NOT BE MODIFIED BY H2. */
+/*     C()    ON ENTRY TO H1 OR H2 C() STORES A MATRIX WHICH WILL BE */
+/*            REGARDED AS A SET OF VECTORS TO WHICH THE HOUSEHOLDER */
+/*            TRANSFORMATION IS TO BE APPLIED. */
+/*            ON EXIT C() STORES THE SET OF TRANSFORMED VECTORS. */
+/*     ICE    STORAGE INCREMENT BETWEEN ELEMENTS OF VECTORS IN C(). */
+/*     ICV    STORAGE INCREMENT BETWEEN VECTORS IN C(). */
+/*     NCV    NUMBER OF VECTORS IN C() TO BE TRANSFORMED. */
+/*            IF NCV <= 0 NO OPERATIONS WILL BE DONE ON C(). */
+    /* Parameter adjustments */
+    u_dim1 = *iue;
+    u_offset = 1 + u_dim1;
+    u -= u_offset;
+    --c__;
+
+    /* Function Body */
+    if (0 >= *lpivot || *lpivot >= *l1 || *l1 > *m) {
+       goto L80;
+    }
+    cl = (d__1 = u[*lpivot * u_dim1 + 1], fabs(d__1));
+    if (*mode == 2) {
+       goto L30;
+    }
+/*     ****** CONSTRUCT THE TRANSFORMATION ****** */
+    i__1 = *m;
+    for (j = *l1; j <= i__1; ++j) {
+       sm = (d__1 = u[j * u_dim1 + 1], fabs(d__1));
+/* L10: */
+       cl = MAX2(sm,cl);
+    }
+    if (cl <= 0.0) {
+       goto L80;
+    }
+    clinv = one / cl;
+/* Computing 2nd power */
+    d__1 = u[*lpivot * u_dim1 + 1] * clinv;
+    sm = d__1 * d__1;
+    i__1 = *m;
+    for (j = *l1; j <= i__1; ++j) {
+/* L20: */
+/* Computing 2nd power */
+       d__1 = u[j * u_dim1 + 1] * clinv;
+       sm += d__1 * d__1;
+    }
+    cl *= sqrt(sm);
+    if (u[*lpivot * u_dim1 + 1] > 0.0) {
+       cl = -cl;
+    }
+    *up = u[*lpivot * u_dim1 + 1] - cl;
+    u[*lpivot * u_dim1 + 1] = cl;
+    goto L40;
+/*     ****** APPLY THE TRANSFORMATION  I+U*(U**T)/B  TO C ****** */
+L30:
+    if (cl <= 0.0) {
+       goto L80;
+    }
+L40:
+    if (*ncv <= 0) {
+       goto L80;
+    }
+    b = *up * u[*lpivot * u_dim1 + 1];
+    if (b >= 0.0) {
+       goto L80;
+    }
+    b = one / b;
+    i2 = 1 - *icv + *ice * (*lpivot - 1);
+    incr = *ice * (*l1 - *lpivot);
+    i__1 = *ncv;
+    for (j = 1; j <= i__1; ++j) {
+       i2 += *icv;
+       i3 = i2 + incr;
+       i4 = i3;
+       sm = c__[i2] * *up;
+       i__2 = *m;
+       for (i__ = *l1; i__ <= i__2; ++i__) {
+           sm += c__[i3] * u[i__ * u_dim1 + 1];
+/* L50: */
+           i3 += *ice;
+       }
+       if (sm == 0.0) {
+           goto L70;
+       }
+       sm *= b;
+       c__[i2] += sm * *up;
+       i__2 = *m;
+       for (i__ = *l1; i__ <= i__2; ++i__) {
+           c__[i4] += sm * u[i__ * u_dim1 + 1];
+/* L60: */
+           i4 += *ice;
+       }
+L70:
+       ;
+    }
+L80:
+    return;
+} /* h12_ */
+
+static void nnls_(double *a, int *mda, int *m, int *
+       n, double *b, double *x, double *rnorm, double *w, 
+       double *z__, int *indx, int *mode)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+    const double factor = .01;
+
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+    double d__1;
+
+    /* Local variables */
+    double c__;
+    int i__, j, k, l;
+    double s, t;
+    int ii, jj, ip, iz, jz;
+    double up;
+    int iz1, iz2, npp1, iter;
+    double wmax, alpha, asave;
+    int itmax, izmax, nsetp;
+    double unorm;
+
+/*     C.L.LAWSON AND R.J.HANSON, JET PROPULSION LABORATORY: */
+/*     'SOLVING LEAST SQUARES PROBLEMS'. PRENTICE-HALL.1974 */
+/*      **********   NONNEGATIVE LEAST SQUARES   ********** */
+/*     GIVEN AN M BY N MATRIX, A, AND AN M-VECTOR, B, COMPUTE AN */
+/*     N-VECTOR, X, WHICH SOLVES THE LEAST SQUARES PROBLEM */
+/*                  A*X = B  SUBJECT TO  X >= 0 */
+/*     A(),MDA,M,N */
+/*            MDA IS THE FIRST DIMENSIONING PARAMETER FOR THE ARRAY,A(). */
+/*            ON ENTRY A()  CONTAINS THE M BY N MATRIX,A. */
+/*            ON EXIT A() CONTAINS THE PRODUCT Q*A, */
+/*            WHERE Q IS AN M BY M ORTHOGONAL MATRIX GENERATED */
+/*            IMPLICITLY BY THIS SUBROUTINE. */
+/*            EITHER M>=N OR M<N IS PERMISSIBLE. */
+/*            THERE IS NO RESTRICTION ON THE RANK OF A. */
+/*     B()    ON ENTRY B() CONTAINS THE M-VECTOR, B. */
+/*            ON EXIT B() CONTAINS Q*B. */
+/*     X()    ON ENTRY X() NEED NOT BE INITIALIZED. */
+/*            ON EXIT X() WILL CONTAIN THE SOLUTION VECTOR. */
+/*     RNORM  ON EXIT RNORM CONTAINS THE EUCLIDEAN NORM OF THE */
+/*            RESIDUAL VECTOR. */
+/*     W()    AN N-ARRAY OF WORKING SPACE. */
+/*            ON EXIT W() WILL CONTAIN THE DUAL SOLUTION VECTOR. */
+/*            W WILL SATISFY W(I)=0 FOR ALL I IN SET P */
+/*            AND W(I)<=0 FOR ALL I IN SET Z */
+/*     Z()    AN M-ARRAY OF WORKING SPACE. */
+/*     INDX()AN INT WORKING ARRAY OF LENGTH AT LEAST N. */
+/*            ON EXIT THE CONTENTS OF THIS ARRAY DEFINE THE SETS */
+/*            P AND Z AS FOLLOWS: */
+/*            INDX(1)    THRU INDX(NSETP) = SET P. */
+/*            INDX(IZ1)  THRU INDX (IZ2)  = SET Z. */
+/*            IZ1=NSETP + 1 = NPP1, IZ2=N. */
+/*     MODE   THIS IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING MEANING: */
+/*            1    THE SOLUTION HAS BEEN COMPUTED SUCCESSFULLY. */
+/*            2    THE DIMENSIONS OF THE PROBLEM ARE WRONG, */
+/*                 EITHER M <= 0 OR N <= 0. */
+/*            3    ITERATION COUNT EXCEEDED, MORE THAN 3*N ITERATIONS. */
+    /* Parameter adjustments */
+    --z__;
+    --b;
+    --indx;
+    --w;
+    --x;
+    a_dim1 = *mda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+
+    /* Function Body */
+/*     revised          Dieter Kraft, March 1983 */
+    *mode = 2;
+    if (*m <= 0 || *n <= 0) {
+       goto L290;
+    }
+    *mode = 1;
+    iter = 0;
+    itmax = *n * 3;
+/* STEP ONE (INITIALIZE) */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L100: */
+       indx[i__] = i__;
+    }
+    iz1 = 1;
+    iz2 = *n;
+    nsetp = 0;
+    npp1 = 1;
+    x[1] = 0.0;
+    dcopy___(n, &x[1], 0, &x[1], 1);
+/* STEP TWO (COMPUTE DUAL VARIABLES) */
+/* .....ENTRY LOOP A */
+L110:
+    if (iz1 > iz2 || nsetp >= *m) {
+       goto L280;
+    }
+    i__1 = iz2;
+    for (iz = iz1; iz <= i__1; ++iz) {
+       j = indx[iz];
+/* L120: */
+       i__2 = *m - nsetp;
+       w[j] = ddot_sl__(&i__2, &a[npp1 + j * a_dim1], 1, &b[npp1], 1)
+               ;
+    }
+/* STEP THREE (TEST DUAL VARIABLES) */
+L130:
+    wmax = 0.0;
+    i__2 = iz2;
+    for (iz = iz1; iz <= i__2; ++iz) {
+       j = indx[iz];
+       if (w[j] <= wmax) {
+           goto L140;
+       }
+       wmax = w[j];
+       izmax = iz;
+L140:
+       ;
+    }
+/* .....EXIT LOOP A */
+    if (wmax <= 0.0) {
+       goto L280;
+    }
+    iz = izmax;
+    j = indx[iz];
+/* STEP FOUR (TEST INDX J FOR LINEAR DEPENDENCY) */
+    asave = a[npp1 + j * a_dim1];
+    i__2 = npp1 + 1;
+    h12_(&c__1, &npp1, &i__2, m, &a[j * a_dim1 + 1], &c__1, &up, &z__[1], &
+           c__1, &c__1, &c__0);
+    unorm = dnrm2___(&nsetp, &a[j * a_dim1 + 1], 1);
+    t = factor * (d__1 = a[npp1 + j * a_dim1], fabs(d__1));
+    d__1 = unorm + t;
+    if (d__1 - unorm <= 0.0) {
+       goto L150;
+    }
+    dcopy___(m, &b[1], 1, &z__[1], 1);
+    i__2 = npp1 + 1;
+    h12_(&c__2, &npp1, &i__2, m, &a[j * a_dim1 + 1], &c__1, &up, &z__[1], &
+           c__1, &c__1, &c__1);
+    if (z__[npp1] / a[npp1 + j * a_dim1] > 0.0) {
+       goto L160;
+    }
+L150:
+    a[npp1 + j * a_dim1] = asave;
+    w[j] = 0.0;
+    goto L130;
+/* STEP FIVE (ADD COLUMN) */
+L160:
+    dcopy___(m, &z__[1], 1, &b[1], 1);
+    indx[iz] = indx[iz1];
+    indx[iz1] = j;
+    ++iz1;
+    nsetp = npp1;
+    ++npp1;
+    i__2 = iz2;
+    for (jz = iz1; jz <= i__2; ++jz) {
+       jj = indx[jz];
+/* L170: */
+       h12_(&c__2, &nsetp, &npp1, m, &a[j * a_dim1 + 1], &c__1, &up, &a[jj * 
+               a_dim1 + 1], &c__1, mda, &c__1);
+    }
+    k = MIN2(npp1,*mda);
+    w[j] = 0.0;
+    i__2 = *m - nsetp;
+    dcopy___(&i__2, &w[j], 0, &a[k + j * a_dim1], 1);
+/* STEP SIX (SOLVE LEAST SQUARES SUB-PROBLEM) */
+/* .....ENTRY LOOP B */
+L180:
+    for (ip = nsetp; ip >= 1; --ip) {
+       if (ip == nsetp) {
+           goto L190;
+       }
+       d__1 = -z__[ip + 1];
+       daxpy_sl__(&ip, &d__1, &a[jj * a_dim1 + 1], 1, &z__[1], 1);
+L190:
+       jj = indx[ip];
+/* L200: */
+       z__[ip] /= a[ip + jj * a_dim1];
+    }
+    ++iter;
+    if (iter <= itmax) {
+       goto L220;
+    }
+L210:
+    *mode = 3;
+    goto L280;
+/* STEP SEVEN TO TEN (STEP LENGTH ALGORITHM) */
+L220:
+    alpha = one;
+    jj = 0;
+    i__2 = nsetp;
+    for (ip = 1; ip <= i__2; ++ip) {
+       if (z__[ip] > 0.0) {
+           goto L230;
+       }
+       l = indx[ip];
+       t = -x[l] / (z__[ip] - x[l]);
+       if (alpha < t) {
+           goto L230;
+       }
+       alpha = t;
+       jj = ip;
+L230:
+       ;
+    }
+    i__2 = nsetp;
+    for (ip = 1; ip <= i__2; ++ip) {
+       l = indx[ip];
+/* L240: */
+       x[l] = (one - alpha) * x[l] + alpha * z__[ip];
+    }
+/* .....EXIT LOOP B */
+    if (jj == 0) {
+       goto L110;
+    }
+/* STEP ELEVEN (DELETE COLUMN) */
+    i__ = indx[jj];
+L250:
+    x[i__] = 0.0;
+    ++jj;
+    i__2 = nsetp;
+    for (j = jj; j <= i__2; ++j) {
+       ii = indx[j];
+       indx[j - 1] = ii;
+       dsrotg_(&a[j - 1 + ii * a_dim1], &a[j + ii * a_dim1], &c__, &s);
+       t = a[j - 1 + ii * a_dim1];
+       dsrot_(*n, &a[j - 1 + a_dim1], *mda, &a[j + a_dim1], *mda, &c__, &s);
+       a[j - 1 + ii * a_dim1] = t;
+       a[j + ii * a_dim1] = 0.0;
+/* L260: */
+       dsrot_(1, &b[j - 1], 1, &b[j], 1, &c__, &s);
+    }
+    npp1 = nsetp;
+    --nsetp;
+    --iz1;
+    indx[iz1] = i__;
+    if (nsetp <= 0) {
+       goto L210;
+    }
+    i__2 = nsetp;
+    for (jj = 1; jj <= i__2; ++jj) {
+       i__ = indx[jj];
+       if (x[i__] <= 0.0) {
+           goto L250;
+       }
+/* L270: */
+    }
+    dcopy___(m, &b[1], 1, &z__[1], 1);
+    goto L180;
+/* STEP TWELVE (SOLUTION) */
+L280:
+    k = MIN2(npp1,*m);
+    i__2 = *m - nsetp;
+    *rnorm = dnrm2___(&i__2, &b[k], 1);
+    if (npp1 > *m) {
+       w[1] = 0.0;
+       dcopy___(n, &w[1], 0, &w[1], 1);
+    }
+/* END OF SUBROUTINE NNLS */
+L290:
+    return;
+} /* nnls_ */
+
+static void ldp_(double *g, int *mg, int *m, int *n, 
+       double *h__, double *x, double *xnorm, double *w, 
+       int *indx, int *mode)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+
+    /* System generated locals */
+    int g_dim1, g_offset, i__1, i__2;
+    double d__1;
+
+    /* Local variables */
+    int i__, j, n1, if__, iw, iy, iz;
+    double fac;
+    double rnorm;
+    int iwdual;
+
+/*                     T */
+/*     MINIMIZE   1/2 X X    SUBJECT TO   G * X >= H. */
+/*       C.L. LAWSON, R.J. HANSON: 'SOLVING LEAST SQUARES PROBLEMS' */
+/*       PRENTICE HALL, ENGLEWOOD CLIFFS, NEW JERSEY, 1974. */
+/*     PARAMETER DESCRIPTION: */
+/*     G(),MG,M,N   ON ENTRY G() STORES THE M BY N MATRIX OF */
+/*                  LINEAR INEQUALITY CONSTRAINTS. G() HAS FIRST */
+/*                  DIMENSIONING PARAMETER MG */
+/*     H()          ON ENTRY H() STORES THE M VECTOR H REPRESENTING */
+/*                  THE RIGHT SIDE OF THE INEQUALITY SYSTEM */
+/*     REMARK: G(),H() WILL NOT BE CHANGED DURING CALCULATIONS BY LDP */
+/*     X()          ON ENTRY X() NEED NOT BE INITIALIZED. */
+/*                  ON EXIT X() STORES THE SOLUTION VECTOR X IF MODE=1. */
+/*     XNORM        ON EXIT XNORM STORES THE EUCLIDIAN NORM OF THE */
+/*                  SOLUTION VECTOR IF COMPUTATION IS SUCCESSFUL */
+/*     W()          W IS A ONE DIMENSIONAL WORKING SPACE, THE LENGTH */
+/*                  OF WHICH SHOULD BE AT LEAST (M+2)*(N+1) + 2*M */
+/*                  ON EXIT W() STORES THE LAGRANGE MULTIPLIERS */
+/*                  ASSOCIATED WITH THE CONSTRAINTS */
+/*                  AT THE SOLUTION OF PROBLEM LDP */
+/*     INDX()      INDX() IS A ONE DIMENSIONAL INT WORKING SPACE */
+/*                  OF LENGTH AT LEAST M */
+/*     MODE         MODE IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING */
+/*                  MEANINGS: */
+/*          MODE=1: SUCCESSFUL COMPUTATION */
+/*               2: ERROR RETURN BECAUSE OF WRONG DIMENSIONS (N.LE.0) */
+/*               3: ITERATION COUNT EXCEEDED BY NNLS */
+/*               4: INEQUALITY CONSTRAINTS INCOMPATIBLE */
+    /* Parameter adjustments */
+    --indx;
+    --h__;
+    --x;
+    g_dim1 = *mg;
+    g_offset = 1 + g_dim1;
+    g -= g_offset;
+    --w;
+
+    /* Function Body */
+    *mode = 2;
+    if (*n <= 0) {
+       goto L50;
+    }
+/*  STATE DUAL PROBLEM */
+    *mode = 1;
+    x[1] = 0.0;
+    dcopy___(n, &x[1], 0, &x[1], 1);
+    *xnorm = 0.0;
+    if (*m == 0) {
+       goto L50;
+    }
+    iw = 0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           ++iw;
+/* L10: */
+           w[iw] = g[j + i__ * g_dim1];
+       }
+       ++iw;
+/* L20: */
+       w[iw] = h__[j];
+    }
+    if__ = iw + 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       ++iw;
+/* L30: */
+       w[iw] = 0.0;
+    }
+    w[iw + 1] = one;
+    n1 = *n + 1;
+    iz = iw + 2;
+    iy = iz + n1;
+    iwdual = iy + *m;
+/*  SOLVE DUAL PROBLEM */
+    nnls_(&w[1], &n1, &n1, m, &w[if__], &w[iy], &rnorm, &w[iwdual], &w[iz], &
+           indx[1], mode);
+    if (*mode != 1) {
+       goto L50;
+    }
+    *mode = 4;
+    if (rnorm <= 0.0) {
+       goto L50;
+    }
+/*  COMPUTE SOLUTION OF PRIMAL PROBLEM */
+    fac = one - ddot_sl__(m, &h__[1], 1, &w[iy], 1);
+    d__1 = one + fac;
+    if (d__1 - one <= 0.0) {
+       goto L50;
+    }
+    *mode = 1;
+    fac = one / fac;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* L40: */
+       x[j] = fac * ddot_sl__(m, &g[j * g_dim1 + 1], 1, &w[iy], 1);
+    }
+    *xnorm = dnrm2___(n, &x[1], 1);
+/*  COMPUTE LAGRANGE MULTIPLIERS FOR PRIMAL PROBLEM */
+    w[1] = 0.0;
+    dcopy___(m, &w[1], 0, &w[1], 1);
+    daxpy_sl__(m, &fac, &w[iy], 1, &w[1], 1);
+/*  END OF SUBROUTINE LDP */
+L50:
+    return;
+} /* ldp_ */
+
+static void lsi_(double *e, double *f, double *g, 
+       double *h__, int *le, int *me, int *lg, int *mg, 
+       int *n, double *x, double *xnorm, double *w, int *
+       jw, int *mode)
+{
+    /* Initialized data */
+
+    const double epmach = 2.22e-16;
+    const double one = 1.;
+
+    /* System generated locals */
+    int e_dim1, e_offset, g_dim1, g_offset, i__1, i__2, i__3;
+    double d__1;
+
+    /* Local variables */
+    int i__, j;
+    double t;
+
+/*     FOR MODE=1, THE SUBROUTINE RETURNS THE SOLUTION X OF */
+/*     INEQUALITY CONSTRAINED LINEAR LEAST SQUARES PROBLEM: */
+/*                    MIN ||E*X-F|| */
+/*                     X */
+/*                    S.T.  G*X >= H */
+/*     THE ALGORITHM IS BASED ON QR DECOMPOSITION AS DESCRIBED IN */
+/*     CHAPTER 23.5 OF LAWSON & HANSON: SOLVING LEAST SQUARES PROBLEMS */
+/*     THE FOLLOWING DIMENSIONS OF THE ARRAYS DEFINING THE PROBLEM */
+/*     ARE NECESSARY */
+/*     DIM(E) :   FORMAL (LE,N),    ACTUAL (ME,N) */
+/*     DIM(F) :   FORMAL (LE  ),    ACTUAL (ME  ) */
+/*     DIM(G) :   FORMAL (LG,N),    ACTUAL (MG,N) */
+/*     DIM(H) :   FORMAL (LG  ),    ACTUAL (MG  ) */
+/*     DIM(X) :   N */
+/*     DIM(W) :   (N+1)*(MG+2) + 2*MG */
+/*     DIM(JW):   LG */
+/*     ON ENTRY, THE USER HAS TO PROVIDE THE ARRAYS E, F, G, AND H. */
+/*     ON RETURN, ALL ARRAYS WILL BE CHANGED BY THE SUBROUTINE. */
+/*     X     STORES THE SOLUTION VECTOR */
+/*     XNORM STORES THE RESIDUUM OF THE SOLUTION IN EUCLIDIAN NORM */
+/*     W     STORES THE VECTOR OF LAGRANGE MULTIPLIERS IN ITS FIRST */
+/*           MG ELEMENTS */
+/*     MODE  IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING MEANINGS: */
+/*          MODE=1: SUCCESSFUL COMPUTATION */
+/*               2: ERROR RETURN BECAUSE OF WRONG DIMENSIONS (N<1) */
+/*               3: ITERATION COUNT EXCEEDED BY NNLS */
+/*               4: INEQUALITY CONSTRAINTS INCOMPATIBLE */
+/*               5: MATRIX E IS NOT OF FULL RANK */
+/*     03.01.1980, DIETER KRAFT: CODED */
+/*     20.03.1987, DIETER KRAFT: REVISED TO FORTRAN 77 */
+    /* Parameter adjustments */
+    --f;
+    --jw;
+    --h__;
+    --x;
+    g_dim1 = *lg;
+    g_offset = 1 + g_dim1;
+    g -= g_offset;
+    e_dim1 = *le;
+    e_offset = 1 + e_dim1;
+    e -= e_offset;
+    --w;
+
+    /* Function Body */
+/*  QR-FACTORS OF E AND APPLICATION TO F */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing MIN */
+       i__2 = i__ + 1;
+       j = MIN2(i__2,*n);
+       i__2 = i__ + 1;
+       i__3 = *n - i__;
+       h12_(&c__1, &i__, &i__2, me, &e[i__ * e_dim1 + 1], &c__1, &t, &e[j * 
+               e_dim1 + 1], &c__1, le, &i__3);
+/* L10: */
+       i__2 = i__ + 1;
+       h12_(&c__2, &i__, &i__2, me, &e[i__ * e_dim1 + 1], &c__1, &t, &f[1], &
+               c__1, &c__1, &c__1);
+    }
+/*  TRANSFORM G AND H TO GET LEAST DISTANCE PROBLEM */
+    *mode = 5;
+    i__2 = *mg;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       i__1 = *n;
+       for (j = 1; j <= i__1; ++j) {
+           if ((d__1 = e[j + j * e_dim1], fabs(d__1)) < epmach) {
+               goto L50;
+           }
+/* L20: */
+           i__3 = j - 1;
+           g[i__ + j * g_dim1] = (g[i__ + j * g_dim1] - ddot_sl__(&i__3, &g[
+                   i__ + g_dim1], *lg, &e[j * e_dim1 + 1], 1)) / e[j + j *
+                    e_dim1];
+       }
+/* L30: */
+       h__[i__] -= ddot_sl__(n, &g[i__ + g_dim1], *lg, &f[1], 1);
+    }
+/*  SOLVE LEAST DISTANCE PROBLEM */
+    ldp_(&g[g_offset], lg, mg, n, &h__[1], &x[1], xnorm, &w[1], &jw[1], mode);
+    if (*mode != 1) {
+       goto L50;
+    }
+/*  SOLUTION OF ORIGINAL PROBLEM */
+    daxpy_sl__(n, &one, &f[1], 1, &x[1], 1);
+    for (i__ = *n; i__ >= 1; --i__) {
+/* Computing MIN */
+       i__2 = i__ + 1;
+       j = MIN2(i__2,*n);
+/* L40: */
+       i__2 = *n - i__;
+       x[i__] = (x[i__] - ddot_sl__(&i__2, &e[i__ + j * e_dim1], *le, &x[j], 1))
+            / e[i__ + i__ * e_dim1];
+    }
+/* Computing MIN */
+    i__2 = *n + 1;
+    j = MIN2(i__2,*me);
+    i__2 = *me - *n;
+    t = dnrm2___(&i__2, &f[j], 1);
+    *xnorm = sqrt(*xnorm * *xnorm + t * t);
+/*  END OF SUBROUTINE LSI */
+L50:
+    return;
+} /* lsi_ */
+
+static void hfti_(double *a, int *mda, int *m, int *
+       n, double *b, int *mdb, const int *nb, double *tau, int 
+       *krank, double *rnorm, double *h__, double *g, int *
+       ip)
+{
+    /* Initialized data */
+
+    const double factor = .001;
+
+    /* System generated locals */
+    int a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
+    double d__1;
+
+    /* Local variables */
+    int i__, j, k, l;
+    int jb, kp1;
+    double tmp, hmax;
+    int lmax, ldiag;
+
+/*     RANK-DEFICIENT LEAST SQUARES ALGORITHM AS DESCRIBED IN: */
+/*     C.L.LAWSON AND R.J.HANSON, JET PROPULSION LABORATORY, 1973 JUN 12 */
+/*     TO APPEAR IN 'SOLVING LEAST SQUARES PROBLEMS', PRENTICE-HALL, 1974 */
+/*     A(*,*),MDA,M,N   THE ARRAY A INITIALLY CONTAINS THE M x N MATRIX A */
+/*                      OF THE LEAST SQUARES PROBLEM AX = B. */
+/*                      THE FIRST DIMENSIONING PARAMETER MDA MUST SATISFY */
+/*                      MDA >= M. EITHER M >= N OR M < N IS PERMITTED. */
+/*                      THERE IS NO RESTRICTION ON THE RANK OF A. */
+/*                      THE MATRIX A WILL BE MODIFIED BY THE SUBROUTINE. */
+/*     B(*,*),MDB,NB    IF NB = 0 THE SUBROUTINE WILL MAKE NO REFERENCE */
+/*                      TO THE ARRAY B. IF NB > 0 THE ARRAY B() MUST */
+/*                      INITIALLY CONTAIN THE M x NB MATRIX B  OF THE */
+/*                      THE LEAST SQUARES PROBLEM AX = B AND ON RETURN */
+/*                      THE ARRAY B() WILL CONTAIN THE N x NB SOLUTION X. */
+/*                      IF NB>1 THE ARRAY B() MUST BE DOUBLE SUBSCRIPTED */
+/*                      WITH FIRST DIMENSIONING PARAMETER MDB>=MAX(M,N), */
+/*                      IF NB=1 THE ARRAY B() MAY BE EITHER SINGLE OR */
+/*                      DOUBLE SUBSCRIPTED. */
+/*     TAU              ABSOLUTE TOLERANCE PARAMETER FOR PSEUDORANK */
+/*                      DETERMINATION, PROVIDED BY THE USER. */
+/*     KRANK            PSEUDORANK OF A, SET BY THE SUBROUTINE. */
+/*     RNORM            ON EXIT, RNORM(J) WILL CONTAIN THE EUCLIDIAN */
+/*                      NORM OF THE RESIDUAL VECTOR FOR THE PROBLEM */
+/*                      DEFINED BY THE J-TH COLUMN VECTOR OF THE ARRAY B. */
+/*     H(), G()         ARRAYS OF WORKING SPACE OF LENGTH >= N. */
+/*     IP()             INT ARRAY OF WORKING SPACE OF LENGTH >= N */
+/*                      RECORDING PERMUTATION INDICES OF COLUMN VECTORS */
+    /* Parameter adjustments */
+    --ip;
+    --g;
+    --h__;
+    a_dim1 = *mda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --rnorm;
+    b_dim1 = *mdb;
+    b_offset = 1 + b_dim1;
+    b -= b_offset;
+
+    /* Function Body */
+    k = 0;
+    ldiag = MIN2(*m,*n);
+    if (ldiag <= 0) {
+       goto L270;
+    }
+/*   COMPUTE LMAX */
+    i__1 = ldiag;
+    for (j = 1; j <= i__1; ++j) {
+       if (j == 1) {
+           goto L20;
+       }
+       lmax = j;
+       i__2 = *n;
+       for (l = j; l <= i__2; ++l) {
+/* Computing 2nd power */
+           d__1 = a[j - 1 + l * a_dim1];
+           h__[l] -= d__1 * d__1;
+/* L10: */
+           if (h__[l] > h__[lmax]) {
+               lmax = l;
+           }
+       }
+       d__1 = hmax + factor * h__[lmax];
+       if (d__1 - hmax > 0.0) {
+           goto L50;
+       }
+L20:
+       lmax = j;
+       i__2 = *n;
+       for (l = j; l <= i__2; ++l) {
+           h__[l] = 0.0;
+           i__3 = *m;
+           for (i__ = j; i__ <= i__3; ++i__) {
+/* L30: */
+/* Computing 2nd power */
+               d__1 = a[i__ + l * a_dim1];
+               h__[l] += d__1 * d__1;
+           }
+/* L40: */
+           if (h__[l] > h__[lmax]) {
+               lmax = l;
+           }
+       }
+       hmax = h__[lmax];
+/*   COLUMN INTERCHANGES IF NEEDED */
+L50:
+       ip[j] = lmax;
+       if (ip[j] == j) {
+           goto L70;
+       }
+       i__2 = *m;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+           tmp = a[i__ + j * a_dim1];
+           a[i__ + j * a_dim1] = a[i__ + lmax * a_dim1];
+/* L60: */
+           a[i__ + lmax * a_dim1] = tmp;
+       }
+       h__[lmax] = h__[j];
+/*   J-TH TRANSFORMATION AND APPLICATION TO A AND B */
+L70:
+/* Computing MIN */
+       i__2 = j + 1;
+       i__ = MIN2(i__2,*n);
+       i__2 = j + 1;
+       i__3 = *n - j;
+       h12_(&c__1, &j, &i__2, m, &a[j * a_dim1 + 1], &c__1, &h__[j], &a[i__ *
+                a_dim1 + 1], &c__1, mda, &i__3);
+/* L80: */
+       i__2 = j + 1;
+       h12_(&c__2, &j, &i__2, m, &a[j * a_dim1 + 1], &c__1, &h__[j], &b[
+               b_offset], &c__1, mdb, nb);
+    }
+/*   DETERMINE PSEUDORANK */
+    i__2 = ldiag;
+    for (j = 1; j <= i__2; ++j) {
+/* L90: */
+       if ((d__1 = a[j + j * a_dim1], fabs(d__1)) <= *tau) {
+           goto L100;
+       }
+    }
+    k = ldiag;
+    goto L110;
+L100:
+    k = j - 1;
+L110:
+    kp1 = k + 1;
+/*   NORM OF RESIDUALS */
+    i__2 = *nb;
+    for (jb = 1; jb <= i__2; ++jb) {
+/* L130: */
+       i__1 = *m - k;
+       rnorm[jb] = dnrm2___(&i__1, &b[kp1 + jb * b_dim1], 1);
+    }
+    if (k > 0) {
+       goto L160;
+    }
+    i__1 = *nb;
+    for (jb = 1; jb <= i__1; ++jb) {
+       i__2 = *n;
+       for (i__ = 1; i__ <= i__2; ++i__) {
+/* L150: */
+           b[i__ + jb * b_dim1] = 0.0;
+       }
+    }
+    goto L270;
+L160:
+    if (k == *n) {
+       goto L180;
+    }
+/*   HOUSEHOLDER DECOMPOSITION OF FIRST K ROWS */
+    for (i__ = k; i__ >= 1; --i__) {
+/* L170: */
+       i__2 = i__ - 1;
+       h12_(&c__1, &i__, &kp1, n, &a[i__ + a_dim1], mda, &g[i__], &a[
+               a_offset], mda, &c__1, &i__2);
+    }
+L180:
+    i__2 = *nb;
+    for (jb = 1; jb <= i__2; ++jb) {
+/*   SOLVE K*K TRIANGULAR SYSTEM */
+       for (i__ = k; i__ >= 1; --i__) {
+/* Computing MIN */
+           i__1 = i__ + 1;
+           j = MIN2(i__1,*n);
+/* L210: */
+           i__1 = k - i__;
+           b[i__ + jb * b_dim1] = (b[i__ + jb * b_dim1] - ddot_sl__(&i__1, &
+                   a[i__ + j * a_dim1], *mda, &b[j + jb * b_dim1], 1)) / 
+                   a[i__ + i__ * a_dim1];
+       }
+/*   COMPLETE SOLUTION VECTOR */
+       if (k == *n) {
+           goto L240;
+       }
+       i__1 = *n;
+       for (j = kp1; j <= i__1; ++j) {
+/* L220: */
+           b[j + jb * b_dim1] = 0.0;
+       }
+       i__1 = k;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+/* L230: */
+           h12_(&c__2, &i__, &kp1, n, &a[i__ + a_dim1], mda, &g[i__], &b[jb *
+                    b_dim1 + 1], &c__1, mdb, &c__1);
+       }
+/*   REORDER SOLUTION ACCORDING TO PREVIOUS COLUMN INTERCHANGES */
+L240:
+       for (j = ldiag; j >= 1; --j) {
+           if (ip[j] == j) {
+               goto L250;
+           }
+           l = ip[j];
+           tmp = b[l + jb * b_dim1];
+           b[l + jb * b_dim1] = b[j + jb * b_dim1];
+           b[j + jb * b_dim1] = tmp;
+L250:
+           ;
+       }
+    }
+L270:
+    *krank = k;
+} /* hfti_ */
+
+static void lsei_(double *c__, double *d__, double *e, 
+       double *f, double *g, double *h__, int *lc, int *
+       mc, int *le, int *me, int *lg, int *mg, int *n, 
+       double *x, double *xnrm, double *w, int *jw, int *
+       mode)
+{
+    /* Initialized data */
+
+    const double epmach = 2.22e-16;
+
+    /* System generated locals */
+    int c_dim1, c_offset, e_dim1, e_offset, g_dim1, g_offset, i__1, i__2, 
+           i__3;
+    double d__1;
+
+    /* Local variables */
+    int i__, j, k, l;
+    double t;
+    int ie, if__, ig, iw, mc1;
+    int krank;
+
+/*     FOR MODE=1, THE SUBROUTINE RETURNS THE SOLUTION X OF */
+/*     EQUALITY & INEQUALITY CONSTRAINED LEAST SQUARES PROBLEM LSEI : */
+/*                MIN ||E*X - F|| */
+/*                 X */
+/*                S.T.  C*X  = D, */
+/*                      G*X >= H. */
+/*     USING QR DECOMPOSITION & ORTHOGONAL BASIS OF NULLSPACE OF C */
+/*     CHAPTER 23.6 OF LAWSON & HANSON: SOLVING LEAST SQUARES PROBLEMS. */
+/*     THE FOLLOWING DIMENSIONS OF THE ARRAYS DEFINING THE PROBLEM */
+/*     ARE NECESSARY */
+/*     DIM(E) :   FORMAL (LE,N),    ACTUAL (ME,N) */
+/*     DIM(F) :   FORMAL (LE  ),    ACTUAL (ME  ) */
+/*     DIM(C) :   FORMAL (LC,N),    ACTUAL (MC,N) */
+/*     DIM(D) :   FORMAL (LC  ),    ACTUAL (MC  ) */
+/*     DIM(G) :   FORMAL (LG,N),    ACTUAL (MG,N) */
+/*     DIM(H) :   FORMAL (LG  ),    ACTUAL (MG  ) */
+/*     DIM(X) :   FORMAL (N   ),    ACTUAL (N   ) */
+/*     DIM(W) :   2*MC+ME+(ME+MG)*(N-MC)  for LSEI */
+/*              +(N-MC+1)*(MG+2)+2*MG     for LSI */
+/*     DIM(JW):   MAX(MG,L) */
+/*     ON ENTRY, THE USER HAS TO PROVIDE THE ARRAYS C, D, E, F, G, AND H. */
+/*     ON RETURN, ALL ARRAYS WILL BE CHANGED BY THE SUBROUTINE. */
+/*     X     STORES THE SOLUTION VECTOR */
+/*     XNORM STORES THE RESIDUUM OF THE SOLUTION IN EUCLIDIAN NORM */
+/*     W     STORES THE VECTOR OF LAGRANGE MULTIPLIERS IN ITS FIRST */
+/*           MC+MG ELEMENTS */
+/*     MODE  IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING MEANINGS: */
+/*          MODE=1: SUCCESSFUL COMPUTATION */
+/*               2: ERROR RETURN BECAUSE OF WRONG DIMENSIONS (N<1) */
+/*               3: ITERATION COUNT EXCEEDED BY NNLS */
+/*               4: INEQUALITY CONSTRAINTS INCOMPATIBLE */
+/*               5: MATRIX E IS NOT OF FULL RANK */
+/*               6: MATRIX C IS NOT OF FULL RANK */
+/*               7: RANK DEFECT IN HFTI */
+/*     18.5.1981, DIETER KRAFT, DFVLR OBERPFAFFENHOFEN */
+/*     20.3.1987, DIETER KRAFT, DFVLR OBERPFAFFENHOFEN */
+    /* Parameter adjustments */
+    --d__;
+    --f;
+    --h__;
+    --x;
+    g_dim1 = *lg;
+    g_offset = 1 + g_dim1;
+    g -= g_offset;
+    e_dim1 = *le;
+    e_offset = 1 + e_dim1;
+    e -= e_offset;
+    c_dim1 = *lc;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+    --w;
+    --jw;
+
+    /* Function Body */
+    *mode = 2;
+    if (*mc > *n) {
+       goto L75;
+    }
+    l = *n - *mc;
+    mc1 = *mc + 1;
+    iw = (l + 1) * (*mg + 2) + (*mg << 1) + *mc;
+    ie = iw + *mc + 1;
+    if__ = ie + *me * l;
+    ig = if__ + *me;
+/*  TRIANGULARIZE C AND APPLY FACTORS TO E AND G */
+    i__1 = *mc;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* Computing MIN */
+       i__2 = i__ + 1;
+       j = MIN2(i__2,*lc);
+       i__2 = i__ + 1;
+       i__3 = *mc - i__;
+       h12_(&c__1, &i__, &i__2, n, &c__[i__ + c_dim1], lc, &w[iw + i__], &
+               c__[j + c_dim1], lc, &c__1, &i__3);
+       i__2 = i__ + 1;
+       h12_(&c__2, &i__, &i__2, n, &c__[i__ + c_dim1], lc, &w[iw + i__], &e[
+               e_offset], le, &c__1, me);
+/* L10: */
+       i__2 = i__ + 1;
+       h12_(&c__2, &i__, &i__2, n, &c__[i__ + c_dim1], lc, &w[iw + i__], &g[
+               g_offset], lg, &c__1, mg);
+    }
+/*  SOLVE C*X=D AND MODIFY F */
+    *mode = 6;
+    i__2 = *mc;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+       if ((d__1 = c__[i__ + i__ * c_dim1], fabs(d__1)) < epmach) {
+           goto L75;
+       }
+       i__1 = i__ - 1;
+       x[i__] = (d__[i__] - ddot_sl__(&i__1, &c__[i__ + c_dim1], *lc, &x[1], 1)) 
+            / c__[i__ + i__ * c_dim1];
+/* L15: */
+    }
+    *mode = 1;
+    w[mc1] = 0.0;
+    i__2 = *mg; // BUGFIX for *mc == *n: changed from *mg - *mc, SGJ 2010
+    dcopy___(&i__2, &w[mc1], 0, &w[mc1], 1);
+    if (*mc == *n) {
+       goto L50;
+    }
+    i__2 = *me;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L20: */
+       w[if__ - 1 + i__] = f[i__] - ddot_sl__(mc, &e[i__ + e_dim1], *le, &x[1], 1);
+    }
+/*  STORE TRANSFORMED E & G */
+    i__2 = *me;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L25: */
+       dcopy___(&l, &e[i__ + mc1 * e_dim1], *le, &w[ie - 1 + i__], *me);
+    }
+    i__2 = *mg;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L30: */
+       dcopy___(&l, &g[i__ + mc1 * g_dim1], *lg, &w[ig - 1 + i__], *mg);
+    }
+    if (*mg > 0) {
+       goto L40;
+    }
+/*  SOLVE LS WITHOUT INEQUALITY CONSTRAINTS */
+    *mode = 7;
+    k = MAX2(*le,*n);
+    t = sqrt(epmach);
+    hfti_(&w[ie], me, me, &l, &w[if__], &k, &c__1, &t, &krank, xnrm, &w[1], &
+           w[l + 1], &jw[1]);
+    dcopy___(&l, &w[if__], 1, &x[mc1], 1);
+    if (krank != l) {
+       goto L75;
+    }
+    *mode = 1;
+    goto L50;
+/*  MODIFY H AND SOLVE INEQUALITY CONSTRAINED LS PROBLEM */
+L40:
+    i__2 = *mg;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L45: */
+       h__[i__] -= ddot_sl__(mc, &g[i__ + g_dim1], *lg, &x[1], 1);
+    }
+    lsi_(&w[ie], &w[if__], &w[ig], &h__[1], me, me, mg, mg, &l, &x[mc1], xnrm,
+            &w[mc1], &jw[1], mode);
+    if (*mc == 0) {
+       goto L75;
+    }
+    t = dnrm2___(mc, &x[1], 1);
+    *xnrm = sqrt(*xnrm * *xnrm + t * t);
+    if (*mode != 1) {
+       goto L75;
+    }
+/*  SOLUTION OF ORIGINAL PROBLEM AND LAGRANGE MULTIPLIERS */
+L50:
+    i__2 = *me;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L55: */
+       f[i__] = ddot_sl__(n, &e[i__ + e_dim1], *le, &x[1], 1) - f[i__];
+    }
+    i__2 = *mc;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+/* L60: */
+       d__[i__] = ddot_sl__(me, &e[i__ * e_dim1 + 1], 1, &f[1], 1) - 
+               ddot_sl__(mg, &g[i__ * g_dim1 + 1], 1, &w[mc1], 1);
+    }
+    for (i__ = *mc; i__ >= 1; --i__) {
+/* L65: */
+       i__2 = i__ + 1;
+       h12_(&c__2, &i__, &i__2, n, &c__[i__ + c_dim1], lc, &w[iw + i__], &x[
+               1], &c__1, &c__1, &c__1);
+    }
+    for (i__ = *mc; i__ >= 1; --i__) {
+/* Computing MIN */
+       i__2 = i__ + 1;
+       j = MIN2(i__2,*lc);
+       i__2 = *mc - i__;
+       w[i__] = (d__[i__] - ddot_sl__(&i__2, &c__[j + i__ * c_dim1], 1, &
+               w[j], 1)) / c__[i__ + i__ * c_dim1];
+/* L70: */
+    }
+/*  END OF SUBROUTINE LSEI */
+L75:
+    return;
+} /* lsei_ */
+
+static void lsq_(int *m, int *meq, int *n, int *nl, 
+       int *la, double *l, double *g, double *a, double *
+       b, const double *xl, const double *xu, double *x, double *y, 
+       double *w, int *jw, int *mode)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+    double d__1;
+
+    /* Local variables */
+    int i__, i1, i2, i3, i4, m1, n1, n2, n3, ic, id, ie, if__, ig, ih, il,
+            im, ip, iu, iw;
+    double diag;
+    int mineq;
+    double xnorm;
+
+/*   MINIMIZE with respect to X */
+/*             ||E*X - F|| */
+/*                                      1/2  T */
+/*   WITH UPPER TRIANGULAR MATRIX E = +D   *L , */
+/*                                      -1/2  -1 */
+/*                     AND VECTOR F = -D    *L  *G, */
+/*  WHERE THE UNIT LOWER TRIDIANGULAR MATRIX L IS STORED COLUMNWISE */
+/*  DENSE IN THE N*(N+1)/2 ARRAY L WITH VECTOR D STORED IN ITS */
+/* 'DIAGONAL' THUS SUBSTITUTING THE ONE-ELEMENTS OF L */
+/*   SUBJECT TO */
+/*             A(J)*X - B(J) = 0 ,         J=1,...,MEQ, */
+/*             A(J)*X - B(J) >=0,          J=MEQ+1,...,M, */
+/*             XL(I) <= X(I) <= XU(I),     I=1,...,N, */
+/*     ON ENTRY, THE USER HAS TO PROVIDE THE ARRAYS L, G, A, B, XL, XU. */
+/*     WITH DIMENSIONS: L(N*(N+1)/2), G(N), A(LA,N), B(M), XL(N), XU(N) */
+/*     THE WORKING ARRAY W MUST HAVE AT LEAST THE FOLLOWING DIMENSION: */
+/*     DIM(W) =        (3*N+M)*(N+1)                        for LSQ */
+/*                    +(N-MEQ+1)*(MINEQ+2) + 2*MINEQ        for LSI */
+/*                    +(N+MINEQ)*(N-MEQ) + 2*MEQ + N        for LSEI */
+/*                      with MINEQ = M - MEQ + 2*N */
+/*     ON RETURN, NO ARRAY WILL BE CHANGED BY THE SUBROUTINE. */
+/*     X     STORES THE N-DIMENSIONAL SOLUTION VECTOR */
+/*     Y     STORES THE VECTOR OF LAGRANGE MULTIPLIERS OF DIMENSION */
+/*           M+N+N (CONSTRAINTS+LOWER+UPPER BOUNDS) */
+/*     MODE  IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING MEANINGS: */
+/*          MODE=1: SUCCESSFUL COMPUTATION */
+/*               2: ERROR RETURN BECAUSE OF WRONG DIMENSIONS (N<1) */
+/*               3: ITERATION COUNT EXCEEDED BY NNLS */
+/*               4: INEQUALITY CONSTRAINTS INCOMPATIBLE */
+/*               5: MATRIX E IS NOT OF FULL RANK */
+/*               6: MATRIX C IS NOT OF FULL RANK */
+/*               7: RANK DEFECT IN HFTI */
+/*     coded            Dieter Kraft, april 1987 */
+/*     revised                        march 1989 */
+    /* Parameter adjustments */
+    --y;
+    --x;
+    --xu;
+    --xl;
+    --g;
+    --l;
+    --b;
+    a_dim1 = *la;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --w;
+    --jw;
+
+    /* Function Body */
+    n1 = *n + 1;
+    mineq = *m - *meq;
+    m1 = mineq + *n + *n;
+/*  determine whether to solve problem */
+/*  with inconsistent linerarization (n2=1) */
+/*  or not (n2=0) */
+    n2 = n1 * *n / 2 + 1;
+    if (n2 == *nl) {
+       n2 = 0;
+    } else {
+       n2 = 1;
+    }
+    n3 = *n - n2;
+/*  RECOVER MATRIX E AND VECTOR F FROM L AND G */
+    i2 = 1;
+    i3 = 1;
+    i4 = 1;
+    ie = 1;
+    if__ = *n * *n + 1;
+    i__1 = n3;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       i1 = n1 - i__;
+       diag = sqrt(l[i2]);
+       w[i3] = 0.0;
+       dcopy___(&i1, &w[i3], 0, &w[i3], 1);
+       i__2 = i1 - n2;
+       dcopy___(&i__2, &l[i2], 1, &w[i3], *n);
+       i__2 = i1 - n2;
+       dscal_sl__(&i__2, &diag, &w[i3], *n);
+       w[i3] = diag;
+       i__2 = i__ - 1;
+       w[if__ - 1 + i__] = (g[i__] - ddot_sl__(&i__2, &w[i4], 1, &w[if__]
+               , 1)) / diag;
+       i2 = i2 + i1 - n2;
+       i3 += n1;
+       i4 += *n;
+/* L10: */
+    }
+    if (n2 == 1) {
+       w[i3] = l[*nl];
+       w[i4] = 0.0;
+       dcopy___(&n3, &w[i4], 0, &w[i4], 1);
+       w[if__ - 1 + *n] = 0.0;
+    }
+    d__1 = -one;
+    dscal_sl__(n, &d__1, &w[if__], 1);
+    ic = if__ + *n;
+    id = ic + *meq * *n;
+    if (*meq > 0) {
+/*  RECOVER MATRIX C FROM UPPER PART OF A */
+       i__1 = *meq;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           dcopy___(n, &a[i__ + a_dim1], *la, &w[ic - 1 + i__], *meq);
+/* L20: */
+       }
+/*  RECOVER VECTOR D FROM UPPER PART OF B */
+       dcopy___(meq, &b[1], 1, &w[id], 1);
+       d__1 = -one;
+       dscal_sl__(meq, &d__1, &w[id], 1);
+    }
+    ig = id + *meq;
+    if (mineq > 0) {
+/*  RECOVER MATRIX G FROM LOWER PART OF A */
+       i__1 = mineq;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+           dcopy___(n, &a[*meq + i__ + a_dim1], *la, &w[ig - 1 + i__], m1);
+/* L30: */
+       }
+    }
+/*  AUGMENT MATRIX G BY +I AND -I */
+    ip = ig + mineq;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       w[ip - 1 + i__] = 0.0;
+       dcopy___(n, &w[ip - 1 + i__], 0, &w[ip - 1 + i__], m1);
+/* L40: */
+    }
+    i__1 = m1 + 1;
+    /* SGJ, 2010: skip constraints for infinite bounds */
+    for (i__ = 1; i__ <= *n; ++i__)
+        if (!nlopt_isinf(xl[i__])) w[(ip - i__1) + i__ * i__1] = +1.0;
+    /* Old code: w[ip] = one; dcopy___(n, &w[ip], 0, &w[ip], i__1); */
+    im = ip + *n;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       w[im - 1 + i__] = 0.0;
+       dcopy___(n, &w[im - 1 + i__], 0, &w[im - 1 + i__], m1);
+/* L50: */
+    }
+    i__1 = m1 + 1;
+    /* SGJ, 2010: skip constraints for infinite bounds */
+    for (i__ = 1; i__ <= *n; ++i__)
+        if (!nlopt_isinf(xu[i__])) w[(im - i__1) + i__ * i__1] = -1.0;
+    /* Old code: w[im] = -one;  dcopy___(n, &w[im], 0, &w[im], i__1); */
+    ih = ig + m1 * *n;
+    if (mineq > 0) {
+/*  RECOVER H FROM LOWER PART OF B */
+       dcopy___(&mineq, &b[*meq + 1], 1, &w[ih], 1);
+       d__1 = -one;
+       dscal_sl__(&mineq, &d__1, &w[ih], 1);
+    }
+/*  AUGMENT VECTOR H BY XL AND XU */
+    il = ih + mineq;
+    iu = il + *n;
+    /* SGJ, 2010: skip constraints for infinite bounds */
+    for (i__ = 1; i__ <= *n; ++i__) {
+        w[(il-1) + i__] = nlopt_isinf(xl[i__]) ? 0 : xl[i__];
+        w[(iu-1) + i__] = nlopt_isinf(xu[i__]) ? 0 : -xu[i__];
+    }
+    /* Old code: dcopy___(n, &xl[1], 1, &w[il], 1);
+                 dcopy___(n, &xu[1], 1, &w[iu], 1);
+                d__1 = -one; dscal_sl__(n, &d__1, &w[iu], 1); */
+    iw = iu + *n;
+    i__1 = MAX2(1,*meq);
+    lsei_(&w[ic], &w[id], &w[ie], &w[if__], &w[ig], &w[ih], &i__1, meq, n, n, 
+           &m1, &m1, n, &x[1], &xnorm, &w[iw], &jw[1], mode);
+    if (*mode == 1) {
+/*   restore Lagrange multipliers */
+       dcopy___(m, &w[iw], 1, &y[1], 1);
+       dcopy___(&n3, &w[iw + *m], 1, &y[*m + 1], 1);
+       dcopy___(&n3, &w[iw + *m + *n], 1, &y[*m + n3 + 1], 1);
+
+       /* SGJ, 2010: make sure bound constraints are satisfied, since
+          roundoff error sometimes causes slight violations and
+          NLopt guarantees that bounds are strictly obeyed */
+       i__1 = *n;
+       for (i__ = 1; i__ <= i__1; ++i__) {
+            if (x[i__] < xl[i__]) x[i__] = xl[i__];
+            else if (x[i__] > xu[i__]) x[i__] = xu[i__];
+       }
+    }
+/*   END OF SUBROUTINE LSQ */
+} /* lsq_ */
+
+static void ldl_(int *n, double *a, double *z__, 
+       double *sigma, double *w)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+    const double four = 4.;
+    const double epmach = 2.22e-16;
+
+    /* System generated locals */
+    int i__1, i__2;
+
+    /* Local variables */
+    int i__, j;
+    double t, u, v;
+    int ij;
+    double tp, beta, gamma_, alpha, delta;
+
+/*   LDL     LDL' - RANK-ONE - UPDATE */
+/*   PURPOSE: */
+/*           UPDATES THE LDL' FACTORS OF MATRIX A BY RANK-ONE MATRIX */
+/*           SIGMA*Z*Z' */
+/*   INPUT ARGUMENTS: (* MEANS PARAMETERS ARE CHANGED DURING EXECUTION) */
+/*     N     : ORDER OF THE COEFFICIENT MATRIX A */
+/*   * A     : POSITIVE DEFINITE MATRIX OF DIMENSION N; */
+/*             ONLY THE LOWER TRIANGLE IS USED AND IS STORED COLUMN BY */
+/*             COLUMN AS ONE DIMENSIONAL ARRAY OF DIMENSION N*(N+1)/2. */
+/*   * Z     : VECTOR OF DIMENSION N OF UPDATING ELEMENTS */
+/*     SIGMA : SCALAR FACTOR BY WHICH THE MODIFYING DYADE Z*Z' IS */
+/*             MULTIPLIED */
+/*   OUTPUT ARGUMENTS: */
+/*     A     : UPDATED LDL' FACTORS */
+/*   WORKING ARRAY: */
+/*     W     : VECTOR OP DIMENSION N (USED ONLY IF SIGMA .LT. ZERO) */
+/*   METHOD: */
+/*     THAT OF FLETCHER AND POWELL AS DESCRIBED IN : */
+/*     FLETCHER,R.,(1974) ON THE MODIFICATION OF LDL' FACTORIZATION. */
+/*     POWELL,M.J.D.      MATH.COMPUTATION 28, 1067-1078. */
+/*   IMPLEMENTED BY: */
+/*     KRAFT,D., DFVLR - INSTITUT FUER DYNAMIK DER FLUGSYSTEME */
+/*               D-8031  OBERPFAFFENHOFEN */
+/*   STATUS: 15. JANUARY 1980 */
+/*   SUBROUTINES REQUIRED: NONE */
+    /* Parameter adjustments */
+    --w;
+    --z__;
+    --a;
+
+    /* Function Body */
+    if (*sigma == 0.0) {
+       goto L280;
+    }
+    ij = 1;
+    t = one / *sigma;
+    if (*sigma > 0.0) {
+       goto L220;
+    }
+/* PREPARE NEGATIVE UPDATE */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+/* L150: */
+       w[i__] = z__[i__];
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       v = w[i__];
+       t += v * v / a[ij];
+       i__2 = *n;
+       for (j = i__ + 1; j <= i__2; ++j) {
+           ++ij;
+/* L160: */
+           w[j] -= v * a[ij];
+       }
+/* L170: */
+       ++ij;
+    }
+    if (t >= 0.0) {
+       t = epmach / *sigma;
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       j = *n + 1 - i__;
+       ij -= i__;
+       u = w[j];
+       w[j] = t;
+/* L210: */
+       t -= u * u / a[ij];
+    }
+L220:
+/* HERE UPDATING BEGINS */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       v = z__[i__];
+       delta = v / a[ij];
+       if (*sigma < 0.0) {
+           tp = w[i__];
+       }
+       else /* if (*sigma > 0.0), since *sigma != 0 from above */ {
+           tp = t + delta * v;
+       }
+       alpha = tp / t;
+       a[ij] = alpha * a[ij];
+       if (i__ == *n) {
+           goto L280;
+       }
+       beta = delta / tp;
+       if (alpha > four) {
+           goto L240;
+       }
+       i__2 = *n;
+       for (j = i__ + 1; j <= i__2; ++j) {
+           ++ij;
+           z__[j] -= v * a[ij];
+/* L230: */
+           a[ij] += beta * z__[j];
+       }
+       goto L260;
+L240:
+       gamma_ = t / tp;
+       i__2 = *n;
+       for (j = i__ + 1; j <= i__2; ++j) {
+           ++ij;
+           u = a[ij];
+           a[ij] = gamma_ * u + beta * z__[j];
+/* L250: */
+           z__[j] -= v * u;
+       }
+L260:
+       ++ij;
+/* L270: */
+       t = tp;
+    }
+L280:
+    return;
+/* END OF LDL */
+} /* ldl_ */
+
+#if 0
+/* we don't want to use this linmin function, for two reasons:
+   1) it was apparently written assuming an old version of Fortran where all variables
+      are saved by default, hence it was missing a "save" statement ... I would
+      need to go through and figure out which variables need to be declared "static"
+      (or, better yet, save them like I did in slsqp to make it re-entrant)
+   2) it doesn't exploit gradient information, which is stupid since we have this info
+   3) in the context of NLopt, it makes much more sence to use the local_opt algorithm
+      to do the line minimization recursively by whatever algorithm the user wants
+      (defaulting to a gradient-based method like LBFGS) */
+static double d_sign(double a, double s) { return s < 0 ? -a : a; }
+static double linmin_(int *mode, const double *ax, const double *bx, double *
+       f, double *tol)
+{
+    /* Initialized data */
+
+    const double c__ = .381966011;
+    const double eps = 1.5e-8;
+
+    /* System generated locals */
+    double ret_val, d__1;
+
+    /* Local variables */
+    double a, b, d__, e, m, p, q, r__, u, v, w, x, fu, fv, fw, fx, tol1, 
+           tol2;
+
+/*   LINMIN  LINESEARCH WITHOUT DERIVATIVES */
+/*   PURPOSE: */
+/*  TO FIND THE ARGUMENT LINMIN WHERE THE FUNCTION F TAKES ITS MINIMUM */
+/*  ON THE INTERVAL AX, BX. */
+/*  COMBINATION OF GOLDEN SECTION AND SUCCESSIVE QUADRATIC INTERPOLATION. */
+/*   INPUT ARGUMENTS: (* MEANS PARAMETERS ARE CHANGED DURING EXECUTION) */
+/* *MODE   SEE OUTPUT ARGUMENTS */
+/*  AX     LEFT ENDPOINT OF INITIAL INTERVAL */
+/*  BX     RIGHT ENDPOINT OF INITIAL INTERVAL */
+/*  F      FUNCTION VALUE AT LINMIN WHICH IS TO BE BROUGHT IN BY */
+/*         REVERSE COMMUNICATION CONTROLLED BY MODE */
+/*  TOL    DESIRED LENGTH OF INTERVAL OF UNCERTAINTY OF FINAL RESULT */
+/*   OUTPUT ARGUMENTS: */
+/*  LINMIN ABSCISSA APPROXIMATING THE POINT WHERE F ATTAINS A MINIMUM */
+/*  MODE   CONTROLS REVERSE COMMUNICATION */
+/*         MUST BE SET TO 0 INITIALLY, RETURNS WITH INTERMEDIATE */
+/*         VALUES 1 AND 2 WHICH MUST NOT BE CHANGED BY THE USER, */
+/*         ENDS WITH CONVERGENCE WITH VALUE 3. */
+/*   WORKING ARRAY: */
+/*  NONE */
+/*   METHOD: */
+/*  THIS FUNCTION SUBPROGRAM IS A SLIGHTLY MODIFIED VERSION OF THE */
+/*  ALGOL 60 PROCEDURE LOCALMIN GIVEN IN */
+/*  R.P. BRENT: ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES, */
+/*              PRENTICE-HALL (1973). */
+/*   IMPLEMENTED BY: */
+/*     KRAFT, D., DFVLR - INSTITUT FUER DYNAMIK DER FLUGSYSTEME */
+/*                D-8031  OBERPFAFFENHOFEN */
+/*   STATUS: 31. AUGUST  1984 */
+/*   SUBROUTINES REQUIRED: NONE */
+/*  EPS = SQUARE - ROOT OF MACHINE PRECISION */
+/*  C = GOLDEN SECTION RATIO = (3-SQRT(5))/2 */
+    switch (*mode) {
+       case 1:  goto L10;
+       case 2:  goto L55;
+    }
+/*  INITIALIZATION */
+    a = *ax;
+    b = *bx;
+    e = 0.0;
+    v = a + c__ * (b - a);
+    w = v;
+    x = w;
+    ret_val = x;
+    *mode = 1;
+    goto L100;
+/*  MAIN LOOP STARTS HERE */
+L10:
+    fx = *f;
+    fv = fx;
+    fw = fv;
+L20:
+    m = (a + b) * .5;
+    tol1 = eps * fabs(x) + *tol;
+    tol2 = tol1 + tol1;
+/*  TEST CONVERGENCE */
+    if ((d__1 = x - m, fabs(d__1)) <= tol2 - (b - a) * .5) {
+       goto L90;
+    }
+    r__ = 0.0;
+    q = r__;
+    p = q;
+    if (fabs(e) <= tol1) {
+       goto L30;
+    }
+/*  FIT PARABOLA */
+    r__ = (x - w) * (fx - fv);
+    q = (x - v) * (fx - fw);
+    p = (x - v) * q - (x - w) * r__;
+    q -= r__;
+    q += q;
+    if (q > 0.0) {
+       p = -p;
+    }
+    if (q < 0.0) {
+       q = -q;
+    }
+    r__ = e;
+    e = d__;
+/*  IS PARABOLA ACCEPTABLE */
+L30:
+    if (fabs(p) >= (d__1 = q * r__, fabs(d__1)) * .5 || p <= q * (a - x) || p >=
+            q * (b - x)) {
+       goto L40;
+    }
+/*  PARABOLIC INTERPOLATION STEP */
+    d__ = p / q;
+/*  F MUST NOT BE EVALUATED TOO CLOSE TO A OR B */
+    if (u - a < tol2) {
+       d__1 = m - x;
+       d__ = d_sign(tol1, d__1);
+    }
+    if (b - u < tol2) {
+       d__1 = m - x;
+       d__ = d_sign(tol1, d__1);
+    }
+    goto L50;
+/*  GOLDEN SECTION STEP */
+L40:
+    if (x >= m) {
+       e = a - x;
+    }
+    if (x < m) {
+       e = b - x;
+    }
+    d__ = c__ * e;
+/*  F MUST NOT BE EVALUATED TOO CLOSE TO X */
+L50:
+    if (fabs(d__) < tol1) {
+       d__ = d_sign(tol1, d__);
+    }
+    u = x + d__;
+    ret_val = u;
+    *mode = 2;
+    goto L100;
+L55:
+    fu = *f;
+/*  UPDATE A, B, V, W, AND X */
+    if (fu > fx) {
+       goto L60;
+    }
+    if (u >= x) {
+       a = x;
+    }
+    if (u < x) {
+       b = x;
+    }
+    v = w;
+    fv = fw;
+    w = x;
+    fw = fx;
+    x = u;
+    fx = fu;
+    goto L85;
+L60:
+    if (u < x) {
+       a = u;
+    }
+    if (u >= x) {
+       b = u;
+    }
+    if (fu <= fw || w == x) {
+       goto L70;
+    }
+    if (fu <= fv || v == x || v == w) {
+       goto L80;
+    }
+    goto L85;
+L70:
+    v = w;
+    fv = fw;
+    w = u;
+    fw = fu;
+    goto L85;
+L80:
+    v = u;
+    fv = fu;
+L85:
+    goto L20;
+/*  END OF MAIN LOOP */
+L90:
+    ret_val = x;
+    *mode = 3;
+L100:
+    return ret_val;
+/*  END OF LINMIN */
+} /* linmin_ */
+#endif
+
+typedef struct {
+    double t, f0, h1, h2, h3, h4;
+    int n1, n2, n3;
+    double t0, gs;
+    double tol;
+    int line;
+    double alpha;
+    int iexact;
+    int incons, ireset, itermx;
+    double *x0;
+} slsqpb_state;
+
+#define SS(var) state->var = var
+#define SAVE_STATE \
+     SS(t); SS(f0); SS(h1); SS(h2); SS(h3); SS(h4);    \
+     SS(n1); SS(n2); SS(n3); \
+     SS(t0); SS(gs); \
+     SS(tol); \
+     SS(line); \
+     SS(alpha); \
+     SS(iexact); \
+     SS(incons); SS(ireset); SS(itermx)
+
+#define RS(var) var = state->var
+#define RESTORE_STATE \
+     RS(t); RS(f0); RS(h1); RS(h2); RS(h3); RS(h4);    \
+     RS(n1); RS(n2); RS(n3); \
+     RS(t0); RS(gs); \
+     RS(tol); \
+     RS(line); \
+     RS(alpha); \
+     RS(iexact); \
+     RS(incons); RS(ireset); RS(itermx)
+
+static void slsqpb_(int *m, int *meq, int *la, int *
+                   n, double *x, const double *xl, const double *xu, double *f, 
+                   double *c__, double *g, double *a, double *acc, 
+                   int *iter, int *mode, double *r__, double *l, 
+                   double *x0, double *mu, double *s, double *u, 
+                   double *v, double *w, int *iw, 
+                   slsqpb_state *state)
+{
+    /* Initialized data */
+
+    const double one = 1.;
+    const double alfmin = .1;
+    const double hun = 100.;
+    const double ten = 10.;
+    const double two = 2.;
+
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+    double d__1, d__2;
+
+    /* Local variables */
+    int i__, j, k;
+
+    /* saved state from one call to the next;
+       SGJ 2010: save/restore via state parameter, to make re-entrant. */
+    double t, f0, h1, h2, h3, h4;
+    int n1, n2, n3;
+    double t0, gs;
+    double tol;
+    int line;
+    double alpha;
+    int iexact;
+    int incons, ireset, itermx;
+    RESTORE_STATE;
+
+/*   NONLINEAR PROGRAMMING BY SOLVING SEQUENTIALLY QUADRATIC PROGRAMS */
+/*        -  L1 - LINE SEARCH,  POSITIVE DEFINITE  BFGS UPDATE  - */
+/*                      BODY SUBROUTINE FOR SLSQP */
+/*     dim(W) =         N1*(N1+1) + MEQ*(N1+1) + MINEQ*(N1+1)  for LSQ */
+/*                     +(N1-MEQ+1)*(MINEQ+2) + 2*MINEQ */
+/*                     +(N1+MINEQ)*(N1-MEQ) + 2*MEQ + N1       for LSEI */
+/*                      with MINEQ = M - MEQ + 2*N1  &  N1 = N+1 */
+    /* Parameter adjustments */
+    --mu;
+    --c__;
+    --v;
+    --u;
+    --s;
+    --x0;
+    --l;
+    --r__;
+    a_dim1 = *la;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --g;
+    --xu;
+    --xl;
+    --x;
+    --w;
+    --iw;
+
+    /* Function Body */
+    if (*mode == -1) {
+       goto L260;
+    } else if (*mode == 0) {
+       goto L100;
+    } else {
+       goto L220;
+    }
+L100:
+    itermx = *iter;
+    if (*acc >= 0.0) {
+       iexact = 0;
+    } else {
+       iexact = 1;
+    }
+    *acc = fabs(*acc);
+    tol = ten * *acc;
+    *iter = 0;
+    ireset = 0;
+    n1 = *n + 1;
+    n2 = n1 * *n / 2;
+    n3 = n2 + 1;
+    s[1] = 0.0;
+    mu[1] = 0.0;
+    dcopy___(n, &s[1], 0, &s[1], 1);
+    dcopy___(m, &mu[1], 0, &mu[1], 1);
+/*   RESET BFGS MATRIX */
+L110:
+    ++ireset;
+    if (ireset > 5) {
+       goto L255;
+    }
+    l[1] = 0.0;
+    dcopy___(&n2, &l[1], 0, &l[1], 1);
+    j = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       l[j] = one;
+       j = j + n1 - i__;
+/* L120: */
+    }
+/*   MAIN ITERATION : SEARCH DIRECTION, STEPLENGTH, LDL'-UPDATE */
+L130:
+    ++(*iter);
+    *mode = 9;
+    if (*iter > itermx && itermx > 0) { /* SGJ 2010: ignore if itermx <= 0 */
+       goto L330;
+    }
+/*   SEARCH DIRECTION AS SOLUTION OF QP - SUBPROBLEM */
+    dcopy___(n, &xl[1], 1, &u[1], 1);
+    dcopy___(n, &xu[1], 1, &v[1], 1);
+    d__1 = -one;
+    daxpy_sl__(n, &d__1, &x[1], 1, &u[1], 1);
+    d__1 = -one;
+    daxpy_sl__(n, &d__1, &x[1], 1, &v[1], 1);
+    h4 = one;
+    lsq_(m, meq, n, &n3, la, &l[1], &g[1], &a[a_offset], &c__[1], &u[1], &v[1]
+           , &s[1], &r__[1], &w[1], &iw[1], mode);
+
+/*   AUGMENTED PROBLEM FOR INCONSISTENT LINEARIZATION */
+    if (*mode == 6) {
+       if (*n == *meq) {
+           *mode = 4;
+       }
+    }
+    if (*mode == 4) {
+       i__1 = *m;
+       for (j = 1; j <= i__1; ++j) {
+           if (j <= *meq) {
+               a[j + n1 * a_dim1] = -c__[j];
+           } else {
+/* Computing MAX */
+               d__1 = -c__[j];
+               a[j + n1 * a_dim1] = MAX2(d__1,0.0);
+           }
+/* L140: */
+       }
+       s[1] = 0.0;
+       dcopy___(n, &s[1], 0, &s[1], 1);
+       h3 = 0.0;
+       g[n1] = 0.0;
+       l[n3] = hun;
+       s[n1] = one;
+       u[n1] = 0.0;
+       v[n1] = one;
+       incons = 0;
+L150:
+       lsq_(m, meq, &n1, &n3, la, &l[1], &g[1], &a[a_offset], &c__[1], &u[1],
+                &v[1], &s[1], &r__[1], &w[1], &iw[1], mode);
+       h4 = one - s[n1];
+       if (*mode == 4) {
+           l[n3] = ten * l[n3];
+           ++incons;
+           if (incons > 5) {
+               goto L330;
+           }
+           goto L150;
+       } else if (*mode != 1) {
+           goto L330;
+       }
+    } else if (*mode != 1) {
+       goto L330;
+    }
+/*   UPDATE MULTIPLIERS FOR L1-TEST */
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       v[i__] = g[i__] - ddot_sl__(m, &a[i__ * a_dim1 + 1], 1, &r__[1], 1);
+/* L160: */
+    }
+    f0 = *f;
+    dcopy___(n, &x[1], 1, &x0[1], 1);
+    gs = ddot_sl__(n, &g[1], 1, &s[1], 1);
+    h1 = fabs(gs);
+    h2 = 0.0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       if (j <= *meq) {
+           h3 = c__[j];
+       } else {
+           h3 = 0.0;
+       }
+/* Computing MAX */
+       d__1 = -c__[j];
+       h2 += MAX2(d__1,h3);
+       h3 = (d__1 = r__[j], fabs(d__1));
+/* Computing MAX */
+       d__1 = h3, d__2 = (mu[j] + h3) / two;
+       mu[j] = MAX2(d__1,d__2);
+       h1 += h3 * (d__1 = c__[j], fabs(d__1));
+/* L170: */
+    }
+/*   CHECK CONVERGENCE */
+    *mode = 0;
+    if (h1 < *acc && h2 < *acc) {
+       goto L330;
+    }
+    h1 = 0.0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       if (j <= *meq) {
+           h3 = c__[j];
+       } else {
+           h3 = 0.0;
+       }
+/* Computing MAX */
+       d__1 = -c__[j];
+       h1 += mu[j] * MAX2(d__1,h3);
+/* L180: */
+    }
+    t0 = *f + h1;
+    h3 = gs - h1 * h4;
+    *mode = 8;
+    if (h3 >= 0.0) {
+       goto L110;
+    }
+/*   LINE SEARCH WITH AN L1-TESTFUNCTION */
+    line = 0;
+    alpha = one;
+    if (iexact == 1) {
+       goto L210;
+    }
+/*   INEXACT LINESEARCH */
+L190:
+    ++line;
+    h3 = alpha * h3;
+    dscal_sl__(n, &alpha, &s[1], 1);
+    dcopy___(n, &x0[1], 1, &x[1], 1);
+    daxpy_sl__(n, &one, &s[1], 1, &x[1], 1);
+    
+    /* SGJ 2010: ensure roundoff doesn't push us past bound constraints */
+    i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) {
+        if (x[i__] < xl[i__]) x[i__] = xl[i__];
+        else if (x[i__] > xu[i__]) x[i__] = xu[i__];
+    }
+
+    /* SGJ 2010: optimizing for the common case where the inexact line
+       search succeeds in one step, use special mode = -2 here to
+       eliminate a a subsequent unnecessary mode = -1 call, at the 
+       expense of extra gradient evaluations when more than one inexact
+       line-search step is required */
+    *mode = line == 1 ? -2 : 1;
+    goto L330;
+L200:
+    if (h1 <= h3 / ten || line > 10) {
+       goto L240;
+    }
+/* Computing MAX */
+    d__1 = h3 / (two * (h3 - h1));
+    alpha = MAX2(d__1,alfmin);
+    goto L190;
+/*   EXACT LINESEARCH */
+L210:
+#if 0
+    /* SGJ: see comments by linmin_ above: if we want to do an exact linesearch
+       (which usually we probably don't), we should call NLopt recursively */
+    if (line != 3) {
+       alpha = linmin_(&line, &alfmin, &one, &t, &tol);
+       dcopy___(n, &x0[1], 1, &x[1], 1);
+       daxpy_sl__(n, &alpha, &s[1], 1, &x[1], 1);
+       *mode = 1;
+       goto L330;
+    }
+#else
+    *mode = 9 /* will yield nlopt_failure */; return;
+#endif
+    dscal_sl__(n, &alpha, &s[1], 1);
+    goto L240;
+/*   CALL FUNCTIONS AT CURRENT X */
+L220:
+    t = *f;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       if (j <= *meq) {
+           h1 = c__[j];
+       } else {
+           h1 = 0.0;
+       }
+/* Computing MAX */
+       d__1 = -c__[j];
+       t += mu[j] * MAX2(d__1,h1);
+/* L230: */
+    }
+    h1 = t - t0;
+    switch (iexact + 1) {
+       case 1:  goto L200;
+       case 2:  goto L210;
+    }
+/*   CHECK CONVERGENCE */
+L240:
+    h3 = 0.0;
+    i__1 = *m;
+    for (j = 1; j <= i__1; ++j) {
+       if (j <= *meq) {
+           h1 = c__[j];
+       } else {
+           h1 = 0.0;
+       }
+/* Computing MAX */
+       d__1 = -c__[j];
+       h3 += MAX2(d__1,h1);
+/* L250: */
+    }
+    if (((d__1 = *f - f0, fabs(d__1)) < *acc || dnrm2___(n, &s[1], 1) < *
+           acc) && h3 < *acc) {
+       *mode = 0;
+    } else {
+       *mode = -1;
+    }
+    goto L330;
+/*   CHECK relaxed CONVERGENCE in case of positive directional derivative */
+L255:
+    if (((d__1 = *f - f0, fabs(d__1)) < tol || dnrm2___(n, &s[1], 1) < tol)
+            && h3 < tol) {
+       *mode = 0;
+    } else {
+       *mode = 8;
+    }
+    goto L330;
+/*   CALL JACOBIAN AT CURRENT X */
+/*   UPDATE CHOLESKY-FACTORS OF HESSIAN MATRIX BY MODIFIED BFGS FORMULA */
+L260:
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       u[i__] = g[i__] - ddot_sl__(m, &a[i__ * a_dim1 + 1], 1, &r__[1], 1) - v[i__];
+/* L270: */
+    }
+/*   L'*S */
+    k = 0;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       h1 = 0.0;
+       ++k;
+       i__2 = *n;
+       for (j = i__ + 1; j <= i__2; ++j) {
+           ++k;
+           h1 += l[k] * s[j];
+/* L280: */
+       }
+       v[i__] = s[i__] + h1;
+/* L290: */
+    }
+/*   D*L'*S */
+    k = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+       v[i__] = l[k] * v[i__];
+       k = k + n1 - i__;
+/* L300: */
+    }
+/*   L*D*L'*S */
+    for (i__ = *n; i__ >= 1; --i__) {
+       h1 = 0.0;
+       k = i__;
+       i__1 = i__ - 1;
+       for (j = 1; j <= i__1; ++j) {
+           h1 += l[k] * v[j];
+           k = k + *n - j;
+/* L310: */
+       }
+       v[i__] += h1;
+/* L320: */
+    }
+    h1 = ddot_sl__(n, &s[1], 1, &u[1], 1);
+    h2 = ddot_sl__(n, &s[1], 1, &v[1], 1);
+    h3 = h2 * .2;
+    if (h1 < h3) {
+       h4 = (h2 - h3) / (h2 - h1);
+       h1 = h3;
+       dscal_sl__(n, &h4, &u[1], 1);
+       d__1 = one - h4;
+       daxpy_sl__(n, &d__1, &v[1], 1, &u[1], 1);
+    }
+    d__1 = one / h1;
+    ldl_(n, &l[1], &u[1], &d__1, &v[1]);
+    d__1 = -one / h2;
+    ldl_(n, &l[1], &v[1], &d__1, &u[1]);
+/*   END OF MAIN ITERATION */
+    goto L130;
+/*   END OF SLSQPB */
+L330:
+    SAVE_STATE;
+} /* slsqpb_ */
+
+/* *********************************************************************** */
+/*                              optimizer                               * */
+/* *********************************************************************** */
+static void slsqp(int *m, int *meq, int *la, int *n,
+                 double *x, const double *xl, const double *xu, double *f, 
+                 double *c__, double *g, double *a, double *acc, 
+                 int *iter, int *mode, double *w, int *l_w__, int *
+                 jw, int *l_jw__, slsqpb_state *state)
+{
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+
+    /* Local variables */
+    int n1, il, im, ir, is, iu, iv, iw, ix, mineq;
+
+/*   SLSQP       S EQUENTIAL  L EAST  SQ UARES  P ROGRAMMING */
+/*            TO SOLVE GENERAL NONLINEAR OPTIMIZATION PROBLEMS */
+/* *********************************************************************** */
+/* *                                                                     * */
+/* *                                                                     * */
+/* *            A NONLINEAR PROGRAMMING METHOD WITH                      * */
+/* *            QUADRATIC  PROGRAMMING  SUBPROBLEMS                      * */
+/* *                                                                     * */
+/* *                                                                     * */
+/* *  THIS SUBROUTINE SOLVES THE GENERAL NONLINEAR PROGRAMMING PROBLEM   * */
+/* *                                                                     * */
+/* *            MINIMIZE    F(X)                                         * */
+/* *                                                                     * */
+/* *            SUBJECT TO  C (X) .EQ. 0  ,  J = 1,...,MEQ               * */
+/* *                         J                                           * */
+/* *                                                                     * */
+/* *                        C (X) .GE. 0  ,  J = MEQ+1,...,M             * */
+/* *                         J                                           * */
+/* *                                                                     * */
+/* *                        XL .LE. X .LE. XU , I = 1,...,N.             * */
+/* *                          I      I       I                           * */
+/* *                                                                     * */
+/* *  THE ALGORITHM IMPLEMENTS THE METHOD OF HAN AND POWELL              * */
+/* *  WITH BFGS-UPDATE OF THE B-MATRIX AND L1-TEST FUNCTION              * */
+/* *  WITHIN THE STEPLENGTH ALGORITHM.                                   * */
+/* *                                                                     * */
+/* *    PARAMETER DESCRIPTION:                                           * */
+/* *    ( * MEANS THIS PARAMETER WILL BE CHANGED DURING CALCULATION )    * */
+/* *                                                                     * */
+/* *    M              IS THE TOTAL NUMBER OF CONSTRAINTS, M .GE. 0      * */
+/* *    MEQ            IS THE NUMBER OF EQUALITY CONSTRAINTS, MEQ .GE. 0 * */
+/* *    LA             SEE A, LA .GE. MAX(M,1)                           * */
+/* *    N              IS THE NUMBER OF VARIBLES, N .GE. 1               * */
+/* *  * X()            X() STORES THE CURRENT ITERATE OF THE N VECTOR X  * */
+/* *                   ON ENTRY X() MUST BE INITIALIZED. ON EXIT X()     * */
+/* *                   STORES THE SOLUTION VECTOR X IF MODE = 0.         * */
+/* *    XL()           XL() STORES AN N VECTOR OF LOWER BOUNDS XL TO X.  * */
+/* *    XU()           XU() STORES AN N VECTOR OF UPPER BOUNDS XU TO X.  * */
+/* *    F              IS THE VALUE OF THE OBJECTIVE FUNCTION.           * */
+/* *    C()            C() STORES THE M VECTOR C OF CONSTRAINTS,         * */
+/* *                   EQUALITY CONSTRAINTS (IF ANY) FIRST.              * */
+/* *                   DIMENSION OF C MUST BE GREATER OR EQUAL LA,       * */
+/* *                   which must be GREATER OR EQUAL MAX(1,M).          * */
+/* *    G()            G() STORES THE N VECTOR G OF PARTIALS OF THE      * */
+/* *                   OBJECTIVE FUNCTION; DIMENSION OF G MUST BE        * */
+/* *                   GREATER OR EQUAL N+1.                             * */
+/* *    A(),LA,M,N     THE LA BY N + 1 ARRAY A() STORES                  * */
+/* *                   THE M BY N MATRIX A OF CONSTRAINT NORMALS.        * */
+/* *                   A() HAS FIRST DIMENSIONING PARAMETER LA,          * */
+/* *                   WHICH MUST BE GREATER OR EQUAL MAX(1,M).          * */
+/* *    F,C,G,A        MUST ALL BE SET BY THE USER BEFORE EACH CALL.     * */
+/* *  * ACC            ABS(ACC) CONTROLS THE FINAL ACCURACY.             * */
+/* *                   IF ACC .LT. ZERO AN EXACT LINESEARCH IS PERFORMED,* */
+/* *                   OTHERWISE AN ARMIJO-TYPE LINESEARCH IS USED.      * */
+/* *  * ITER           PRESCRIBES THE MAXIMUM NUMBER OF ITERATIONS.      * */
+/* *                   ON EXIT ITER INDICATES THE NUMBER OF ITERATIONS.  * */
+/* *  * MODE           MODE CONTROLS CALCULATION:                        * */
+/* *                   REVERSE COMMUNICATION IS USED IN THE SENSE THAT   * */
+/* *                   THE PROGRAM IS INITIALIZED BY MODE = 0; THEN IT IS* */
+/* *                   TO BE CALLED REPEATEDLY BY THE USER UNTIL A RETURN* */
+/* *                   WITH MODE .NE. IABS(1) TAKES PLACE.               * */
+/* *                   IF MODE = -1 GRADIENTS HAVE TO BE CALCULATED,     * */
+/* *                   WHILE WITH MODE = 1 FUNCTIONS HAVE TO BE CALCULATED */
+/* *                   MODE MUST NOT BE CHANGED BETWEEN SUBSEQUENT CALLS * */
+/* *                   OF SQP.                                           * */
+/* *                   EVALUATION MODES:                                 * */
+/* *        MODE = -2,-1: GRADIENT EVALUATION, (G&A)                     * */
+/* *                0: ON ENTRY: INITIALIZATION, (F,G,C&A)               * */
+/* *                   ON EXIT : REQUIRED ACCURACY FOR SOLUTION OBTAINED * */
+/* *                1: FUNCTION EVALUATION, (F&C)                        * */
+/* *                                                                     * */
+/* *                   FAILURE MODES:                                    * */
+/* *                2: NUMBER OF EQUALITY CONTRAINTS LARGER THAN N       * */
+/* *                3: MORE THAN 3*N ITERATIONS IN LSQ SUBPROBLEM        * */
+/* *                4: INEQUALITY CONSTRAINTS INCOMPATIBLE               * */
+/* *                5: SINGULAR MATRIX E IN LSQ SUBPROBLEM               * */
+/* *                6: SINGULAR MATRIX C IN LSQ SUBPROBLEM               * */
+/* *                7: RANK-DEFICIENT EQUALITY CONSTRAINT SUBPROBLEM HFTI* */
+/* *                8: POSITIVE DIRECTIONAL DERIVATIVE FOR LINESEARCH    * */
+/* *                9: MORE THAN ITER ITERATIONS IN SQP                  * */
+/* *             >=10: WORKING SPACE W OR JW TOO SMALL,                  * */
+/* *                   W SHOULD BE ENLARGED TO L_W=MODE/1000             * */
+/* *                   JW SHOULD BE ENLARGED TO L_JW=MODE-1000*L_W       * */
+/* *  * W(), L_W       W() IS A ONE DIMENSIONAL WORKING SPACE,           * */
+/* *                   THE LENGTH L_W OF WHICH SHOULD BE AT LEAST        * */
+/* *                   (3*N1+M)*(N1+1)                        for LSQ    * */
+/* *                  +(N1-MEQ+1)*(MINEQ+2) + 2*MINEQ         for LSI    * */
+/* *                  +(N1+MINEQ)*(N1-MEQ) + 2*MEQ + N1       for LSEI   * */
+/* *                  + N1*N/2 + 2*M + 3*N + 3*N1 + 1         for SLSQPB * */
+/* *                   with MINEQ = M - MEQ + 2*N1  &  N1 = N+1          * */
+/* *        NOTICE:    FOR PROPER DIMENSIONING OF W IT IS RECOMMENDED TO * */
+/* *                   COPY THE FOLLOWING STATEMENTS INTO THE HEAD OF    * */
+/* *                   THE CALLING PROGRAM (AND REMOVE THE COMMENT C)    * */
+/* ####################################################################### */
+/*     INT LEN_W, LEN_JW, M, N, N1, MEQ, MINEQ */
+/*     PARAMETER (M=... , MEQ=... , N=...  ) */
+/*     PARAMETER (N1= N+1, MINEQ= M-MEQ+N1+N1) */
+/*     PARAMETER (LEN_W= */
+/*    $           (3*N1+M)*(N1+1) */
+/*    $          +(N1-MEQ+1)*(MINEQ+2) + 2*MINEQ */
+/*    $          +(N1+MINEQ)*(N1-MEQ) + 2*MEQ + N1 */
+/*    $          +(N+1)*N/2 + 2*M + 3*N + 3*N1 + 1, */
+/*    $           LEN_JW=MINEQ) */
+/*     DOUBLE PRECISION W(LEN_W) */
+/*     INT          JW(LEN_JW) */
+/* ####################################################################### */
+/* *                   THE FIRST M+N+N*N1/2 ELEMENTS OF W MUST NOT BE    * */
+/* *                   CHANGED BETWEEN SUBSEQUENT CALLS OF SLSQP.        * */
+/* *                   ON RETURN W(1) ... W(M) CONTAIN THE MULTIPLIERS   * */
+/* *                   ASSOCIATED WITH THE GENERAL CONSTRAINTS, WHILE    * */
+/* *                   W(M+1) ... W(M+N(N+1)/2) STORE THE CHOLESKY FACTOR* */
+/* *                   L*D*L(T) OF THE APPROXIMATE HESSIAN OF THE        * */
+/* *                   LAGRANGIAN COLUMNWISE DENSE AS LOWER TRIANGULAR   * */
+/* *                   UNIT MATRIX L WITH D IN ITS 'DIAGONAL' and        * */
+/* *                   W(M+N(N+1)/2+N+2 ... W(M+N(N+1)/2+N+2+M+2N)       * */
+/* *                   CONTAIN THE MULTIPLIERS ASSOCIATED WITH ALL       * */
+/* *                   ALL CONSTRAINTS OF THE QUADRATIC PROGRAM FINDING  * */
+/* *                   THE SEARCH DIRECTION TO THE SOLUTION X*           * */
+/* *  * JW(), L_JW     JW() IS A ONE DIMENSIONAL INT WORKING SPACE   * */
+/* *                   THE LENGTH L_JW OF WHICH SHOULD BE AT LEAST       * */
+/* *                   MINEQ                                             * */
+/* *                   with MINEQ = M - MEQ + 2*N1  &  N1 = N+1          * */
+/* *                                                                     * */
+/* *  THE USER HAS TO PROVIDE THE FOLLOWING SUBROUTINES:                 * */
+/* *     LDL(N,A,Z,SIG,W) :   UPDATE OF THE LDL'-FACTORIZATION.          * */
+/* *     LINMIN(A,B,F,TOL) :  LINESEARCH ALGORITHM IF EXACT = 1          * */
+/* *     LSQ(M,MEQ,LA,N,NC,C,D,A,B,XL,XU,X,LAMBDA,W,....) :              * */
+/* *                                                                     * */
+/* *        SOLUTION OF THE QUADRATIC PROGRAM                            * */
+/* *                QPSOL IS RECOMMENDED:                                * */
+/* *     PE GILL, W MURRAY, MA SAUNDERS, MH WRIGHT:                      * */
+/* *     USER'S GUIDE FOR SOL/QPSOL:                                     * */
+/* *     A FORTRAN PACKAGE FOR QUADRATIC PROGRAMMING,                    * */
+/* *     TECHNICAL REPORT SOL 83-7, JULY 1983                            * */
+/* *     DEPARTMENT OF OPERATIONS RESEARCH, STANFORD UNIVERSITY          * */
+/* *     STANFORD, CA 94305                                              * */
+/* *     QPSOL IS THE MOST ROBUST AND EFFICIENT QP-SOLVER                * */
+/* *     AS IT ALLOWS WARM STARTS WITH PROPER WORKING SETS               * */
+/* *                                                                     * */
+/* *     IF IT IS NOT AVAILABLE USE LSEI, A CONSTRAINT LINEAR LEAST      * */
+/* *     SQUARES SOLVER IMPLEMENTED USING THE SOFTWARE HFTI, LDP, NNLS   * */
+/* *     FROM C.L. LAWSON, R.J.HANSON: SOLVING LEAST SQUARES PROBLEMS,   * */
+/* *     PRENTICE HALL, ENGLEWOOD CLIFFS, 1974.                          * */
+/* *     LSEI COMES WITH THIS PACKAGE, together with all necessary SR's. * */
+/* *                                                                     * */
+/* *     TOGETHER WITH A COUPLE OF SUBROUTINES FROM BLAS LEVEL 1         * */
+/* *                                                                     * */
+/* *     SQP IS HEAD SUBROUTINE FOR BODY SUBROUTINE SQPBDY               * */
+/* *     IN WHICH THE ALGORITHM HAS BEEN IMPLEMENTED.                    * */
+/* *                                                                     * */
+/* *  IMPLEMENTED BY: DIETER KRAFT, DFVLR OBERPFAFFENHOFEN               * */
+/* *  as described in Dieter Kraft: A Software Package for               * */
+/* *                                Sequential Quadratic Programming     * */
+/* *                                DFVLR-FB 88-28, 1988                 * */
+/* *  which should be referenced if the user publishes results of SLSQP  * */
+/* *                                                                     * */
+/* *  DATE:           APRIL - OCTOBER, 1981.                             * */
+/* *  STATUS:         DECEMBER, 31-ST, 1984.                             * */
+/* *  STATUS:         MARCH   , 21-ST, 1987, REVISED TO FORTAN 77        * */
+/* *  STATUS:         MARCH   , 20-th, 1989, REVISED TO MS-FORTRAN       * */
+/* *  STATUS:         APRIL   , 14-th, 1989, HESSE   in-line coded       * */
+/* *  STATUS:         FEBRUARY, 28-th, 1991, FORTRAN/2 Version 1.04      * */
+/* *                                         accepts Statement Functions * */
+/* *  STATUS:         MARCH   ,  1-st, 1991, tested with SALFORD         * */
+/* *                                         FTN77/386 COMPILER VERS 2.40* */
+/* *                                         in protected mode           * */
+/* *                                                                     * */
+/* *********************************************************************** */
+/* *                                                                     * */
+/* *  Copyright 1991: Dieter Kraft, FHM                                  * */
+/* *                                                                     * */
+/* *********************************************************************** */
+/*     dim(W) =         N1*(N1+1) + MEQ*(N1+1) + MINEQ*(N1+1)  for LSQ */
+/*                    +(N1-MEQ+1)*(MINEQ+2) + 2*MINEQ          for LSI */
+/*                    +(N1+MINEQ)*(N1-MEQ) + 2*MEQ + N1        for LSEI */
+/*                    + N1*N/2 + 2*M + 3*N +3*N1 + 1           for SLSQPB */
+/*                      with MINEQ = M - MEQ + 2*N1  &  N1 = N+1 */
+/*   CHECK LENGTH OF WORKING ARRAYS */
+    /* Parameter adjustments */
+    --c__;
+    a_dim1 = *la;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --g;
+    --xu;
+    --xl;
+    --x;
+    --w;
+    --jw;
+
+    /* Function Body */
+    n1 = *n + 1;
+    mineq = *m - *meq + n1 + n1;
+    il = (n1 * 3 + *m) * (n1 + 1) + (n1 - *meq + 1) * (mineq + 2) + (mineq << 
+           1) + (n1 + mineq) * (n1 - *meq) + (*meq << 1) + n1 * *n / 2 + (*m 
+           << 1) + *n * 3 + (n1 << 2) + 1;
+/* Computing MAX */
+    i__1 = mineq, i__2 = n1 - *meq;
+    im = MAX2(i__1,i__2);
+    if (*l_w__ < il || *l_jw__ < im) {
+       *mode = MAX2(10,il) * 1000;
+       *mode += MAX2(10,im);
+       return;
+    }
+/*   PREPARE DATA FOR CALLING SQPBDY  -  INITIAL ADDRESSES IN W */
+    im = 1;
+    il = im + MAX2(1,*m);
+    il = im + *la;
+    ix = il + n1 * *n / 2 + 1;
+    ir = ix + *n;
+    is = ir + *n + *n + MAX2(1,*m);
+    is = ir + *n + *n + *la;
+    iu = is + n1;
+    iv = iu + n1;
+    iw = iv + n1;
+    slsqpb_(m, meq, la, n, &x[1], &xl[1], &xu[1], f, &c__[1], &g[1], &a[
+           a_offset], acc, iter, mode, &w[ir], &w[il], &w[ix], &w[im], &w[is]
+           , &w[iu], &w[iv], &w[iw], &jw[1], state);
+    state->x0 = &w[ix];
+    return;
+} /* slsqp_ */
+
+static void length_work(int *LEN_W, int *LEN_JW, int M, int MEQ, int N)
+{
+     int N1 = N+1, MINEQ = M-MEQ+N1+N1;
+     *LEN_W = (3*N1+M)*(N1+1) 
+         +(N1-MEQ+1)*(MINEQ+2) + 2*MINEQ
+          +(N1+MINEQ)*(N1-MEQ) + 2*MEQ + N1
+          +(N+1)*N/2 + 2*M + 3*N + 3*N1 + 1;
+     *LEN_JW = MINEQ;
+}
+
+nlopt_result nlopt_slsqp(unsigned n, nlopt_func f, void *f_data,
+                        unsigned m, nlopt_constraint *fc,
+                        unsigned p, nlopt_constraint *h,
+                        const double *lb, const double *ub,
+                        double *x, double *minf,
+                        nlopt_stopping *stop)
+{
+     slsqpb_state state = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL};
+     unsigned mtot = nlopt_count_constraints(m, fc);
+     unsigned ptot = nlopt_count_constraints(p, h);
+     double *work, *cgrad, *c, *grad, *w, 
+         fcur, *xcur, fprev, *xprev, *cgradtmp;
+     int mpi = (int) (mtot + ptot), pi = (int) ptot,  ni = (int) n, mpi1 = mpi > 0 ? mpi : 1;
+     int len_w, len_jw, *jw;
+     int mode = 0, prev_mode = 0;
+     double acc = 0; /* we do our own convergence tests below */
+     int iter = 0; /* tell sqsqp to ignore this check, since we check evaluation counts ourselves */
+     unsigned i, ii;
+     nlopt_result ret = NLOPT_SUCCESS;
+     int feasible, feasible_cur;
+     double infeasibility = HUGE_VAL, infeasibility_cur = HUGE_VAL;
+     unsigned max_cdim;
+     
+     max_cdim = MAX2(nlopt_max_constraint_dim(m, fc),
+                   nlopt_max_constraint_dim(p, h));
+     length_work(&len_w, &len_jw, mpi, pi, ni);
+
+#define U(n) ((unsigned) (n))
+     work = (double *) malloc(sizeof(double) * (U(mpi1) * (n + 1) 
+                                               + U(mpi) 
+                                               + n+1 + n + n + max_cdim*n
+                                               + U(len_w))
+                             + sizeof(int) * U(len_jw));
+     if (!work) return NLOPT_OUT_OF_MEMORY;
+     cgrad = work;
+     c = cgrad + U(mpi1) * (n + 1);
+     grad = c + mpi;
+     xcur = grad + n+1;
+     xprev = xcur + n;
+     cgradtmp = xprev + n;
+     w = cgradtmp + max_cdim*n;
+     jw = (int *) (w + len_w);
+     
+     memcpy(xcur, x, sizeof(double) * n);
+     memcpy(xprev, x, sizeof(double) * n);
+     fprev = fcur = *minf = HUGE_VAL;
+     feasible = feasible_cur = 0;
+
+     goto eval_f_and_grad; /* eval before calling slsqp the first time */
+
+     do {
+         slsqp(&mpi, &pi, &mpi1, &ni,
+               xcur, lb, ub, &fcur,
+               c, grad, cgrad,
+               &acc, &iter, &mode,
+               w, &len_w, jw, &len_jw,
+               &state);
+
+         switch (mode) {
+             case -1:  /* objective & gradient evaluation */
+                  if (prev_mode == -2) break; /* just evaluated this point */
+             case -2:
+                  eval_f_and_grad:
+                  feasible_cur = 1; infeasibility_cur = 0;
+                  fcur = f(n, xcur, grad, f_data);
+                  stop->nevals++;
+                  if (nlopt_stop_forced(stop)) { 
+                       fcur = HUGE_VAL; ret = NLOPT_FORCED_STOP; goto done; }
+                  ii = 0;
+                  for (i = 0; i < p; ++i) {
+                       unsigned j, k;
+                       nlopt_eval_constraint(c+ii, cgradtmp, h+i, n, xcur);
+                       if (nlopt_stop_forced(stop)) { 
+                            ret = NLOPT_FORCED_STOP; goto done; }
+                       for (k = 0; k < h[i].m; ++k, ++ii) {
+                            infeasibility_cur = 
+                                 MAX2(infeasibility_cur, fabs(c[ii]));
+                            feasible_cur = 
+                                 feasible_cur && fabs(c[ii]) <= h[i].tol[k];
+                            for (j = 0; j < n; ++ j)
+                                 cgrad[j*U(mpi1) + ii] = cgradtmp[k*n + j];
+                       }
+                  }
+                  for (i = 0; i < m; ++i) {
+                       unsigned j, k;
+                       nlopt_eval_constraint(c+ii, cgradtmp, fc+i, n, xcur);
+                       if (nlopt_stop_forced(stop)) { 
+                            ret = NLOPT_FORCED_STOP; goto done; }
+                       for (k = 0; k < fc[i].m; ++k, ++ii) {
+                            infeasibility_cur = 
+                                 MAX2(infeasibility_cur, c[ii]);
+                            feasible_cur = 
+                                 feasible_cur && c[ii] <= fc[i].tol[k];
+                            for (j = 0; j < n; ++ j)
+                                 cgrad[j*U(mpi1) + ii] = -cgradtmp[k*n + j];
+                            c[ii] = -c[ii]; /* slsqp sign convention */
+                       }
+                  }
+                  break;
+             case 0: /* required accuracy for solution obtained */
+                  goto done;
+             case 1: /* objective evaluation only (no gradient) */
+                  feasible_cur = 1; infeasibility_cur = 0;
+                  fcur = f(n, xcur, NULL, f_data);
+                  stop->nevals++;
+                  if (nlopt_stop_forced(stop)) { 
+                       fcur = HUGE_VAL; ret = NLOPT_FORCED_STOP; goto done; }
+                  ii = 0;
+                  for (i = 0; i < p; ++i) {
+                       unsigned k;
+                       nlopt_eval_constraint(c+ii, NULL, h+i, n, xcur);
+                       if (nlopt_stop_forced(stop)) { 
+                            ret = NLOPT_FORCED_STOP; goto done; }
+                       for (k = 0; k < h[i].m; ++k, ++ii) {
+                            infeasibility_cur = 
+                                 MAX2(infeasibility_cur, fabs(c[ii]));
+                            feasible_cur = 
+                                 feasible_cur && fabs(c[ii]) <= h[i].tol[k];
+                       }
+                  }
+                  for (i = 0; i < m; ++i) {
+                       unsigned k;
+                       nlopt_eval_constraint(c+ii, NULL, fc+i, n, xcur);
+                       if (nlopt_stop_forced(stop)) { 
+                            ret = NLOPT_FORCED_STOP; goto done; }
+                       for (k = 0; k < fc[i].m; ++k, ++ii) {
+                            infeasibility_cur = 
+                                 MAX2(infeasibility_cur, c[ii]);
+                            feasible_cur = 
+                                 feasible_cur && c[ii] <= fc[i].tol[k];
+                            c[ii] = -c[ii]; /* slsqp sign convention */
+                       }
+                  }
+                  break;
+             case 8: /* positive directional derivative for linesearch */
+                  /* relaxed convergence check for a feasible_cur point,
+                     as in the SLSQP code (except xtol as well as ftol) */
+                  ret = NLOPT_ROUNDOFF_LIMITED; /* usually why deriv>0 */
+                  if (feasible_cur) {
+                       double save_ftol_rel = stop->ftol_rel;
+                       double save_xtol_rel = stop->xtol_rel;
+                       double save_ftol_abs = stop->ftol_abs;
+                       stop->ftol_rel *= 10;
+                       stop->ftol_abs *= 10;
+                       stop->xtol_rel *= 10;
+                       if (nlopt_stop_ftol(stop, fcur, state.f0))
+                            ret = NLOPT_FTOL_REACHED;
+                       else if (nlopt_stop_x(stop, xcur, state.x0))
+                            ret = NLOPT_XTOL_REACHED;
+                       stop->ftol_rel = save_ftol_rel;
+                       stop->ftol_abs = save_ftol_abs;
+                       stop->xtol_rel = save_xtol_rel;
+                  }
+                  goto done;
+             case 5: /* singular matrix E in LSQ subproblem */
+             case 6: /* singular matrix C in LSQ subproblem */
+             case 7: /* rank-deficient equality constraint subproblem HFTI */
+                  ret = NLOPT_ROUNDOFF_LIMITED;
+                  goto done;
+             case 4: /* inequality constraints incompatible */
+             case 3: /* more than 3*n iterations in LSQ subproblem */
+             case 9: /* more than iter iterations in SQP */
+                  ret = NLOPT_FAILURE;
+                  goto done;
+             case 2: /* number of equality constraints > n */
+             default: /* >= 10: working space w or jw too small */
+                  ret = NLOPT_INVALID_ARGS;
+                  goto done;
+         }
+         prev_mode = mode;
+
+         /* update best point so far */
+         if ((fcur < *minf && (feasible_cur || !feasible))
+             || (!feasible && infeasibility_cur < infeasibility)) {
+              *minf = fcur;
+              feasible = feasible_cur;
+              infeasibility = infeasibility_cur;
+              memcpy(x, xcur, sizeof(double)*n);
+         }
+
+         /* note: mode == -1 corresponds to the completion of a line search,
+            and is the only time we should check convergence (as in original slsqp code) */
+         if (mode == -1) {
+              if (!nlopt_isinf(fprev)) {
+                   if (nlopt_stop_ftol(stop, fcur, fprev))
+                        ret = NLOPT_FTOL_REACHED;
+                   else if (nlopt_stop_x(stop, xcur, xprev))
+                        ret = NLOPT_XTOL_REACHED;
+              }
+              fprev = fcur;
+              memcpy(xprev, xcur, sizeof(double)*n);
+         }
+
+         /* do some additional termination tests */
+         if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
+         else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
+         else if (feasible && *minf < stop->minf_max) ret = NLOPT_MINF_MAX_REACHED;
+     } while (ret == NLOPT_SUCCESS);
+
+done:
+     if (nlopt_isinf(*minf)) { /* didn't find any feasible points, just return last point evaluated */
+         if (nlopt_isinf(fcur)) { /* invalid cur. point, use previous pt. */
+              *minf = fprev;
+              memcpy(x, xprev, sizeof(double)*n);
+         }
+         else {
+              *minf = fcur;
+              memcpy(x, xcur, sizeof(double)*n);
+         }
+     }
+
+     free(work);
+     return ret;
+}
diff --git a/slsqp/slsqp.h b/slsqp/slsqp.h
new file mode 100644 (file)
index 0000000..44b7ab9
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef SLSQP_H
+#define SLSQP_H
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+nlopt_result nlopt_slsqp(unsigned n, nlopt_func f, void *f_data,
+                        unsigned m, nlopt_constraint *fc,
+                        unsigned p, nlopt_constraint *h,
+                        const double *lb, const double *ub,
+                        double *x, double *minf,
+                        nlopt_stopping *stop);
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
diff --git a/stogo/COPYRIGHT b/stogo/COPYRIGHT
new file mode 100644 (file)
index 0000000..dd637e5
--- /dev/null
@@ -0,0 +1,75 @@
+The original StoGO code is:
+
+Copyright (c) 1998 by S. Zertchaninov and K. Madsen.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+----------------------------------------------------------------------
+
+The StoGO source code on the authors' web site has no copyright or
+license information, but I (Steven G. Johnson) contacted the author
+K. Madsen for clarification and he gave me permission to distribute
+it under the MIT license above.  See the correspondence below:
+
+----------------------------------------------------------------------
+Date: Fri, 24 Aug 2007 10:46:09 +0200
+From: Kaj Madsen <km@imm.dtu.dk>
+To: stevenj@math.mit.edu
+Subject: RE: open source license for StoGO software?
+
+The MIT licence is ok with me, and so is your copyright suggestion. 
+
+Kaj Madsen. 
+
+-----Original Message-----
+From: Steven G. Johnson [mailto:stevenj@fftw.org] 
+Sent: 23. august 2007 22:23
+To: Kaj Madsen
+Subject: RE: open source license for StoGO software?
+
+On Thu, 23 Aug 2007, Kaj Madsen wrote:
+> Many thanks for your mail. You can definitely consider the software as
+> open source, please use it as you like, however please refer to us if 
+> you publish results based on the software.
+>
+> I am now in a heavy administrative position as a Head of Department 
+> (has been since 1998, therefore I never really followed up on this). 
+> The paper was never published, however I am attaching two fdf-files, 
+> one with the paper, one with some descriptions of the code. I hope 
+> this makes sense, otherwise please don't hesitate to contact me again.
+
+Thanks so much for your response!
+
+To be open source it needs some specific open-source license to specify
+the permissions in legal terms.  The simplest open-source license is
+probably the MIT license, is this okay?
+
+        http://opensource.org/licenses/mit-license.php
+
+Also, I need to know who the authors are for the copyright statement. 
+Should I list it as:
+        Copyright (c) 1998 by S. Zertchaninov and K. Madsen ?
+
+Thanks again!  I will definitely cite it if I publish any results based
+on StoGO!  (It's one of the few public global-optimization programs that
+is able to exploit gradient information.)
+
+Regards,
+Steven G. Johnson
diff --git a/stogo/Makefile.am b/stogo/Makefile.am
new file mode 100644 (file)
index 0000000..3defc18
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libstogo.la
+libstogo_la_SOURCES = global.cc linalg.cc local.cc stogo.cc tools.cc   \
+global.h linalg.h local.h stogo_config.h stogo.h tools.h
+
+EXTRA_DIST = testros.cc tst.cc tstc.c prog.cc testfun.h rosen.h README \
+paper.pdf techreport.pdf COPYRIGHT
diff --git a/stogo/Makefile.in b/stogo/Makefile.in
new file mode 100644 (file)
index 0000000..3175f0a
--- /dev/null
@@ -0,0 +1,633 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = stogo
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libstogo_la_LIBADD =
+am_libstogo_la_OBJECTS = global.lo linalg.lo local.lo stogo.lo \
+       tools.lo
+libstogo_la_OBJECTS = $(am_libstogo_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libstogo_la_SOURCES)
+DIST_SOURCES = $(libstogo_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libstogo.la
+libstogo_la_SOURCES = global.cc linalg.cc local.cc stogo.cc tools.cc   \
+global.h linalg.h local.h stogo_config.h stogo.h tools.h
+
+EXTRA_DIST = testros.cc tst.cc tstc.c prog.cc testfun.h rosen.h README \
+paper.pdf techreport.pdf COPYRIGHT
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu stogo/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu stogo/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libstogo.la: $(libstogo_la_OBJECTS) $(libstogo_la_DEPENDENCIES) $(EXTRA_libstogo_la_DEPENDENCIES) 
+       $(AM_V_CXXLD)$(CXXLINK)  $(libstogo_la_OBJECTS) $(libstogo_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/global.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linalg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stogo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Plo@am__quote@
+
+.cc.o:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/stogo/README b/stogo/README
new file mode 100644 (file)
index 0000000..1fe3dff
--- /dev/null
@@ -0,0 +1,23 @@
+This code is modified from the original StoGO Global Optimization library
+by Madsen et al., downloaded from:
+
+       http://www2.imm.dtu.dk/~km/GlobOpt/opt.html
+
+It was modified to allow C-callable wrappers and some other niceties by
+Steven G. Johnson (stevenj@alum.mit.edu) in 2007.
+
+StoGO uses a gradient-based direct-search branch-and-bound algorithm,
+described in:
+
+S. Gudmundsson, "Parallel Global Optimization," M.Sc. Thesis, IMM,
+       Technical University of Denmark, 1998.
+
+K. Madsen, S. Zertchaninov, and A. Zilinskas, "Global Optimization
+       using Branch-and-Bound," Submitted to the Journal of Global
+       Optimization, 1998.
+       [ never published, but preprint is included as paper.pdf ]
+
+S. Zertchaninov and K. Madsen, "A C++ Programme for Global Optimization,"
+       IMM-REP-1998-04, Department of Mathematical Modelling,
+       Technical University of Denmark, DK-2800 Lyngby, Denmark, 1998.
+       [ included as techreport.pdf ]
diff --git a/stogo/global.cc b/stogo/global.cc
new file mode 100644 (file)
index 0000000..6a54518
--- /dev/null
@@ -0,0 +1,351 @@
+/*
+   Multi Dimensional Global Search.
+
+   Author: Steinn Gudmundsson
+   Email: steinng@hotmail.com
+
+   This program is supplied without any warranty whatsoever.
+
+   NB The RNGs seed should be initialized using some timer
+*/
+
+#include <iostream>
+
+#include <iterator>
+#include <algorithm>
+#include <stack>
+
+#include "stogo_config.h"
+#include "global.h"
+#include "local.h"
+#include "nlopt-util.h"
+
+// Timer stuff
+double   StartTime;
+
+double MacEpsilon ;
+int FC=0, GC=0 ;
+
+int stogo_verbose = 0; /* set to nonzero for verbose output */
+
+Global::Global(RTBox D, Pobj o, Pgrad g, GlobalParams P): Domain(D) {
+
+  dim=Domain.GetDim();
+  Objective=o;
+  Gradient=g;
+
+  // Initialize parameters
+#ifdef NLOPT_UTIL_H
+  stop = P.stop;
+#else
+  maxtime=P.maxtime;
+  maxeval = P.maxeval;
+#endif
+  numeval = 0;
+  eps_cl=P.eps_cl; mu=P.mu; rshift=P.rshift;
+  det_pnts=P.det_pnts; rnd_pnts=P.rnd_pnts;
+  fbound=DBL_MAX;
+}
+
+#if 0 // not necessary; default copy is sufficient 
+Global& Global::operator=(const Global &G) {
+  // Copy the problem info and parameter settings
+  Domain=G.Domain; Objective=G.Objective;  Gradient=G.Gradient;
+#ifdef NLOPT_UTIL_H
+  stop = G.stop;
+#else
+  maxtime=G.maxtime;
+  maxeval = G.maxeval;
+#endif
+  numeval = G.numeval;
+  eps_cl=G.eps_cl; mu=G.mu; rshift=G.rshift;
+  det_pnts=G.det_pnts; rnd_pnts=G.rnd_pnts;
+  return *this;
+}
+#endif
+
+void Global::FillRegular(RTBox SampleBox, RTBox box) {
+  // Generation of regular sampling points
+  double w;
+  int i, flag, dir;
+  Trial tmpTrial(dim);
+  RVector m(dim), x(dim);
+
+  if (det_pnts>0) {
+    box.Midpoint(m) ;
+    tmpTrial.objval=DBL_MAX ;
+    // Add the rest
+    i=1 ; flag=1 ; dir=0 ;
+    x=m ; 
+    while (i<det_pnts) {
+      w=box.Width(dir) ;
+      x(dir)=m(dir)+flag*rshift*w ;
+      tmpTrial.xvals=x ; 
+      SampleBox.AddTrial(tmpTrial) ;
+      flag=-flag;
+      if (flag==1 && dir<dim) {
+       x(dir)=m(dir) ;
+       dir++ ;
+      }
+      i++ ;
+    }
+    // Add midpoint
+    tmpTrial.xvals=m ; 
+    SampleBox.AddTrial(tmpTrial) ;
+  }
+}
+
+void Global::FillRandom(RTBox SampleBox, RTBox box) {
+  // Generation of stochastic sampling points
+  Trial tmpTrial(dim);
+
+  tmpTrial.objval=DBL_MAX;
+  for (int i=1 ; i<=rnd_pnts ; i++) {
+    for (int dir=0 ; dir<dim ; dir++)
+      tmpTrial.xvals(dir) = nlopt_urand(box.lb(dir), box.ub(dir));
+    SampleBox.AddTrial(tmpTrial) ;
+  }
+}
+
+double Global::NewtonTest(RTBox box, int axis, RCRVector x_av, int *noutside) {
+  // Perform the Newton test
+
+  int info,nout=0;
+  Trial tmpTrial(dim);
+  TBox SampleBox(dim) ;
+  double maxgrad=0 ;
+
+  // Create sampling points
+  FillRandom(SampleBox, box);
+  FillRegular(SampleBox, box);
+
+  // Perform the actual sampling
+  while ( !SampleBox.EmptyBox() ) {
+    SampleBox.RemoveTrial(tmpTrial) ;
+    info = local(tmpTrial, box, Domain, eps_cl, &maxgrad, *this,
+                axis, x_av
+#ifdef NLOPT_UTIL_H
+                , stop
+#endif
+                ) ;
+    // What should we do when info=LS_Unstable?
+    if (info == LS_Out)
+      nout++;
+    else if (info == LS_New ) {
+      box.AddTrial(tmpTrial) ;
+
+      if (tmpTrial.objval<=fbound+mu && tmpTrial.objval<=box.minf+mu) {
+       if (stogo_verbose) {
+         cout << "Found a candidate, x=" << tmpTrial.xvals;
+         cout << " F=" <<tmpTrial.objval << " FC=" << FC << endl;
+       }
+       SolSet.push_back(tmpTrial);
+#ifdef NLOPT_UTIL_H
+       if (tmpTrial.objval < stop->minf_max)
+         break;
+#endif
+      }
+#ifdef GS_DEBUG
+      cout << "Found a stationary point, X= " << tmpTrial.xvals;
+      cout <<" objval=" << tmpTrial.objval << endl;
+#endif
+    }
+
+    if (!InTime() || info == LS_MaxEvalTime)
+      break;
+  }
+  *noutside=nout;
+  return maxgrad;
+}
+
+void Global::ReduceOrSubdivide(RTBox box, int axis, RCRVector x_av) {
+  TBox B1(dim), B2(dim);
+  Trial tmpTrial(dim);
+  double maxgrad;
+  int ns,nout;
+
+  // Monotonicity test has not been implemented yet
+  maxgrad=NewtonTest(box, axis, x_av, &nout);
+  ns=box.NStationary() ;
+  if (ns==0) {
+    // All iterates outside
+    // NB result=Intersection(B,boundary(Domain))
+    Garbage.push(box) ;
+  }
+  else
+    if (ns==1 && nout==0) {
+      // All iterates converge to same point
+      Garbage.push(box) ;
+    }
+    else
+      if ( (ns>1) && (box.LowerBound(maxgrad)>fbound) ) {
+       // Several stationary points found and lower bound > fbound
+       Garbage.push(box) ;
+      }
+      else {
+       // Subdivision
+       B1.ClearBox() ; B2.ClearBox() ;
+       box.split(B1,B2) ;
+       CandSet.push(B1) ; CandSet.push(B2) ;
+      }
+
+  // Update fbound
+  if (box.minf < fbound) {
+    fbound=box.minf ;
+#ifdef GS_DEBUG
+    cout <<"*** Improving fbound, fbound=" << fbound << endl;
+#endif
+  }
+}
+
+void Global::Search(int axis, RCRVector x_av){
+  Trial tmpTrial(dim) ;
+  TBox box(dim), B1(dim), B2(dim);
+  RVector m(dim), x(dim);
+  int inner_iter, outer_iter;
+
+  MacEpsilon=eps(); // Get machine precision
+  if (det_pnts>2*dim+1) {
+    det_pnts=2*dim+1;
+    if (stogo_verbose)
+      cout << "Warning: Reducing det_pnts to " << det_pnts << endl;
+  }
+
+  // Initialize timer
+  StartTime = nlopt_seconds();
+
+  // Clear priority_queues
+  while (!Garbage.empty())
+    Garbage.pop();
+  while (!CandSet.empty())
+    CandSet.pop();
+
+  box=Domain;
+  CandSet.push(box);
+  int done=0 ; outer_iter=0 ;
+
+  while (!done) {
+    outer_iter++ ;
+
+    // Inner loop
+    inner_iter=0 ;
+    while (!CandSet.empty()) {
+      inner_iter++ ;
+      // Get best box from Candidate set
+      box=CandSet.top() ; CandSet.pop() ;
+
+#ifdef GS_DEBUG
+      cout << "Iteration..." << inner_iter << " #CS=" << CandSet.size()+1 ;
+      cout << " Processing " << box.NStationary() << " trials in the box " <<box;
+#endif
+      ReduceOrSubdivide(box, axis, x_av);
+
+#ifdef NLOPT_UTIL_H
+      if (!NoMinimizers() && OneMinimizer(x) < stop->minf_max) {
+       done = TRUE;
+       break;
+      }
+#endif
+      if (!InTime()) {
+        done=TRUE;
+       if (stogo_verbose)
+         cout << "The program has run out of time or function evaluations\n";
+        break;
+      }
+
+    } // inner while-loop
+    if (stogo_verbose)
+      cout << endl << "*** Inner loop completed ***" << endl ;
+    
+    // Reduce SolSet if necessary
+    SolSet.erase(remove_if(SolSet.begin(), SolSet.end(),
+                          TrialGT(fbound+mu)),SolSet.end());
+    if (InTime()) {
+      if (stogo_verbose) {
+       cout << "Current set of minimizers (" << SolSet.size() << ")" << endl ;
+       DispMinimizers() ;
+      }
+
+      while (!Garbage.empty()) {
+        box=Garbage.top() ;
+        Garbage.pop() ;
+        // Split box
+        B1.ClearBox() ; B2.ClearBox() ;
+        box.split(B1,B2) ;
+        // Add boxes to Candidate set
+        CandSet.push(B1) ; CandSet.push(B2) ;
+      }
+    }
+  } // Outer while-loop
+
+  if (stogo_verbose) {
+    cout << "Number of outer iterations : " << outer_iter << endl;
+    cout << "Number of unexplored boxes : " << CandSet.size() << endl;
+    cout << "Number of boxes in garbage : " << Garbage.size() << endl;
+    cout << "Number of elements in SolSet : " << SolSet.size() << endl;
+    cout << "Number of function evaluations : " << FC << endl;
+    cout << "Number of gradient evaluations : " << GC << endl;
+  }
+
+  if (axis != -1) {
+    // Return minimizer when doing the AV method
+    tmpTrial=SolSet.back();
+    x_av(axis)=tmpTrial.xvals(0);
+  }
+}
+
+/************* Various utility functions ****************/
+double Global::GetTime()
+{
+  return nlopt_seconds() - StartTime;
+}
+
+bool Global::InTime()
+{
+#ifdef NLOPT_UTIL_H
+  return !nlopt_stop_evalstime(stop);
+#else
+ return (maxtime <= 0.0 || GetTime()<maxtime) && (!maxeval || numeval<maxeval);
+#endif
+}
+
+double Global::GetMinValue() {
+  return fbound;
+}
+
+void Global::SetMinValue(double new_fb) {
+  fbound=new_fb;
+}
+
+void Global::SetDomain(RTBox box) {
+  Domain=box;
+}
+
+void Global::GetDomain(RTBox box) {
+  box=Domain;
+}
+
+void Global::DispMinimizers() {
+  copy(SolSet.begin(), SolSet.end(), ostream_iterator<Trial>(cout));
+}
+
+double Global::OneMinimizer(RCRVector x) {
+  if (NoMinimizers()) return 0.0;
+  for (int i=0;i<x.GetLength();i++) x(i) = SolSet.front().xvals(i);
+  return SolSet.front().objval;
+}
+
+bool Global::NoMinimizers() {
+  return SolSet.empty();
+}
+
+void Global::ClearSolSet() {
+  SolSet.erase(SolSet.begin(), SolSet.end()) ;
+}
+
+void Global::AddPoint(RCRVector x, double f) {
+  Trial T(dim);
+  T.xvals=x; T.objval=f;
+  Domain.AddTrial(T);
+  SolSet.push_back(T);
+}
diff --git a/stogo/global.h b/stogo/global.h
new file mode 100644 (file)
index 0000000..36c2b0e
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include "nlopt-util.h"
+
+#include <queue>
+//#include "function.h"
+#include "tools.h"
+using namespace std;
+
+extern "C" int stogo_verbose;
+
+typedef void dom(RTBox) ;
+typedef dom* Pdom ;
+
+typedef double obj(RCRVector) ;
+typedef obj* Pobj ;
+
+typedef void grad(RCRVector,RVector&) ;
+typedef grad* Pgrad ;
+
+typedef enum { OBJECTIVE_ONLY, GRADIENT_ONLY, OBJECTIVE_AND_GRADIENT } whichO;
+
+typedef double objgrad(RCRVector,RCRVector,whichO) ;
+typedef objgrad* Pobjgrad ;
+
+class GlobalParams {
+public:
+#ifdef NLOPT_UTIL_H
+  nlopt_stopping *stop;
+#else
+  double maxtime;
+  long int maxeval;
+#endif
+  double eps_cl, mu, rshift;
+  int det_pnts, rnd_pnts;
+};
+
+class Global: public GlobalParams {
+public:
+  // Problem specification
+  int dim ;
+  Pobj  Objective ;
+  Pgrad Gradient ;
+  long int numeval;
+
+  virtual double ObjectiveGradient(RCRVector xy, RVector&grad, whichO which){
+       ++numeval;
+       switch (which) {
+          case OBJECTIVE_AND_GRADIENT:
+               Gradient(xy, grad);
+          case OBJECTIVE_ONLY:
+               return Objective(xy);
+          case GRADIENT_ONLY:
+               Gradient(xy, grad);
+       }
+       return 0.0;
+  }
+                                  
+  Global(RTBox, Pobj, Pgrad, GlobalParams);
+//  Global& operator=(const Global &);
+
+  void Search(int, RCRVector);
+  void DispMinimizers();
+  double OneMinimizer(RCRVector);
+  bool NoMinimizers();
+  void SetDomain(RTBox);
+  void GetDomain(RTBox);
+  double GetMinValue();
+  void SetMinValue(double);
+  void ClearSolSet();
+  void AddPoint(RCRVector, double);
+
+  double GetTime();
+  bool InTime();
+
+private:
+  list<Trial> SolSet;
+  list<Trial>::const_iterator titr;
+  priority_queue<TBox> CandSet;
+  priority_queue<TBox> Garbage;
+
+  double fbound;
+  TBox Domain;
+
+  void FillRegular(RTBox, RTBox);
+  void FillRandom(RTBox, RTBox);
+  double NewtonTest(RTBox, int, RCRVector, int*);
+  void ReduceOrSubdivide(RTBox, int, RCRVector);
+};
+#endif
+
diff --git a/stogo/linalg.cc b/stogo/linalg.cc
new file mode 100644 (file)
index 0000000..04916cf
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+   Temporary implementation of vector and matrix classes
+   No attempt is made to check if the function arguments are valid
+*/
+
+#include <iostream>
+#include <math.h>         // for sqrt()
+
+#include "linalg.h"
+
+double eps() {
+  /* Returns the machine precision : (min { x >= 0 : 1 + x > 1 }) 
+     NB This routine should be replaced by LAPACK_LAMCH */
+  double Current, Last, OnePlusCurrent ;
+  Current = 1.0 ;
+  do
+    {
+      Last = Current ;
+      Current /= 2.0 ;
+      OnePlusCurrent = 1.0 + Current ;
+    } while (OnePlusCurrent > 1.0) ;
+  return Last ;
+}
+
+
+RVector::RVector() {
+ // Constructor
+ len=0;
+ elements=0; (*this)=0.;
+}
+
+RVector::RVector(int n) {
+ // Constructor
+ len=n;
+ elements=new double[len]; (*this)=0.;
+}
+
+RVector::RVector(RCRVector vect)
+{
+ // Constructor + Copy
+ len=vect.len;
+ elements=new double[len]; (*this)=vect;
+}
+
+RCRVector RVector::operator=(RCRVector vect)
+{
+ // Copy
+ for (int i=0;i<len;i++) elements[i]=vect.elements[i];
+ return *this;
+}
+
+RCRVector RVector::operator=(double num) {
+ // Assignment
+ for (int i=0;i<len;i++) elements[i]=num;
+ return *this;
+}
+
+double RVector::nrm2() {
+  double sum=0 ;
+  for (int i = 0; i < len; i++)
+    sum+=elements[i]*elements[i] ;
+  return sqrt(sum) ;
+}
+
+void scal(double alpha, RCRVector x) {
+  int n=x.len ;
+  for (int i = 0; i < n; i++)
+    x.elements[i] = alpha*x.elements[i] ;
+}
+
+double norm2(RCRVector x) {
+  // Euclidian norm
+  double sum=0 ;
+  double* pa=x.elements ;
+  int n=x.len ;
+  for (int i = 0; i < n; i++) {
+    sum+=(*pa)*(*pa) ;
+    pa++ ;
+  }
+  return sqrt(sum) ;
+}
+
+double normInf(RCRVector x) {
+  // Infinity norm
+  int n=x.len ;
+  double tmp=DBL_MIN ;
+  for (int i=0 ; i<n ; i++)
+    tmp=max(tmp,fabs(x.elements[i])) ;
+  return tmp ;
+}
+
+double dot(RCRVector x, RCRVector y) {
+  // dot <- x'y
+  int n=x.len ;
+  double sum=0 ;
+  for (int i=0 ; i<n ; i++)
+    sum+= x.elements[i]*y.elements[i] ;
+  return sum ;
+}
+
+void copy(RCRVector x, RCRVector y) {
+  // y <- x
+  double *px=x.elements ;
+  double *py=y.elements ;
+  int n=x.len ;
+  for (int i=0 ; i<n ; i++)
+    (*py++)=(*px++) ;
+}
+
+void axpy(double alpha, RCRVector x, RCRVector y) {
+  // y <- alpha*x + y
+  double *px=x.elements ;
+  double *py=y.elements ;
+  int n=x.len ;
+  for (int i=0 ; i<n ; i++) {
+    *py=alpha*(*px) + *py ;
+    px++ ; py++ ;
+  }
+}
+
+void gemv(char trans, double alpha, RCRMatrix A,RCRVector x,
+         double beta, RCRVector y) {
+  // Matrix-vector multiplication
+  int i, j, dim=A.Dim;
+  double sum ;
+
+  if (trans=='N') {
+    // y=alpha*A*x + beta*y
+    for (i=0;i<dim;i++) {
+      sum=0.;
+      for (j=0;j<dim;j++)
+        sum+=A.Vals[j+i*dim]*x.elements[j]*alpha;
+      y.elements[i]=y.elements[i]*beta + sum ;
+    }
+  }
+  else {
+    // y=alpha*transpose(A)*x +  beta*y
+    for (i=0;i<dim;i++) {
+      sum=0.;
+      for (j=0;j<dim;j++) {
+        sum+=A.Vals[i+j*dim]*x.elements[j]*alpha ;
+      }
+      y.elements[i]=y.elements[i]*beta + sum ;
+    }
+  }
+}
+
+ostream & operator << (ostream & os, const RVector & v) {
+  os << '[';
+  for (int i = 0; i < v.len; i++) {
+    if (i>0) os << "," ;
+    os << v.elements[i] ;
+  }
+  return os << ']';
+}
+
+/*************************** Matrix Class ***********************/
+
+RMatrix::RMatrix() {
+ // Constructor
+ Dim=0 ; Vals=0 ; (*this)=0 ;
+}
+
+RMatrix::RMatrix(int dim) {
+ // Constructor
+ Dim=dim;
+ Vals=new double[long(Dim)*long(Dim)]; (*this)=0.;
+}
+
+RMatrix::RMatrix(RCRMatrix matr) {
+ // Constructor + Copy 
+ Dim=matr.Dim;
+ Vals=new double[long(Dim)*long(Dim)]; (*this)=matr;
+}
+
+RCRMatrix RMatrix::operator=(RCRMatrix mat)
+{ // Assignment, A=B
+ long int Len=long(Dim)*long(Dim);
+ for (int i=0;i<Len;i++) Vals[i]=mat.Vals[i] ;
+ return *this;
+}
+
+RCRMatrix RMatrix::operator=(double num) {
+ long int Len=long(Dim)*long(Dim);
+ for (long int i=0;i<Len;i++) Vals[i]=num;
+ return *this;
+}
+
+double& RMatrix::operator()(int vidx,int hidx) {
+ return Vals[vidx*Dim+hidx];
+}
+
+void ger(double alpha, RCRVector x,RCRVector y, RCRMatrix A) {
+  // Rank one update : A=alpha*xy'+A
+  int dim=x.len;
+  double* pa=A.Vals ;
+
+  for (int i=0;i<dim;i++)
+    for (int j=0;j<dim;j++) {
+      *pa=alpha*x.elements[i]*y.elements[j] + *pa;
+      pa++ ;
+    }
+}
+
+ostream & operator << (ostream & os, const RMatrix & A) {
+  int n=A.Dim ;
+  double* pa=A.Vals ;
+  os << endl ;
+  for (int i = 0; i < n; i++) {
+    for (int j=0 ; j< n ; j++) {
+      os << (*(pa++)) << " " ;
+    }
+    os << endl ;
+  }
+  return os ;
+}
diff --git a/stogo/linalg.h b/stogo/linalg.h
new file mode 100644 (file)
index 0000000..d5b8d7b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+   Temporary implementation of vector and matrix classes
+   This is more or less borrowed from Serguei's program
+*/
+
+#ifndef LINALG_H
+#define LINALG_H
+
+#include <iostream>
+using namespace std;
+#include <math.h>         // for sqrt()
+#include <float.h>
+
+typedef const class RVector CRVector;
+typedef CRVector& RCRVector;
+typedef const class RMatrix CRMatrix ;
+typedef CRMatrix& RCRMatrix;
+
+double eps() ;
+
+#define max(A,B)    ((A) > (B) ? (A):(B))
+#define min(A,B)    ((A) < (B) ? (A):(B))
+
+/********************* Class RVector *********************/
+
+class RVector{
+protected:
+
+ public:
+  int      len;       // size of array
+  double*  elements;  // array of values
+
+  RVector() ;
+  RVector(int);       // Constructor
+  RVector(RCRVector); // copy constructor
+  ~RVector() { delete[] elements; elements=0 ; len=0; }
+
+  RCRVector operator=(double) ;
+  RCRVector operator=(RCRVector);
+
+  double & operator () (int i) const {return elements[i] ; }
+  double nrm2() ; // Euclidian norm
+
+  double *raw_data() { return elements; }
+  const double *raw_data_const() const { return elements; }
+
+  friend ostream & operator << (ostream &, const RVector &);
+
+  friend double norm2(RCRVector) ;
+  friend double normInf(RCRVector) ;
+  friend double dot(RCRVector, RCRVector) ;
+  friend void scal(double, RCRVector) ;
+  friend void copy(RCRVector, RCRVector) ;
+  friend void axpy(double, RCRVector, RCRVector) ;
+  friend void gemv(char,double, RCRMatrix, RCRVector, double, RCRVector);
+  friend void ger(double alpha, RCRVector, RCRVector, RCRMatrix);
+
+  int GetLength() const { return len; }; // get vector size
+};
+
+/******************* Class RMatrix *************************/
+
+class RMatrix
+{
+ protected:
+  double*  Vals; // array of values
+  int       Dim; // dimension
+
+ public:
+   RMatrix() ;
+   RMatrix(int); // dimension
+  ~RMatrix() { delete[] Vals;  Vals=0 ; Dim=0; }
+  RMatrix(RCRMatrix); // copy constructor
+  RCRMatrix operator=(double num) ;
+  RCRMatrix operator=(RCRMatrix) ; // (needed for template stuff)
+
+  double& operator()(int vidx,int hidx) ;
+  friend ostream & operator << (ostream &, const RMatrix &);
+
+  friend void gemv(char,double, RCRMatrix, RCRVector, double, RCRVector);
+  friend void ger(double alpha,RCRVector,RCRVector,RCRMatrix);
+
+  int       GetDim() { return Dim; }; // get dimension
+};
+
+#endif
diff --git a/stogo/local.cc b/stogo/local.cc
new file mode 100644 (file)
index 0000000..89802b6
--- /dev/null
@@ -0,0 +1,409 @@
+
+/*
+   Local search - A trust region algorithm with BFGS update.
+*/
+
+#include <iostream>
+#include <stdlib.h>
+
+#include "stogo_config.h"
+#include "global.h"
+#include "local.h"
+#include "tools.h"
+
+#ifdef NLOPT_UTIL_H
+#  define IF_NLOPT_CHECK_EVALS stop->nevals++; \
+                               if (nlopt_stop_evalstime(stop)) \
+                                  return LS_MaxEvalTime
+#else
+#  define IF_NLOPT_CHECK_EVALS 
+#endif
+
+////////////////////////////////////////////////////////////////////////
+// SGJ, 2007: allow local to use local optimizers in NLopt, to compare
+// to the BFGS code below
+#if 0
+#include "nlopt.h"
+
+typedef struct {
+  Global *glob;
+  double maxgrad;
+  nlopt_stopping *stop;
+} f_local_data;
+
+static double f_local(int n, const double *x, double *grad, void *data_)
+{
+  f_local_data *data = (f_local_data *) data_;
+  double f;
+  RVector xv, gv;
+  // hack to avoid pointless copy of x and grad
+  xv.len = gv.len = n;
+  xv.elements = const_cast<double *>(x);
+  gv.elements = grad;
+  f=data->glob->ObjectiveGradient(xv, gv,
+                                  grad?OBJECTIVE_AND_GRADIENT:OBJECTIVE_ONLY);
+  if (grad) data->maxgrad = max(data->maxgrad, normInf(gv));
+  xv.elements = gv.elements = 0; // prevent deallocation
+  data->stop->nevals++;
+  return f;
+}
+#endif
+////////////////////////////////////////////////////////////////////////
+
+int local(Trial &T, TBox &box, TBox &domain, double eps_cl, double *mgr,
+          Global &glob, int axis, RCRVector x_av
+#ifdef NLOPT_UTIL_H
+         , nlopt_stopping *stop
+#endif
+         ) {
+
+  int n=box.GetDim();
+  RVector x(n);
+  double tmp, f;
+
+  x=T.xvals ;
+
+#ifdef LS_DEBUG
+  cout << "Local Search, x=" << x << endl;
+#endif
+
+  if (box.OutsideBox(x, domain) != 0) {
+    cout << "Starting point is not inside the boundary. Exiting...\n" ;
+    exit(1) ;
+    return LS_Out ;
+  }
+
+  // Check if we are close to a stationary point located previously
+  if (box.CloseToMin(x, &tmp, eps_cl)) {
+#ifdef LS_DEBUG
+     cout << "Close to a previously located stationary point, exiting" << endl;
+#endif
+     T.objval=tmp;
+     return LS_Old ;
+   } 
+
+#if 0
+
+  if (axis != -1) {
+    cout << "NLopt code only works with axis == -1, exiting...\n" ;
+    exit(EXIT_FAILURE);
+  }
+  f_local_data data;
+  data.glob = &glob;
+  data.maxgrad = *mgr;
+  data.stop = stop;
+  nlopt_result ret = nlopt_minimize(NLOPT_LOCAL_LBFGS, n, f_local, &data,
+                                   box.lb.raw_data(), box.ub.raw_data(),
+                                   x.raw_data(), &f, 
+                                   stop->minf_max,
+                                   stop->ftol_rel, stop->ftol_abs,
+                                   stop->xtol_rel, stop->xtol_abs,
+                                   stop->maxeval - stop->nevals,
+                                   stop->maxtime - stop->start);
+  *mgr = data.maxgrad;
+  T.xvals=x ; T.objval=f ;
+  if (ret == NLOPT_MAXEVAL_REACHED || ret == NLOPT_MAXTIME_REACHED)
+    return LS_MaxEvalTime;
+  else if (ret > 0)
+    return LS_New;
+  else
+    return LS_Out; // failure
+  
+#else /* not using NLopt local optimizer ... use original STOgo BFGS code */
+
+  int k_max, info, outside = 0;
+  int k, i, good_enough, iTmp ;
+
+  double maxgrad, delta, f_new;
+  double alpha, gamma, beta, d2, s2, nom, den, ro ;
+  double nrm_sd, nrm_hn, snrm_hn, nrm_dl ;
+  RVector g(n), h_sd(n), h_dl(n), h_n(n), x_new(n), g_new(n) ;
+  RVector s(n),y(n),z(n),w(n) ; // Temporary vectors
+  RMatrix B(n), H(n) ;          // Hessian and it's inverse
+
+  k_max = max_iter*n ;
+
+  // Initially B and H are equal to the identity matrix
+  B=0 ; H=0 ;
+  for (i=0 ; i<n ; i++) {
+    B(i,i)=1 ;
+    H(i,i)=1 ;
+  }
+
+  RVector g_av(x_av.GetLength());
+  if (axis==-1) {
+    f=glob.ObjectiveGradient(x,g,OBJECTIVE_AND_GRADIENT);
+  }
+  else {
+    x_av(axis)=x(0);
+    f=glob.ObjectiveGradient(x_av,g_av,OBJECTIVE_AND_GRADIENT);
+    g(0)=g_av(axis);
+  }
+  IF_NLOPT_CHECK_EVALS;
+  FC++;GC++;
+
+  if (axis == -1) {
+    // Skipping AV
+#ifdef INI3
+    // Elaborate scheme to initalize delta
+    delta=delta_coef*norm2(g) ;
+    copy(g,z) ;
+    axpy(1.0,x,z) ;
+    if (!box.InsideBox(z)) {
+      if (box.Intersection(x,g,z)==TRUE) {
+       axpy(-1.0,x,z) ;
+       delta=min(delta,delta_coef*norm2(z)) ;
+      }
+      else {
+       // Algorithm broke down, use INI1
+        delta = (1.0/7)*box.ShortestSide(&iTmp) ;
+      }
+    }
+#endif
+#ifdef INI2
+    // Use INI2 scheme
+    delta = box.ClosestSide(x)*delta_coef ;
+    if (delta<MacEpsilon)
+      // Patch to avoid trust region with radius close to zero
+      delta = (1.0/7)*box.ShortestSide(&iTmp) ;
+#endif
+#ifdef INI1
+    delta = delta_coef*box.ShortestSide(&iTmp) ;
+#endif
+  }
+  else {
+    // Use a simple scheme for the 1D minimization (INI1)
+    delta = (1.0/7.0)*box.ShortestSide(&iTmp) ;
+  }
+
+  k=0 ; good_enough = 0 ; info=LS_New ; outside=0 ;
+  maxgrad=*mgr ;
+  while (good_enough == 0) {
+    k++ ;
+    if (k>k_max) {
+#ifdef LS_DEBUG
+      cout << "Maximum number of iterations reached\n" ;
+#endif
+      info=LS_MaxIter ;
+      break ;
+    }
+
+    // Update maximal gradient value
+    maxgrad=max(maxgrad,normInf(g)) ;
+
+    // Steepest descent, h_sd = -g
+    copy(g,h_sd) ;
+    scal(-1.0,h_sd) ;
+    nrm_sd=norm2(h_sd) ;
+
+    if (nrm_sd < epsilon) {
+      // Stop criterion (gradient) fullfilled
+#ifdef LS_DEBUG
+      cout << "Gradient small enough" << endl ;
+#endif
+      good_enough = 1 ;
+      break ;
+    }
+
+    // Compute Newton step, h_n = -H*g
+    gemv('N',-1.0, H, g, 0.0, h_n) ;
+    nrm_hn = norm2(h_n) ;
+
+    if (nrm_hn < delta) {
+      // Pure Newton step
+      copy(h_n, h_dl) ;
+#ifdef LS_DEBUG
+      cout << "[Newton step]      " ;
+#endif
+    }
+    else {
+      gemv('N',1.0,B,g,0.0,z) ;
+      tmp=dot(g,z) ;
+      if (tmp==0) {
+       info = LS_Unstable ;
+       break ;
+      }
+      alpha=(nrm_sd*nrm_sd)/tmp ; // Normalization (N38,eq. 3.30)
+      scal(alpha,h_sd) ;
+      nrm_sd=fabs(alpha)*nrm_sd ;
+
+      if (nrm_sd >= delta) {
+       gamma = delta/nrm_sd ; // Normalization (N38, eq. 3.33)
+       copy(h_sd,h_dl) ;
+       scal(gamma,h_dl) ;
+#ifdef LS_DEBUG
+       cout << "[Steepest descent]  " ;
+#endif
+      }
+      else {
+       // Combination of Newton and SD steps
+       d2 = delta*delta ; 
+       copy(h_sd,s) ; 
+       s2=nrm_sd*nrm_sd ;
+       nom = d2 - s2 ;
+       snrm_hn=nrm_hn*nrm_hn ;
+       tmp = dot(h_n,s) ;
+        den = tmp-s2 + sqrt((tmp-d2)*(tmp-d2)+(snrm_hn-d2)*(d2-s2)) ;
+       if (den==0) {
+         info = LS_Unstable ;
+         break ;
+       }
+       // Normalization (N38, eq. 3.31)
+       beta = nom/den ; 
+       copy(h_n,h_dl) ;
+       scal(beta,h_dl) ;
+       axpy((1-beta),h_sd,h_dl) ;
+#ifdef LS_DEBUG
+       cout << "[Mixed step]        " ;
+#endif
+      }
+    }
+    nrm_dl=norm2(h_dl) ;
+
+    //x_new = x+h_dl ;
+    copy(x,x_new) ;
+    axpy(1.0,h_dl,x_new) ;
+
+    // Check if x_new is inside the box
+    iTmp=box.OutsideBox(x_new, domain) ;
+    if (iTmp == 1) {
+#ifdef LS_DEBUG
+      cout << "x_new is outside the box " << endl ;
+#endif
+      outside++ ;
+      if (outside>max_outside_steps) {
+       // Previous point was also outside, exit
+       break ;
+      }
+    }
+    else if (iTmp == 2) {
+#ifdef LS_DEBUG
+      cout << " x_new is outside the domain" << endl ;
+#endif
+      info=LS_Out ;
+      break ;
+    }
+    else {
+      outside=0 ;  
+    }
+
+    // Compute the gain
+    if (axis==-1)
+      f_new=glob.ObjectiveGradient(x_new,g_new,OBJECTIVE_AND_GRADIENT);
+    else {
+      x_av(axis)=x_new(0);
+      f_new=glob.ObjectiveGradient(x_av,g_av,OBJECTIVE_AND_GRADIENT);
+    }
+    IF_NLOPT_CHECK_EVALS;
+    FC++; GC++;
+    gemv('N',0.5,B,h_dl,0.0,z);
+    ro = (f_new-f) / (dot(g,h_dl) + dot(h_dl,z)); // Quadratic model
+    if (ro > 0.75) {
+      delta = delta*2;
+    }
+    if (ro < 0.25) {
+      delta = delta/3;
+    }
+    if (ro > 0) {
+      // Update the Hessian and it's inverse using the BFGS formula
+#if 0 // changed by SGJ to compute OBJECTIVE_AND_GRADIENT above
+      if (axis==-1)
+       glob.ObjectiveGradient(x_new,g_new,GRADIENT_ONLY);
+      else {
+       x_av(axis)=x_new(0);
+       glob.ObjectiveGradient(x_av,g_av,GRADIENT_ONLY);
+       g_new(0)=g_av(axis);
+      }
+      GC++;
+      IF_NLOPT_CHECK_EVALS;
+#else
+      if (axis != -1)
+       g_new(0)=g_av(axis);
+#endif
+
+      // y=g_new-g
+      copy(g_new,y);
+      axpy(-1.0,g,y);
+
+      // Check curvature condition
+      alpha=dot(y,h_dl);
+      if (alpha <= sqrt(MacEpsilon)*nrm_dl*norm2(y)) {
+#ifdef LS_DEBUG
+       cout << "Curvature condition violated " ;
+#endif
+      }
+      else {
+       // Update Hessian
+       gemv('N',1.0,B,h_dl,0.0,z) ; // z=Bh_dl
+       beta=-1/dot(h_dl,z) ;
+       ger(1/alpha,y,y,B) ;
+       ger(beta,z,z,B) ;
+
+        // Update Hessian inverse
+        gemv('N',1.0,H,y,0.0,z) ; // z=H*y
+        gemv('T',1.0,H,y,0.0,w) ; // w=y'*H
+       beta=dot(y,z) ;
+       beta=(1+beta/alpha)/alpha ;
+
+       // It should be possible to do this updating more efficiently, by
+       // exploiting the fact that (h_dl*y'*H) = transpose(H*y*h_dl')
+       ger(beta,h_dl,h_dl,H) ;
+       ger(-1/alpha,z,h_dl,H) ;
+       ger(-1/alpha,h_dl,w,H) ;
+      }
+
+      if (nrm_dl < norm2(x)*epsilon) {
+       // Stop criterion (iteration progress) fullfilled
+#ifdef LS_DEBUG
+       cout << "Progress is marginal" ;
+#endif
+       good_enough = 1 ;
+      }
+
+      // Check if we are close to a stationary point located previously
+      if (box.CloseToMin(x_new, &f_new, eps_cl)) {
+       // Note that x_new and f_new may be overwritten on exit from CloseToMin
+#ifdef LS_DEBUG
+       cout << "Close to a previously located stationary point, exiting" << endl;
+#endif
+       info = LS_Old ;
+       good_enough = 1 ;
+      }
+
+      // Update x, g and f
+      copy(x_new,x) ; copy(g_new,g) ; f=f_new ;
+
+#ifdef LS_DEBUG
+      cout << " x=" << x << endl ;
+#endif
+
+    }
+    else {
+#ifdef LS_DEBUG
+      cout << "Step is no good, ro=" << ro << " delta=" << delta << endl ;
+#endif
+    }
+    
+  } // wend
+
+  // Make sure the routine returns correctly...
+  // Check if last iterate is outside the boundary
+  if (box.OutsideBox(x, domain) != 0) {
+    info=LS_Out; f=DBL_MAX;
+  }
+
+  if (info == LS_Unstable) {
+    cout << "Local search became unstable. No big deal but exiting anyway\n" ;
+    exit(1);
+  }
+
+  *mgr=maxgrad ;
+
+  T.xvals=x ; T.objval=f ;
+  if (outside>0)
+    return LS_Out ;
+  else
+    return info ;
+
+#endif
+}
diff --git a/stogo/local.h b/stogo/local.h
new file mode 100644 (file)
index 0000000..d9d4c41
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+    Definitions of various variables used in the local search
+*/
+
+#ifndef LOCAL_H
+#define LOCAL_H
+
+#include "tools.h"
+#include "global.h"
+
+extern int FC, GC ;
+
+// Results of local search
+enum {LS_Unstable, LS_MaxIter, LS_Old, LS_New,LS_Out, LS_MaxEvalTime} ;
+
+const double delta_coef = 1.0/2.0; // Initialization of trust region
+const double epsilon = 1.0E-4 ;    // Stopping criterion, var 1e-4
+const int max_outside_steps=1 ;    // Maximum number of steps outside the box
+const int max_iter=50 ;            // Max iterations = max_iter*dim. of problem
+
+extern double MacEpsilon ;   //  min {x >= 0 : 1 + x > 1}
+
+int local(Trial &, TBox &, TBox &, double, double*, Global&, int, RCRVector
+#ifdef NLOPT_UTIL_H
+         , nlopt_stopping *stop
+#endif
+     );
+
+#endif
diff --git a/stogo/prog.cc b/stogo/prog.cc
new file mode 100644 (file)
index 0000000..1cb941a
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+       A simple program to test the global optimizer.
+*/
+
+#include "global.h"
+#include "tools.h"
+#include "testfun.h"
+
+#define STRLEN_MAX 80
+
+int main() {
+  bool AVfail, AVflag;
+  int testfnc, dim, axis, i;
+  double AVbest;
+  Pdom  Dom;
+  Pgrad Grad;
+  Pobj  Obj;
+
+  cout << "Global Optimizer v0.1" << endl;
+  cout << "1.  Rosenbrock (min=0)" << endl;
+  cout << "2.  McCormick (min=-1.91)" << endl;
+  cout << "3.  Box & Betts (min=0)" << endl;
+  cout << "4.  Paviani (min=-45.7)" << endl;
+  cout << "5.  Extended Beale (min=0)" << endl;
+  cout << "6.  Three-hump Camel (min=0)" << endl;
+  cout << "7.  Jacobsen & Pedersen (min=3)" << endl;
+  cout << "8.  Poly1 (min=0)" << endl;
+  cout << "9.  Six-hump Camel (min=-1.03) " << endl;
+  cout << "10. One-dimensional (min=-23.58)" << endl;
+  cout << "11. Kowalik (min=0.0003075)" << endl;
+  cout << "12. Hansen (min=-176.54)" << endl;
+  cout << "13. Shubert (min=-24.06)" << endl;
+  cout << "14. Griewank (min=0)" << endl;
+  cout << "15. Levy4 (min=-21.502)" << endl;
+  cout << "16. Levy5 (min=-11.504)" << endl;
+  cout << "17. Levy6 (min=-11.504)" << endl;
+  cout << "18. Levy7 (min=-11.504)" << endl;
+  cout << "19. Rastrigin (min=0)" << endl;
+  cout << "20. Trid" << endl;
+  cout << "21. Perm(4,50)" << endl;
+  cout << "22. Perm(4,0.5)" << endl;
+  cout << "23. Powersum(8,18,44,114)" << endl;
+  cout << "24. Schwefel (min=-12569.5)" << endl;
+  cout << "25. Shekel (-10.0)" << endl;
+  cout << endl << "Select test function :";
+  cin >> testfnc;
+
+  switch (testfnc) {
+  case 10:
+    dim=1;
+    Dom=Domain_OneDim;
+    Obj=Objective_OneDim;
+    Grad=Gradient_OneDim;
+    break;
+  case 1:
+    dim=2;
+    Dom=Domain_Rosenbrock;
+    Obj=Objective_Rosenbrock;
+    Grad=Gradient_Rosenbrock;
+    break;
+  case 8:
+    dim=2;
+    Dom=Domain_Poly1;
+    Obj=Objective_Poly1;
+    Grad=Gradient_Poly1;
+    break;
+  case 7:
+    dim=2;
+    Dom=Domain_Jacobsen;
+    Obj=Objective_Jacobsen;
+    Grad=Gradient_Jacobsen;
+    break;
+  case 6:
+    dim=2;
+    Dom=Domain_Camel3;
+    Obj=Objective_Camel3;
+    Grad=Gradient_Camel3;
+    break;
+  case 5:
+    dim=2;
+    Dom=Domain_Beale3;
+    Obj=Objective_Beale3;
+    Grad=Gradient_Beale3;
+    break;
+  case 4:
+    dim=10;
+    Dom=Domain_Paviani;
+    Obj=Objective_Paviani;
+    Grad=Gradient_Paviani;
+    break;
+  case 12:
+    dim=2;
+    Dom=Domain_Hansen;
+    Obj=Objective_Hansen;
+    Grad=Gradient_Hansen;
+    break;
+  case 13:
+    dim=2;
+    Dom=Domain_Shubert;
+    Obj=Objective_Shubert;
+    Grad=Gradient_Shubert;
+    break;
+  case 11:
+    dim=4;
+    Dom=Domain_Kowalik;
+    Obj=Objective_Kowalik;
+    Grad=Gradient_Kowalik;
+    break;
+  case 9:
+    dim=2;
+    Dom=Domain_Camel6;
+    Obj=Objective_Camel6;
+    Grad=Gradient_Camel6;
+    break;
+  case 2:
+    dim=2;
+    Dom=Domain_McCormick;
+    Obj=Objective_McCormick;
+    Grad=Gradient_McCormick;
+    break;
+  case 3:
+    dim=3;
+    Dom=Domain_BoxBetts; 
+    Obj=Objective_BoxBetts;
+    Grad=Gradient_BoxBetts; 
+    break;
+  case 14:
+    dim=10;
+    Dom=Domain_Griewank;
+    Obj=Objective_Griewank;
+    Grad=Gradient_Griewank;
+    break;
+  case 15:
+    dim=4;
+    Dom=Domain_Levy;
+    Obj=Objective_Levy;
+    Grad=Gradient_Levy;  
+    break;
+  case 16:
+    dim=5;
+    Dom=Domain_Levy; 
+    Obj=Objective_Levy; 
+    Grad=Gradient_Levy; 
+    break;
+ case 17:
+    dim=6;
+    Dom=Domain_Levy;
+    Obj=Objective_Levy;
+    Grad=Gradient_Levy;
+    break;
+ case 18:
+    dim=7;
+    Dom=Domain_Levy;
+    Obj=Objective_Levy;
+    Grad=Gradient_Levy;
+    break;
+  case 19:
+    cout << "Enter problem dimension ";
+    int rast_dim;   
+    cin >> rast_dim;
+    dim=rast_dim;
+    Dom=Domain_Rastrigin;   
+    Obj=Objective_Rastrigin;
+    Grad=Gradient_Rastrigin;
+    break;
+  case 20:
+    cout << "Enter problem dimension (two or larger) ";
+    int trid_dim;
+    cin >> trid_dim;
+    dim=trid_dim; 
+    Dom=Domain_Trid;
+    Obj=Objective_Trid;
+    Grad=Gradient_Trid;
+    break;
+  case 21:
+    dim=4;
+    Dom=Domain_Perm;
+    Obj=Objective_Perm_4_50;
+    Grad=Gradient_Perm_4_50;
+    break;
+ case 22:
+    dim=4;
+    Dom=Domain_Perm;
+    Obj=Objective_Perm_4_05;
+    Grad=Gradient_Perm_4_05;
+    break;
+ case 23:  
+    dim=4;
+    Dom=Domain_Powersum;
+    Obj=Objective_Powersum;
+    Grad=Gradient_Powersum;
+    break;
+ case 24:
+    cout << "Enter problem dimension ";
+    int schwef_dim;
+    cin >> schwef_dim;
+    dim=schwef_dim;
+    Dom=Domain_Schwefel;
+    Obj=Objective_Schwefel;
+    Grad=Gradient_Schwefel;
+    break;
+  case 25:
+    dim=4;
+    Dom=Domain_Shekel;
+    Obj=Objective_Shekel;
+    Grad=Gradient_Shekel;
+    break;
+  default:
+    cout << "Error : Function not defined" << endl;
+    exit(1);
+  }
+
+  cout << "Dimension=" <<dim << endl;
+  TBox D(dim);
+  Dom(D);
+  cout << "Domain=";
+  for (i=0; i<dim; i++)
+    cout << "[" << D.lb(i) << "," << D.ub(i) << "]";
+  cout << endl << endl;
+
+  GlobalParams params;
+  cout << "Enter time limit (seconds) ";
+  cin >> params.maxtime;
+  if (params.maxtime<1) {   
+    cout << "Warning: time limit set to 1 second\n";
+  }
+  params.maxeval = 0;
+  cout << "Use factory settings (y/n) ";
+  char str[STRLEN_MAX]; cin >> str;
+  if (str[0]=='y') {
+    params.det_pnts=2*dim+1; params.rnd_pnts=0;
+    params.eps_cl=0.1; params.rshift=0.3;
+    params.mu=1.0E-4; AVflag=FALSE;
+  }
+  else {
+    cout << "Number of deterministic points ";
+    cin >> params.det_pnts;
+    cout << "Numer of stochastic points ";
+    cin >> params.rnd_pnts;
+    cout << "Radius of attraction ";
+    cin >> params.eps_cl;
+    cout << "Parameter rshift ";
+    cin >> params.rshift;
+    cout << "Parameter mu ";
+    cin >> params.mu;
+    cout << "Use the AV initialization (y/n) ";
+    cin >> str;
+    if (str[0]=='y') AVflag=TRUE; else AVflag=FALSE;
+  }
+
+  Global Problem(D,Obj, Grad, params);
+  RVector x_av(dim);
+  if (AVflag==TRUE) {
+    cout << "Enter time limit for each coordinate direction (seconds) ";
+    cin >> params.maxtime;
+    if (params.maxtime<1) {
+      cout << "Warning: time limit set to 1 second\n";
+    }
+    params.maxeval = 0;
+    params.det_pnts=3;
+    TBox I(1);
+    Global AV(I, Obj, Grad, params);
+
+    x_av=0.0; AVfail=FALSE;
+    for (axis=0; axis<Problem.dim; axis++) {
+      cout << "### axis=" << axis << " ###" << endl;
+      I.lb=(D.lb)(axis); I.ub=(D.ub)(axis);
+      AV.SetDomain(I);
+      AV.ClearSolSet();
+      AV.Search(axis, x_av);
+
+      if (AV.NoMinimizers()) {
+       cout << "AV failed with axis=" << axis << endl;
+       AVfail=TRUE; break;
+      }
+    }
+
+    if (AVfail==FALSE) {
+      AVbest=AV.GetMinValue();
+      cout << "### AV Located x=" << x_av << " fbound=" << AVbest << endl;
+      RVector AVx(Problem.dim);
+      AVx=x_av;
+
+      // Use result from AV for new fbound
+      Problem.SetMinValue(AVbest);
+
+      // Add the best point found to the initial box (domain)
+      Problem.AddPoint(x_av, AVbest);      
+    }
+  }
+
+  // Perform the main search
+  cout << "### Starting main search ###" << endl;
+  Problem.Search(-1, x_av);
+
+  cout << "Optimization terminated. Current set of minimizers is" << endl;
+  if (Problem.NoMinimizers() && AVflag==FALSE)
+    cout << "### No improvement found ###" << endl;
+  else
+    Problem.DispMinimizers();
+}
diff --git a/stogo/rosen.h b/stogo/rosen.h
new file mode 100644 (file)
index 0000000..f8080a3
--- /dev/null
@@ -0,0 +1,18 @@
+#include "linalg.h" 
+#include "tools.h"
+#include "stogo_config.h"
+
+void Domain_Rosenbrock(RTBox box) {
+  box.lb=-10.0 ; box.ub=10.0;
+}
+
+double Objective_Rosenbrock(RCRVector x) {
+   double a=x(1)-x(0)*x(0);
+   double b=1-x(0);
+   return 100*a*a + b*b;
+}
+
+void Gradient_Rosenbrock(RCRVector x, RCRVector grad) {
+  grad(0)=200*(x(1)-x(0)*x(0))*(-2*x(0))-2*(1-x(0));
+  grad(1)=200*(x(1)-x(0)*x(0));   
+}
diff --git a/stogo/stogo.cc b/stogo/stogo.cc
new file mode 100644 (file)
index 0000000..146a9bc
--- /dev/null
@@ -0,0 +1,65 @@
+// A C-callable front-end to the StoGO global-optimization library.
+//  -- Steven G. Johnson
+
+#include "stogo.h"
+#include "global.h"
+
+class MyGlobal : public Global {
+protected:
+  objective_func my_func;
+  void *my_data;
+
+public:
+
+  MyGlobal(RTBox D, GlobalParams P, objective_func func, void *data) : Global(D, 0, 0, P), my_func(func), my_data(data) {}
+  
+  virtual double ObjectiveGradient(RCRVector xy, RVector &grad, whichO which){
+    ++numeval;
+    switch (which) {
+    case GRADIENT_ONLY:
+    case OBJECTIVE_AND_GRADIENT:
+      return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data);
+    case OBJECTIVE_ONLY:
+      return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), NULL, my_data);
+    }
+    return 0.0;
+  }
+};
+
+int stogo_minimize(int n,
+                  objective_func fgrad, void *data,
+                  double *x, double *minf,
+                  const double *l, const double *u,
+#ifdef NLOPT_UTIL_H
+                  nlopt_stopping *stop,
+#else
+                  long int maxeval, double maxtime,
+#endif
+                  int nrandom)
+{
+  GlobalParams params;
+
+  // FIXME: WTF do these parameters mean?
+  params.rnd_pnts=nrandom;
+  params.det_pnts=2*n+1 - nrandom; 
+  params.eps_cl=0.1; params.rshift=0.3;
+  params.mu=1.0E-4;
+  params.stop = stop;
+
+  TBox D(n);
+  for (int i = 0; i < n; ++i) {
+    D.lb(i) = l[i];
+    D.ub(i) = u[i];
+  }
+
+  MyGlobal Problem(D, params, fgrad, data);
+  RVector dummyvec(n);
+  Problem.Search(-1, dummyvec);
+
+  if (Problem.NoMinimizers())
+    return 0;
+  
+  *minf = Problem.OneMinimizer(dummyvec);
+  for (int i = 0; i < n; ++i) x[i] = dummyvec(i);
+  return 1;
+}
diff --git a/stogo/stogo.h b/stogo/stogo.h
new file mode 100644 (file)
index 0000000..211f3d8
--- /dev/null
@@ -0,0 +1,73 @@
+/* A C-callable front-end to the StoGO global-optimization library.
+   -- Steven G. Johnson   */
+
+#ifndef STOGO_H
+#define STOGO_H
+
+#include "nlopt-util.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef double (*objective_func)(unsigned n, const double *x, double *grad,
+                                void *data);
+
+/* search for the global minimum of the function fgrad(n, x, grad, data)
+   inside a simple n-dimensional hyperrectangle.
+
+   Input:
+
+       n: dimension of search space (number of decision variables)
+
+       fgrad: the objective function of the form fgrad(n, x, grad, data),
+              returning the objective function at x, where
+                 n: dimension of search space
+                x: pointer to array of length n, point to evaluate
+                 grad: if non-NULL, an array of length n which
+                       should on return be the gradient d(fgrad)/dx
+                       [ if NULL, grad should be ignored ]
+                 data: arbitrary data pointer, whose value is the
+                      data argument of stogo_minimize
+
+       data: arbitrary pointer to any auxiliary data needed by fgrad
+
+       l, u: arrays of length n giving the lower and upper bounds of the
+             search space
+
+       maxeval: if nonzero, a maximum number of fgrad evaluations
+       maxtime: if nonzero, a maximum time (in seconds)
+        -- REPLACED in NLopt by nlopt_stopping *stop
+
+       nrandom: number of randomized search points to use per box,
+                in addition to 2*n+1 deterministic search points
+               (0 for a deterministic algorithm).
+
+   Output:
+
+      minf: the minimum value of the objective function found
+
+      x: pointer to array of length n, giving the location of the minimum
+
+   Return value: 0 if no minimum found, 1 otherwise.
+
+ */
+
+int stogo_minimize(int n,
+                   objective_func fgrad, void *data,
+                   double *x, double *minf,
+                   const double *l, const double *u,
+#ifdef NLOPT_UTIL_H
+                  nlopt_stopping *stop,
+#else
+                  long int maxeval, double maxtime,
+#endif
+                  int nrandom);
+
+extern int stogo_verbose; /* set to nonzero for verbose output */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/stogo/stogo_config.h b/stogo/stogo_config.h
new file mode 100644 (file)
index 0000000..1e94f37
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef STOGO_CONFIG_H
+#define STOGO_CONFIG_H
+
+// Compiler flags to enable/disable various options in the code
+
+// To obtain extra information on the global search process:
+//#define GS_DEBUG
+
+// To obtain info on the local search process:
+//#define LS_DEBUG     
+
+// Initialization strategy in the local search (INI1,INI2 or INI3)
+#define INI2
+
+// Use the more pessimistic strategy for lower bound estimation
+//#define LB2
+
+
+#endif
diff --git a/stogo/testfun.h b/stogo/testfun.h
new file mode 100644 (file)
index 0000000..5aadafe
--- /dev/null
@@ -0,0 +1,539 @@
+#ifndef TESTFUN_H
+#define TESTFUN_H
+
+#include "linalg.h"
+#include "tools.h"
+#include "stogo_config.h"
+
+const double pi=fabs(acos(-1.));
+
+/* The Matrix a and vector c are needed in the Shekel function */
+static double a[10][4]={ { 4,4,4,4 } ,
+                        { 1,1,1,1 } ,
+                        { 8,8,8,8 } ,
+                        { 6,6,6,6 } ,
+                        { 3,7,3,7 } ,
+                        { 2,9,2,9 } ,
+                        { 5,5,3,3 } ,
+                        { 8,1,8,1 } ,
+                        { 6,2,6,2 } ,
+                        {7,3.6,7,3.6} };
+static double c[10]= { .1 , .2 , .2 , .4 , .4 , .6 , .3, .7 , .5 , .5 };
+
+void Domain_Shekel(RTBox box) {
+  box.lb=0.0 ; box.ub=10.0 ;
+}
+
+double Objective_Shekel(RCRVector x) {
+  int n=x.GetLength() ;
+  double R=0.0, S;
+  for(int i=0;i<10;i++) {
+    S=0;
+    for(int j=0;j<n;j++) S+=pow(x(j)-a[i][j],2);
+    R-=1/(S+c[i]);
+  }
+  return R;
+}
+
+void Gradient_Shekel(RCRVector x, RVector &grad) {
+  int n=x.GetLength() ;
+  double R;
+  for(int k=0;k<n;k++) {
+    R=0.0;
+    for(int i=0;i<10;i++) {
+      R+=(2.0*x(k)-2.0*a[i][k])/(pow(pow(x(0)-a[i][0],2.0)+pow(x(1)-a[i][1],2.0)
+                                +pow(x(2)-a[i][2],2.0)+pow(x(3)-a[i][3],2.0)+c[i],2.0));
+    }
+    grad(k)=R;
+  }
+}
+
+
+/******************** Unimodal functions ******************/
+void Domain_Rosenbrock(RTBox box) {
+  box.lb=-10.0 ; box.ub=10.0 ;
+}
+
+double Objective_Rosenbrock(RCRVector x) {
+   double a=x(1)-x(0)*x(0) ;
+   double b=1-x(0) ;
+   return 100*a*a + b*b ;
+}
+
+void Gradient_Rosenbrock(RCRVector x, RVector &grad) {
+  grad(0)=200*(x(1)-x(0)*x(0))*(-2*x(0))-2*(1-x(0)) ;
+  grad(1)=200*(x(1)-x(0)*x(0)) ;
+}
+
+
+void Domain_McCormick(RTBox box) {
+  box.lb(0)=-1.5 ; box.ub(0)=4.0 ;
+  box.lb(1)=-3.0 ; box.ub(1)=4.0 ;
+}
+
+double Objective_McCormick(RCRVector x) {
+  return sin(x(0)+x(1)) + pow(x(0)-x(1),2.0) - 1.5*x(0) + 2.5*x(1) + 1.0 ;
+}
+
+void Gradient_McCormick(RCRVector x, RVector &grad) {
+  grad(0)=cos(x(0)+x(1)) + 2*(x(0)-x(1)) - 1.5 ;
+  grad(1)=cos(x(0)+x(1)) - 2*(x(0)-x(1)) + 2.5 ;
+}
+
+
+void Domain_BoxBetts(RTBox box) {
+  box.lb(0)=0.9 ; box.ub(0)=1.2 ;
+  box.lb(1)=9.0 ; box.ub(1)=11.2 ;
+  box.lb(2)=0.9 ; box.ub(2)=1.2 ;
+}
+
+double Objective_BoxBetts(RCRVector x) {
+  double x0=x(0),x1=x(1),x2=x(2) ;
+  double sum=0.0 ;
+  for (int i=1 ; i<=10 ; i++)
+    sum+=pow(exp(-0.1*i*x0)-exp(-0.1*i*x1)-(exp(-0.1*i)-exp(-1.0*i))*x2,2.0);
+  return sum ;
+}
+
+void Gradient_BoxBetts(RCRVector x, RVector &grad) {
+  double x0=x(0),x1=x(1),x2=x(2) ;
+  double g0=0.0, g1=0.0, g2=0.0 ;
+  for (int i=1 ; i<=10 ; i++) {
+    g0 += -0.2*(exp(-0.1*i*x0)-exp(-0.1*i*x1)
+         -(exp(-0.1*i)-exp(-1.0*i))*x2)*i*exp(-0.1*i*x0);
+    g1 += 0.2*(exp(-0.1*i*x0)-exp(-0.1*i*x1)-(exp(-0.1*i)
+         -exp(-1.0*i))*x2)*i*exp(-0.1*i*x1);
+    g2 += 2.0*(exp(-0.1*i*x0)-exp(-0.1*i*x1)
+         -(exp(-0.1*i)-exp(-1.0*i))*x2)*(-exp(-0.1*i)+exp(-1.0*i));
+  }
+  grad(0)=g0 ; grad(1)=g1 ; grad(2)=g2 ;
+}
+
+
+void Domain_Paviani(RTBox box) {
+ box.lb=2.001 ; box.ub=9.999 ;
+}
+
+double Objective_Paviani(RCRVector x) { 
+  double a,b,sum=0.0, mul=1.0 ;
+  int n=x.GetLength() ;
+  for (int i=0 ; i<n ; i++) {
+    a=log(x(i)-2.0) ; b=log(10.0-x(i)) ;
+    sum+= a*a + b*b ;
+    mul*= x(i) ;
+  }
+  return sum - pow(mul,0.2) ;
+}
+
+void Gradient_Paviani(RCRVector x, RVector &grad) {
+  double sum, mul=1.0 ;
+  int n=10 ;
+  for (int i=0 ; i<n ; i++) {
+    mul*= x(i) ;
+  }
+
+  for (int j=0 ; j<n ; j++) {
+    sum=2*log(x(j)-2.0)/(x(j)-2.0) - 2*log(10.0-x(j))/(10.0-x(j)) ;
+    grad(j) = sum - 0.2*(mul/x(j))/pow(mul,0.8) ;
+  }
+}
+
+
+void Domain_Beale3(RTBox box) { // NB Make sure that there is only one minima
+ box.lb=-0.5 ; box.ub=4.0 ;
+}
+
+double Objective_Beale3(RCRVector x) {
+  double x1=x(0), x2=x(1) ;
+  double b1=1.500 + (x2 - 1.)*x1 ;
+  double b2=2.250 + (x2*x2 - 1.)*x1 ;
+  double b3=2.625 + (x2*x2*x2 - 1.)*x1 ;
+  return b1*b1 + b2*b2 + b3*b3 ;
+}
+
+void Gradient_Beale3(RCRVector x, RVector &grad) {
+  double x1=x(0), x2=x(1) ;
+  grad(0) = 2*(1.500 + (x2 - 1.)*x1)*(x2 - 1.)
+          + 2*(2.250 + (x2*x2 - 1.)*x1)*(x2*x2 - 1.)
+          + 2*(2.625 + (x2*x2*x2 - 1.)*x1)*(x2*x2*x2 - 1.) ;
+
+  grad(1) = 2*(1.500 + (x2 - 1.)*x1)*x1
+          + 4*(2.250 + (x2*x2  - 1.)*x1)*x2*x1
+          + 6*(2.625 + (x2*x2*x2 - 1.)*x1)*x2*x2*x1 ;
+}
+
+/************** Difficult unimodal problems ****************/
+void Domain_Trid(RTBox box) {
+  int n=(box.lb).GetLength() ;
+  double tmp=pow(n,2.0);
+  box.lb=-tmp ; box.ub=tmp ;  // [-n^2,n^2]
+}
+
+double Objective_Trid(RCRVector x) {
+  int n=x.GetLength();
+  double sum1=0.0, sum2=0.0;
+  for (int i=1 ; i<=n ; i++)
+    sum1+=pow(x(i-1)-1,2.0);
+  for (int i=2 ; i<=n ; i++)
+    sum2+=x(i-1)*x(i-2);
+  return sum1 - sum2;
+}
+
+void Gradient_Trid(RCRVector x, RVector &grad) {
+  int n=x.GetLength();
+  grad(0)=2*(x(0)-1)-x(1) ;
+  for (int i=1 ; i<=n-2 ; i++)
+    grad(i)=2*(x(i)-1) - (x(i-1) + x(i+1)) ;
+  grad(n-1)=2*(x(n-1)-1) - x(n-2) ;
+}
+
+/******************** Multimodal functions ****************/
+
+void Domain_OneDim(RTBox box) {
+ box.lb=-25.0 ; box.ub=25.0 ;
+}
+
+double Objective_OneDim(RCRVector x) {
+  return x(0)*sin(x(0)) ;
+}
+
+void Gradient_OneDim(RCRVector x, RVector &grad) {
+  grad(0) = x(0)*cos(x(0)) + sin(x(0)) ;
+}
+
+void Domain_Poly1(RTBox box) {
+// box.lb=-5.0 ; box.ub=5.0 ;
+ box.lb=-4.0;box.ub=4.01;
+}
+
+double Objective_Poly1(RCRVector x) {
+  double a=(x(0)*x(0) + x(1)*x(1) - 11) ;
+  double b=(x(0)+x(1)*x(1) - 7) ;
+  return a*a + b*b ;
+}
+
+void Gradient_Poly1(RCRVector x, RVector &grad) {
+  double a=(x(0)*x(0) + x(1)*x(1) - 11) ;
+  double b=(x(0)+x(1)*x(1) - 7) ;
+  grad(0) = 4*x(0)* a + 2*b ;
+  grad(1) = 4*x(1)* a + 4*x(1)*b ;
+}
+
+void Domain_Jacobsen(RTBox box) {
+ box.lb=-100.0 ; box.ub=100.0 ;
+}
+
+double Objective_Jacobsen(RCRVector x) {
+  double a=(x(0)*x(0) + x(1) - 11) ;
+  double b=(x(0)+x(1)*x(1) - 7) ;
+  return a*a + b*b + 3;
+}
+
+void Gradient_Jacobsen(RCRVector x, RVector &grad) {
+  double a=(x(0)*x(0) + x(1) - 11) ;
+  double b=(x(0)+x(1)*x(1) - 7) ;
+  grad(0) = 4*x(0)* a + 2*b ;
+  grad(1) = 2*x(1)* a + 4*x(1)*b ;
+}
+
+void Domain_Camel3(RTBox box) {
+ box.lb=-1.0 ; box.ub=2.0 ;
+}
+
+double Objective_Camel3(RCRVector x) {
+  double a=x(0)*x(0) ;
+  return 12*a - 6.3*a*a + a*a*a + 6*x(1)*(x(1)-x(0)) ;
+}
+
+void Gradient_Camel3(RCRVector x, RVector &grad) {
+  double a=x(0)*x(0) ;
+  grad(0) = 24*x(0) - 25.2*a*x(0) + 6*a*a*x(0) - 6*x(1) ;
+  grad(1) = 12*x(1) - 6*x(0) ;
+}
+
+
+void Domain_Hansen(RTBox box) {
+  box.lb=-10.0 ; box.ub=10.0 ;
+}
+
+double Objective_Hansen(RCRVector x) {
+  return (cos(1.0)+2.0*cos(x(0)+2.0)+3.0*cos(2.0*x(0)+3.0)+4.0*cos(3.0*x(0)
+        +4.0)+5.0*cos(4.0*x(0)+5.0))*(cos(2.0*x(1)+1.0)+2.0*cos(3.0*x(1)+2.0)   
+        +3.0*cos(4.0*x(1)+3.0)+4.0*cos(5.0*x(1)+4.0)+5.0*cos(6.0*x(1)+5.0));
+}
+
+void Gradient_Hansen(RCRVector x, RVector &grad) {
+   grad(0) = (-2.0*sin(x(0)+2.0)-6.0*sin(2.0*x(0)+3.0)-12.0*sin(3.0*x(0)+4.0)
+           -20.0*sin(4.0*x(0)+5.0))*(cos(2.0*x(1)+1.0)+2.0*cos(3.0*x(1)+2.0)
+           +3.0*cos(4.0*x(1)+3.0)+4.0*cos(5.0*x(1)+4.0)+5.0*cos(6.0*x(1)+5.0));
+
+   grad(1) = (cos(1.0)+2.0*cos(x(0)+2.0)+3.0*cos(2.0*x(0)+3.0)+4.0*cos(3.0*x(0)
+             +4.0)+5.0*cos(4.0*x(0)+5.0))*(-2.0*sin(2.0*x(1)+1.0)
+             -6.0*sin(3.0*x(1)+2.0)-12.0*sin(4.0*x(1)+3.0)
+             -20.0*sin(5.0*x(1)+4.0)-30.0*sin(6.0*x(1)+5.0));
+}
+
+
+void Domain_Shubert(RTBox box) {
+  box.lb=-10.0 ; box.ub=10.0 ;
+}
+
+double Objective_Shubert(RCRVector x) {
+   return -sin(2.0*x(0)+1.0)-2.0*sin(3.0*x(0)+2.0)-3.0*sin(4.0*x(0)+3.0)
+          -4.0*sin(5.0*x(0)+4.0)-5.0*sin(6.0*x(0)+5.0)-sin(2.0*x(1)+1.0)
+          -2.0*sin(3.0*x(1)+2.0)-3.0*sin(4.0*x(1)+3.0)-4.0*sin(5.0*x(1)+4.0)
+          -5.0*sin(6.0*x(1)+5.0);
+}
+
+void Gradient_Shubert(RCRVector x, RVector &grad) {
+   grad(0) = -2.0*cos(2.0*x(0)+1.0)-6.0*cos(3.0*x(0)+2.0)-12.0*cos(4.0*x(0)+3.0)
+             -20.0*cos(5.0*x(0)+4.0)-30.0*cos(6.0*x(0)+5.0);
+   grad(1) = -2.0*cos(2.0*x(1)+1.0)-6.0*cos(3.0*x(1)+2.0)-12.0*cos(4.0*x(1)+3.0)
+             -20.0*cos(5.0*x(1)+4.0)-30.0*cos(6.0*x(1)+5.0);
+}
+
+
+void Domain_Griewank(RTBox box) {
+  box.lb=-500 ; box.ub=700 ;
+}
+
+double Objective_Griewank(RCRVector x) {
+  double sum=0 ;
+  double prod=1 ;
+  for (int i=0 ; i<10 ; i++) {
+    sum+=x(i)*x(i) ;
+    prod*=cos(x(i)/sqrt(double(i+1))) ;
+  }
+  return sum/4000.0-prod + 1 ;
+}
+
+void Gradient_Griewank(RCRVector x, RVector &grad) {
+  double prod=1 ;
+  for (int i=0 ; i<10 ; i++) {
+    prod*=cos(x(i)/sqrt(double(i+1))) ;
+  }
+  for (int i=0 ; i<10 ; i++) {
+    grad(i)=x(i)/2000.0 + 1/sqrt(double(i+1))
+           *prod/cos(x(i)/sqrt(double(i+1)))*sin(x(i)/sqrt(double(i+1))) ;
+  }
+}
+
+
+void Domain_Levy(RTBox box) {
+  int n=(box.lb).GetLength() ;
+  switch (n) {
+  case 4 :
+    box.lb=-10.0 ; box.ub=10.0 ;
+    break ;
+  default:
+    box.lb=-5.0 ; box.ub=5.0 ;
+  }
+}
+
+double Objective_Levy(RCRVector x) {
+  int n=x.GetLength();
+  double sum=0.0;
+
+  for (int i=0 ; i<=n-2 ; i++)
+    sum+=pow(x(i)-1,2.0)*(1+pow(sin(3*pi*x(i+1)),2.0));
+  return pow(sin(3*pi*x(0)),2.0) + sum + (x(n-1)-1)*(1+pow(sin(2*pi*x(n-1)),2.0));
+}
+
+
+void Gradient_Levy(RCRVector x, RVector &grad) {
+  int n=x.GetLength();
+
+  grad(0)=6*sin(3*pi*x(0))*cos(3*pi*x(0))*pi + 2*(x(0)-1)*(1+pow(sin(3*pi*x(1)),2.0));
+
+  for (int i=1 ; i<=n-2 ; i++)
+    grad(i)=6*pow(x(i-1)-1,2.0)*sin(3*pi*x(i))*cos(3*pi*x(i))*pi
+      + 2*(x(i)-1)*(1+pow(sin(3*pi*x(i+1)),2.0)) ;
+
+  grad(n-1)=6*pow(x(n-2)-1,2.0)*sin(3*pi*x(n-1))*cos(3*pi*x(n-1))*pi
+    + 1 + pow(sin(2*pi*x(n-1)),2.0) + 4*(x(n-1)-1)*sin(2*pi*x(n-1))*cos(2*pi*x(n-1))*pi;
+}
+
+
+void Domain_Kowalik(RTBox box) {
+  box.lb=0 ; box.ub=5.0 ;
+}
+
+double Objective_Kowalik(RCRVector x) {
+  // First element in a and b is not used
+  double a[]={999,0.1957,0.1947,0.1735,0.1600,0.0844,0.0627,0.0456,0.0342,0.0323,0.0235,0.0246};
+  double b[]={999,1./0.25,1./0.5,1.,1./2,1./4,1./6,1./8,1./10,1./12,1./14,1./16};
+  double x1=x(0),x2=x(1),x3=x(2),x4=x(3);
+
+  double s=0;
+  for (int i=1 ; i<=11 ; i++)
+    s+=pow(a[i]- (x1*(b[i]*b[i] + b[i]*x2))/(b[i]*b[i] + b[i]*x3 + x4),2.0) ;
+  return s;
+}
+
+void Gradient_Kowalik(RCRVector x, RVector &grad) {
+  double a[]={999,0.1957,0.1947,0.1735,0.1600,0.0844,0.0627,0.0456,0.0342,0.0323,0.0235,0.0246};
+  double b[]={999,1./0.25,1./0.5,1.,1./2,1./4,1./6,1./8,1./10,1./12,1./14,1./16};
+  double x1=x(0),x2=x(1),x3=x(2),x4=x(3);
+  double g1=0,g2=0,g3=0,g4=0,tmp;
+  for (int i=1 ; i<=11 ; i++) {
+    tmp=a[i]- (x1*(b[i]*b[i] + b[i]*x2))/(b[i]*b[i] + b[i]*x3 + x4) ;
+    g1=g1-2*tmp*(b[i]*b[i]+b[i]*x2)/(b[i]*b[i]+b[i]*x3+x4) ;
+    g2=g2-2*tmp*(x1*b[i])/(b[i]*b[i]+b[i]*x3+x4) ;
+    g3=g3+2*tmp*x1*(b[i]*b[i]+b[i]*x2)*b[i]/pow(b[i]*b[i]+b[i]*x3+x4,2.0) ;
+    g4=g4+2*tmp*x1*(b[i]*b[i]+b[i]*x2)/pow(b[i]*b[i]+b[i]*x3+x4,2.0) ;
+  }
+  grad(0)=g1; grad(1)=g2; grad(2)=g3; grad(3)=g4;
+}
+
+
+void Domain_Camel6(RTBox box) {
+ box.lb=-5.0 ; box.ub=10.0 ;
+}
+
+double Objective_Camel6(RCRVector x) {
+  double x1=x(0),x2=x(1) ;
+  return 4.0*x1*x1-0.21E1*pow(x1,4.0)+pow(x1,6.0)/3+x1*x2-4.0*x2*x2 
+    + 4.0*pow(x2,4.0);
+}
+
+void Gradient_Camel6(RCRVector x, RVector &grad) {
+  double x1=x(0),x2=x(1) ;
+  grad(0) = 8.0*x1-0.84E1*x1*x1*x1+2.0*pow(x1,5.0)+x2;
+  grad(1) = x1-8.0*x2+16.0*x2*x2*x2;
+}
+
+/** Multimodal function with a huge number of local optima **/
+
+void Domain_Rastrigin(RTBox box) {
+  box.lb=-4.12 ; box.ub=6.12;
+}
+
+double Objective_Rastrigin(RCRVector x) {
+  double sum=0.0;
+  int n=x.GetLength();
+
+  for (int i=1 ; i<=n ; i++)
+     sum+=pow(x(i-1),2.0)-10*cos(2*pi*x(i-1))+10 ;
+  return sum ;
+}
+
+void Gradient_Rastrigin(RCRVector x, RVector &grad) {
+  int n=x.GetLength();
+
+  for (int i=1 ; i<=n ; i++)
+    grad(i-1)= 2*x(i-1) + 20*sin(2*pi*x(i-1))*pi ;
+}
+
+void Domain_Schwefel(RTBox box) {
+  box.lb=-500.0;box.ub=500.0;
+}
+
+double Objective_Schwefel(RCRVector x) {
+  double sum=0.0;
+  int n=x.GetLength();
+
+  for (int i=0 ; i<n ; i++)
+    sum+=x(i)*sin(sqrt(fabs(x(i))));
+  return -sum;
+}
+
+void Gradient_Schwefel(RCRVector x, RVector &grad) {
+  int n=x.GetLength();
+
+  for (int i=0; i<n ; i++) {
+    if (x(i)>=0)
+      grad(i)=-( sin(sqrt(x(i)))+sqrt(x(i))/2.0*cos(sqrt(x(i))) );
+    else
+      grad(i)=-( sin(sqrt(-x(i)))+sqrt(-x(i))/2.0*cos(sqrt(-x(i))) );
+  }
+}
+
+/******* Difficult multimodal problem, PERM(n) *********/
+
+void Domain_Perm(RTBox box) {
+  int n=(box.lb).GetLength();
+  box.lb=double(-n) ; box.ub=double(n) ;
+}
+
+double ObjPerm(RCRVector x, double beta) {
+  int n=x.GetLength();
+  double s1=0.0;
+  for (int k=1; k<=n ; k++) {
+    double s2=0.0;
+    for (int i=1 ; i<=n; i++)
+      //  s2+=(i^k+beta)*((x(i-1)/i)^k-1);
+      s2+=(pow(1.0*i,1.0*k)+beta)*(pow(x(i-1)/i,1.0*k)-1) ;
+    s1+=s2*s2;
+  }
+  return s1;
+}
+
+void GradPerm(RCRVector x, RVector &grad, double beta) {
+  int n=x.GetLength();
+  for (int j=1 ; j<=n ; j++) {
+    double s1=0.0;
+    for (int k=1 ; k<=n ; k++) {
+      double s2=0.0;
+      for (int i=1 ; i<=n; i++)
+       //      s2+=(i^k+beta)*((x(i-1)/i)^k-1);
+       s2+=(pow(1.0*i,1.0*k)+beta)*(pow(x(i-1)/i,1.0*k)-1);
+      //    s1+=2*s2*(j^k+beta)/(x(j-1)*j^k)*k*x(j-1)^k;
+      s1+=2*s2*(pow(1.0*j,1.0*k)+beta)/pow(1.0*j,1.0*k)*k*pow(x(j-1),k-1.0);
+    }
+    grad(j-1)=s1;
+  }
+}
+
+double Objective_Perm_4_50(RCRVector x) {
+  return ObjPerm(x,50);
+}
+
+void Gradient_Perm_4_50(RCRVector x, RVector &grad) {
+  GradPerm(x,grad,50);
+}
+
+double Objective_Perm_4_05(RCRVector x) {
+  return ObjPerm(x,0.5);
+}
+
+void Gradient_Perm_4_05(RCRVector x, RVector &grad) {
+  GradPerm(x,grad,0.5);
+}
+
+/******************* Powersum **************/
+void Domain_Powersum(RTBox box) {
+  box.lb=0.0 ; box.ub=4.0 ;
+}
+
+double Objective_Powersum(RCRVector x) {
+  int n=x.GetLength();
+  double b[]={8,18,44,114};
+
+  double s1=0.0;
+  for (int k=1 ; k<=n ; k++) {
+    double s2=0.0;
+    for (int i=1 ; i<=n ; i++)
+      s2+=pow(x(i-1),1.0*k);
+    s1+=pow(s2-b[k-1],2.0);
+  }
+  return s1;
+}
+
+void Gradient_Powersum(RCRVector x, RVector &grad) {
+  int n=x.GetLength();
+  double b[]={8,18,44,114};
+
+  for (int j=0 ; j<n ; j++) {
+    double s1=0.0;
+    for (int k=1 ; k<=n ; k++) {
+      double s2=0.0;
+      for (int i=1 ; i<=n ; i++)
+       s2+=pow(x(i-1),1.0*k);
+      s1+=2*(s2-b[k-1])*k*pow(x(j),k-1.0);
+    }
+    grad(j)=s1;
+  }
+}
+
+#endif
diff --git a/stogo/testros.cc b/stogo/testros.cc
new file mode 100644 (file)
index 0000000..7c0dea7
--- /dev/null
@@ -0,0 +1,25 @@
+#include "global.h"
+#include "tools.h"
+#include "rosen.h"
+
+int main() {
+  int dim=2;
+
+  Pdom Dom=Domain_Rosenbrock;
+  Pobj Obj=Objective_Rosenbrock;
+  Pgrad Grad=Gradient_Rosenbrock;
+
+  GlobalParams params;
+  params.det_pnts=2*dim+1; params.rnd_pnts=0;
+  params.eps_cl=0.1; params.rshift=0.3;
+  params.mu=1.0E-4; params.maxtime=5;
+
+  TBox D(dim);
+  Dom(D);
+  Global Problem(D,Obj, Grad, params);
+  RVector dummyvec(dim);
+  Problem.Search(-1, dummyvec);
+
+  cout << "Minimizers found\n";
+  Problem.DispMinimizers();
+}
diff --git a/stogo/tools.cc b/stogo/tools.cc
new file mode 100644 (file)
index 0000000..773edce
--- /dev/null
@@ -0,0 +1,423 @@
+
+#include <float.h>
+#include <iostream>
+
+#include "stogo_config.h"
+#include "tools.h"
+
+Trial::Trial():xvals(0) {
+  objval=DBL_MAX;
+}
+
+Trial::Trial(int n):xvals(n) {
+  objval=DBL_MAX;
+}
+
+Trial::Trial(RCTrial tr):xvals(tr.xvals) {
+  objval=tr.objval ;
+}
+
+RCTrial Trial::operator=(RCTrial tr) {
+  xvals=tr.xvals ;
+  objval=tr.objval ;
+  return *this ;
+}
+
+ostream & operator << (ostream & os, const Trial & T) {
+  os << T.xvals << "  " << "(" << T.objval << ")" << endl ;
+  return os;
+}
+
+/********************* Vanilla Box **********************/
+VBox::VBox():lb(0),ub(0) {} // Constructor
+
+VBox::VBox(int n):lb(n),ub(n) {} // Constructor
+
+VBox::VBox(RCVBox box):lb(box.lb), ub(box.ub) {} // Constructor
+
+RCVBox VBox::operator=(RCVBox box) {
+  // Copy: Box1=Box2
+  lb=box.lb; ub=box.ub;
+  return *this;
+}
+
+int VBox::GetDim() {
+  return lb.GetLength();
+}
+
+double VBox::Width(int i) {
+  // Returns the width of the i-th interval, i between [0,...,dim-1]
+  return ub(i)-lb(i);
+}
+
+void VBox::Midpoint(RCRVector x) {
+  // Returns the midpoint of Box in x
+  int n=GetDim();
+  for (int i=0 ; i<n ; i++)
+    x(i)=fabs(ub(i)-lb(i))/2 + lb(i);
+}
+
+ostream & operator << (ostream & os, const VBox & B) {
+  int n=(B.lb).GetLength() ;
+  for (int i=0 ; i<n ;i++)
+    os << '[' << B.lb(i) << "," << B.ub(i) << "]";
+  return os;
+}
+
+/************************ Trial Box ***********************/
+TBox::TBox() : VBox() {
+  // Constructor
+  minf=DBL_MAX;
+}
+
+TBox::TBox(int n) : VBox(n) {
+  // Constructor
+  minf=DBL_MAX;
+}
+
+TBox::TBox(RCTBox box) : VBox(box) {
+  // Constructor + Copy
+  minf=box.minf;
+  TList=box.TList ;
+}
+
+RCTBox TBox::operator=(RCTBox box) {
+  // Copy
+  // NB We should 'somehow' use VBox to copy lb and ub
+  // Note that assignment operators are _not_ inherited
+  lb=box.lb ; ub=box.ub ;
+  minf=box.minf ;
+  TList=box.TList ;
+  return *this ;
+}
+
+double TBox::GetMin() {
+  return minf;
+}
+
+bool TBox::EmptyBox() {
+  // Returns TRUE if the list of Trials is empty
+  return TList.empty() ;
+}
+
+void TBox::AddTrial(RCTrial T) {
+  // Add a Trial to the (back of) TList
+  TList.push_back(T) ;
+  if (T.objval<minf)
+    minf=T.objval ;
+}
+
+void TBox::RemoveTrial(Trial &T) {
+  // Remove a trial from the (back of) box
+  T=TList.back() ;
+  TList.pop_back() ;
+}
+
+void TBox::GetLastTrial(Trial &T) {
+// Return a trial from the (back of) box
+  T=TList.back() ;
+}
+
+list<Trial>::const_iterator TBox::FirstTrial() {
+  return TList.begin();
+}
+
+list<Trial>::const_iterator TBox::LastTrial() {
+  return TList.end();
+}
+
+void TBox::GetTrial(list<Trial>::const_iterator itr, Trial &T) {
+  T.xvals=(*itr).xvals;
+  T.objval=(*itr).objval;
+}
+
+void TBox::ClearBox() {
+  TList.erase(TList.begin(), TList.end());
+  minf=DBL_MAX;
+}
+
+bool TBox::CloseToMin(RVector &vec, double *objval, double eps_cl) {
+  // Returns TRUE if 'vec' is close to some of the trials in the box,
+  // in this case, 'vec' and 'objval' are overwritten by the Trial data
+  // otherwise 'vec' and 'objval' are not affected.
+  //
+  // Here "close" means norm2(T - some trial in box)<=eps_cl
+  //
+  // NB It might be better to accept Trial as argument instead of vector
+
+  int n=GetDim();
+  RVector x(n), y(n);
+  list<Trial>::const_iterator itr;
+  for ( itr = TList.begin(); itr != TList.end(); ++itr ) {
+    y=vec ; // NB Should be possible to avoid this copying
+    x=(*itr).xvals;
+    axpy(-1,x,y);
+    if (norm2(y)<=eps_cl) {
+      vec=x;
+      *objval=(*itr).objval;
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+unsigned int TBox::NStationary() {
+  // Returns the number of trials in a box
+  return TList.size() ;
+}
+
+void TBox::split(RTBox B1, RTBox B2) {
+  list<Trial>::const_iterator itr;
+  double w,m,tmp;
+  double fm1=DBL_MAX, fm2=DBL_MAX;
+  int i, k, ns;
+  int n=GetDim();
+
+  B1.lb=lb; B1.ub=ub;
+  B2.lb=lb; B2.ub=ub;
+  w=LongestSide(&i);
+  ns=TList.size();
+  switch (ns) {
+  case 0: case 1:
+    // Bisection
+    w=ub(i)-lb(i); // Length of interval
+    m=lb(i)+w/2;   // Midpoint
+    B1.ub(i)=m; B2.lb(i)=m;
+    break;
+  default:
+    // More elaborate split when there are more than one trials in B
+    // See Serguies and Kaj's tech. report, page 11
+    // Compute the center point of all stationary points
+    RVector center(n), x(n), dispers(n);
+    center=0; dispers=0;
+    for ( itr = TList.begin(); itr != TList.end(); ++itr )
+      axpy(1.0, (*itr).xvals, center);
+    scal((double)(1.0/ns),center);
+
+    // Compute the relative deviations
+    for ( itr = TList.begin(); itr != TList.end(); ++itr ) {
+      for (k = 0; k<n; k++) {
+       x=(*itr).xvals;
+       dispers(k)=dispers(k)+pow(center(k)-x(k),2.0);
+      }
+    }
+    scal((double)(1.0/ns),dispers);
+
+    // i=arg max(disp)
+    tmp=dispers(0);i=0;
+    for (k=1; k<n; k++) {
+      if (dispers(k)>tmp) {
+       tmp=dispers(k);i=k;
+      }
+    }
+    B1.ub(i)=center(i) ; B2.lb(i)=center(i);
+    break;
+  }
+
+  // Split the set of trials accordingly
+  for ( itr = TList.begin(); itr != TList.end(); ++itr ) {
+    if ( B1.InsideBox((*itr).xvals) ) {
+      fm1=min(fm1,(*itr).objval);
+      B1.AddTrial(*itr);
+    }
+    else {
+      B2.AddTrial(*itr);
+      fm2=min(fm2,(*itr).objval);
+    }
+  }
+  // Set minf of B1 and B2
+  B1.minf=fm1 ; B2.minf=fm2;
+}
+
+void TBox::dispTrials() {
+  // Display information about box
+#ifdef KCC
+  copy(TList.begin(), TList.end(), ostream_iterator<Trial,char>(cout));
+#else
+  copy(TList.begin(), TList.end(), ostream_iterator<Trial>(cout));
+#endif
+}
+
+ostream & operator << (ostream & os, const TBox & B) {
+  int n=(B.lb).GetLength() ;
+  for (int i=0 ; i<n ;i++)
+    os << '[' << B.lb(i) << "," << B.ub(i) << "]";
+  os << "   minf= " << B.minf << endl;
+  return os;
+}
+
+bool TBox::InsideBox(RCRVector x) {
+  // Returns TRUE if the point X lies inside BOX, FALSE otherwise
+  int n=GetDim();
+  for (int i=0 ; i<n ; i++)
+    if (x(i)<lb(i) || x(i)>ub(i)) return FALSE;
+  return TRUE;
+}
+
+int TBox::OutsideBox(RCRVector x, RCTBox domain) {
+  // The function returns
+  //    0 if X is inside both 'box' and 'domain'
+  //    1 if X is inside 'domain' but outside 'box'
+  //    2 if X is outside both 'domain' and 'box
+
+  int n=GetDim();
+  int ins_box=1, ins_dom=1, outs=999;
+  for (int i=0 ; i<n ; i++) {
+    if (x(i)<lb(i) || x(i)>ub(i))
+      ins_box=0;
+    if (x(i)<domain.lb(i) || x(i)>domain.ub(i)) {
+      ins_dom=0; break;
+    }
+  }
+  if (ins_box==1 && ins_dom==1)
+    outs=0;
+  if (ins_box==0 && ins_dom==1)
+    outs=1;
+  if (ins_box==0 && ins_dom==0)
+    outs=2;
+  if (outs==999) {
+    // Something has gone wrong!
+    cout << "Error in OutsideBox, exiting\n";
+    exit(1);
+  }
+  return outs;
+}
+
+double TBox::ShortestSide(int *idx) {
+  // Returns the shortest side of the box and it's index
+  int n=GetDim(),j=0;
+  double tmp=ub(0)-lb(0);
+  for (int i=1 ; i<n ;i++)
+    if ( (ub(i)-lb(i))<tmp ) {
+      tmp=ub(i)-lb(i);
+      j=i;
+    }
+  *idx=j;
+  return tmp;
+}
+
+double TBox::LongestSide(int *idx) {
+  // Returns the longest side of the box and it's index
+  int n=GetDim(),j=0;
+  double tmp=ub(0)-lb(0);
+  for (int i=1 ; i<n ;i++)
+    if ( (ub(i)-lb(i))>tmp ) {
+      tmp=ub(i)-lb(i);
+      j=i;
+    }
+  *idx=j;
+  return tmp;
+}
+
+double TBox::ClosestSide(RCRVector x) {
+  // Returns the shortest distance from point X to the box B.
+
+  //   Warning: The output of this functon is nonsense if the
+  //   point X lies outside B. Should we try to detect this case?
+  
+  double dist, tmp ;
+  int n=GetDim();
+  dist=DBL_MAX;
+  for (int i=0 ; i<n ; i++) {
+    tmp = min( x(i)-lb(i), ub(i)-x(i) );
+    dist = min(dist, tmp);
+  }
+  return dist;
+}
+
+double TBox::FarthestSide(RCRVector x) {
+  // Returns the longest distance from point X to the box B.
+  //   Same comment apply here as in ClosestSide(X)
+    
+  double dist, tmp;
+  int n=GetDim();
+  dist=DBL_MIN;
+  for (int i=0 ; i<n ; i++) {
+    tmp = max( x(i)-lb(i), ub(i)-x(i) );
+    dist = max(dist, tmp);
+  }
+  return dist;
+}
+
+bool TBox::Intersection(RCRVector x, RCRVector h, RCRVector z) {
+// Intersection of a line with a box
+// The line is described by a vector 'h' and a point 'x' and
+// the point of intersection is returned in 'z'
+// Note that h+x must lie outside of box
+//
+// Known problem:
+//   Due to round of errors the algorithm can fail to find an intersection
+//   The caller is notified and should act accordingly
+//
+//  The routine returns FALSE if no intersection was found, TRUE otherwise
+
+  int n=GetDim();
+  RVector tmpV(n);
+  bool done;
+  int i, j, k, isect;
+  double alpha, gamma;
+
+  i=0; done=FALSE;
+  while (i<n && done==FALSE) {
+    if (h(i)==0) {
+      z(i)=x(i);
+      break;
+    }
+    for (k=1; k<=2; k++) {
+      if (k==1)
+       alpha=lb(i);
+      else
+       alpha=ub(i);
+      gamma=(alpha-x(i))/h(i);
+      z(i)=alpha;
+      isect=1;
+      for (j=0; j<n; j++) {
+       if (j != i) {
+         z(j)=x(j)+gamma*h(j);
+         if (z(j)<lb(j) || z(j)>ub(j)) {
+           isect=0;
+           break;
+         }
+       }
+      }
+      copy(z,tmpV); axpy(-1.0,x,tmpV);  // tmpV=z-x
+      if (isect==1 && dot(tmpV,h)>0) {
+       done=TRUE; break;
+      }
+    }
+    i++;
+  }
+  return done;
+}
+
+double TBox::LowerBound(double maxgrad) {
+// Lower bound estimation
+  double lb=minf ;
+  double f1,f2,est ;
+  list<Trial>::const_iterator itr1,itr2 ;
+
+  int n=GetDim();
+  RVector x1(n), x2(n) ;
+#ifndef LB2
+  for ( itr1 = TList.begin(); itr1 != TList.end(); ++itr1 ) {
+    itr2=itr1 ;
+    while (++itr2 != TList.end()) {
+      x1=(*itr1).xvals ; f1=(*itr1).objval ;
+      x2=(*itr2).xvals ; f2=(*itr2).objval ;
+      axpy(-1.0,x2,x1) ; // x1=x1-x2
+      est=0.5*(f1+f2-maxgrad*norm2(x1)) ;
+      lb=min(lb,est) ;
+      // cout << "est=" << est << " x1=" << x1 << " x2=" << x2 << endl ;
+    }
+  }
+#endif
+#ifdef LB2
+  for ( itr1 = TList.begin(); itr1 != TList.end(); ++itr1 ) {
+    // Use also max distance to border
+    x1=(*itr1).xvals; f1=(*itr1).objval;
+    est=f1-FarthestSide(x1)*maxgrad;
+    lb=min(lb,est);
+  }
+#endif
+  return lb ;
+}
diff --git a/stogo/tools.h b/stogo/tools.h
new file mode 100644 (file)
index 0000000..668a5ee
--- /dev/null
@@ -0,0 +1,119 @@
+
+//   Various datastructures and functions used by the global optimizer
+
+#ifndef TOOLS_H
+#define TOOLS_H
+
+#include <float.h>
+#include <iostream>
+
+#include <algorithm>
+#include <iterator>
+#include <list>
+
+#include "linalg.h"
+
+#ifndef FALSE
+const int FALSE=(1==0); // boolean FALSE
+#endif
+#ifndef FALSE
+const int TRUE=(1==1); // boolean TRUE
+#endif
+
+typedef const class Trial CTrial;
+typedef CTrial& RCTrial;
+typedef CTrial* PCTrial;
+
+class Trial{
+public:
+  RVector xvals;
+  double objval;
+
+  Trial();
+  Trial(int);
+  Trial(RCTrial); // Copy constructor
+  RCTrial operator=(RCTrial) ; // assignment operator
+  friend ostream & operator << (ostream &, RCTrial) ;
+};
+
+class TrialGT : public unary_function<Trial, bool>
+// Predicate for Trial (needed for remove_if)
+{
+public:
+  explicit TrialGT(double val) : _val(val) {}
+  bool operator()(Trial& foo) { 
+    return foo.objval > _val;
+  }
+private:
+  double _val;
+};
+
+typedef class VBox& RVBox;
+typedef const class VBox CVBox;
+typedef CVBox* PCVBox;
+typedef CVBox& RCVBox;
+
+class VBox{
+public:
+  RVector lb, ub;
+
+  VBox();        // Construct a box
+  VBox(int);
+  VBox(RCVBox);  // Copy constructor
+  RCVBox operator=(RCVBox);      // assignment operator
+
+  int GetDim();                  // Returns the dimension of the box
+  double Width(int) ;            // Returns the width of the i-th interval
+  void Midpoint(RCRVector);      // Returns the midpoint
+
+  friend ostream & operator << (ostream &, const VBox &);
+};
+
+typedef class TBox& RTBox;
+typedef const class TBox CTBox;
+typedef CTBox* PCTBox;
+typedef CTBox& RCTBox;
+
+class TBox: public VBox {
+public:
+  double minf;   // Smallest function value found so far
+  list<Trial> TList; // List of trials
+
+  TBox();        // Construct a box
+  TBox(int);
+  TBox(RCTBox);  // Copy constructor
+
+  RCTBox operator=(RCTBox);      // assignment operator
+
+  double GetMin();               // Returns 'minf'
+  bool EmptyBox();               // Returns TRUE if Box contains no trials
+  void AddTrial(RCTrial);        // Add a trial to the (back of) box
+  void RemoveTrial(Trial &);     // Remove a trial from the (back of) box
+  void GetLastTrial(Trial &);    // Return a trial from the back of the box
+
+  list<Trial>::const_iterator FirstTrial();
+  list<Trial>::const_iterator LastTrial();
+
+  void GetTrial(list<Trial>::const_iterator, Trial&);
+  void ClearBox();            
+  bool CloseToMin(RVector&, double*, double);
+
+  unsigned int NStationary();      // Returns the number of stationary points
+
+  void split(RTBox, RTBox);     // Split a box
+  void dispTrials();
+
+  bool InsideBox(RCRVector);
+  int  OutsideBox(RCRVector, RCTBox);
+  double ShortestSide(int*);    // Returns the shortest side
+  double LongestSide(int*);     // Returns the longest side
+  double ClosestSide(RCRVector x);
+  double FarthestSide(RCRVector x);
+  bool Intersection(RCRVector, RCRVector, RCRVector);
+  double LowerBound(double);
+
+  bool operator<(const TBox & x) const {return (minf>x.minf);}
+  friend ostream & operator << (ostream &, const TBox &);
+};
+
+#endif
diff --git a/stogo/tst.cc b/stogo/tst.cc
new file mode 100644 (file)
index 0000000..b2721ac
--- /dev/null
@@ -0,0 +1,62 @@
+#include <unistd.h>
+
+#include "global.h"
+#include "tools.h"
+
+#include "linalg.h" 
+#include "tools.h"
+#include "stogo_config.h"
+
+void Domain_Mine(RTBox box) {
+  box.lb=-3.0 ; box.ub=3.0;
+}
+
+static int cnt = 0;
+double Objective_Mine(RCRVector xy) {
+  double x = xy(0);
+  double y = xy(1);
+  double f = ((x*x)*(4-2.1*(x*x)+((x*x)*(x*x))/3) + x*y + (y*y)*(-4+4*(y*y)));
+  printf("feval:, %d, %g, %g, %g\n", ++cnt, x,y, f);
+  return f;
+}
+
+void Gradient_Mine(RCRVector xy, RVector &grad) {
+  double x = xy(0);
+  double y = xy(1);
+  grad(0) = /* df/dx */
+    ((2*x)*(4-2.1*(x*x)+((x*x)*(x*x))/3)
+     + (x*x)*(-4.2*x+4*(x*(x*x))/3)
+     + y);
+  grad(1) = /* df/dy */
+    (x + (2*y)*(-4+4*(y*y)) + (y*y)*(8*(y)));
+}
+
+
+int main(int argc, char **argv) {
+  int dim=2;
+
+  Pdom Dom=Domain_Mine;
+  Pobj Obj=Objective_Mine;
+  Pgrad Grad=Gradient_Mine;
+
+  GlobalParams params;
+  params.det_pnts=2*dim+1; params.rnd_pnts=0;
+  params.eps_cl=0.1; params.rshift=0.3;
+  params.mu=1.0E-4; params.maxtime=0;
+
+  params.maxeval = argc < 2 ? 100 : atoi(argv[1]);
+
+  TBox D(dim);
+  Dom(D);
+  Global Problem(D,Obj, Grad, params);
+  RVector dummyvec(dim);
+  Problem.Search(-1, dummyvec);
+
+  cout << "Minimizers found\n";
+  Problem.DispMinimizers();
+
+  cout << "dummyvec: " << dummyvec << "\n";
+  
+  double val = Problem.OneMinimizer(dummyvec);
+  cout << "one minimizer: " << val << ": " << dummyvec << "\n";
+}
diff --git a/stogo/tstc.c b/stogo/tstc.c
new file mode 100644 (file)
index 0000000..d5c66ad
--- /dev/null
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "stogo.h"
+
+/* has two global minima at (0.09,-0.71) and (-0.09,0.71), plus
+   4 additional local minima */
+static int cnt=0;
+double tst_obj(int n, const double *xy, double *g, void *unused)
+{
+  double x, y, f;
+  x = xy[0];
+  y = xy[1];
+  f = ((x*x)*(4-2.1*(x*x)+((x*x)*(x*x))/3) + x*y + (y*y)*(-4+4*(y*y)));
+  printf("feval:, %d, %g, %g, %g\n", ++cnt, x,y, f);
+  if (g) {
+       g[0] = /* df/dx */
+           ((2*x)*(4-2.1*(x*x)+((x*x)*(x*x))/3)
+            + (x*x)*(-4.2*x+4*(x*(x*x))/3)
+            + y);
+       g[1] = /* df/dy */
+           (x + (2*y)*(-4+4*(y*y)) + (y*y)*(8*(y)));
+  }
+  return f;
+}
+
+int main(int argc, char **argv)
+{
+  int n = 2;
+  double x[2], l[2], u[2];
+  long int maxits = 0, maxtim = 0;
+  int info;
+  double minf;
+
+  maxits = argc < 2 ? 100 : atoi(argv[1]);
+
+  l[0] = -3; l[1] = -3;
+  u[0] = 3; u[1] = 3;
+
+  info = stogo_minimize(n, tst_obj, NULL, x, &minf, l, u, maxits, maxtim);
+
+  printf("min f = %g at (%g,%g) after %d evals, return value %d\n",
+        minf, x[0], x[1], cnt, info);
+
+  return EXIT_SUCCESS;
+}
diff --git a/swig/Makefile.am b/swig/Makefile.am
new file mode 100644 (file)
index 0000000..5ccbfe1
--- /dev/null
@@ -0,0 +1,56 @@
+SWIG_SRC = nlopt.i nlopt-exceptions.i nlopt-enum-renames.i 
+EXTRA_DIST = $(SWIG_SRC) nlopt-guile.i nlopt-python.i nlopt.scm.in nlopt.py numpy.i
+
+BUILT_SOURCES = nlopt-guile.cpp nlopt-python.cpp nlopt-enum-renames.i nlopt.scm.in
+
+HDR = $(top_srcdir)/api/nlopt.hpp
+
+##############################################################################
+# Guile wrapper
+
+libnlopt@NLOPT_SUFFIX@_guile_la_SOURCES = nlopt-guile.cpp
+libnlopt@NLOPT_SUFFIX@_guile_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la
+libnlopt@NLOPT_SUFFIX@_guile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
+libnlopt@NLOPT_SUFFIX@_guile_la_CPPFLAGS = $(GUILE_CPPFLAGS) -I$(top_srcdir)/api
+
+guiledir = $(GUILE_INSTALL_DIR)
+if WITH_GUILE
+guile_DATA = nlopt.scm
+guilelib = libnlopt@NLOPT_SUFFIX@_guile.la
+endif
+
+##############################################################################
+# Python wrapper
+
+_nlopt_la_SOURCES = nlopt-python.cpp
+_nlopt_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la
+_nlopt_la_LDFLAGS = -module -version-info @SHARED_VERSION_INFO@
+_nlopt_la_CPPFLAGS = $(PYTHON_INCLUDES) -I$(top_srcdir)/api
+
+if WITH_PYTHON
+python_PYTHON = nlopt.py
+pyexec_LTLIBRARIES = _nlopt.la
+endif
+
+##############################################################################
+
+
+lib_LTLIBRARIES = $(guilelib)
+
+##############################################################################
+# Generate wrappers via SWIG:
+
+if MAINTAINER_MODE
+
+nlopt-guile.cpp nlopt.scm.in: $(SWIG_SRC) nlopt-guile.i $(HDR)
+       swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -guile -scmstub -o $@ $(srcdir)/nlopt.i
+       rm -f nlopt.scm.in
+       mv nlopt.scm nlopt.scm.in
+
+nlopt-python.cpp nlopt.py: $(SWIG_SRC) nlopt-python.i numpy.i $(HDR)
+       swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -python -o $@ $(srcdir)/nlopt.i
+
+nlopt-enum-renames.i: $(top_srcdir)/api/nlopt.h
+       (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(top_srcdir)/api/nlopt.h | sed 's/NLOPT_//g' |tr -d ' ' |tr '/' ',' |tr '=' ',' |cut -d, -f1 |while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done; egrep 'NLOPT_[A-Z_]* =' $(top_srcdir)/api/nlopt.h | egrep -v 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' | sed 's/NLOPT_//g' |tr -d ' ' |cut -d'=' -f1 | while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done) > $@
+
+endif
diff --git a/swig/Makefile.in b/swig/Makefile.in
new file mode 100644 (file)
index 0000000..9dc897c
--- /dev/null
@@ -0,0 +1,857 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = swig
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(srcdir)/nlopt.scm.in $(top_srcdir)/depcomp \
+       $(am__python_PYTHON_DIST) $(top_srcdir)/py-compile
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = nlopt.scm
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pyexecdir)" \
+       "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(guiledir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(pyexec_LTLIBRARIES)
+_nlopt_la_DEPENDENCIES = ../libnlopt@NLOPT_SUFFIX@.la
+am__nlopt_la_OBJECTS = _nlopt_la-nlopt-python.lo
+_nlopt_la_OBJECTS = $(am__nlopt_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+_nlopt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(_nlopt_la_LDFLAGS) $(LDFLAGS) -o $@
+@WITH_PYTHON_TRUE@am__nlopt_la_rpath = -rpath $(pyexecdir)
+libnlopt@NLOPT_SUFFIX@_guile_la_DEPENDENCIES =  \
+       ../libnlopt@NLOPT_SUFFIX@.la
+am_libnlopt@NLOPT_SUFFIX@_guile_la_OBJECTS =  \
+       libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo
+libnlopt@NLOPT_SUFFIX@_guile_la_OBJECTS =  \
+       $(am_libnlopt@NLOPT_SUFFIX@_guile_la_OBJECTS)
+libnlopt@NLOPT_SUFFIX@_guile_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+       $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+       $(AM_CXXFLAGS) $(CXXFLAGS) \
+       $(libnlopt@NLOPT_SUFFIX@_guile_la_LDFLAGS) $(LDFLAGS) -o $@
+@WITH_GUILE_TRUE@am_libnlopt@NLOPT_SUFFIX@_guile_la_rpath = -rpath \
+@WITH_GUILE_TRUE@      $(libdir)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+SOURCES = $(_nlopt_la_SOURCES) \
+       $(libnlopt@NLOPT_SUFFIX@_guile_la_SOURCES)
+DIST_SOURCES = $(_nlopt_la_SOURCES) \
+       $(libnlopt@NLOPT_SUFFIX@_guile_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__python_PYTHON_DIST = nlopt.py
+am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
+am__pep3147_tweak = \
+  sed -e 's|\.py$$||' -e 's|[^/]*$$|__pycache__/&.*.py|'
+py_compile = $(top_srcdir)/py-compile
+DATA = $(guile_DATA)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SWIG_SRC = nlopt.i nlopt-exceptions.i nlopt-enum-renames.i 
+EXTRA_DIST = $(SWIG_SRC) nlopt-guile.i nlopt-python.i nlopt.scm.in nlopt.py numpy.i
+BUILT_SOURCES = nlopt-guile.cpp nlopt-python.cpp nlopt-enum-renames.i nlopt.scm.in
+HDR = $(top_srcdir)/api/nlopt.hpp
+
+##############################################################################
+# Guile wrapper
+libnlopt@NLOPT_SUFFIX@_guile_la_SOURCES = nlopt-guile.cpp
+libnlopt@NLOPT_SUFFIX@_guile_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la
+libnlopt@NLOPT_SUFFIX@_guile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
+libnlopt@NLOPT_SUFFIX@_guile_la_CPPFLAGS = $(GUILE_CPPFLAGS) -I$(top_srcdir)/api
+guiledir = $(GUILE_INSTALL_DIR)
+@WITH_GUILE_TRUE@guile_DATA = nlopt.scm
+@WITH_GUILE_TRUE@guilelib = libnlopt@NLOPT_SUFFIX@_guile.la
+
+##############################################################################
+# Python wrapper
+_nlopt_la_SOURCES = nlopt-python.cpp
+_nlopt_la_LIBADD = ../libnlopt@NLOPT_SUFFIX@.la
+_nlopt_la_LDFLAGS = -module -version-info @SHARED_VERSION_INFO@
+_nlopt_la_CPPFLAGS = $(PYTHON_INCLUDES) -I$(top_srcdir)/api
+@WITH_PYTHON_TRUE@python_PYTHON = nlopt.py
+@WITH_PYTHON_TRUE@pyexec_LTLIBRARIES = _nlopt.la
+
+##############################################################################
+lib_LTLIBRARIES = $(guilelib)
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu swig/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu swig/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+nlopt.scm: $(top_builddir)/config.status $(srcdir)/nlopt.scm.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+       }
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+install-pyexecLTLIBRARIES: $(pyexec_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(MKDIR_P) '$(DESTDIR)$(pyexecdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(pyexecdir)" || exit 1; \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pyexecdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pyexecdir)"; \
+       }
+
+uninstall-pyexecLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pyexecdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pyexecdir)/$$f"; \
+       done
+
+clean-pyexecLTLIBRARIES:
+       -test -z "$(pyexec_LTLIBRARIES)" || rm -f $(pyexec_LTLIBRARIES)
+       @list='$(pyexec_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+_nlopt.la: $(_nlopt_la_OBJECTS) $(_nlopt_la_DEPENDENCIES) $(EXTRA__nlopt_la_DEPENDENCIES) 
+       $(AM_V_CXXLD)$(_nlopt_la_LINK) $(am__nlopt_la_rpath) $(_nlopt_la_OBJECTS) $(_nlopt_la_LIBADD) $(LIBS)
+
+libnlopt@NLOPT_SUFFIX@_guile.la: $(libnlopt@NLOPT_SUFFIX@_guile_la_OBJECTS) $(libnlopt@NLOPT_SUFFIX@_guile_la_DEPENDENCIES) $(EXTRA_libnlopt@NLOPT_SUFFIX@_guile_la_DEPENDENCIES) 
+       $(AM_V_CXXLD)$(libnlopt@NLOPT_SUFFIX@_guile_la_LINK) $(am_libnlopt@NLOPT_SUFFIX@_guile_la_rpath) $(libnlopt@NLOPT_SUFFIX@_guile_la_OBJECTS) $(libnlopt@NLOPT_SUFFIX@_guile_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_nlopt_la-nlopt-python.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+_nlopt_la-nlopt-python.lo: nlopt-python.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(_nlopt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT _nlopt_la-nlopt-python.lo -MD -MP -MF $(DEPDIR)/_nlopt_la-nlopt-python.Tpo -c -o _nlopt_la-nlopt-python.lo `test -f 'nlopt-python.cpp' || echo '$(srcdir)/'`nlopt-python.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/_nlopt_la-nlopt-python.Tpo $(DEPDIR)/_nlopt_la-nlopt-python.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='nlopt-python.cpp' object='_nlopt_la-nlopt-python.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(_nlopt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o _nlopt_la-nlopt-python.lo `test -f 'nlopt-python.cpp' || echo '$(srcdir)/'`nlopt-python.cpp
+
+libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo: nlopt-guile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnlopt@NLOPT_SUFFIX@_guile_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo -MD -MP -MF $(DEPDIR)/libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.Tpo -c -o libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo `test -f 'nlopt-guile.cpp' || echo '$(srcdir)/'`nlopt-guile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.Tpo $(DEPDIR)/libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='nlopt-guile.cpp' object='libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnlopt@NLOPT_SUFFIX@_guile_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libnlopt@NLOPT_SUFFIX@_guile_la-nlopt-guile.lo `test -f 'nlopt-guile.cpp' || echo '$(srcdir)/'`nlopt-guile.cpp
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-pythonPYTHON: $(python_PYTHON)
+       @$(NORMAL_INSTALL)
+       @list='$(python_PYTHON)'; dlist=; list2=; test -n "$(pythondir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(pythondir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(pythondir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+         if test -f $$b$$p; then \
+           $(am__strip_dir) \
+           dlist="$$dlist $$f"; \
+           list2="$$list2 $$b$$p"; \
+         else :; fi; \
+       done; \
+       for file in $$list2; do echo $$file; done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pythondir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(pythondir)" || exit $$?; \
+       done || exit $$?; \
+       if test -n "$$dlist"; then \
+         $(am__py_compile) --destdir "$(DESTDIR)" \
+                           --basedir "$(pythondir)" $$dlist; \
+       else :; fi
+
+uninstall-pythonPYTHON:
+       @$(NORMAL_UNINSTALL)
+       @list='$(python_PYTHON)'; test -n "$(pythondir)" || list=; \
+       py_files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$py_files" || exit 0; \
+       dir='$(DESTDIR)$(pythondir)'; \
+       pyc_files=`echo "$$py_files" | sed 's|$$|c|'`; \
+       pyo_files=`echo "$$py_files" | sed 's|$$|o|'`; \
+       py_files_pep3147=`echo "$$py_files" | $(am__pep3147_tweak)`; \
+       echo "$$py_files_pep3147";\
+       pyc_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|c|'`; \
+       pyo_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|o|'`; \
+       st=0; \
+       for files in \
+         "$$py_files" \
+         "$$pyc_files" \
+         "$$pyo_files" \
+         "$$pyc_files_pep3147" \
+         "$$pyo_files_pep3147" \
+       ; do \
+         $(am__uninstall_files_from_dir) || st=$$?; \
+       done; \
+       exit $$st
+install-guileDATA: $(guile_DATA)
+       @$(NORMAL_INSTALL)
+       @list='$(guile_DATA)'; test -n "$(guiledir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(guiledir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(guiledir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(guiledir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(guiledir)" || exit $$?; \
+       done
+
+uninstall-guileDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(guile_DATA)'; test -n "$(guiledir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(guiledir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA)
+installdirs:
+       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pyexecdir)" "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(guiledir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+       clean-pyexecLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-guileDATA install-pythonPYTHON
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES install-pyexecLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-guileDATA uninstall-libLTLIBRARIES \
+       uninstall-pyexecLTLIBRARIES uninstall-pythonPYTHON
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libLTLIBRARIES clean-libtool clean-pyexecLTLIBRARIES \
+       cscopelist-am ctags ctags-am distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-guileDATA install-html \
+       install-html-am install-info install-info-am \
+       install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-pyexecLTLIBRARIES \
+       install-pythonPYTHON install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am uninstall-guileDATA \
+       uninstall-libLTLIBRARIES uninstall-pyexecLTLIBRARIES \
+       uninstall-pythonPYTHON
+
+
+##############################################################################
+# Generate wrappers via SWIG:
+
+@MAINTAINER_MODE_TRUE@nlopt-guile.cpp nlopt.scm.in: $(SWIG_SRC) nlopt-guile.i $(HDR)
+@MAINTAINER_MODE_TRUE@ swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -guile -scmstub -o $@ $(srcdir)/nlopt.i
+@MAINTAINER_MODE_TRUE@ rm -f nlopt.scm.in
+@MAINTAINER_MODE_TRUE@ mv nlopt.scm nlopt.scm.in
+
+@MAINTAINER_MODE_TRUE@nlopt-python.cpp nlopt.py: $(SWIG_SRC) nlopt-python.i numpy.i $(HDR)
+@MAINTAINER_MODE_TRUE@ swig -I$(top_srcdir)/api -outdir $(builddir) -c++ -python -o $@ $(srcdir)/nlopt.i
+
+@MAINTAINER_MODE_TRUE@nlopt-enum-renames.i: $(top_srcdir)/api/nlopt.h
+@MAINTAINER_MODE_TRUE@ (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(top_srcdir)/api/nlopt.h | sed 's/NLOPT_//g' |tr -d ' ' |tr '/' ',' |tr '=' ',' |cut -d, -f1 |while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done; egrep 'NLOPT_[A-Z_]* =' $(top_srcdir)/api/nlopt.h | egrep -v 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' | sed 's/NLOPT_//g' |tr -d ' ' |cut -d'=' -f1 | while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done) > $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/swig/nlopt-enum-renames.i b/swig/nlopt-enum-renames.i
new file mode 100644 (file)
index 0000000..90531ec
--- /dev/null
@@ -0,0 +1,56 @@
+// AUTOMATICALLY GENERATED -- DO NOT EDIT
+%rename(NLOPT_GN_DIRECT) nlopt::GN_DIRECT;
+%rename(NLOPT_GN_DIRECT_L) nlopt::GN_DIRECT_L;
+%rename(NLOPT_GN_DIRECT_L_RAND) nlopt::GN_DIRECT_L_RAND;
+%rename(NLOPT_GN_DIRECT_NOSCAL) nlopt::GN_DIRECT_NOSCAL;
+%rename(NLOPT_GN_DIRECT_L_NOSCAL) nlopt::GN_DIRECT_L_NOSCAL;
+%rename(NLOPT_GN_DIRECT_L_RAND_NOSCAL) nlopt::GN_DIRECT_L_RAND_NOSCAL;
+%rename(NLOPT_GN_ORIG_DIRECT) nlopt::GN_ORIG_DIRECT;
+%rename(NLOPT_GN_ORIG_DIRECT_L) nlopt::GN_ORIG_DIRECT_L;
+%rename(NLOPT_GD_STOGO) nlopt::GD_STOGO;
+%rename(NLOPT_GD_STOGO_RAND) nlopt::GD_STOGO_RAND;
+%rename(NLOPT_LD_LBFGS_NOCEDAL) nlopt::LD_LBFGS_NOCEDAL;
+%rename(NLOPT_LD_LBFGS) nlopt::LD_LBFGS;
+%rename(NLOPT_LN_PRAXIS) nlopt::LN_PRAXIS;
+%rename(NLOPT_LD_VAR1) nlopt::LD_VAR1;
+%rename(NLOPT_LD_VAR2) nlopt::LD_VAR2;
+%rename(NLOPT_LD_TNEWTON) nlopt::LD_TNEWTON;
+%rename(NLOPT_LD_TNEWTON_RESTART) nlopt::LD_TNEWTON_RESTART;
+%rename(NLOPT_LD_TNEWTON_PRECOND) nlopt::LD_TNEWTON_PRECOND;
+%rename(NLOPT_LD_TNEWTON_PRECOND_RESTART) nlopt::LD_TNEWTON_PRECOND_RESTART;
+%rename(NLOPT_GN_CRS2_LM) nlopt::GN_CRS2_LM;
+%rename(NLOPT_GN_MLSL) nlopt::GN_MLSL;
+%rename(NLOPT_GD_MLSL) nlopt::GD_MLSL;
+%rename(NLOPT_GN_MLSL_LDS) nlopt::GN_MLSL_LDS;
+%rename(NLOPT_GD_MLSL_LDS) nlopt::GD_MLSL_LDS;
+%rename(NLOPT_LD_MMA) nlopt::LD_MMA;
+%rename(NLOPT_LN_COBYLA) nlopt::LN_COBYLA;
+%rename(NLOPT_LN_NEWUOA) nlopt::LN_NEWUOA;
+%rename(NLOPT_LN_NEWUOA_BOUND) nlopt::LN_NEWUOA_BOUND;
+%rename(NLOPT_LN_NELDERMEAD) nlopt::LN_NELDERMEAD;
+%rename(NLOPT_LN_SBPLX) nlopt::LN_SBPLX;
+%rename(NLOPT_LN_AUGLAG) nlopt::LN_AUGLAG;
+%rename(NLOPT_LD_AUGLAG) nlopt::LD_AUGLAG;
+%rename(NLOPT_LN_AUGLAG_EQ) nlopt::LN_AUGLAG_EQ;
+%rename(NLOPT_LD_AUGLAG_EQ) nlopt::LD_AUGLAG_EQ;
+%rename(NLOPT_LN_BOBYQA) nlopt::LN_BOBYQA;
+%rename(NLOPT_GN_ISRES) nlopt::GN_ISRES;
+%rename(NLOPT_AUGLAG) nlopt::AUGLAG;
+%rename(NLOPT_AUGLAG_EQ) nlopt::AUGLAG_EQ;
+%rename(NLOPT_G_MLSL) nlopt::G_MLSL;
+%rename(NLOPT_G_MLSL_LDS) nlopt::G_MLSL_LDS;
+%rename(NLOPT_LD_SLSQP) nlopt::LD_SLSQP;
+%rename(NLOPT_LD_CCSAQ) nlopt::LD_CCSAQ;
+%rename(NLOPT_GN_ESCH) nlopt::GN_ESCH;
+%rename(NLOPT_NUM_ALGORITHMS) nlopt::NUM_ALGORITHMS;
+%rename(NLOPT_FAILURE) nlopt::FAILURE;
+%rename(NLOPT_INVALID_ARGS) nlopt::INVALID_ARGS;
+%rename(NLOPT_OUT_OF_MEMORY) nlopt::OUT_OF_MEMORY;
+%rename(NLOPT_ROUNDOFF_LIMITED) nlopt::ROUNDOFF_LIMITED;
+%rename(NLOPT_FORCED_STOP) nlopt::FORCED_STOP;
+%rename(NLOPT_SUCCESS) nlopt::SUCCESS;
+%rename(NLOPT_STOPVAL_REACHED) nlopt::STOPVAL_REACHED;
+%rename(NLOPT_FTOL_REACHED) nlopt::FTOL_REACHED;
+%rename(NLOPT_XTOL_REACHED) nlopt::XTOL_REACHED;
+%rename(NLOPT_MAXEVAL_REACHED) nlopt::MAXEVAL_REACHED;
+%rename(NLOPT_MAXTIME_REACHED) nlopt::MAXTIME_REACHED;
diff --git a/swig/nlopt-exceptions.i b/swig/nlopt-exceptions.i
new file mode 100644 (file)
index 0000000..625914a
--- /dev/null
@@ -0,0 +1,70 @@
+// since exception specifications in C++ are evil, we instead provide
+// %catches specifications here so that SWIG can generate language-specific
+// exceptions (at least for exceptions explicitly thrown by NLopt)
+//
+// manually doing this stuff is annoying
+
+%catches(std::bad_alloc) nlopt::opt::opt();
+%catches(std::bad_alloc) nlopt::opt::opt(algorithm a, unsigned n);
+%catches(std::bad_alloc) nlopt::opt::opt(const opt& f);
+%catches(std::bad_alloc) nlopt::opt::operator=(opt const& f);
+
+%catches(nlopt::roundoff_limited,nlopt::forced_stop,std::runtime_error,std::bad_alloc,std::invalid_argument) nlopt::opt::optimize(std::vector<double> &x, double &opt_f);
+%catches(nlopt::roundoff_limited,nlopt::forced_stop,std::runtime_error,std::bad_alloc,std::invalid_argument) nlopt::opt::optimize(const std::vector<double> &x0);
+
+%catches(std::runtime_error) nlopt::opt::get_algorithm();
+%catches(std::runtime_error) nlopt::opt::get_algorithm_name();
+%catches(std::runtime_error) nlopt::opt::get_dimension();
+
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(func f, void *f_data);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(vfunc vf, void *f_data);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(func f, void *f_data);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(vfunc vf, void *f_data);
+
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(func f, void *f_data, nlopt_munge md, nlopt_munge mc);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(func f, void *f_data, nlopt_munge md, nlopt_munge mc);
+
+%catches(std::invalid_argument) nlopt::opt::remove_inequality_constraints();
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(func f, void *f_data, double tol=0);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(vfunc vf, void *f_data, double tol=0);
+%catches(std::invalid_argument) nlopt::opt::remove_equality_constraints();
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(func f, void *f_data, double tol=0);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(vfunc vf, void *f_data, double tol=0);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_mconstraint(mfunc mf, void *f_data, const std::vector<double> &tol);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_mconstraint(mfunc mf, void *f_data, const std::vector<double> &tol);
+
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(func f, void *f_data, nlopt_munge md, nlopt_munge mc, double tol=0);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(func f, void *f_data, nlopt_munge md, nlopt_munge mc, double tol=0);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_mconstraint(mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc, const std::vector<double> &tol);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_mconstraint(mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc, const std::vector<double> &tol);
+
+#define SET_EXCEPT(name, T) %catches(std::invalid_argument) nlopt::opt::set_##name(T val);
+#define GET_EXCEPT(name) %catches(std::invalid_argument) nlopt::opt::get_##name();
+#define SETVEC_EXCEPT(name) %catches(std::invalid_argument) nlopt::opt::set_##name(const std::vector<double> &v);
+#define GETVEC_EXCEPT(name) %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::get_##name(std::vector<double> &v);
+#define GETSET_EXCEPT(name, T) GET_EXCEPT(name) SET_EXCEPT(name, T)
+#define GETSETVEC_EXCEPT(name) GET_EXCEPT(name) SET_EXCEPT(name, double) GETVEC_EXCEPT(name) SETVEC_EXCEPT(name)
+
+GETSETVEC_EXCEPT(lower_bounds)
+GETSETVEC_EXCEPT(upper_bounds)
+
+GETSET_EXCEPT(stopval, double)
+GETSET_EXCEPT(ftol_rel, double)
+GETSET_EXCEPT(ftol_abs, double)
+GETSET_EXCEPT(xtol_rel, double)
+GETSETVEC_EXCEPT(xtol_abs)
+GETSET_EXCEPT(maxeval, int)
+GETSET_EXCEPT(maxtime, double)
+GETSET_EXCEPT(force_stop, int)
+
+%catches(std::invalid_argument) nlopt::opt::force_stop();
+
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_local_optimizer(const opt &lo);
+
+GETSET_EXCEPT(population, unsigned)
+GETSET_EXCEPT(vector_storage, unsigned)
+GETSETVEC_EXCEPT(initial_step)
+
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_default_initial_step(const std::vector<double> &x);
+%catches(std::invalid_argument) nlopt::opt::get_initial_step(const std::vector<double> &x, std::vector<double> &dx);
+%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::get_initial_step_(const std::vector<double> &x);
diff --git a/swig/nlopt-guile.cpp b/swig/nlopt-guile.cpp
new file mode 100644 (file)
index 0000000..2cbbf04
--- /dev/null
@@ -0,0 +1,7707 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.12
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGGUILE
+#define SWIG_GUILE_INIT_STATIC extern
+extern "C" {
+
+SWIG_GUILE_INIT_STATIC void
+SWIG_init (void);
+
+}
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+  struct SwigMovePointer {
+    T *ptr;
+    SwigMovePointer(T *p) : ptr(p) { }
+    ~SwigMovePointer() { delete ptr; }
+    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+  } pointer;
+  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+  SwigValueWrapper() : pointer(0) { }
+  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+  operator T&() const { return *pointer.ptr; }
+  T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+  return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__))
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__))
+# else
+#   define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic C API SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+   or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+  creating a static or dynamic library from the SWIG runtime code.
+  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
+
+  But only do this if strictly necessary, ie, if you have problems
+  with your compiler or suchlike.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/*  Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN        0x1
+#define SWIG_CAST_NEW_MEMORY       0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN           0x1
+
+
+/*
+   Flags/methods for returning states.
+
+   The SWIG conversion methods, as ConvertPtr, return an integer
+   that tells if the conversion was successful or not. And if not,
+   an error code can be returned (see swigerrors.swg for the codes).
+
+   Use the following macros/flags to set or process the returning
+   states.
+
+   In old versions of SWIG, code such as the following was usually written:
+
+     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+       // success code
+     } else {
+       //fail code
+     }
+
+   Now you can be more explicit:
+
+    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+    } else {
+      // fail code
+    }
+
+   which is the same really, but now you can also do
+
+    Type *ptr;
+    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+      if (SWIG_IsNewObj(res) {
+        ...
+       delete *ptr;
+      } else {
+        ...
+      }
+    } else {
+      // fail code
+    }
+
+   I.e., now SWIG_ConvertPtr can return new objects and you can
+   identify the case and take care of the deallocation. Of course that
+   also requires SWIG_ConvertPtr to return new result values, such as
+
+      int SWIG_ConvertPtr(obj, ptr,...) {
+        if (<obj is ok>) {
+          if (<need new object>) {
+            *ptr = <ptr to new allocated object>;
+            return SWIG_NEWOBJ;
+          } else {
+            *ptr = <ptr to old object>;
+            return SWIG_OLDOBJ;
+          }
+        } else {
+          return SWIG_BADOBJ;
+        }
+      }
+
+   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+   SWIG errors code.
+
+   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+   allows to return the 'cast rank', for example, if you have this
+
+       int food(double)
+       int fooi(int);
+
+   and you call
+
+      food(1)   // cast rank '1'  (1 -> 1.0)
+      fooi(1)   // cast rank '0'
+
+   just use the SWIG_AddCast()/SWIG_CheckState()
+*/
+
+#define SWIG_OK                    (0)
+#define SWIG_ERROR                 (-1)
+#define SWIG_IsOK(r)               (r >= 0)
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT         (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ                (SWIG_ERROR)
+#define SWIG_OLDOBJ                (SWIG_OK)
+#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+#  ifndef SWIG_TypeRank
+#    define SWIG_TypeRank             unsigned long
+#  endif
+#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
+#    define SWIG_MAXCASTRANK          (2)
+#  endif
+#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
+#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+}
+#else /* no cast-rank mode */
+#  define SWIG_AddCast(r) (r)
+#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+  const char             *name;                        /* mangled name of this type */
+  const char             *str;                 /* human readable name of this type */
+  swig_dycast_func        dcast;               /* dynamic cast function down a hierarchy */
+  struct swig_cast_info  *cast;                        /* linked list of types that can cast into this type */
+  void                   *clientdata;          /* language specific type data */
+  int                    owndata;              /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+  swig_type_info         *type;                        /* pointer to type that is equivalent to this type */
+  swig_converter_func     converter;           /* function to cast the void pointers */
+  struct swig_cast_info  *next;                        /* pointer to next cast in linked list */
+  struct swig_cast_info  *prev;                        /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+  swig_type_info         **types;              /* Array of pointers to swig_type_info structures that are in this module */
+  size_t                 size;                 /* Number of types in this module */
+  struct swig_module_info *next;               /* Pointer to next element in circularly linked list */
+  swig_type_info         **type_initial;       /* Array of initially generated type structures */
+  swig_cast_info         **cast_initial;       /* Array of initially generated casting structures */
+  void                    *clientdata;         /* Language specific module data */
+} swig_module_info;
+
+/*
+  Compare two type names skipping the space characters, therefore
+  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+  Return 0 when the two name types are equivalent, as in
+  strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+                 const char *f2, const char *l2) {
+  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+    while ((*f1 == ' ') && (f1 != l1)) ++f1;
+    while ((*f2 == ' ') && (f2 != l2)) ++f2;
+    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+  }
+  return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCmp(const char *nb, const char *tb) {
+  int equiv = 1;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (equiv != 0 && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
+}
+
+/*
+  Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (strcmp(iter->type->name, c) == 0) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
+}
+
+/*
+  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (iter->type == from) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
+}
+
+/*
+  Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/*
+   Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+  swig_type_info *lastty = ty;
+  if (!ty || !ty->dcast) return ty;
+  while (ty && (ty->dcast)) {
+    ty = (*ty->dcast)(ptr);
+    if (ty) lastty = ty;
+  }
+  return lastty;
+}
+
+/*
+  Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+  return ty->name;
+}
+
+/*
+  Return the pretty name associated with this type,
+  that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+  /* The "str" field contains the equivalent pretty names of the
+     type, separated by vertical-bar characters.  We choose
+     to print the last name, as it is often (?) the most
+     specific. */
+  if (!type) return NULL;
+  if (type->str != NULL) {
+    const char *last_name = type->str;
+    const char *s;
+    for (s = type->str; *s; s++)
+      if (*s == '|') last_name = s+1;
+    return last_name;
+  }
+  else
+    return type->name;
+}
+
+/*
+   Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+  swig_cast_info *cast = ti->cast;
+  /* if (ti->clientdata == clientdata) return; */
+  ti->clientdata = clientdata;
+
+  while (cast) {
+    if (!cast->converter) {
+      swig_type_info *tc = cast->type;
+      if (!tc->clientdata) {
+       SWIG_TypeClientData(tc, clientdata);
+      }
+    }
+    cast = cast->next;
+  }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+  SWIG_TypeClientData(ti, clientdata);
+  ti->owndata = 1;
+}
+
+/*
+  Search for a swig_type_info structure only by mangled name
+  Search is a O(log #types)
+
+  We start searching at module start, and finish searching when start == end.
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+                            swig_module_info *end,
+                           const char *name) {
+  swig_module_info *iter = start;
+  do {
+    if (iter->size) {
+      register size_t l = 0;
+      register size_t r = iter->size - 1;
+      do {
+       /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+       register size_t i = (l + r) >> 1;
+       const char *iname = iter->types[i]->name;
+       if (iname) {
+         register int compare = strcmp(name, iname);
+         if (compare == 0) {
+           return iter->types[i];
+         } else if (compare < 0) {
+           if (i) {
+             r = i - 1;
+           } else {
+             break;
+           }
+         } else if (compare > 0) {
+           l = i + 1;
+         }
+       } else {
+         break; /* should never happen */
+       }
+      } while (l <= r);
+    }
+    iter = iter->next;
+  } while (iter != end);
+  return 0;
+}
+
+/*
+  Search for a swig_type_info structure for either a mangled name or a human readable name.
+  It first searches the mangled names of the types, which is a O(log #types)
+  If a type is not found it then searches the human readable names, which is O(#types).
+
+  We start searching at module start, and finish searching when start == end.
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+                     swig_module_info *end,
+                    const char *name) {
+  /* STEP 1: Search the name field using binary search */
+  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+  if (ret) {
+    return ret;
+  } else {
+    /* STEP 2: If the type hasn't been found, do a complete search
+       of the str field (the human readable name) */
+    swig_module_info *iter = start;
+    do {
+      register size_t i = 0;
+      for (; i < iter->size; ++i) {
+       if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+         return iter->types[i];
+      }
+      iter = iter->next;
+    } while (iter != end);
+  }
+
+  /* neither found a match */
+  return 0;
+}
+
+/*
+   Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+  static const char hex[17] = "0123456789abcdef";
+  register const unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu =  u + sz;
+  for (; u != eu; ++u) {
+    register unsigned char uu = *u;
+    *(c++) = hex[(uu & 0xf0) >> 4];
+    *(c++) = hex[uu & 0xf];
+  }
+  return c;
+}
+
+/*
+   Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+  register unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu = u + sz;
+  for (; u != eu; ++u) {
+    register char d = *(c++);
+    register unsigned char uu;
+    if ((d >= '0') && (d <= '9'))
+      uu = ((d - '0') << 4);
+    else if ((d >= 'a') && (d <= 'f'))
+      uu = ((d - ('a'-10)) << 4);
+    else
+      return (char *) 0;
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu |= (d - '0');
+    else if ((d >= 'a') && (d <= 'f'))
+      uu |= (d - ('a'-10));
+    else
+      return (char *) 0;
+    *u = uu;
+  }
+  return c;
+}
+
+/*
+   Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+  char *r = buff;
+  if ((2*sizeof(void *) + 2) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,&ptr,sizeof(void *));
+  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+  strcpy(r,name);
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      *ptr = (void *) 0;
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+  char *r = buff;
+  size_t lname = (name ? strlen(name) : 0);
+  if ((2*sz + 2 + lname) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,ptr,sz);
+  if (lname) {
+    strncpy(r,name,lname+1);
+  } else {
+    *r = 0;
+  }
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      memset(ptr,0,sz);
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * guile_scm_run.swg
+ * ----------------------------------------------------------------------------- */
+
+#include <libguile.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* In the code below, use guile 2.0 compatible functions where possible.
+   Functions that don't exist in older versions will be mapped to
+   a deprecated equivalent for those versions only */
+#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2)
+
+static SCM
+scm_module_variable (SCM module, SCM sym)
+{
+  return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
+}
+
+#endif
+
+#if SCM_MAJOR_VERSION >= 2
+// scm_c_define_gsubr takes a different parameter type
+// depending on the guile version
+
+typedef scm_t_subr swig_guile_proc;
+#else
+typedef SCM (*swig_guile_proc)();
+#endif
+typedef SCM (*guile_destructor)(SCM);
+
+typedef struct swig_guile_clientdata {
+  guile_destructor destroy;
+  SCM goops_class;
+} swig_guile_clientdata;
+
+#if SCM_MAJOR_VERSION <= 2
+#define scm_to_utf8_string scm_to_locale_string
+#define scm_from_utf8_string scm_from_locale_string
+#endif
+#define SWIG_scm2str(s) \
+  SWIG_Guile_scm2newstr(s, NULL)
+#define SWIG_str02scm(str) \
+  str ? scm_from_utf8_string(str) : SCM_BOOL_F 
+# define SWIG_malloc(size) \
+  scm_malloc(size)
+# define SWIG_free(mem) \
+  free(mem)
+#define SWIG_ConvertPtr(s, result, type, flags) \
+  SWIG_Guile_ConvertPtr(s, result, type, flags)
+#define SWIG_MustGetPtr(s, type, argnum, flags) \
+  SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME)
+#define SWIG_NewPointerObj(ptr, type, owner) \
+  SWIG_Guile_NewPointerObj((void*)ptr, type, owner)
+#define SWIG_PointerAddress(object) \
+  SWIG_Guile_PointerAddress(object)
+#define SWIG_PointerType(object) \
+  SWIG_Guile_PointerType(object)
+#define SWIG_IsPointerOfType(object, type) \
+  SWIG_Guile_IsPointerOfType(object, type)
+#define SWIG_IsPointer(object) \
+  SWIG_Guile_IsPointer(object)
+#define SWIG_contract_assert(expr, msg)                                \
+  if (!(expr))                                                 \
+    scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"),        \
+             (char *) FUNC_NAME, (char *) msg,                 \
+             SCM_EOL, SCM_BOOL_F); else
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) \
+  SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME)
+#define SWIG_NewMemberObj(ptr, sz, type) \
+  SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME)
+  
+/* Runtime API */
+static swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata));
+#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata)
+#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
+  
+SWIGINTERN char *
+SWIG_Guile_scm2newstr(SCM str, size_t *len) {
+#define FUNC_NAME "SWIG_Guile_scm2newstr"
+  char *ret;
+
+  SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME);
+
+  ret = scm_to_utf8_string(str);
+  if (!ret) return NULL;
+
+  if (len) *len = strlen(ret) - 1;
+  return ret;
+#undef FUNC_NAME
+}
+
+static int swig_initialized = 0;
+static scm_t_bits swig_tag = 0;
+static scm_t_bits swig_collectable_tag = 0;
+static scm_t_bits swig_destroyed_tag = 0;
+static scm_t_bits swig_member_function_tag = 0;
+static SCM swig_make_func = SCM_EOL;
+static SCM swig_keyword = SCM_EOL;
+static SCM swig_symbol = SCM_EOL;
+
+#define SWIG_Guile_GetSmob(x) \
+  ( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \
+      ? scm_slot_ref(x, swig_symbol) : (x) )
+
+SWIGINTERN SCM
+SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner)
+{
+  if (ptr == NULL)
+    return SCM_EOL;
+  else {
+    SCM smob;
+    swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata;
+    if (owner)
+      SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type);
+    else
+      SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type);
+
+    if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) {
+      return smob;
+    } else {
+      /* the scm_make() C function only handles the creation of gf,
+        methods and classes (no instances) the (make ...) function is
+        later redefined in goops.scm.  So we need to call that
+        Scheme function. */
+      return scm_apply(swig_make_func,
+                      scm_list_3(cdata->goops_class,
+                                 swig_keyword,
+                                 smob),
+                      SCM_EOL);
+    }
+  }
+}
+
+SWIGINTERN unsigned long
+SWIG_Guile_PointerAddress(SCM object)
+{
+  SCM smob = SWIG_Guile_GetSmob(object);
+  if (SCM_NULLP(smob)) return 0;
+  else if (SCM_SMOB_PREDICATE(swig_tag, smob)
+          || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)
+          || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) {
+    return (unsigned long) (void *) SCM_CELL_WORD_1(smob);
+  }
+  else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object);
+}
+
+SWIGINTERN swig_type_info *
+SWIG_Guile_PointerType(SCM object)
+{
+  SCM smob = SWIG_Guile_GetSmob(object);
+  if (SCM_NULLP(smob)) return NULL;
+  else if (SCM_SMOB_PREDICATE(swig_tag, smob)
+          || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)
+          || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) {
+    return (swig_type_info *) SCM_CELL_WORD_2(smob);
+  }
+  else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object);
+}
+  
+SWIGINTERN int
+SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
+{
+  swig_cast_info *cast;
+  swig_type_info *from;
+  SCM smob = SWIG_Guile_GetSmob(s);
+
+  if (SCM_NULLP(smob)) {
+    *result = NULL;
+    return SWIG_OK;
+  } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
+    /* we do not accept smobs representing destroyed pointers */
+    from = (swig_type_info *) SCM_CELL_WORD_2(smob);
+    if (!from) return SWIG_ERROR;
+    if (type) {
+      cast = SWIG_TypeCheckStruct(from, type);
+      if (cast) {
+        int newmemory = 0;
+        *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory);
+        assert(!newmemory); /* newmemory handling not yet implemented */
+        return SWIG_OK;
+      } else {
+        return SWIG_ERROR;
+      }
+    } else {
+      *result = (void *) SCM_CELL_WORD_1(smob);
+      return SWIG_OK;
+    }
+  }
+  return SWIG_ERROR;
+}
+
+SWIGINTERNINLINE void *
+SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
+                      int argnum, int flags, const char *func_name)
+{
+  void *result;
+  int res = SWIG_Guile_ConvertPtr(s, &result, type, flags);
+  if (!SWIG_IsOK(res)) {
+    /* type mismatch */
+    scm_wrong_type_arg((char *) func_name, argnum, s);
+  }
+  return result;
+}
+
+SWIGINTERNINLINE int
+SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type)
+{
+  void *result;
+  if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) {
+    /* type mismatch */
+    return 0;
+  }
+  else return 1;
+}
+
+SWIGINTERNINLINE int
+SWIG_Guile_IsPointer (SCM s)
+{
+  /* module might not be initialized yet, so initialize it */
+  SWIG_GetModule(0);
+  return SWIG_Guile_IsPointerOfType (s, NULL);
+}
+
+/* Mark a pointer object non-collectable */
+SWIGINTERN void
+SWIG_Guile_MarkPointerNoncollectable(SCM s)
+{
+  SCM smob = SWIG_Guile_GetSmob(s);
+  if (!SCM_NULLP(smob)) {
+    if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
+      SCM_SET_CELL_TYPE(smob, swig_tag);
+    }
+    else scm_wrong_type_arg(NULL, 0, s);
+  }
+}
+
+/* Mark a pointer object destroyed */
+SWIGINTERN void
+SWIG_Guile_MarkPointerDestroyed(SCM s)
+{
+  SCM smob = SWIG_Guile_GetSmob(s);
+  if (!SCM_NULLP(smob)) {
+    if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
+      SCM_SET_CELL_TYPE(smob, swig_destroyed_tag);
+    }
+    else scm_wrong_type_arg(NULL, 0, s);
+  }
+}
+
+/* Member functions */
+
+SWIGINTERN SCM
+SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type,
+                       const char *func_name)
+{
+  SCM smob;
+  void *copy = malloc(sz);
+  memcpy(copy, ptr, sz);
+  SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type);
+  return smob;
+}
+
+SWIGINTERN int
+SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type,
+                        const char *func_name)
+{
+  swig_cast_info *cast;
+  swig_type_info *from;
+
+  if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) {
+    from = (swig_type_info *) SCM_CELL_WORD_2(smob);
+    if (!from) return SWIG_ERROR;
+    if (type) {
+      cast = SWIG_TypeCheckStruct(from, type);
+      if (!cast) return SWIG_ERROR;
+    }
+    memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz);
+    return SWIG_OK;
+  }
+  return SWIG_ERROR;
+}
+     
+
+/* Init */
+
+SWIGINTERN int
+print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate, 
+                const char *attribute)
+{
+  swig_type_info *type;
+  
+  type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
+  if (type) {
+    scm_puts((char *) "#<", port);
+    scm_puts((char *) attribute, port);
+    scm_puts((char *) "swig-pointer ", port);
+    scm_puts((char *) SWIG_TypePrettyName(type), port);
+    scm_puts((char *) " ", port);
+    scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port);
+    scm_puts((char *) ">", port);
+    /* non-zero means success */
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+  
+SWIGINTERN int
+print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
+{
+  return print_swig_aux(swig_smob, port, pstate, "");
+}
+
+SWIGINTERN int
+print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
+{
+  return print_swig_aux(swig_smob, port, pstate, "collectable-");
+}
+
+SWIGINTERN int
+print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
+{
+  return print_swig_aux(swig_smob, port, pstate, "destroyed-");
+}
+
+SWIGINTERN int
+print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
+{
+  swig_type_info *type;
+  type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
+  if (type) {
+    scm_puts((char *) "#<", port);
+    scm_puts((char *) "swig-member-function-pointer ", port);
+    scm_puts((char *) SWIG_TypePrettyName(type), port);
+    scm_puts((char *) " >", port);
+    /* non-zero means success */
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+SWIGINTERN SCM
+equalp_swig (SCM A, SCM B)
+{
+  if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B) 
+      && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B))
+    return SCM_BOOL_T;
+  else return SCM_BOOL_F;
+}
+
+SWIGINTERN size_t
+free_swig(SCM A)
+{
+  swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A);
+  if (type) {
+    if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy)
+      ((swig_guile_clientdata *)type->clientdata)->destroy(A);
+  } 
+  return 0;
+}
+
+SWIGINTERN size_t
+free_swig_member_function(SCM A)
+{
+  free((swig_type_info *) SCM_CELL_WORD_1(A));
+  return 0;
+}
+
+SWIGINTERN int
+ensure_smob_tag(SCM swig_module,
+               scm_t_bits *tag_variable,
+               const char *smob_name,
+               const char *scheme_variable_name)
+{
+  SCM variable = scm_module_variable(swig_module,
+                             scm_from_locale_symbol(scheme_variable_name));
+  if (scm_is_false(variable)) {
+    *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0);
+    scm_c_module_define(swig_module, scheme_variable_name, 
+                        scm_from_ulong(*tag_variable));
+    return 1;
+  }
+  else {
+    *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable));
+    return 0;
+  }
+}
+
+SWIGINTERN SCM
+SWIG_Guile_Init ()
+{
+  static SCM swig_module;
+  
+  if (swig_initialized) return swig_module;
+  swig_initialized = 1;
+
+  swig_module = scm_c_resolve_module("Swig swigrun");
+  if (ensure_smob_tag(swig_module, &swig_tag,
+                     "swig-pointer", "swig-pointer-tag")) {
+    scm_set_smob_print(swig_tag, print_swig);
+    scm_set_smob_equalp(swig_tag, equalp_swig);
+  }
+  if (ensure_smob_tag(swig_module, &swig_collectable_tag,
+                     "collectable-swig-pointer", "collectable-swig-pointer-tag")) {
+    scm_set_smob_print(swig_collectable_tag, print_collectable_swig);
+    scm_set_smob_equalp(swig_collectable_tag, equalp_swig);
+    scm_set_smob_free(swig_collectable_tag, free_swig);
+  }
+  if (ensure_smob_tag(swig_module, &swig_destroyed_tag,
+                     "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) {
+    scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig);
+    scm_set_smob_equalp(swig_destroyed_tag, equalp_swig);
+  }
+  if (ensure_smob_tag(swig_module, &swig_member_function_tag,
+                     "swig-member-function-pointer", "swig-member-function-pointer-tag")) {
+    scm_set_smob_print(swig_member_function_tag, print_member_function_swig);
+    scm_set_smob_free(swig_member_function_tag, free_swig_member_function);
+  }
+  swig_make_func = scm_permanent_object(
+  scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make")));
+  swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob"));
+  swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob"));
+#ifdef SWIG_INIT_RUNTIME_MODULE
+  SWIG_INIT_RUNTIME_MODULE
+#endif
+
+  return swig_module;
+}
+
+SWIGINTERN swig_module_info *
+SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
+{
+  SCM module;
+  SCM variable;
+
+  module = SWIG_Guile_Init();
+
+  variable = scm_module_variable(module,
+                 scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME));
+  if (scm_is_false(variable)) {
+    return NULL;
+  } else {
+    return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable));
+  }
+}
+
+SWIGINTERN void
+SWIG_Guile_SetModule(swig_module_info *swig_module)
+{
+  SCM module;
+  SCM variable;
+
+  module = SWIG_Guile_Init();
+    
+  scm_module_define(module,
+                    scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
+                    scm_from_ulong((unsigned long) swig_module));
+}
+
+SWIGINTERN int
+SWIG_Guile_GetArgs (SCM *dest, SCM rest,
+                   int reqargs, int optargs,
+                   const char *procname)
+{
+  int i;
+  int num_args_passed = 0;
+  for (i = 0; i<reqargs; i++) {
+    if (!SCM_CONSP(rest))
+      scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
+    *dest++ = SCM_CAR(rest);
+    rest = SCM_CDR(rest);
+    num_args_passed++;
+  }
+  for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
+    *dest++ = SCM_CAR(rest);
+    rest = SCM_CDR(rest);
+    num_args_passed++;
+  }
+  for (; i<optargs; i++)
+    *dest++ = SCM_UNDEFINED;
+  if (!SCM_NULLP(rest))
+      scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
+  return num_args_passed;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#define GUILE_MAYBE_VALUES \
+      if (gswig_list_p) gswig_result = scm_values(gswig_result);
+
+#define GUILE_MAYBE_VECTOR \
+      if (gswig_list_p) gswig_result = scm_vector(gswig_result);
+
+#define SWIG_APPEND_VALUE(object)                                              \
+    if (gswig_result == SCM_UNSPECIFIED)                                               \
+        gswig_result = object;                                                 \
+    else {                                                                     \
+      if (!gswig_list_p) {                                                     \
+             gswig_list_p = 1;                                                 \
+             gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED);  \
+      }                                                                        \
+      else                                                                     \
+            gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED));           \
+    }
+
+
+static swig_guile_clientdata _swig_guile_clientdatanlopt_doublevector = { NULL, SCM_EOL };
+static swig_guile_clientdata _swig_guile_clientdatanlopt_roundoff_limited = { NULL, SCM_EOL };
+static swig_guile_clientdata _swig_guile_clientdatanlopt_forced_stop = { NULL, SCM_EOL };
+static swig_guile_clientdata _swig_guile_clientdatanlopt_opt = { NULL, SCM_EOL };
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_double swig_types[0]
+#define SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double swig_types[1]
+#define SWIGTYPE_p_int swig_types[2]
+#define SWIGTYPE_p_nlopt__forced_stop swig_types[3]
+#define SWIGTYPE_p_nlopt__opt swig_types[4]
+#define SWIGTYPE_p_nlopt__roundoff_limited swig_types[5]
+#define SWIGTYPE_p_nlopt_func swig_types[6]
+#define SWIGTYPE_p_nlopt_mfunc swig_types[7]
+#define SWIGTYPE_p_nlopt_munge swig_types[8]
+#define SWIGTYPE_p_nlopt_opt swig_types[9]
+#define SWIGTYPE_p_nlopt_result swig_types[10]
+#define SWIGTYPE_p_std__out_of_range swig_types[11]
+#define SWIGTYPE_p_std__vectorT_double_t swig_types[12]
+#define SWIGTYPE_p_unsigned_long swig_types[13]
+static swig_type_info *swig_types[15];
+static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+
+#include "nlopt.hpp"
+
+
+#include <stdexcept>
+
+
+#include <string>
+
+inline std::string SWIG_scm2string(SCM x) {
+    char* temp;
+    temp = SWIG_scm2str(x);
+    std::string s(temp);
+    if (temp) SWIG_free(temp);
+    return s;
+}
+
+
+#include <vector>
+#include <algorithm>
+#include <stdexcept>
+
+SWIGINTERN double std_vector_Sl_double_Sg__pop(std::vector< double > *self){
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty vector");
+                double x = self->back();
+                self->pop_back();
+                return x;
+            }
+SWIGINTERN double std_vector_Sl_double_Sg__ref(std::vector< double > *self,int i){
+                int size = int(self->size());
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("vector index out of range");
+            }
+SWIGINTERN void std_vector_Sl_double_Sg__set(std::vector< double > *self,int i,double x){
+                int size = int(self->size());
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("vector index out of range");
+            }
+
+// work around obsolete stuff used by swig guile
+#if SCM_MAJOR_VERSION >= 2
+#  define gh_symbol2scm scm_from_latin1_symbol
+#else
+#  define gh_symbol2scm scm_str2symbol
+#endif
+
+
+// because our f_data pointer to the Scheme function is stored on the
+// heap, rather than the stack, it may be missed by the Guile garbage
+// collection and be accidentally freed.  Hence, use NLopts munge
+// feature to prevent this, by incrementing Guile's reference count.
+static void *free_guilefunc(void *p) { 
+  scm_gc_unprotect_object((SCM) p); return p; }
+static void *dup_guilefunc(void *p) { 
+  scm_gc_protect_object((SCM) p); return p; }
+
+// func wrapper around Guile function val = f(x, grad)
+static double func_guile(unsigned n, const double *x, double *grad, void *f) {
+  SCM xscm = scm_c_make_vector(n, SCM_UNSPECIFIED);
+  for (unsigned i = 0; i < n; ++i)
+    SCM_SIMPLE_VECTOR_SET(xscm, i, scm_make_real(x[i]));
+  SCM grad_scm = grad ? scm_c_make_vector(n, SCM_UNSPECIFIED) : SCM_BOOL_F;
+  SCM ret = scm_call_2((SCM) f, xscm, grad_scm);
+  if (!scm_real_p(ret))
+    throw std::invalid_argument("invalid result passed to nlopt");
+  if (grad) {
+    for (unsigned i = 0; i < n; ++i) {
+      if (!scm_real_p(ret)) 
+       throw std::invalid_argument("invalid gradient passed to nlopt");
+      grad[i] = scm_to_double(SCM_SIMPLE_VECTOR_REF(grad_scm, i));
+    }
+  }
+  return scm_to_double(ret);
+}
+
+static int gswig_const_NLOPT_GN_DIRECT = nlopt::GN_DIRECT;
+static int gswig_const_NLOPT_GN_DIRECT_L = nlopt::GN_DIRECT_L;
+static int gswig_const_NLOPT_GN_DIRECT_L_RAND = nlopt::GN_DIRECT_L_RAND;
+static int gswig_const_NLOPT_GN_DIRECT_NOSCAL = nlopt::GN_DIRECT_NOSCAL;
+static int gswig_const_NLOPT_GN_DIRECT_L_NOSCAL = nlopt::GN_DIRECT_L_NOSCAL;
+static int gswig_const_NLOPT_GN_DIRECT_L_RAND_NOSCAL = nlopt::GN_DIRECT_L_RAND_NOSCAL;
+static int gswig_const_NLOPT_GN_ORIG_DIRECT = nlopt::GN_ORIG_DIRECT;
+static int gswig_const_NLOPT_GN_ORIG_DIRECT_L = nlopt::GN_ORIG_DIRECT_L;
+static int gswig_const_NLOPT_GD_STOGO = nlopt::GD_STOGO;
+static int gswig_const_NLOPT_GD_STOGO_RAND = nlopt::GD_STOGO_RAND;
+static int gswig_const_NLOPT_LD_LBFGS_NOCEDAL = nlopt::LD_LBFGS_NOCEDAL;
+static int gswig_const_NLOPT_LD_LBFGS = nlopt::LD_LBFGS;
+static int gswig_const_NLOPT_LN_PRAXIS = nlopt::LN_PRAXIS;
+static int gswig_const_NLOPT_LD_VAR1 = nlopt::LD_VAR1;
+static int gswig_const_NLOPT_LD_VAR2 = nlopt::LD_VAR2;
+static int gswig_const_NLOPT_LD_TNEWTON = nlopt::LD_TNEWTON;
+static int gswig_const_NLOPT_LD_TNEWTON_RESTART = nlopt::LD_TNEWTON_RESTART;
+static int gswig_const_NLOPT_LD_TNEWTON_PRECOND = nlopt::LD_TNEWTON_PRECOND;
+static int gswig_const_NLOPT_LD_TNEWTON_PRECOND_RESTART = nlopt::LD_TNEWTON_PRECOND_RESTART;
+static int gswig_const_NLOPT_GN_CRS2_LM = nlopt::GN_CRS2_LM;
+static int gswig_const_NLOPT_GN_MLSL = nlopt::GN_MLSL;
+static int gswig_const_NLOPT_GD_MLSL = nlopt::GD_MLSL;
+static int gswig_const_NLOPT_GN_MLSL_LDS = nlopt::GN_MLSL_LDS;
+static int gswig_const_NLOPT_GD_MLSL_LDS = nlopt::GD_MLSL_LDS;
+static int gswig_const_NLOPT_LD_MMA = nlopt::LD_MMA;
+static int gswig_const_NLOPT_LN_COBYLA = nlopt::LN_COBYLA;
+static int gswig_const_NLOPT_LN_NEWUOA = nlopt::LN_NEWUOA;
+static int gswig_const_NLOPT_LN_NEWUOA_BOUND = nlopt::LN_NEWUOA_BOUND;
+static int gswig_const_NLOPT_LN_NELDERMEAD = nlopt::LN_NELDERMEAD;
+static int gswig_const_NLOPT_LN_SBPLX = nlopt::LN_SBPLX;
+static int gswig_const_NLOPT_LN_AUGLAG = nlopt::LN_AUGLAG;
+static int gswig_const_NLOPT_LD_AUGLAG = nlopt::LD_AUGLAG;
+static int gswig_const_NLOPT_LN_AUGLAG_EQ = nlopt::LN_AUGLAG_EQ;
+static int gswig_const_NLOPT_LD_AUGLAG_EQ = nlopt::LD_AUGLAG_EQ;
+static int gswig_const_NLOPT_LN_BOBYQA = nlopt::LN_BOBYQA;
+static int gswig_const_NLOPT_GN_ISRES = nlopt::GN_ISRES;
+static int gswig_const_NLOPT_AUGLAG = nlopt::AUGLAG;
+static int gswig_const_NLOPT_AUGLAG_EQ = nlopt::AUGLAG_EQ;
+static int gswig_const_NLOPT_G_MLSL = nlopt::G_MLSL;
+static int gswig_const_NLOPT_G_MLSL_LDS = nlopt::G_MLSL_LDS;
+static int gswig_const_NLOPT_LD_SLSQP = nlopt::LD_SLSQP;
+static int gswig_const_NLOPT_LD_CCSAQ = nlopt::LD_CCSAQ;
+static int gswig_const_NLOPT_GN_ESCH = nlopt::GN_ESCH;
+static int gswig_const_NLOPT_NUM_ALGORITHMS = nlopt::NUM_ALGORITHMS;
+static int gswig_const_NLOPT_FAILURE = nlopt::FAILURE;
+static int gswig_const_NLOPT_INVALID_ARGS = nlopt::INVALID_ARGS;
+static int gswig_const_NLOPT_OUT_OF_MEMORY = nlopt::OUT_OF_MEMORY;
+static int gswig_const_NLOPT_ROUNDOFF_LIMITED = nlopt::ROUNDOFF_LIMITED;
+static int gswig_const_NLOPT_FORCED_STOP = nlopt::FORCED_STOP;
+static int gswig_const_NLOPT_SUCCESS = nlopt::SUCCESS;
+static int gswig_const_NLOPT_STOPVAL_REACHED = nlopt::STOPVAL_REACHED;
+static int gswig_const_NLOPT_FTOL_REACHED = nlopt::FTOL_REACHED;
+static int gswig_const_NLOPT_XTOL_REACHED = nlopt::XTOL_REACHED;
+static int gswig_const_NLOPT_MAXEVAL_REACHED = nlopt::MAXEVAL_REACHED;
+static int gswig_const_NLOPT_MAXTIME_REACHED = nlopt::MAXTIME_REACHED;
+static SCM
+_wrap_new_nlopt_doublevector__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-doublevector"
+  unsigned int arg1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > *result = 0 ;
+  
+  {
+    arg1 = (unsigned int) scm_to_uint(argv[0]);
+  }
+  result = (std::vector< double > *)new std::vector< double >(arg1);
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_std__vectorT_double_t, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_doublevector__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-doublevector"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > *result = 0 ;
+  
+  result = (std::vector< double > *)new std::vector< double >();
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_std__vectorT_double_t, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_doublevector__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-doublevector"
+  unsigned int arg1 ;
+  double *arg2 = 0 ;
+  double temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > *result = 0 ;
+  
+  {
+    arg1 = (unsigned int) scm_to_uint(argv[0]);
+  }
+  {
+    temp2 = scm_to_double(argv[1]);
+    arg2 = (double *) &temp2;
+  }
+  result = (std::vector< double > *)new std::vector< double >(arg1,(double const &)*arg2);
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_std__vectorT_double_t, 1);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_doublevector__SWIG_3 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-doublevector"
+  std::vector< double > *arg1 = 0 ;
+  std::vector< double > temp1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > *result = 0 ;
+  
+  {
+    if (scm_is_vector(argv[0])) {
+      unsigned long size = scm_c_vector_length(argv[0]);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[0],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, argv[0]);
+      }
+    } else if (scm_is_null(argv[0])) {
+      temp1 = std::vector<double >();
+      arg1 = &temp1;
+    } else if (scm_is_pair(argv[0])) {
+      SCM v = scm_vector(argv[0]);
+      unsigned long size = scm_c_vector_length(v);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, argv[0]);
+      }
+    } else {
+      arg1 = (std::vector< double > *) SWIG_MustGetPtr(argv[0],SWIGTYPE_p_std__vectorT_double_t,1, 0);
+    }
+  }
+  result = (std::vector< double > *)new std::vector< double >((std::vector< double > const &)*arg1);
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_std__vectorT_double_t, 1);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_doublevector(SCM rest)
+{
+#define FUNC_NAME "new-nlopt-doublevector"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "new-nlopt-doublevector");
+  if (argc == 0) {
+    return _wrap_new_nlopt_doublevector__SWIG_1(argc,argv);
+  }
+  if (argc == 1) {
+    int _v;
+    {
+      _v = scm_is_true(scm_integer_p(argv[0])) && scm_is_true(scm_exact_p(argv[0]))? 1 : 0;
+    }
+    if (_v) {
+      return _wrap_new_nlopt_doublevector__SWIG_0(argc,argv);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    {
+      /* native sequence? */
+      if (scm_is_vector(argv[0])) {
+        unsigned int size = scm_c_vector_length(argv[0]);
+        if (size == 0) {
+          /* an empty sequence can be of any type */
+          _v = 1;
+        } else {
+          /* check the first element only */
+          double* x;
+          SCM o = scm_vector_ref(argv[0],scm_from_ulong(0));
+          _v = scm_is_number(o) ? 1 : 0;
+        }
+      } else if (scm_is_null(argv[0])) {
+        /* again, an empty sequence can be of any type */
+        _v = 1;
+      } else if (scm_is_pair(argv[0])) {
+        /* check the first element only */
+        double* x;
+        SCM head = SCM_CAR(argv[0]);
+        _v = scm_is_number(head) ? 1 : 0;
+      } else {
+        /* wrapped vector? */
+        std::vector<double >* v;
+        _v = (SWIG_ConvertPtr(argv[0],(void **) &v, 
+            SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+      }
+    }
+    if (_v) {
+      return _wrap_new_nlopt_doublevector__SWIG_3(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      _v = scm_is_true(scm_integer_p(argv[0])) && scm_is_true(scm_exact_p(argv[0]))? 1 : 0;
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_real_p(argv[1])) ? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_new_nlopt_doublevector__SWIG_2(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("new-nlopt-doublevector", "No matching method for generic function `new_nlopt_doublevector'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_length (SCM s_0)
+{
+#define FUNC_NAME "nlopt-doublevector-length"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double > temp1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  unsigned int result;
+  
+  {
+    if (scm_is_vector(s_0)) {
+      unsigned long size = scm_c_vector_length(s_0);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(s_0,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, s_0);
+      }
+    } else if (scm_is_null(s_0)) {
+      temp1 = std::vector<double >();
+      arg1 = &temp1;
+    } else if (scm_is_pair(s_0)) {
+      SCM v = scm_vector(s_0);
+      unsigned long size = scm_c_vector_length(v);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, s_0);
+      }
+    } else {
+      arg1 = (std::vector< double > *) SWIG_MustGetPtr(s_0,SWIGTYPE_p_std__vectorT_double_t,1, 0);
+    }
+  }
+  result = (unsigned int)((std::vector< double > const *)arg1)->size();
+  {
+    gswig_result = scm_from_ulong(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_emptyq___ (SCM s_0)
+{
+#define FUNC_NAME "nlopt-doublevector-empty?"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double > temp1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  bool result;
+  
+  {
+    if (scm_is_vector(s_0)) {
+      unsigned long size = scm_c_vector_length(s_0);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(s_0,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, s_0);
+      }
+    } else if (scm_is_null(s_0)) {
+      temp1 = std::vector<double >();
+      arg1 = &temp1;
+    } else if (scm_is_pair(s_0)) {
+      SCM v = scm_vector(s_0);
+      unsigned long size = scm_c_vector_length(v);
+      temp1 = std::vector<double >(size);
+      arg1 = &temp1;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp1[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 1, s_0);
+      }
+    } else {
+      arg1 = (std::vector< double > *) SWIG_MustGetPtr(s_0,SWIGTYPE_p_std__vectorT_double_t,1, 0);
+    }
+  }
+  result = (bool)((std::vector< double > const *)arg1)->empty();
+  {
+    gswig_result = scm_from_bool(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_clearN___ (SCM s_0)
+{
+#define FUNC_NAME "nlopt-doublevector-clear!"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  (arg1)->clear();
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_pushN___ (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-doublevector-push!"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  (arg1)->push_back(arg2);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_popN___ (SCM s_0)
+{
+#define FUNC_NAME "nlopt-doublevector-pop!"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  try {
+    result = (double)std_vector_Sl_double_Sg__pop(arg1);
+  }
+  catch(std::out_of_range &_e) {
+    {
+      std::out_of_range * temp = new std::out_of_range(_e);
+      scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
+        scm_listify(SWIG_NewPointerObj(temp, SWIGTYPE_p_std__out_of_range, 1),
+          SCM_UNDEFINED));
+    }
+  }
+  
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_ref (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-doublevector-ref"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  {
+    arg2 = (int) scm_to_int(s_1);
+  }
+  try {
+    result = (double)std_vector_Sl_double_Sg__ref(arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    {
+      std::out_of_range * temp = new std::out_of_range(_e);
+      scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
+        scm_listify(SWIG_NewPointerObj(temp, SWIGTYPE_p_std__out_of_range, 1),
+          SCM_UNDEFINED));
+    }
+  }
+  
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_doublevector_setN___ (SCM s_0, SCM s_1, SCM s_2)
+{
+#define FUNC_NAME "nlopt-doublevector-set!"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  int arg2 ;
+  double arg3 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  {
+    arg2 = (int) scm_to_int(s_1);
+  }
+  {
+    arg3 = (double) scm_to_double(s_2);
+  }
+  try {
+    std_vector_Sl_double_Sg__set(arg1,arg2,arg3);
+  }
+  catch(std::out_of_range &_e) {
+    {
+      std::out_of_range * temp = new std::out_of_range(_e);
+      scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
+        scm_listify(SWIG_NewPointerObj(temp, SWIGTYPE_p_std__out_of_range, 1),
+          SCM_UNDEFINED));
+    }
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_delete_nlopt_doublevector (SCM s_0)
+{
+#define FUNC_NAME "delete-nlopt-doublevector"
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (std::vector< double > *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_std__vectorT_double_t, 1, 0);
+  }
+  delete arg1;
+  gswig_result = SCM_UNSPECIFIED;
+  
+  SWIG_Guile_MarkPointerDestroyed(s_0);
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_get_initial_step (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-get-initial-step"
+  nlopt_opt arg1 ;
+  double *arg2 = (double *) 0 ;
+  nlopt_opt *argp1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt_result result;
+  
+  {
+    argp1 = (nlopt_opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt_opt, 1, 0);
+    arg1 = *argp1;
+  }
+  {
+    arg2 = (double *)SWIG_MustGetPtr(s_1, SWIGTYPE_p_double, 2, 0);
+  }
+  result = nlopt_get_initial_step(arg1,arg2);
+  {
+    nlopt_result * resultptr;
+    resultptr = new nlopt_result((const nlopt_result &) result);
+    gswig_result =  SWIG_NewPointerObj (resultptr, SWIGTYPE_p_nlopt_result, 1);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT_L(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT-L"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT_L);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT_L_RAND(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT-L-RAND"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT_L_RAND);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT_NOSCAL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT-NOSCAL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT_NOSCAL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT_L_NOSCAL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT-L-NOSCAL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT_L_NOSCAL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_DIRECT_L_RAND_NOSCAL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-DIRECT-L-RAND-NOSCAL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_DIRECT_L_RAND_NOSCAL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_ORIG_DIRECT(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-ORIG-DIRECT"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_ORIG_DIRECT);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_ORIG_DIRECT_L(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-ORIG-DIRECT-L"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_ORIG_DIRECT_L);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GD_STOGO(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GD-STOGO"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GD_STOGO);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GD_STOGO_RAND(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GD-STOGO-RAND"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GD_STOGO_RAND);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_LBFGS_NOCEDAL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-LBFGS-NOCEDAL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_LBFGS_NOCEDAL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_LBFGS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-LBFGS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_LBFGS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_PRAXIS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-PRAXIS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_PRAXIS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_VAR1(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-VAR1"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_VAR1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_VAR2(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-VAR2"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_VAR2);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_TNEWTON(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-TNEWTON"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_TNEWTON);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_TNEWTON_RESTART(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-TNEWTON-RESTART"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_TNEWTON_RESTART);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_TNEWTON_PRECOND(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-TNEWTON-PRECOND"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_TNEWTON_PRECOND);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_TNEWTON_PRECOND_RESTART(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-TNEWTON-PRECOND-RESTART"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_TNEWTON_PRECOND_RESTART);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_CRS2_LM(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-CRS2-LM"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_CRS2_LM);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_MLSL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-MLSL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_MLSL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GD_MLSL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GD-MLSL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GD_MLSL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_MLSL_LDS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-MLSL-LDS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_MLSL_LDS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GD_MLSL_LDS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GD-MLSL-LDS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GD_MLSL_LDS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_MMA(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-MMA"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_MMA);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_COBYLA(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-COBYLA"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_COBYLA);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_NEWUOA(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-NEWUOA"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_NEWUOA);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_NEWUOA_BOUND(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-NEWUOA-BOUND"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_NEWUOA_BOUND);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_NELDERMEAD(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-NELDERMEAD"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_NELDERMEAD);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_SBPLX(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-SBPLX"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_SBPLX);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_AUGLAG(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-AUGLAG"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_AUGLAG);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_AUGLAG(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-AUGLAG"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_AUGLAG);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_AUGLAG_EQ(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-AUGLAG-EQ"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_AUGLAG_EQ);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_AUGLAG_EQ(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-AUGLAG-EQ"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_AUGLAG_EQ);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LN_BOBYQA(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LN-BOBYQA"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LN_BOBYQA);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_ISRES(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-ISRES"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_ISRES);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_AUGLAG(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-AUGLAG"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_AUGLAG);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_AUGLAG_EQ(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-AUGLAG-EQ"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_AUGLAG_EQ);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_G_MLSL(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-G-MLSL"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_G_MLSL);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_G_MLSL_LDS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-G-MLSL-LDS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_G_MLSL_LDS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_SLSQP(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-SLSQP"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_SLSQP);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_LD_CCSAQ(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-LD-CCSAQ"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_LD_CCSAQ);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_GN_ESCH(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-GN-ESCH"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_GN_ESCH);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_NUM_ALGORITHMS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-NUM-ALGORITHMS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_NUM_ALGORITHMS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_FAILURE(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-FAILURE"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_FAILURE);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_INVALID_ARGS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-INVALID-ARGS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_INVALID_ARGS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_OUT_OF_MEMORY(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-OUT-OF-MEMORY"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_OUT_OF_MEMORY);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_ROUNDOFF_LIMITED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-ROUNDOFF-LIMITED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_ROUNDOFF_LIMITED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_FORCED_STOP(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-FORCED-STOP"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_FORCED_STOP);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_SUCCESS(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-SUCCESS"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_SUCCESS);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_STOPVAL_REACHED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-STOPVAL-REACHED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_STOPVAL_REACHED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_FTOL_REACHED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-FTOL-REACHED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_FTOL_REACHED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_XTOL_REACHED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-XTOL-REACHED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_XTOL_REACHED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_MAXEVAL_REACHED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-MAXEVAL-REACHED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_MAXEVAL_REACHED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_NLOPT_MAXTIME_REACHED(SCM s_0)
+{
+#define FUNC_NAME "NLOPT-MAXTIME-REACHED"
+  SCM gswig_result;
+  
+  {
+    gswig_result = scm_from_long(gswig_const_NLOPT_MAXTIME_REACHED);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_roundoff_limited ()
+{
+#define FUNC_NAME "new-nlopt-roundoff-limited"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::roundoff_limited *result = 0 ;
+  
+  result = (nlopt::roundoff_limited *)new nlopt::roundoff_limited();
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_nlopt__roundoff_limited, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_delete_nlopt_roundoff_limited (SCM s_0)
+{
+#define FUNC_NAME "delete-nlopt-roundoff-limited"
+  nlopt::roundoff_limited *arg1 = (nlopt::roundoff_limited *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::roundoff_limited *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__roundoff_limited, 1, 0);
+  }
+  delete arg1;
+  gswig_result = SCM_UNSPECIFIED;
+  
+  SWIG_Guile_MarkPointerDestroyed(s_0);
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_forced_stop ()
+{
+#define FUNC_NAME "new-nlopt-forced-stop"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::forced_stop *result = 0 ;
+  
+  result = (nlopt::forced_stop *)new nlopt::forced_stop();
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_nlopt__forced_stop, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_delete_nlopt_forced_stop (SCM s_0)
+{
+#define FUNC_NAME "delete-nlopt-forced-stop"
+  nlopt::forced_stop *arg1 = (nlopt::forced_stop *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::forced_stop *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__forced_stop, 1, 0);
+  }
+  delete arg1;
+  gswig_result = SCM_UNSPECIFIED;
+  
+  SWIG_Guile_MarkPointerDestroyed(s_0);
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_opt__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-opt"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::opt *result = 0 ;
+  
+  try {
+    result = (nlopt::opt *)new nlopt::opt();
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_nlopt__opt, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_delete_nlopt_opt (SCM s_0)
+{
+#define FUNC_NAME "delete-nlopt-opt"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  delete arg1;
+  gswig_result = SCM_UNSPECIFIED;
+  
+  SWIG_Guile_MarkPointerDestroyed(s_0);
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_opt__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-opt"
+  nlopt::algorithm arg1 ;
+  unsigned int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::opt *result = 0 ;
+  
+  {
+    arg1 = (nlopt::algorithm) scm_to_int(argv[0]); 
+  }
+  {
+    arg2 = (unsigned int) scm_to_uint(argv[1]);
+  }
+  try {
+    result = (nlopt::opt *)new nlopt::opt(arg1,arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_nlopt__opt, 1);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_opt__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "new-nlopt-opt"
+  nlopt::opt *arg1 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::opt *result = 0 ;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  try {
+    result = (nlopt::opt *)new nlopt::opt((nlopt::opt const &)*arg1);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  {
+    gswig_result = SWIG_NewPointerObj (result, SWIGTYPE_p_nlopt__opt, 1);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_new_nlopt_opt(SCM rest)
+{
+#define FUNC_NAME "new-nlopt-opt"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "new-nlopt-opt");
+  if (argc == 0) {
+    return _wrap_new_nlopt_opt__SWIG_0(argc,argv);
+  }
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_new_nlopt_opt__SWIG_2(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      _v = scm_is_true(scm_integer_p(argv[0])) && scm_is_true(scm_exact_p(argv[0]))? 1 : 0;
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_integer_p(argv[1])) && scm_is_true(scm_exact_p(argv[1]))? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_new_nlopt_opt__SWIG_1(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("new-nlopt-opt", "No matching method for generic function `new_nlopt_opt'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_optimize__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-optimize"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  double *arg3 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::result result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (std::vector< double > *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_std__vectorT_double_t, 2, 0);
+  }
+  {
+    arg3 = (double *)SWIG_MustGetPtr(argv[2], SWIGTYPE_p_double, 3, 0);
+  }
+  try {
+    result = (nlopt::result)(arg1)->optimize(*arg2,*arg3);
+  }
+  catch(nlopt::roundoff_limited &_e) {
+    scm_throw(gh_symbol2scm("roundoff-limited"), SCM_EOL);
+    
+  }
+  catch(nlopt::forced_stop &_e) {
+    scm_throw(gh_symbol2scm("forced-stop"), SCM_EOL);
+    
+  }
+  catch(std::runtime_error &_e) {
+    scm_throw(gh_symbol2scm("runtime-error"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  {
+    gswig_result = scm_from_long(result); 
+  }
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_optimize__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-optimize"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    result = (arg1)->optimize((std::vector< double > const &)*arg2);
+  }
+  catch(nlopt::roundoff_limited &_e) {
+    scm_throw(gh_symbol2scm("roundoff-limited"), SCM_EOL);
+    
+  }
+  catch(nlopt::forced_stop &_e) {
+    scm_throw(gh_symbol2scm("forced-stop"), SCM_EOL);
+    
+  }
+  catch(std::runtime_error &_e) {
+    scm_throw(gh_symbol2scm("runtime-error"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_optimize(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-optimize"
+  SCM argv[3];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 3, "nlopt-opt-optimize");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_optimize__SWIG_1(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, SWIGTYPE_p_double, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_optimize__SWIG_0(argc,argv);
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-optimize", "No matching method for generic function `nlopt_opt_optimize'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_last_optimize_result (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-last-optimize-result"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::result result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (nlopt::result)((nlopt::opt const *)arg1)->last_optimize_result();
+  {
+    gswig_result = scm_from_long(result); 
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_last_optimum_value (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-last-optimum-value"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->last_optimum_value();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_algorithm (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-algorithm"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  nlopt::algorithm result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (nlopt::algorithm)((nlopt::opt const *)arg1)->get_algorithm();
+  {
+    gswig_result = scm_from_long(result); 
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_algorithm_name (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-algorithm-name"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  char *result = 0 ;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (char *)((nlopt::opt const *)arg1)->get_algorithm_name();
+  {
+    gswig_result = SWIG_str02scm((const char *)result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_dimension (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-dimension"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  unsigned int result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_dimension();
+  {
+    gswig_result = scm_from_ulong(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_min_objective__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-min-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_min_objective__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-min-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_max_objective__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-max-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_max_objective__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-max-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_min_objective__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-min-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_min_objective(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-min-objective"
+  SCM argv[3];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 3, "nlopt-opt-set-min-objective");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_nlopt_opt_set_min_objective__SWIG_2(argc,argv);
+        }
+        if (argc <= 3) {
+          return _wrap_nlopt_opt_set_min_objective__SWIG_2(argc,argv);
+        }
+        if (argc <= 4) {
+          return _wrap_nlopt_opt_set_min_objective__SWIG_2(argc,argv);
+        }
+        return _wrap_nlopt_opt_set_min_objective__SWIG_2(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_set_min_objective__SWIG_1(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_set_min_objective__SWIG_0(argc,argv);
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-min-objective", "No matching method for generic function `nlopt_opt_set_min_objective'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_max_objective__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-max-objective"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_max_objective(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-max-objective"
+  SCM argv[3];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 3, "nlopt-opt-set-max-objective");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_nlopt_opt_set_max_objective__SWIG_2(argc,argv);
+        }
+        if (argc <= 3) {
+          return _wrap_nlopt_opt_set_max_objective__SWIG_2(argc,argv);
+        }
+        if (argc <= 4) {
+          return _wrap_nlopt_opt_set_max_objective__SWIG_2(argc,argv);
+        }
+        return _wrap_nlopt_opt_set_max_objective__SWIG_2(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_set_max_objective__SWIG_1(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_set_max_objective__SWIG_0(argc,argv);
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-max-objective", "No matching method for generic function `nlopt_opt_set_max_objective'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_remove_inequality_constraints (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-remove-inequality-constraints"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  try {
+    (arg1)->remove_inequality_constraints();
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    arg4 = (double) scm_to_double(argv[3]);
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    arg4 = (double) scm_to_double(argv[3]);
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_3 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_mconstraint__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-mconstraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  std::vector< double > *arg4 = 0 ;
+  nlopt::mfunc *argp2 ;
+  std::vector< double > temp4 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::mfunc *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_mfunc, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    if (scm_is_vector(argv[3])) {
+      unsigned long size = scm_c_vector_length(argv[3]);
+      temp4 = std::vector<double >(size);
+      arg4 = &temp4;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[3],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp4[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 4, argv[3]);
+      }
+    } else if (scm_is_null(argv[3])) {
+      temp4 = std::vector<double >();
+      arg4 = &temp4;
+    } else if (scm_is_pair(argv[3])) {
+      SCM v = scm_vector(argv[3]);
+      unsigned long size = scm_c_vector_length(v);
+      temp4 = std::vector<double >(size);
+      arg4 = &temp4;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp4[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 4, argv[3]);
+      }
+    } else {
+      arg4 = (std::vector< double > *) SWIG_MustGetPtr(argv[3],SWIGTYPE_p_std__vectorT_double_t,4, 0);
+    }
+  }
+  try {
+    (arg1)->add_inequality_mconstraint(arg2,arg3,(std::vector< double > const &)*arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_remove_equality_constraints (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-remove-equality-constraints"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  try {
+    (arg1)->remove_equality_constraints();
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    arg4 = (double) scm_to_double(argv[3]);
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt::func *argp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::func *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_func, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    arg4 = (double) scm_to_double(argv[3]);
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_3 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::vfunc)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 2, 0);
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_mconstraint__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-mconstraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  std::vector< double > *arg4 = 0 ;
+  nlopt::mfunc *argp2 ;
+  std::vector< double > temp4 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::mfunc *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_mfunc, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    if (scm_is_vector(argv[3])) {
+      unsigned long size = scm_c_vector_length(argv[3]);
+      temp4 = std::vector<double >(size);
+      arg4 = &temp4;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[3],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp4[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 4, argv[3]);
+      }
+    } else if (scm_is_null(argv[3])) {
+      temp4 = std::vector<double >();
+      arg4 = &temp4;
+    } else if (scm_is_pair(argv[3])) {
+      SCM v = scm_vector(argv[3]);
+      unsigned long size = scm_c_vector_length(v);
+      temp4 = std::vector<double >(size);
+      arg4 = &temp4;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp4[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 4, argv[3]);
+      }
+    } else {
+      arg4 = (std::vector< double > *) SWIG_MustGetPtr(argv[3],SWIGTYPE_p_std__vectorT_double_t,4, 0);
+    }
+  }
+  try {
+    (arg1)->add_equality_mconstraint(arg2,arg3,(std::vector< double > const &)*arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_4 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  double arg6 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  {
+    arg6 = (double) scm_to_double(argv[2]);
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4,arg5,arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint__SWIG_5 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_constraint(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-constraint"
+  SCM argv[4];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 4, "nlopt-opt-add-inequality-constraint");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_5(argc,argv);
+        }
+        if (argc <= 3) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_5(argc,argv);
+        }
+        if (argc <= 4) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_5(argc,argv);
+        }
+        return _wrap_nlopt_opt_add_inequality_constraint__SWIG_5(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_3(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        {
+          _v = scm_is_true(scm_real_p(argv[2])) ? 1 : 0;
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_4(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_inequality_constraint__SWIG_1(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            _v = scm_is_true(scm_real_p(argv[3])) ? 1 : 0;
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_inequality_constraint__SWIG_2(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            _v = scm_is_true(scm_real_p(argv[3])) ? 1 : 0;
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_inequality_constraint__SWIG_0(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-add-inequality-constraint", "No matching method for generic function `nlopt_opt_add_inequality_constraint'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_4 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  double arg6 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  {
+    arg6 = (double) scm_to_double(argv[2]);
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4,arg5,arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint__SWIG_5 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = func_guile;
+    arg3 = dup_guilefunc((void*) argv[1]); // input = SCM pointer to Scheme function
+    arg4 = free_guilefunc;
+    arg5 = dup_guilefunc;
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_constraint(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-constraint"
+  SCM argv[4];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 4, "nlopt-opt-add-equality-constraint");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_5(argc,argv);
+        }
+        if (argc <= 3) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_5(argc,argv);
+        }
+        if (argc <= 4) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_5(argc,argv);
+        }
+        return _wrap_nlopt_opt_add_equality_constraint__SWIG_5(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_3(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = SCM_NFALSEP(scm_procedure_p(argv[1]));
+      }
+      if (_v) {
+        {
+          _v = scm_is_true(scm_real_p(argv[2])) ? 1 : 0;
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_4(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_add_equality_constraint__SWIG_1(argc,argv);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            _v = scm_is_true(scm_real_p(argv[3])) ? 1 : 0;
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_equality_constraint__SWIG_2(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_func, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            _v = scm_is_true(scm_real_p(argv[3])) ? 1 : 0;
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_equality_constraint__SWIG_0(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-add-equality-constraint", "No matching method for generic function `nlopt_opt_add_equality_constraint'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_mconstraint__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-mconstraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  std::vector< double > *arg6 = 0 ;
+  nlopt::mfunc *argp2 ;
+  nlopt_munge *argp4 ;
+  nlopt_munge *argp5 ;
+  std::vector< double > temp6 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::mfunc *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_mfunc, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    argp4 = (nlopt_munge *)SWIG_MustGetPtr(argv[3], SWIGTYPE_p_nlopt_munge, 4, 0);
+    arg4 = *argp4;
+  }
+  {
+    argp5 = (nlopt_munge *)SWIG_MustGetPtr(argv[4], SWIGTYPE_p_nlopt_munge, 5, 0);
+    arg5 = *argp5;
+  }
+  {
+    if (scm_is_vector(argv[5])) {
+      unsigned long size = scm_c_vector_length(argv[5]);
+      temp6 = std::vector<double >(size);
+      arg6 = &temp6;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[5],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp6[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 6, argv[5]);
+      }
+    } else if (scm_is_null(argv[5])) {
+      temp6 = std::vector<double >();
+      arg6 = &temp6;
+    } else if (scm_is_pair(argv[5])) {
+      SCM v = scm_vector(argv[5]);
+      unsigned long size = scm_c_vector_length(v);
+      temp6 = std::vector<double >(size);
+      arg6 = &temp6;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp6[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 6, argv[5]);
+      }
+    } else {
+      arg6 = (std::vector< double > *) SWIG_MustGetPtr(argv[5],SWIGTYPE_p_std__vectorT_double_t,6, 0);
+    }
+  }
+  try {
+    (arg1)->add_inequality_mconstraint(arg2,arg3,arg4,arg5,(std::vector< double > const &)*arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_inequality_mconstraint(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-add-inequality-mconstraint"
+  SCM argv[6];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 6, "nlopt-opt-add-inequality-mconstraint");
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_mfunc, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            /* native sequence? */
+            if (scm_is_vector(argv[3])) {
+              unsigned int size = scm_c_vector_length(argv[3]);
+              if (size == 0) {
+                /* an empty sequence can be of any type */
+                _v = 1;
+              } else {
+                /* check the first element only */
+                double* x;
+                SCM o = scm_vector_ref(argv[3],scm_from_ulong(0));
+                _v = scm_is_number(o) ? 1 : 0;
+              }
+            } else if (scm_is_null(argv[3])) {
+              /* again, an empty sequence can be of any type */
+              _v = 1;
+            } else if (scm_is_pair(argv[3])) {
+              /* check the first element only */
+              double* x;
+              SCM head = SCM_CAR(argv[3]);
+              _v = scm_is_number(head) ? 1 : 0;
+            } else {
+              /* wrapped vector? */
+              std::vector<double >* v;
+              _v = (SWIG_ConvertPtr(argv[3],(void **) &v, 
+                  SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+            }
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_inequality_mconstraint__SWIG_0(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 6) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_mfunc, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            void *ptr;
+            int res = SWIG_ConvertPtr(argv[3], &ptr, SWIGTYPE_p_nlopt_munge, 0);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            {
+              void *ptr;
+              int res = SWIG_ConvertPtr(argv[4], &ptr, SWIGTYPE_p_nlopt_munge, 0);
+              _v = SWIG_CheckState(res);
+            }
+            if (_v) {
+              {
+                /* native sequence? */
+                if (scm_is_vector(argv[5])) {
+                  unsigned int size = scm_c_vector_length(argv[5]);
+                  if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    _v = 1;
+                  } else {
+                    /* check the first element only */
+                    double* x;
+                    SCM o = scm_vector_ref(argv[5],scm_from_ulong(0));
+                    _v = scm_is_number(o) ? 1 : 0;
+                  }
+                } else if (scm_is_null(argv[5])) {
+                  /* again, an empty sequence can be of any type */
+                  _v = 1;
+                } else if (scm_is_pair(argv[5])) {
+                  /* check the first element only */
+                  double* x;
+                  SCM head = SCM_CAR(argv[5]);
+                  _v = scm_is_number(head) ? 1 : 0;
+                } else {
+                  /* wrapped vector? */
+                  std::vector<double >* v;
+                  _v = (SWIG_ConvertPtr(argv[5],(void **) &v, 
+                      SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+                }
+              }
+              if (_v) {
+                return _wrap_nlopt_opt_add_inequality_mconstraint__SWIG_1(argc,argv);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-add-inequality-mconstraint", "No matching method for generic function `nlopt_opt_add_inequality_mconstraint'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_mconstraint__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-mconstraint"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  std::vector< double > *arg6 = 0 ;
+  nlopt::mfunc *argp2 ;
+  nlopt_munge *argp4 ;
+  nlopt_munge *argp5 ;
+  std::vector< double > temp6 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    argp2 = (nlopt::mfunc *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_nlopt_mfunc, 2, 0);
+    arg2 = *argp2;
+  }
+  {
+    arg3 = (void *)SWIG_MustGetPtr(argv[2], NULL, 3, 0);
+  }
+  {
+    argp4 = (nlopt_munge *)SWIG_MustGetPtr(argv[3], SWIGTYPE_p_nlopt_munge, 4, 0);
+    arg4 = *argp4;
+  }
+  {
+    argp5 = (nlopt_munge *)SWIG_MustGetPtr(argv[4], SWIGTYPE_p_nlopt_munge, 5, 0);
+    arg5 = *argp5;
+  }
+  {
+    if (scm_is_vector(argv[5])) {
+      unsigned long size = scm_c_vector_length(argv[5]);
+      temp6 = std::vector<double >(size);
+      arg6 = &temp6;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[5],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp6[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 6, argv[5]);
+      }
+    } else if (scm_is_null(argv[5])) {
+      temp6 = std::vector<double >();
+      arg6 = &temp6;
+    } else if (scm_is_pair(argv[5])) {
+      SCM v = scm_vector(argv[5]);
+      unsigned long size = scm_c_vector_length(v);
+      temp6 = std::vector<double >(size);
+      arg6 = &temp6;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp6[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 6, argv[5]);
+      }
+    } else {
+      arg6 = (std::vector< double > *) SWIG_MustGetPtr(argv[5],SWIGTYPE_p_std__vectorT_double_t,6, 0);
+    }
+  }
+  try {
+    (arg1)->add_equality_mconstraint(arg2,arg3,arg4,arg5,(std::vector< double > const &)*arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_add_equality_mconstraint(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-add-equality-mconstraint"
+  SCM argv[6];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 6, "nlopt-opt-add-equality-mconstraint");
+  if (argc == 4) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_mfunc, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            /* native sequence? */
+            if (scm_is_vector(argv[3])) {
+              unsigned int size = scm_c_vector_length(argv[3]);
+              if (size == 0) {
+                /* an empty sequence can be of any type */
+                _v = 1;
+              } else {
+                /* check the first element only */
+                double* x;
+                SCM o = scm_vector_ref(argv[3],scm_from_ulong(0));
+                _v = scm_is_number(o) ? 1 : 0;
+              }
+            } else if (scm_is_null(argv[3])) {
+              /* again, an empty sequence can be of any type */
+              _v = 1;
+            } else if (scm_is_pair(argv[3])) {
+              /* check the first element only */
+              double* x;
+              SCM head = SCM_CAR(argv[3]);
+              _v = scm_is_number(head) ? 1 : 0;
+            } else {
+              /* wrapped vector? */
+              std::vector<double >* v;
+              _v = (SWIG_ConvertPtr(argv[3],(void **) &v, 
+                  SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+            }
+          }
+          if (_v) {
+            return _wrap_nlopt_opt_add_equality_mconstraint__SWIG_0(argc,argv);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 6) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_nlopt_mfunc, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            void *ptr;
+            int res = SWIG_ConvertPtr(argv[3], &ptr, SWIGTYPE_p_nlopt_munge, 0);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            {
+              void *ptr;
+              int res = SWIG_ConvertPtr(argv[4], &ptr, SWIGTYPE_p_nlopt_munge, 0);
+              _v = SWIG_CheckState(res);
+            }
+            if (_v) {
+              {
+                /* native sequence? */
+                if (scm_is_vector(argv[5])) {
+                  unsigned int size = scm_c_vector_length(argv[5]);
+                  if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    _v = 1;
+                  } else {
+                    /* check the first element only */
+                    double* x;
+                    SCM o = scm_vector_ref(argv[5],scm_from_ulong(0));
+                    _v = scm_is_number(o) ? 1 : 0;
+                  }
+                } else if (scm_is_null(argv[5])) {
+                  /* again, an empty sequence can be of any type */
+                  _v = 1;
+                } else if (scm_is_pair(argv[5])) {
+                  /* check the first element only */
+                  double* x;
+                  SCM head = SCM_CAR(argv[5]);
+                  _v = scm_is_number(head) ? 1 : 0;
+                } else {
+                  /* wrapped vector? */
+                  std::vector<double >* v;
+                  _v = (SWIG_ConvertPtr(argv[5],(void **) &v, 
+                      SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+                }
+              }
+              if (_v) {
+                return _wrap_nlopt_opt_add_equality_mconstraint__SWIG_1(argc,argv);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-add-equality-mconstraint", "No matching method for generic function `nlopt_opt_add_equality_mconstraint'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_lower_bounds__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-lower-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(argv[1]);
+  }
+  try {
+    (arg1)->set_lower_bounds(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_lower_bounds__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-lower-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (std::vector< double > *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_std__vectorT_double_t, 2, 0);
+  }
+  ((nlopt::opt const *)arg1)->get_lower_bounds(*arg2);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_lower_bounds__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-lower-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = ((nlopt::opt const *)arg1)->get_lower_bounds();
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_lower_bounds(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-get-lower-bounds"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-get-lower-bounds");
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_nlopt_opt_get_lower_bounds__SWIG_1(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_get_lower_bounds__SWIG_0(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-get-lower-bounds", "No matching method for generic function `nlopt_opt_get_lower_bounds'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_lower_bounds__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-lower-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    (arg1)->set_lower_bounds((std::vector< double > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_lower_bounds(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-lower-bounds"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-set-lower-bounds");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_real_p(argv[1])) ? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_lower_bounds__SWIG_0(argc,argv);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_lower_bounds__SWIG_1(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-lower-bounds", "No matching method for generic function `nlopt_opt_set_lower_bounds'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_upper_bounds__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-upper-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(argv[1]);
+  }
+  try {
+    (arg1)->set_upper_bounds(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_upper_bounds__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-upper-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (std::vector< double > *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_std__vectorT_double_t, 2, 0);
+  }
+  ((nlopt::opt const *)arg1)->get_upper_bounds(*arg2);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_upper_bounds__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-upper-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = ((nlopt::opt const *)arg1)->get_upper_bounds();
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_upper_bounds(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-get-upper-bounds"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-get-upper-bounds");
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_nlopt_opt_get_upper_bounds__SWIG_1(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_get_upper_bounds__SWIG_0(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-get-upper-bounds", "No matching method for generic function `nlopt_opt_get_upper_bounds'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_upper_bounds__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-upper-bounds"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    (arg1)->set_upper_bounds((std::vector< double > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_upper_bounds(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-upper-bounds"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-set-upper-bounds");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_real_p(argv[1])) ? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_upper_bounds__SWIG_0(argc,argv);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_upper_bounds__SWIG_1(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-upper-bounds", "No matching method for generic function `nlopt_opt_set_upper_bounds'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_stopval (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-stopval"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->get_stopval();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_stopval (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-stopval"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  try {
+    (arg1)->set_stopval(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_ftol_rel (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-ftol-rel"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->get_ftol_rel();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_ftol_rel (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-ftol-rel"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  try {
+    (arg1)->set_ftol_rel(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_ftol_abs (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-ftol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->get_ftol_abs();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_ftol_abs (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-ftol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  try {
+    (arg1)->set_ftol_abs(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_xtol_rel (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-xtol-rel"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->get_xtol_rel();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_xtol_rel (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-xtol-rel"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  try {
+    (arg1)->set_xtol_rel(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_xtol_abs__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-xtol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(argv[1]);
+  }
+  try {
+    (arg1)->set_xtol_abs(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_xtol_abs__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-xtol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (std::vector< double > *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_std__vectorT_double_t, 2, 0);
+  }
+  ((nlopt::opt const *)arg1)->get_xtol_abs(*arg2);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_xtol_abs__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-xtol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = ((nlopt::opt const *)arg1)->get_xtol_abs();
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_xtol_abs(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-get-xtol-abs"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-get-xtol-abs");
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_nlopt_opt_get_xtol_abs__SWIG_1(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_get_xtol_abs__SWIG_0(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-get-xtol-abs", "No matching method for generic function `nlopt_opt_get_xtol_abs'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_xtol_abs__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-xtol-abs"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    (arg1)->set_xtol_abs((std::vector< double > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_xtol_abs(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-xtol-abs"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-set-xtol-abs");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_real_p(argv[1])) ? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_xtol_abs__SWIG_0(argc,argv);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_xtol_abs__SWIG_1(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-xtol-abs", "No matching method for generic function `nlopt_opt_set_xtol_abs'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_maxeval (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-maxeval"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  int result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (int)((nlopt::opt const *)arg1)->get_maxeval();
+  {
+    gswig_result = scm_from_long(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_maxeval (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-maxeval"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (int) scm_to_int(s_1);
+  }
+  try {
+    (arg1)->set_maxeval(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_maxtime (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-maxtime"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  double result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (double)((nlopt::opt const *)arg1)->get_maxtime();
+  {
+    gswig_result = scm_from_double(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_maxtime (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-maxtime"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(s_1);
+  }
+  try {
+    (arg1)->set_maxtime(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_force_stop (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-force-stop"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  int result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (int)((nlopt::opt const *)arg1)->get_force_stop();
+  {
+    gswig_result = scm_from_long(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_force_stop (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-force-stop"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (int) scm_to_int(s_1);
+  }
+  try {
+    (arg1)->set_force_stop(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_force_stop (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-force-stop"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  try {
+    (arg1)->force_stop();
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_local_optimizer (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-local-optimizer"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::opt *arg2 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (nlopt::opt *)SWIG_MustGetPtr(s_1, SWIGTYPE_p_nlopt__opt, 2, 0);
+  }
+  try {
+    (arg1)->set_local_optimizer((nlopt::opt const &)*arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_population (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-population"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  unsigned int result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_population();
+  {
+    gswig_result = scm_from_ulong(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_population (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-population"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  unsigned int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (unsigned int) scm_to_uint(s_1);
+  }
+  try {
+    (arg1)->set_population(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_vector_storage (SCM s_0)
+{
+#define FUNC_NAME "nlopt-opt-get-vector-storage"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  unsigned int result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_vector_storage();
+  {
+    gswig_result = scm_from_ulong(result);
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_vector_storage (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-vector-storage"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  unsigned int arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (unsigned int) scm_to_uint(s_1);
+  }
+  try {
+    (arg1)->set_vector_storage(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_initial_step__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (double) scm_to_double(argv[1]);
+  }
+  try {
+    (arg1)->set_initial_step(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_initial_step__SWIG_0 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    arg2 = (std::vector< double > *)SWIG_MustGetPtr(argv[1], SWIGTYPE_p_std__vectorT_double_t, 2, 0);
+  }
+  ((nlopt::opt const *)arg1)->get_initial_step(*arg2);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_initial_step__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  result = ((nlopt::opt const *)arg1)->get_initial_step();
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_initial_step__SWIG_1 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-set-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    (arg1)->set_initial_step((std::vector< double > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_initial_step(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-set-initial-step"
+  SCM argv[2];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 2, "nlopt-opt-set-initial-step");
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        _v = scm_is_true(scm_real_p(argv[1])) ? 1 : 0;
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_initial_step__SWIG_0(argc,argv);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_set_initial_step__SWIG_1(argc,argv);
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-set-initial-step", "No matching method for generic function `nlopt_opt_set_initial_step'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_set_default_initial_step (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-set-default-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(s_1)) {
+      unsigned long size = scm_c_vector_length(s_1);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(s_1,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, s_1);
+      }
+    } else if (scm_is_null(s_1)) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(s_1)) {
+      SCM v = scm_vector(s_1);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, s_1);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(s_1,SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  try {
+    (arg1)->set_default_initial_step((std::vector< double > const &)*arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    scm_throw(gh_symbol2scm("bad-alloc"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  catch(std::invalid_argument &_e) {
+    scm_throw(gh_symbol2scm("invalid-argument"), 
+      scm_list_1(scm_from_locale_string((_e).what())));
+    
+  }
+  
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_initial_step__SWIG_2 (int argc, SCM *argv)
+{
+#define FUNC_NAME "nlopt-opt-get-initial-step"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > *arg3 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(argv[0], SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(argv[1])) {
+      unsigned long size = scm_c_vector_length(argv[1]);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(argv[1],scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else if (scm_is_null(argv[1])) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(argv[1])) {
+      SCM v = scm_vector(argv[1]);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, argv[1]);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(argv[1],SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  {
+    arg3 = (std::vector< double > *)SWIG_MustGetPtr(argv[2], SWIGTYPE_p_std__vectorT_double_t, 3, 0);
+  }
+  ((nlopt::opt const *)arg1)->get_initial_step((std::vector< double > const &)*arg2,*arg3);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_initial_step(SCM rest)
+{
+#define FUNC_NAME "nlopt-opt-get-initial-step"
+  SCM argv[3];
+  int argc = SWIG_Guile_GetArgs (argv, rest, 0, 3, "nlopt-opt-get-initial-step");
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_nlopt_opt_get_initial_step__SWIG_1(argc,argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        void *ptr;
+        int res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_opt_get_initial_step__SWIG_0(argc,argv);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_nlopt__opt, 0);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        /* native sequence? */
+        if (scm_is_vector(argv[1])) {
+          unsigned int size = scm_c_vector_length(argv[1]);
+          if (size == 0) {
+            /* an empty sequence can be of any type */
+            _v = 1;
+          } else {
+            /* check the first element only */
+            double* x;
+            SCM o = scm_vector_ref(argv[1],scm_from_ulong(0));
+            _v = scm_is_number(o) ? 1 : 0;
+          }
+        } else if (scm_is_null(argv[1])) {
+          /* again, an empty sequence can be of any type */
+          _v = 1;
+        } else if (scm_is_pair(argv[1])) {
+          /* check the first element only */
+          double* x;
+          SCM head = SCM_CAR(argv[1]);
+          _v = scm_is_number(head) ? 1 : 0;
+        } else {
+          /* wrapped vector? */
+          std::vector<double >* v;
+          _v = (SWIG_ConvertPtr(argv[1],(void **) &v, 
+              SWIGTYPE_p_std__vectorT_double_t, 0) != -1) ? 1 : 0;
+        }
+      }
+      if (_v) {
+        {
+          void *ptr;
+          int res = SWIG_ConvertPtr(argv[2], &ptr, SWIGTYPE_p_std__vectorT_double_t, 0);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_opt_get_initial_step__SWIG_2(argc,argv);
+        }
+      }
+    }
+  }
+  
+  scm_misc_error("nlopt-opt-get-initial-step", "No matching method for generic function `nlopt_opt_get_initial_step'", SCM_EOL);
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_opt_get_initial_step_ (SCM s_0, SCM s_1)
+{
+#define FUNC_NAME "nlopt-opt-get-initial-step-"
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  std::vector< double > temp2 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  std::vector< double > result;
+  
+  {
+    arg1 = (nlopt::opt *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_nlopt__opt, 1, 0);
+  }
+  {
+    if (scm_is_vector(s_1)) {
+      unsigned long size = scm_c_vector_length(s_1);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(s_1,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, s_1);
+      }
+    } else if (scm_is_null(s_1)) {
+      temp2 = std::vector<double >();
+      arg2 = &temp2;
+    } else if (scm_is_pair(s_1)) {
+      SCM v = scm_vector(s_1);
+      unsigned long size = scm_c_vector_length(v);
+      temp2 = std::vector<double >(size);
+      arg2 = &temp2;
+      for (unsigned long i=0; i<size; i++) {
+        SCM o = scm_vector_ref(v,scm_from_ulong(i));
+        if (scm_is_number(o))
+        temp2[i] = (double)(scm_to_double(o));
+        else
+        scm_wrong_type_arg(FUNC_NAME, 2, s_1);
+      }
+    } else {
+      arg2 = (std::vector< double > *) SWIG_MustGetPtr(s_1,SWIGTYPE_p_std__vectorT_double_t,2, 0);
+    }
+  }
+  result = ((nlopt::opt const *)arg1)->get_initial_step_((std::vector< double > const &)*arg2);
+  {
+    gswig_result = scm_make_vector(scm_from_long((&result)->size()),SCM_UNSPECIFIED);
+    for (unsigned int i=0; i<(&result)->size(); i++) {
+      SCM x = scm_from_double(((std::vector< double > &)result)[i]);
+      scm_vector_set_x(gswig_result,scm_from_long(i),x);
+    }
+  }
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_srand (SCM s_0)
+{
+#define FUNC_NAME "nlopt-srand"
+  unsigned long arg1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (unsigned long) scm_to_ulong(s_0);
+  }
+  nlopt::srand(arg1);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_srand_time ()
+{
+#define FUNC_NAME "nlopt-srand-time"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  nlopt::srand_time();
+  gswig_result = SCM_UNSPECIFIED;
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_version (SCM s_0, SCM s_1, SCM s_2)
+{
+#define FUNC_NAME "nlopt-version"
+  int *arg1 = 0 ;
+  int *arg2 = 0 ;
+  int *arg3 = 0 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  
+  {
+    arg1 = (int *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_int, 1, 0);
+  }
+  {
+    arg2 = (int *)SWIG_MustGetPtr(s_1, SWIGTYPE_p_int, 2, 0);
+  }
+  {
+    arg3 = (int *)SWIG_MustGetPtr(s_2, SWIGTYPE_p_int, 3, 0);
+  }
+  nlopt::version(*arg1,*arg2,*arg3);
+  gswig_result = SCM_UNSPECIFIED;
+  
+  
+  
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_version_major ()
+{
+#define FUNC_NAME "nlopt-version-major"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  int result;
+  
+  result = (int)nlopt::version_major();
+  {
+    gswig_result = scm_from_long(result);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_version_minor ()
+{
+#define FUNC_NAME "nlopt-version-minor"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  int result;
+  
+  result = (int)nlopt::version_minor();
+  {
+    gswig_result = scm_from_long(result);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_version_bugfix ()
+{
+#define FUNC_NAME "nlopt-version-bugfix"
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  int result;
+  
+  result = (int)nlopt::version_bugfix();
+  {
+    gswig_result = scm_from_long(result);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+static SCM
+_wrap_nlopt_algorithm_name (SCM s_0)
+{
+#define FUNC_NAME "nlopt-algorithm-name"
+  nlopt::algorithm arg1 ;
+  SCM gswig_result;
+  SWIGUNUSED int gswig_list_p = 0;
+  char *result = 0 ;
+  
+  {
+    arg1 = (nlopt::algorithm) scm_to_int(s_0); 
+  }
+  result = (char *)nlopt::algorithm_name(arg1);
+  {
+    gswig_result = SWIG_str02scm((const char *)result);
+  }
+  
+  return gswig_result;
+#undef FUNC_NAME
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double = {"_p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double", "nlopt::vfunc|double (*)(std::vector< double > const &,std::vector< double > &,void *)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__forced_stop = {"_p_nlopt__forced_stop", "nlopt::forced_stop *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__opt = {"_p_nlopt__opt", "nlopt::opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__roundoff_limited = {"_p_nlopt__roundoff_limited", "nlopt::roundoff_limited *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_func = {"_p_nlopt_func", "nlopt::func *|nlopt_func *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_mfunc = {"_p_nlopt_mfunc", "nlopt_mfunc *|nlopt::mfunc *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_munge = {"_p_nlopt_munge", "nlopt_munge *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_opt = {"_p_nlopt_opt", "nlopt_opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_result = {"_p_nlopt_result", "nlopt_result *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__out_of_range = {"_p_std__out_of_range", "std::out_of_range *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorT_double_t = {"_p_std__vectorT_double_t", "std::vector< double > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "SCM *|unsigned long *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+  &_swigt__p_double,
+  &_swigt__p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double,
+  &_swigt__p_int,
+  &_swigt__p_nlopt__forced_stop,
+  &_swigt__p_nlopt__opt,
+  &_swigt__p_nlopt__roundoff_limited,
+  &_swigt__p_nlopt_func,
+  &_swigt__p_nlopt_mfunc,
+  &_swigt__p_nlopt_munge,
+  &_swigt__p_nlopt_opt,
+  &_swigt__p_nlopt_result,
+  &_swigt__p_std__out_of_range,
+  &_swigt__p_std__vectorT_double_t,
+  &_swigt__p_unsigned_long,
+};
+
+static swig_cast_info _swigc__p_double[] = {  {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double[] = {  {&_swigt__p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__forced_stop[] = {  {&_swigt__p_nlopt__forced_stop, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__opt[] = {  {&_swigt__p_nlopt__opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__roundoff_limited[] = {  {&_swigt__p_nlopt__roundoff_limited, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_func[] = {  {&_swigt__p_nlopt_func, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_mfunc[] = {  {&_swigt__p_nlopt_mfunc, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_munge[] = {  {&_swigt__p_nlopt_munge, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_opt[] = {  {&_swigt__p_nlopt_opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_result[] = {  {&_swigt__p_nlopt_result, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__out_of_range[] = {  {&_swigt__p_std__out_of_range, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorT_double_t[] = {  {&_swigt__p_std__vectorT_double_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long[] = {  {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+  _swigc__p_double,
+  _swigc__p_f_r_q_const__std__vector__double___r_std__vector__double___p_void__double,
+  _swigc__p_int,
+  _swigc__p_nlopt__forced_stop,
+  _swigc__p_nlopt__opt,
+  _swigc__p_nlopt__roundoff_limited,
+  _swigc__p_nlopt_func,
+  _swigc__p_nlopt_mfunc,
+  _swigc__p_nlopt_munge,
+  _swigc__p_nlopt_opt,
+  _swigc__p_nlopt_result,
+  _swigc__p_std__out_of_range,
+  _swigc__p_std__vectorT_double_t,
+  _swigc__p_unsigned_long,
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ *  1) If the cast->type has already been loaded AND the type we are adding
+ *     casting info to has not been loaded (it is in this module), THEN we
+ *     replace the cast->type pointer with the type pointer that has already
+ *     been loaded.
+ *  2) If BOTH types (the one we are adding casting info to, and the
+ *     cast->type) are loaded, THEN the cast info has already been loaded by
+ *     the previous module so we just ignore it.
+ *  3) Finally, if cast->type has not already been loaded, then we add that
+ *     swig_cast_info to the linked list (because the cast->type) pointer will
+ *     be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+  size_t i;
+  swig_module_info *module_head, *iter;
+  int found, init;
+  
+  /* check to see if the circular list has been setup, if not, set it up */
+  if (swig_module.next==0) {
+    /* Initialize the swig_module */
+    swig_module.type_initial = swig_type_initial;
+    swig_module.cast_initial = swig_cast_initial;
+    swig_module.next = &swig_module;
+    init = 1;
+  } else {
+    init = 0;
+  }
+  
+  /* Try and load any already created modules */
+  module_head = SWIG_GetModule(clientdata);
+  if (!module_head) {
+    /* This is the first module loaded for this interpreter */
+    /* so set the swig module into the interpreter */
+    SWIG_SetModule(clientdata, &swig_module);
+    module_head = &swig_module;
+  } else {
+    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+    found=0;
+    iter=module_head;
+    do {
+      if (iter==&swig_module) {
+        found=1;
+        break;
+      }
+      iter=iter->next;
+    } while (iter!= module_head);
+    
+    /* if the is found in the list, then all is done and we may leave */
+    if (found) return;
+    /* otherwise we must add out module into the list */
+    swig_module.next = module_head->next;
+    module_head->next = &swig_module;
+  }
+  
+  /* When multiple interpreters are used, a module could have already been initialized in
+       a different interpreter, but not yet have a pointer in this interpreter.
+       In this case, we do not want to continue adding types... everything should be
+       set up already */
+  if (init == 0) return;
+  
+  /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+  for (i = 0; i < swig_module.size; ++i) {
+    swig_type_info *type = 0;
+    swig_type_info *ret;
+    swig_cast_info *cast;
+    
+#ifdef SWIGRUNTIME_DEBUG
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+    
+    /* if there is another module already loaded */
+    if (swig_module.next != &swig_module) {
+      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+    }
+    if (type) {
+      /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+      if (swig_module.type_initial[i]->clientdata) {
+        type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+      }
+    } else {
+      type = swig_module.type_initial[i];
+    }
+    
+    /* Insert casting types */
+    cast = swig_module.cast_initial[i];
+    while (cast->type) {
+      /* Don't need to add information already in the list */
+      ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+      if (swig_module.next != &swig_module) {
+        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+        if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+      }
+      if (ret) {
+        if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+          printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+          cast->type = ret;
+          ret = 0;
+        } else {
+          /* Check for casting already in the list */
+          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+          if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+          if (!ocast) ret = 0;
+        }
+      }
+      
+      if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+        if (type->cast) {
+          type->cast->prev = cast;
+          cast->next = type->cast;
+        }
+        type->cast = cast;
+      }
+      cast++;
+    }
+    /* Set entry in modules->types array equal to the type */
+    swig_module.types[i] = type;
+  }
+  swig_module.types[i] = 0;
+  
+#ifdef SWIGRUNTIME_DEBUG
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+  for (i = 0; i < swig_module.size; ++i) {
+    int j = 0;
+    swig_cast_info *cast = swig_module.cast_initial[i];
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+    while (cast->type) {
+      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+      cast++;
+      ++j;
+    }
+    printf("---- Total casts: %d\n",j);
+  }
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types.  It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+  size_t i;
+  swig_cast_info *equiv;
+  static int init_run = 0;
+  
+  if (init_run) return;
+  init_run = 1;
+  
+  for (i = 0; i < swig_module.size; i++) {
+    if (swig_module.types[i]->clientdata) {
+      equiv = swig_module.types[i]->cast;
+      while (equiv) {
+        if (!equiv->converter) {
+          if (equiv->type && !equiv->type->clientdata)
+          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+        }
+        equiv = equiv->next;
+      }
+    }
+  }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+  /* c-mode */
+#endif
+}
+#endif
+
+
+SWIG_GUILE_INIT_STATIC void
+SWIG_init(void)
+{
+  SWIG_InitializeModule(0);
+  SWIG_PropagateClientData();
+  
+  SWIG_TypeClientData(SWIGTYPE_p_std__vectorT_double_t, (void *) &_swig_guile_clientdatanlopt_doublevector);
+  scm_c_define_gsubr("new-nlopt-doublevector", 0, 0, 1, (swig_guile_proc) _wrap_new_nlopt_doublevector);
+  scm_c_define_gsubr("nlopt-doublevector-length", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_length);
+  scm_c_define_gsubr("nlopt-doublevector-empty?", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_emptyq___);
+  scm_c_define_gsubr("nlopt-doublevector-clear!", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_clearN___);
+  scm_c_define_gsubr("nlopt-doublevector-push!", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_pushN___);
+  scm_c_define_gsubr("nlopt-doublevector-pop!", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_popN___);
+  scm_c_define_gsubr("nlopt-doublevector-ref", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_ref);
+  scm_c_define_gsubr("nlopt-doublevector-set!", 3, 0, 0, (swig_guile_proc) _wrap_nlopt_doublevector_setN___);
+  ((swig_guile_clientdata *)(SWIGTYPE_p_std__vectorT_double_t->clientdata))->destroy = (guile_destructor) _wrap_delete_nlopt_doublevector;
+  scm_c_define_gsubr("delete-nlopt-doublevector", 1, 0, 0, (swig_guile_proc) _wrap_delete_nlopt_doublevector);
+  scm_c_define_gsubr("nlopt-get-initial-step", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_get_initial_step);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT-L", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT_L);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT-L-RAND", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT_L_RAND);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT-NOSCAL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT_NOSCAL);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT-L-NOSCAL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT_L_NOSCAL);
+  scm_c_define_gsubr("NLOPT-GN-DIRECT-L-RAND-NOSCAL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_DIRECT_L_RAND_NOSCAL);
+  scm_c_define_gsubr("NLOPT-GN-ORIG-DIRECT", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_ORIG_DIRECT);
+  scm_c_define_gsubr("NLOPT-GN-ORIG-DIRECT-L", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_ORIG_DIRECT_L);
+  scm_c_define_gsubr("NLOPT-GD-STOGO", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GD_STOGO);
+  scm_c_define_gsubr("NLOPT-GD-STOGO-RAND", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GD_STOGO_RAND);
+  scm_c_define_gsubr("NLOPT-LD-LBFGS-NOCEDAL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_LBFGS_NOCEDAL);
+  scm_c_define_gsubr("NLOPT-LD-LBFGS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_LBFGS);
+  scm_c_define_gsubr("NLOPT-LN-PRAXIS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_PRAXIS);
+  scm_c_define_gsubr("NLOPT-LD-VAR1", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_VAR1);
+  scm_c_define_gsubr("NLOPT-LD-VAR2", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_VAR2);
+  scm_c_define_gsubr("NLOPT-LD-TNEWTON", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_TNEWTON);
+  scm_c_define_gsubr("NLOPT-LD-TNEWTON-RESTART", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_TNEWTON_RESTART);
+  scm_c_define_gsubr("NLOPT-LD-TNEWTON-PRECOND", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_TNEWTON_PRECOND);
+  scm_c_define_gsubr("NLOPT-LD-TNEWTON-PRECOND-RESTART", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_TNEWTON_PRECOND_RESTART);
+  scm_c_define_gsubr("NLOPT-GN-CRS2-LM", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_CRS2_LM);
+  scm_c_define_gsubr("NLOPT-GN-MLSL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_MLSL);
+  scm_c_define_gsubr("NLOPT-GD-MLSL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GD_MLSL);
+  scm_c_define_gsubr("NLOPT-GN-MLSL-LDS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_MLSL_LDS);
+  scm_c_define_gsubr("NLOPT-GD-MLSL-LDS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GD_MLSL_LDS);
+  scm_c_define_gsubr("NLOPT-LD-MMA", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_MMA);
+  scm_c_define_gsubr("NLOPT-LN-COBYLA", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_COBYLA);
+  scm_c_define_gsubr("NLOPT-LN-NEWUOA", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_NEWUOA);
+  scm_c_define_gsubr("NLOPT-LN-NEWUOA-BOUND", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_NEWUOA_BOUND);
+  scm_c_define_gsubr("NLOPT-LN-NELDERMEAD", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_NELDERMEAD);
+  scm_c_define_gsubr("NLOPT-LN-SBPLX", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_SBPLX);
+  scm_c_define_gsubr("NLOPT-LN-AUGLAG", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_AUGLAG);
+  scm_c_define_gsubr("NLOPT-LD-AUGLAG", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_AUGLAG);
+  scm_c_define_gsubr("NLOPT-LN-AUGLAG-EQ", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_AUGLAG_EQ);
+  scm_c_define_gsubr("NLOPT-LD-AUGLAG-EQ", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_AUGLAG_EQ);
+  scm_c_define_gsubr("NLOPT-LN-BOBYQA", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LN_BOBYQA);
+  scm_c_define_gsubr("NLOPT-GN-ISRES", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_ISRES);
+  scm_c_define_gsubr("NLOPT-AUGLAG", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_AUGLAG);
+  scm_c_define_gsubr("NLOPT-AUGLAG-EQ", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_AUGLAG_EQ);
+  scm_c_define_gsubr("NLOPT-G-MLSL", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_G_MLSL);
+  scm_c_define_gsubr("NLOPT-G-MLSL-LDS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_G_MLSL_LDS);
+  scm_c_define_gsubr("NLOPT-LD-SLSQP", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_SLSQP);
+  scm_c_define_gsubr("NLOPT-LD-CCSAQ", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_LD_CCSAQ);
+  scm_c_define_gsubr("NLOPT-GN-ESCH", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_GN_ESCH);
+  scm_c_define_gsubr("NLOPT-NUM-ALGORITHMS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_NUM_ALGORITHMS);
+  scm_c_define_gsubr("NLOPT-FAILURE", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_FAILURE);
+  scm_c_define_gsubr("NLOPT-INVALID-ARGS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_INVALID_ARGS);
+  scm_c_define_gsubr("NLOPT-OUT-OF-MEMORY", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_OUT_OF_MEMORY);
+  scm_c_define_gsubr("NLOPT-ROUNDOFF-LIMITED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_ROUNDOFF_LIMITED);
+  scm_c_define_gsubr("NLOPT-FORCED-STOP", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_FORCED_STOP);
+  scm_c_define_gsubr("NLOPT-SUCCESS", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_SUCCESS);
+  scm_c_define_gsubr("NLOPT-STOPVAL-REACHED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_STOPVAL_REACHED);
+  scm_c_define_gsubr("NLOPT-FTOL-REACHED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_FTOL_REACHED);
+  scm_c_define_gsubr("NLOPT-XTOL-REACHED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_XTOL_REACHED);
+  scm_c_define_gsubr("NLOPT-MAXEVAL-REACHED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_MAXEVAL_REACHED);
+  scm_c_define_gsubr("NLOPT-MAXTIME-REACHED", 0, 0, 0, (swig_guile_proc) _wrap_NLOPT_MAXTIME_REACHED);
+  SWIG_TypeClientData(SWIGTYPE_p_nlopt__roundoff_limited, (void *) &_swig_guile_clientdatanlopt_roundoff_limited);
+  scm_c_define_gsubr("new-nlopt-roundoff-limited", 0, 0, 0, (swig_guile_proc) _wrap_new_nlopt_roundoff_limited);
+  ((swig_guile_clientdata *)(SWIGTYPE_p_nlopt__roundoff_limited->clientdata))->destroy = (guile_destructor) _wrap_delete_nlopt_roundoff_limited;
+  scm_c_define_gsubr("delete-nlopt-roundoff-limited", 1, 0, 0, (swig_guile_proc) _wrap_delete_nlopt_roundoff_limited);
+  SWIG_TypeClientData(SWIGTYPE_p_nlopt__forced_stop, (void *) &_swig_guile_clientdatanlopt_forced_stop);
+  scm_c_define_gsubr("new-nlopt-forced-stop", 0, 0, 0, (swig_guile_proc) _wrap_new_nlopt_forced_stop);
+  ((swig_guile_clientdata *)(SWIGTYPE_p_nlopt__forced_stop->clientdata))->destroy = (guile_destructor) _wrap_delete_nlopt_forced_stop;
+  scm_c_define_gsubr("delete-nlopt-forced-stop", 1, 0, 0, (swig_guile_proc) _wrap_delete_nlopt_forced_stop);
+  SWIG_TypeClientData(SWIGTYPE_p_nlopt__opt, (void *) &_swig_guile_clientdatanlopt_opt);
+  ((swig_guile_clientdata *)(SWIGTYPE_p_nlopt__opt->clientdata))->destroy = (guile_destructor) _wrap_delete_nlopt_opt;
+  scm_c_define_gsubr("delete-nlopt-opt", 1, 0, 0, (swig_guile_proc) _wrap_delete_nlopt_opt);
+  scm_c_define_gsubr("new-nlopt-opt", 0, 0, 1, (swig_guile_proc) _wrap_new_nlopt_opt);
+  scm_c_define_gsubr("nlopt-opt-optimize", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_optimize);
+  scm_c_define_gsubr("nlopt-opt-last-optimize-result", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_last_optimize_result);
+  scm_c_define_gsubr("nlopt-opt-last-optimum-value", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_last_optimum_value);
+  scm_c_define_gsubr("nlopt-opt-get-algorithm", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_algorithm);
+  scm_c_define_gsubr("nlopt-opt-get-algorithm-name", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_algorithm_name);
+  scm_c_define_gsubr("nlopt-opt-get-dimension", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_dimension);
+  scm_c_define_gsubr("nlopt-opt-set-min-objective", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_min_objective);
+  scm_c_define_gsubr("nlopt-opt-set-max-objective", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_max_objective);
+  scm_c_define_gsubr("nlopt-opt-remove-inequality-constraints", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_remove_inequality_constraints);
+  scm_c_define_gsubr("nlopt-opt-remove-equality-constraints", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_remove_equality_constraints);
+  scm_c_define_gsubr("nlopt-opt-add-inequality-constraint", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_add_inequality_constraint);
+  scm_c_define_gsubr("nlopt-opt-add-equality-constraint", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_add_equality_constraint);
+  scm_c_define_gsubr("nlopt-opt-add-inequality-mconstraint", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_add_inequality_mconstraint);
+  scm_c_define_gsubr("nlopt-opt-add-equality-mconstraint", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_add_equality_mconstraint);
+  scm_c_define_gsubr("nlopt-opt-get-lower-bounds", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_get_lower_bounds);
+  scm_c_define_gsubr("nlopt-opt-set-lower-bounds", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_lower_bounds);
+  scm_c_define_gsubr("nlopt-opt-get-upper-bounds", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_get_upper_bounds);
+  scm_c_define_gsubr("nlopt-opt-set-upper-bounds", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_upper_bounds);
+  scm_c_define_gsubr("nlopt-opt-get-stopval", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_stopval);
+  scm_c_define_gsubr("nlopt-opt-set-stopval", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_stopval);
+  scm_c_define_gsubr("nlopt-opt-get-ftol-rel", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_ftol_rel);
+  scm_c_define_gsubr("nlopt-opt-set-ftol-rel", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_ftol_rel);
+  scm_c_define_gsubr("nlopt-opt-get-ftol-abs", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_ftol_abs);
+  scm_c_define_gsubr("nlopt-opt-set-ftol-abs", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_ftol_abs);
+  scm_c_define_gsubr("nlopt-opt-get-xtol-rel", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_xtol_rel);
+  scm_c_define_gsubr("nlopt-opt-set-xtol-rel", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_xtol_rel);
+  scm_c_define_gsubr("nlopt-opt-get-xtol-abs", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_get_xtol_abs);
+  scm_c_define_gsubr("nlopt-opt-set-xtol-abs", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_xtol_abs);
+  scm_c_define_gsubr("nlopt-opt-get-maxeval", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_maxeval);
+  scm_c_define_gsubr("nlopt-opt-set-maxeval", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_maxeval);
+  scm_c_define_gsubr("nlopt-opt-get-maxtime", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_maxtime);
+  scm_c_define_gsubr("nlopt-opt-set-maxtime", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_maxtime);
+  scm_c_define_gsubr("nlopt-opt-get-force-stop", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_force_stop);
+  scm_c_define_gsubr("nlopt-opt-set-force-stop", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_force_stop);
+  scm_c_define_gsubr("nlopt-opt-force-stop", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_force_stop);
+  scm_c_define_gsubr("nlopt-opt-set-local-optimizer", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_local_optimizer);
+  scm_c_define_gsubr("nlopt-opt-get-population", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_population);
+  scm_c_define_gsubr("nlopt-opt-set-population", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_population);
+  scm_c_define_gsubr("nlopt-opt-get-vector-storage", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_vector_storage);
+  scm_c_define_gsubr("nlopt-opt-set-vector-storage", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_vector_storage);
+  scm_c_define_gsubr("nlopt-opt-set-initial-step", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_set_initial_step);
+  scm_c_define_gsubr("nlopt-opt-set-default-initial-step", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_set_default_initial_step);
+  scm_c_define_gsubr("nlopt-opt-get-initial-step", 0, 0, 1, (swig_guile_proc) _wrap_nlopt_opt_get_initial_step);
+  scm_c_define_gsubr("nlopt-opt-get-initial-step-", 2, 0, 0, (swig_guile_proc) _wrap_nlopt_opt_get_initial_step_);
+  scm_c_define_gsubr("nlopt-srand", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_srand);
+  scm_c_define_gsubr("nlopt-srand-time", 0, 0, 0, (swig_guile_proc) _wrap_nlopt_srand_time);
+  scm_c_define_gsubr("nlopt-version", 3, 0, 0, (swig_guile_proc) _wrap_nlopt_version);
+  scm_c_define_gsubr("nlopt-version-major", 0, 0, 0, (swig_guile_proc) _wrap_nlopt_version_major);
+  scm_c_define_gsubr("nlopt-version-minor", 0, 0, 0, (swig_guile_proc) _wrap_nlopt_version_minor);
+  scm_c_define_gsubr("nlopt-version-bugfix", 0, 0, 0, (swig_guile_proc) _wrap_nlopt_version_bugfix);
+  scm_c_define_gsubr("nlopt-algorithm-name", 1, 0, 0, (swig_guile_proc) _wrap_nlopt_algorithm_name);
+}
+
+#ifdef __cplusplus
+}
+#endif
+extern "C" {
+/* Linkage: simple */
+
+}
+
diff --git a/swig/nlopt-guile.i b/swig/nlopt-guile.i
new file mode 100644 (file)
index 0000000..c3eb297
--- /dev/null
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+
+%{
+// work around obsolete stuff used by swig guile
+#if SCM_MAJOR_VERSION >= 2
+#  define gh_symbol2scm scm_from_latin1_symbol
+#else
+#  define gh_symbol2scm scm_str2symbol
+#endif
+%}
+
+%typemap(throws) std::runtime_error %{
+  scm_throw(gh_symbol2scm("runtime-error"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) std::bad_alloc %{
+  scm_throw(gh_symbol2scm("bad-alloc"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) std::invalid_argument %{
+  scm_throw(gh_symbol2scm("invalid-argument"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) nlopt::forced_stop %{
+  scm_throw(gh_symbol2scm("forced-stop"), SCM_EOL);
+%}
+
+%typemap(throws) nlopt::roundoff_limited %{
+  scm_throw(gh_symbol2scm("roundoff-limited"), SCM_EOL);
+%}
+
+%{
+// because our f_data pointer to the Scheme function is stored on the
+// heap, rather than the stack, it may be missed by the Guile garbage
+// collection and be accidentally freed.  Hence, use NLopts munge
+// feature to prevent this, by incrementing Guile's reference count.
+static void *free_guilefunc(void *p) { 
+  scm_gc_unprotect_object((SCM) p); return p; }
+static void *dup_guilefunc(void *p) { 
+  scm_gc_protect_object((SCM) p); return p; }
+
+// func wrapper around Guile function val = f(x, grad)
+static double func_guile(unsigned n, const double *x, double *grad, void *f) {
+  SCM xscm = scm_c_make_vector(n, SCM_UNSPECIFIED);
+  for (unsigned i = 0; i < n; ++i)
+    SCM_SIMPLE_VECTOR_SET(xscm, i, scm_make_real(x[i]));
+  SCM grad_scm = grad ? scm_c_make_vector(n, SCM_UNSPECIFIED) : SCM_BOOL_F;
+  SCM ret = scm_call_2((SCM) f, xscm, grad_scm);
+  if (!scm_real_p(ret))
+    throw std::invalid_argument("invalid result passed to nlopt");
+  if (grad) {
+    for (unsigned i = 0; i < n; ++i) {
+      if (!scm_real_p(ret)) 
+       throw std::invalid_argument("invalid gradient passed to nlopt");
+      grad[i] = scm_to_double(SCM_SIMPLE_VECTOR_REF(grad_scm, i));
+    }
+  }
+  return scm_to_double(ret);
+}
+%}
+
+%typemap(in)(nlopt::func f, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = func_guile;
+  $2 = dup_guilefunc((void*) $input); // input = SCM pointer to Scheme function
+  $3 = free_guilefunc;
+  $4 = dup_guilefunc;
+}
+%typecheck(SWIG_TYPECHECK_POINTER)(nlopt::func f, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = SCM_NFALSEP(scm_procedure_p($input));
+}
+
+// export constants as variables, rather than as functions returning the value
+%feature("constasvar", "1");
+
+%scheme %{ 
+(load-extension "libnlopt@NLOPT_SUFFIX@_guile.so" "SWIG_init")
+%}
diff --git a/swig/nlopt-python.cpp b/swig/nlopt-python.cpp
new file mode 100644 (file)
index 0000000..30a2dad
--- /dev/null
@@ -0,0 +1,13520 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.12
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+  struct SwigMovePointer {
+    T *ptr;
+    SwigMovePointer(T *p) : ptr(p) { }
+    ~SwigMovePointer() { delete ptr; }
+    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+  } pointer;
+  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+  SwigValueWrapper() : pointer(0) { }
+  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+  operator T&() const { return *pointer.ptr; }
+  T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+  return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__))
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__))
+# else
+#   define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
+/* Use debug wrappers with the Python release dll */
+# undef _DEBUG
+# include <Python.h>
+# define _DEBUG
+#else
+# include <Python.h>
+#endif
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic C API SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+   or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+  creating a static or dynamic library from the SWIG runtime code.
+  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
+
+  But only do this if strictly necessary, ie, if you have problems
+  with your compiler or suchlike.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/*  Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN        0x1
+#define SWIG_CAST_NEW_MEMORY       0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN           0x1
+
+
+/*
+   Flags/methods for returning states.
+
+   The SWIG conversion methods, as ConvertPtr, return an integer
+   that tells if the conversion was successful or not. And if not,
+   an error code can be returned (see swigerrors.swg for the codes).
+
+   Use the following macros/flags to set or process the returning
+   states.
+
+   In old versions of SWIG, code such as the following was usually written:
+
+     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+       // success code
+     } else {
+       //fail code
+     }
+
+   Now you can be more explicit:
+
+    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+    } else {
+      // fail code
+    }
+
+   which is the same really, but now you can also do
+
+    Type *ptr;
+    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+      if (SWIG_IsNewObj(res) {
+        ...
+       delete *ptr;
+      } else {
+        ...
+      }
+    } else {
+      // fail code
+    }
+
+   I.e., now SWIG_ConvertPtr can return new objects and you can
+   identify the case and take care of the deallocation. Of course that
+   also requires SWIG_ConvertPtr to return new result values, such as
+
+      int SWIG_ConvertPtr(obj, ptr,...) {
+        if (<obj is ok>) {
+          if (<need new object>) {
+            *ptr = <ptr to new allocated object>;
+            return SWIG_NEWOBJ;
+          } else {
+            *ptr = <ptr to old object>;
+            return SWIG_OLDOBJ;
+          }
+        } else {
+          return SWIG_BADOBJ;
+        }
+      }
+
+   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+   SWIG errors code.
+
+   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+   allows to return the 'cast rank', for example, if you have this
+
+       int food(double)
+       int fooi(int);
+
+   and you call
+
+      food(1)   // cast rank '1'  (1 -> 1.0)
+      fooi(1)   // cast rank '0'
+
+   just use the SWIG_AddCast()/SWIG_CheckState()
+*/
+
+#define SWIG_OK                    (0)
+#define SWIG_ERROR                 (-1)
+#define SWIG_IsOK(r)               (r >= 0)
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT         (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ                (SWIG_ERROR)
+#define SWIG_OLDOBJ                (SWIG_OK)
+#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+#  ifndef SWIG_TypeRank
+#    define SWIG_TypeRank             unsigned long
+#  endif
+#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
+#    define SWIG_MAXCASTRANK          (2)
+#  endif
+#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
+#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+}
+#else /* no cast-rank mode */
+#  define SWIG_AddCast(r) (r)
+#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+  const char             *name;                        /* mangled name of this type */
+  const char             *str;                 /* human readable name of this type */
+  swig_dycast_func        dcast;               /* dynamic cast function down a hierarchy */
+  struct swig_cast_info  *cast;                        /* linked list of types that can cast into this type */
+  void                   *clientdata;          /* language specific type data */
+  int                    owndata;              /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+  swig_type_info         *type;                        /* pointer to type that is equivalent to this type */
+  swig_converter_func     converter;           /* function to cast the void pointers */
+  struct swig_cast_info  *next;                        /* pointer to next cast in linked list */
+  struct swig_cast_info  *prev;                        /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+  swig_type_info         **types;              /* Array of pointers to swig_type_info structures that are in this module */
+  size_t                 size;                 /* Number of types in this module */
+  struct swig_module_info *next;               /* Pointer to next element in circularly linked list */
+  swig_type_info         **type_initial;       /* Array of initially generated type structures */
+  swig_cast_info         **cast_initial;       /* Array of initially generated casting structures */
+  void                    *clientdata;         /* Language specific module data */
+} swig_module_info;
+
+/*
+  Compare two type names skipping the space characters, therefore
+  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+  Return 0 when the two name types are equivalent, as in
+  strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+                 const char *f2, const char *l2) {
+  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+    while ((*f1 == ' ') && (f1 != l1)) ++f1;
+    while ((*f2 == ' ') && (f2 != l2)) ++f2;
+    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+  }
+  return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCmp(const char *nb, const char *tb) {
+  int equiv = 1;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (equiv != 0 && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
+}
+
+/*
+  Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (strcmp(iter->type->name, c) == 0) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
+}
+
+/*
+  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (iter->type == from) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
+}
+
+/*
+  Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/*
+   Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+  swig_type_info *lastty = ty;
+  if (!ty || !ty->dcast) return ty;
+  while (ty && (ty->dcast)) {
+    ty = (*ty->dcast)(ptr);
+    if (ty) lastty = ty;
+  }
+  return lastty;
+}
+
+/*
+  Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+  return ty->name;
+}
+
+/*
+  Return the pretty name associated with this type,
+  that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+  /* The "str" field contains the equivalent pretty names of the
+     type, separated by vertical-bar characters.  We choose
+     to print the last name, as it is often (?) the most
+     specific. */
+  if (!type) return NULL;
+  if (type->str != NULL) {
+    const char *last_name = type->str;
+    const char *s;
+    for (s = type->str; *s; s++)
+      if (*s == '|') last_name = s+1;
+    return last_name;
+  }
+  else
+    return type->name;
+}
+
+/*
+   Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+  swig_cast_info *cast = ti->cast;
+  /* if (ti->clientdata == clientdata) return; */
+  ti->clientdata = clientdata;
+
+  while (cast) {
+    if (!cast->converter) {
+      swig_type_info *tc = cast->type;
+      if (!tc->clientdata) {
+       SWIG_TypeClientData(tc, clientdata);
+      }
+    }
+    cast = cast->next;
+  }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+  SWIG_TypeClientData(ti, clientdata);
+  ti->owndata = 1;
+}
+
+/*
+  Search for a swig_type_info structure only by mangled name
+  Search is a O(log #types)
+
+  We start searching at module start, and finish searching when start == end.
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+                            swig_module_info *end,
+                           const char *name) {
+  swig_module_info *iter = start;
+  do {
+    if (iter->size) {
+      register size_t l = 0;
+      register size_t r = iter->size - 1;
+      do {
+       /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+       register size_t i = (l + r) >> 1;
+       const char *iname = iter->types[i]->name;
+       if (iname) {
+         register int compare = strcmp(name, iname);
+         if (compare == 0) {
+           return iter->types[i];
+         } else if (compare < 0) {
+           if (i) {
+             r = i - 1;
+           } else {
+             break;
+           }
+         } else if (compare > 0) {
+           l = i + 1;
+         }
+       } else {
+         break; /* should never happen */
+       }
+      } while (l <= r);
+    }
+    iter = iter->next;
+  } while (iter != end);
+  return 0;
+}
+
+/*
+  Search for a swig_type_info structure for either a mangled name or a human readable name.
+  It first searches the mangled names of the types, which is a O(log #types)
+  If a type is not found it then searches the human readable names, which is O(#types).
+
+  We start searching at module start, and finish searching when start == end.
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+                     swig_module_info *end,
+                    const char *name) {
+  /* STEP 1: Search the name field using binary search */
+  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+  if (ret) {
+    return ret;
+  } else {
+    /* STEP 2: If the type hasn't been found, do a complete search
+       of the str field (the human readable name) */
+    swig_module_info *iter = start;
+    do {
+      register size_t i = 0;
+      for (; i < iter->size; ++i) {
+       if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+         return iter->types[i];
+      }
+      iter = iter->next;
+    } while (iter != end);
+  }
+
+  /* neither found a match */
+  return 0;
+}
+
+/*
+   Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+  static const char hex[17] = "0123456789abcdef";
+  register const unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu =  u + sz;
+  for (; u != eu; ++u) {
+    register unsigned char uu = *u;
+    *(c++) = hex[(uu & 0xf0) >> 4];
+    *(c++) = hex[uu & 0xf];
+  }
+  return c;
+}
+
+/*
+   Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+  register unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu = u + sz;
+  for (; u != eu; ++u) {
+    register char d = *(c++);
+    register unsigned char uu;
+    if ((d >= '0') && (d <= '9'))
+      uu = ((d - '0') << 4);
+    else if ((d >= 'a') && (d <= 'f'))
+      uu = ((d - ('a'-10)) << 4);
+    else
+      return (char *) 0;
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu |= (d - '0');
+    else if ((d >= 'a') && (d <= 'f'))
+      uu |= (d - ('a'-10));
+    else
+      return (char *) 0;
+    *u = uu;
+  }
+  return c;
+}
+
+/*
+   Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+  char *r = buff;
+  if ((2*sizeof(void *) + 2) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,&ptr,sizeof(void *));
+  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+  strcpy(r,name);
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      *ptr = (void *) 0;
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+  char *r = buff;
+  size_t lname = (name ? strlen(name) : 0);
+  if ((2*sz + 2 + lname) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,ptr,sz);
+  if (lname) {
+    strncpy(r,name,lname+1);
+  } else {
+    *r = 0;
+  }
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      memset(ptr,0,sz);
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/*  Errors in SWIG */
+#define  SWIG_UnknownError        -1
+#define  SWIG_IOError             -2
+#define  SWIG_RuntimeError        -3
+#define  SWIG_IndexError          -4
+#define  SWIG_TypeError           -5
+#define  SWIG_DivisionByZero      -6
+#define  SWIG_OverflowError       -7
+#define  SWIG_SyntaxError         -8
+#define  SWIG_ValueError          -9
+#define  SWIG_SystemError         -10
+#define  SWIG_AttributeError      -11
+#define  SWIG_MemoryError         -12
+#define  SWIG_NullReferenceError   -13
+
+
+
+/* Compatibility macros for Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+
+#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
+#define PyInt_Check(x) PyLong_Check(x)
+#define PyInt_AsLong(x) PyLong_AsLong(x)
+#define PyInt_FromLong(x) PyLong_FromLong(x)
+#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
+#define PyString_Check(name) PyBytes_Check(name)
+#define PyString_FromString(x) PyUnicode_FromString(x)
+#define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)
+#define PyString_AsString(str) PyBytes_AsString(str)
+#define PyString_Size(str) PyBytes_Size(str)   
+#define PyString_InternFromString(key) PyUnicode_InternFromString(key)
+#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
+#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
+#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
+
+#endif
+
+#ifndef Py_TYPE
+#  define Py_TYPE(op) ((op)->ob_type)
+#endif
+
+/* SWIG APIs for compatibility of both Python 2 & 3 */
+
+#if PY_VERSION_HEX >= 0x03000000
+#  define SWIG_Python_str_FromFormat PyUnicode_FromFormat
+#else
+#  define SWIG_Python_str_FromFormat PyString_FromFormat
+#endif
+
+
+/* Warning: This function will allocate a new string in Python 3,
+ * so please call SWIG_Python_str_DelForPy3(x) to free the space.
+ */
+SWIGINTERN char*
+SWIG_Python_str_AsChar(PyObject *str)
+{
+#if PY_VERSION_HEX >= 0x03000000
+  char *cstr;
+  char *newstr;
+  Py_ssize_t len;
+  str = PyUnicode_AsUTF8String(str);
+  PyBytes_AsStringAndSize(str, &cstr, &len);
+  newstr = (char *) malloc(len+1);
+  memcpy(newstr, cstr, len+1);
+  Py_XDECREF(str);
+  return newstr;
+#else
+  return PyString_AsString(str);
+#endif
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+#  define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
+#else
+#  define SWIG_Python_str_DelForPy3(x) 
+#endif
+
+
+SWIGINTERN PyObject*
+SWIG_Python_str_FromChar(const char *c)
+{
+#if PY_VERSION_HEX >= 0x03000000
+  return PyUnicode_FromString(c); 
+#else
+  return PyString_FromString(c);
+#endif
+}
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+#  define PyOS_snprintf _snprintf
+# else
+#  define PyOS_snprintf snprintf
+# endif
+#endif
+
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
+
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+  va_list ap;
+  char buf[SWIG_PYBUFFER_SIZE * 2];
+  int res;
+  va_start(ap, fmt);
+  res = vsnprintf(buf, sizeof(buf), fmt, ap);
+  va_end(ap);
+  return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
+
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+#  define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+#  define PyObject_GenericGetAttr 0
+# endif
+#endif
+
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+#  define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
+
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+#  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
+
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+#  define PySequence_Size PySequence_Length
+# endif
+#endif
+
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+  PyObject *result = ok ? Py_True : Py_False;
+  Py_INCREF(result);
+  return result;
+}
+#endif
+
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+typedef inquiry lenfunc;
+typedef intargfunc ssizeargfunc;
+typedef intintargfunc ssizessizeargfunc;
+typedef intobjargproc ssizeobjargproc;
+typedef intintobjargproc ssizessizeobjargproc;
+typedef getreadbufferproc readbufferproc;
+typedef getwritebufferproc writebufferproc;
+typedef getsegcountproc segcountproc;
+typedef getcharbufferproc charbufferproc;
+static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
+{
+  long result = 0;
+  PyObject *i = PyNumber_Int(x);
+  if (i) {
+    result = PyInt_AsLong(i);
+    Py_DECREF(i);
+  }
+  return result;
+}
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
+#endif
+
+#if PY_VERSION_HEX < 0x02040000
+#define Py_VISIT(op)                           \
+  do {                                                 \
+    if (op) {                                  \
+      int vret = visit((op), arg);             \
+      if (vret)                                        \
+        return vret;                           \
+    }                                          \
+  } while (0)
+#endif
+
+#if PY_VERSION_HEX < 0x02030000
+typedef struct {
+  PyTypeObject type;
+  PyNumberMethods as_number;
+  PyMappingMethods as_mapping;
+  PySequenceMethods as_sequence;
+  PyBufferProcs as_buffer;
+  PyObject *name, *slots;
+} PyHeapTypeObject;
+#endif
+
+#if PY_VERSION_HEX < 0x02030000
+typedef destructor freefunc;
+#endif
+
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
+     (PY_MAJOR_VERSION > 3))
+# define SWIGPY_USE_CAPSULE
+# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
+
+#if PY_VERSION_HEX < 0x03020000
+#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
+#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+  PyObject* type = 0;
+  switch(code) {
+  case SWIG_MemoryError:
+    type = PyExc_MemoryError;
+    break;
+  case SWIG_IOError:
+    type = PyExc_IOError;
+    break;
+  case SWIG_RuntimeError:
+    type = PyExc_RuntimeError;
+    break;
+  case SWIG_IndexError:
+    type = PyExc_IndexError;
+    break;
+  case SWIG_TypeError:
+    type = PyExc_TypeError;
+    break;
+  case SWIG_DivisionByZero:
+    type = PyExc_ZeroDivisionError;
+    break;
+  case SWIG_OverflowError:
+    type = PyExc_OverflowError;
+    break;
+  case SWIG_SyntaxError:
+    type = PyExc_SyntaxError;
+    break;
+  case SWIG_ValueError:
+    type = PyExc_ValueError;
+    break;
+  case SWIG_SystemError:
+    type = PyExc_SystemError;
+    break;
+  case SWIG_AttributeError:
+    type = PyExc_AttributeError;
+    break;
+  default:
+    type = PyExc_RuntimeError;
+  }
+  return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+  PyObject *type = 0;
+  PyObject *value = 0;
+  PyObject *traceback = 0;
+
+  if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+  if (value) {
+    char *tmp;
+    PyObject *old_str = PyObject_Str(value);
+    PyErr_Clear();
+    Py_XINCREF(type);
+
+    PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+    SWIG_Python_str_DelForPy3(tmp);
+    Py_DECREF(old_str);
+    Py_DECREF(value);
+  } else {
+    PyErr_SetString(PyExc_RuntimeError, mesg);
+  }
+}
+
+#if defined(SWIG_PYTHON_NO_THREADS)
+#  if defined(SWIG_PYTHON_THREADS)
+#    undef SWIG_PYTHON_THREADS
+#  endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+#  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+#    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+#      define SWIG_PYTHON_USE_GIL
+#    endif
+#  endif
+#  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+#    ifndef SWIG_PYTHON_INITIALIZE_THREADS
+#     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() 
+#    endif
+#    ifdef __cplusplus /* C++ code */
+       class SWIG_Python_Thread_Block {
+         bool status;
+         PyGILState_STATE state;
+       public:
+         void end() { if (status) { PyGILState_Release(state); status = false;} }
+         SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+         ~SWIG_Python_Thread_Block() { end(); }
+       };
+       class SWIG_Python_Thread_Allow {
+         bool status;
+         PyThreadState *save;
+       public:
+         void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+         SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+         ~SWIG_Python_Thread_Allow() { end(); }
+       };
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block
+#      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow
+#      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()
+#    else /* C code */
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+#      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+#      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)
+#    endif
+#  else /* Old thread way, not implemented, user must provide it */
+#    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+#      define SWIG_PYTHON_INITIALIZE_THREADS
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+#      define SWIG_PYTHON_THREAD_END_BLOCK
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+#      define SWIG_PYTHON_THREAD_END_ALLOW
+#    endif
+#  endif
+#else /* No thread support */
+#  define SWIG_PYTHON_INITIALIZE_THREADS
+#  define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+#  define SWIG_PYTHON_THREAD_END_BLOCK
+#  define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+#  define SWIG_PYTHON_THREAD_END_ALLOW
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY  5
+
+/* Constant information structure */
+typedef struct swig_const_info {
+  int type;
+  char *name;
+  long lvalue;
+  double dvalue;
+  void   *pvalue;
+  swig_type_info **ptype;
+} swig_const_info;
+
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyInstanceMethod_New() used in Python 3
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+#if PY_VERSION_HEX >= 0x03000000
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)
+{
+  return PyInstanceMethod_New(func);
+}
+#else
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
+{
+  return NULL;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+
+#ifdef SWIGPYTHON_BUILTIN
+#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(self, ptr, type, flags)
+#else
+#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
+#endif
+
+#define SWIG_InternalNewPointerObj(ptr, type, flags)   SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
+
+#define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
+#define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype                                    int
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule(clientdata)
+#define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj)                         SwigPyClientData_New(obj)
+
+#define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
+#define SWIG_SetErrorMsg                               SWIG_Python_SetErrorMsg                            
+#define SWIG_ErrorType(code)                           SWIG_Python_ErrorType(code)                        
+#define SWIG_Error(code, msg)                          SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
+#define SWIG_fail                                      goto fail                                          
+
+
+/* Runtime API implementation */
+
+/* Error manipulation */
+
+SWIGINTERN void 
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+  SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
+  PyErr_SetObject(errtype, obj);
+  Py_DECREF(obj);
+  SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+SWIGINTERN void 
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+  SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+  PyErr_SetString(errtype, msg);
+  SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+#define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
+
+/* Set a constant value */
+
+#if defined(SWIGPYTHON_BUILTIN)
+
+SWIGINTERN void
+SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
+  PyObject *s = PyString_InternFromString(key);
+  PyList_Append(seq, s);
+  Py_DECREF(s);
+}
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {   
+#if PY_VERSION_HEX < 0x02030000
+  PyDict_SetItemString(d, (char *)name, obj);
+#else
+  PyDict_SetItemString(d, name, obj);
+#endif
+  Py_DECREF(obj);
+  if (public_interface)
+    SwigPyBuiltin_AddPublicSymbol(public_interface, name);
+}
+
+#else
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
+#if PY_VERSION_HEX < 0x02030000
+  PyDict_SetItemString(d, (char *)name, obj);
+#else
+  PyDict_SetItemString(d, name, obj);
+#endif
+  Py_DECREF(obj);                            
+}
+
+#endif
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+  if (!result) {
+    result = obj;
+  } else if (result == Py_None) {
+    Py_DECREF(result);
+    result = obj;
+  } else {
+    if (!PyList_Check(result)) {
+      PyObject *o2 = result;
+      result = PyList_New(1);
+      PyList_SetItem(result, 0, o2);
+    }
+    PyList_Append(result,obj);
+    Py_DECREF(obj);
+  }
+  return result;
+#else
+  PyObject*   o2;
+  PyObject*   o3;
+  if (!result) {
+    result = obj;
+  } else if (result == Py_None) {
+    Py_DECREF(result);
+    result = obj;
+  } else {
+    if (!PyTuple_Check(result)) {
+      o2 = result;
+      result = PyTuple_New(1);
+      PyTuple_SET_ITEM(result, 0, o2);
+    }
+    o3 = PyTuple_New(1);
+    PyTuple_SET_ITEM(o3, 0, obj);
+    o2 = result;
+    result = PySequence_Concat(o2, o3);
+    Py_DECREF(o2);
+    Py_DECREF(o3);
+  }
+  return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+{
+  if (!args) {
+    if (!min && !max) {
+      return 1;
+    } else {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 
+                  name, (min == max ? "" : "at least "), (int)min);
+      return 0;
+    }
+  }  
+  if (!PyTuple_Check(args)) {
+    if (min <= 1 && max >= 1) {
+      register int i;
+      objs[0] = args;
+      for (i = 1; i < max; ++i) {
+       objs[i] = 0;
+      }
+      return 2;
+    }
+    PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+    return 0;
+  } else {
+    register Py_ssize_t l = PyTuple_GET_SIZE(args);
+    if (l < min) {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
+                  name, (min == max ? "" : "at least "), (int)min, (int)l);
+      return 0;
+    } else if (l > max) {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
+                  name, (min == max ? "" : "at most "), (int)max, (int)l);
+      return 0;
+    } else {
+      register int i;
+      for (i = 0; i < l; ++i) {
+       objs[i] = PyTuple_GET_ITEM(args, i);
+      }
+      for (; l < max; ++l) {
+       objs[l] = 0;
+      }
+      return i + 1;
+    }    
+  }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj)          PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj)          PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+  Helper for static pointer initialization for both C and C++ code, for example
+  static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var)  var
+#else
+#define SWIG_STATIC_POINTER(var)  var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW       (SWIG_POINTER_OWN      << 1)
+#define SWIG_POINTER_NEW            (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)
+
+#define SWIG_BUILTIN_TP_INIT       (SWIG_POINTER_OWN << 2)
+#define SWIG_BUILTIN_INIT          (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*  How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#  ifndef SWIG_PYTHON_NO_BUILD_NONE
+#    ifndef SWIG_PYTHON_BUILD_NONE
+#      define SWIG_PYTHON_BUILD_NONE
+#    endif
+#  endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+#  ifdef Py_None
+#   undef Py_None
+#   define Py_None SWIG_Py_None()
+#  endif
+SWIGRUNTIMEINLINE PyObject * 
+_SWIG_Py_None(void)
+{
+  PyObject *none = Py_BuildValue((char*)"");
+  Py_DECREF(none);
+  return none;
+}
+SWIGRUNTIME PyObject * 
+SWIG_Py_None(void)
+{
+  static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+  return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject * 
+SWIG_Py_Void(void)
+{
+  PyObject *none = Py_None;
+  Py_INCREF(none);
+  return none;
+}
+
+/* SwigPyClientData */
+
+typedef struct {
+  PyObject *klass;
+  PyObject *newraw;
+  PyObject *newargs;
+  PyObject *destroy;
+  int delargs;
+  int implicitconv;
+  PyTypeObject *pytype;
+} SwigPyClientData;
+
+SWIGRUNTIMEINLINE int 
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+  SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
+  return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+  SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
+  PyObject *klass = data ? data->klass : 0;
+  return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME SwigPyClientData * 
+SwigPyClientData_New(PyObject* obj)
+{
+  if (!obj) {
+    return 0;
+  } else {
+    SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
+    /* the klass element */
+    data->klass = obj;
+    Py_INCREF(data->klass);
+    /* the newraw method and newargs arguments used to create a new raw instance */
+    if (PyClass_Check(obj)) {
+      data->newraw = 0;
+      data->newargs = obj;
+      Py_INCREF(obj);
+    } else {
+#if (PY_VERSION_HEX < 0x02020000)
+      data->newraw = 0;
+#else
+      data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+      if (data->newraw) {
+       Py_INCREF(data->newraw);
+       data->newargs = PyTuple_New(1);
+       PyTuple_SetItem(data->newargs, 0, obj);
+      } else {
+       data->newargs = obj;
+      }
+      Py_INCREF(data->newargs);
+    }
+    /* the destroy method, aka as the C++ delete method */
+    data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+    if (PyErr_Occurred()) {
+      PyErr_Clear();
+      data->destroy = 0;
+    }
+    if (data->destroy) {
+      int flags;
+      Py_INCREF(data->destroy);
+      flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+      data->delargs = !(flags & (METH_O));
+#else
+      data->delargs = 0;
+#endif
+    } else {
+      data->delargs = 0;
+    }
+    data->implicitconv = 0;
+    data->pytype = 0;
+    return data;
+  }
+}
+
+SWIGRUNTIME void 
+SwigPyClientData_Del(SwigPyClientData *data) {
+  Py_XDECREF(data->newraw);
+  Py_XDECREF(data->newargs);
+  Py_XDECREF(data->destroy);
+}
+
+/* =============== SwigPyObject =====================*/
+
+typedef struct {
+  PyObject_HEAD
+  void *ptr;
+  swig_type_info *ty;
+  int own;
+  PyObject *next;
+#ifdef SWIGPYTHON_BUILTIN
+  PyObject *dict;
+#endif
+} SwigPyObject;
+
+SWIGRUNTIME PyObject *
+SwigPyObject_long(SwigPyObject *v)
+{
+  return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_format(const char* fmt, SwigPyObject *v)
+{
+  PyObject *res = NULL;
+  PyObject *args = PyTuple_New(1);
+  if (args) {
+    if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
+      PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
+      if (ofmt) {
+#if PY_VERSION_HEX >= 0x03000000
+       res = PyUnicode_Format(ofmt,args);
+#else
+       res = PyString_Format(ofmt,args);
+#endif
+       Py_DECREF(ofmt);
+      }
+      Py_DECREF(args);
+    }
+  }
+  return res;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_oct(SwigPyObject *v)
+{
+  return SwigPyObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_hex(SwigPyObject *v)
+{
+  return SwigPyObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+SwigPyObject_repr(SwigPyObject *v)
+#else
+SwigPyObject_repr(SwigPyObject *v, PyObject *args)
+#endif
+{
+  const char *name = SWIG_TypePrettyName(v->ty);
+  PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
+  if (v->next) {
+# ifdef METH_NOARGS
+    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
+# else
+    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
+# endif
+# if PY_VERSION_HEX >= 0x03000000
+    PyObject *joined = PyUnicode_Concat(repr, nrep);
+    Py_DecRef(repr);
+    Py_DecRef(nrep);
+    repr = joined;
+# else
+    PyString_ConcatAndDel(&repr,nrep);
+# endif
+  }
+  return repr;  
+}
+
+SWIGRUNTIME int
+SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
+{
+  void *i = v->ptr;
+  void *j = w->ptr;
+  return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+/* Added for Python 3.x, would it also be useful for Python 2.x? */
+SWIGRUNTIME PyObject*
+SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
+{
+  PyObject* res;
+  if( op != Py_EQ && op != Py_NE ) {
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
+  }
+  res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
+  return res;  
+}
+
+
+SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
+
+#ifdef SWIGPYTHON_BUILTIN
+static swig_type_info *SwigPyObject_stype = 0;
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+    SwigPyClientData *cd;
+    assert(SwigPyObject_stype);
+    cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+    assert(cd);
+    assert(cd->pytype);
+    return cd->pytype;
+}
+#else
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
+  return type;
+}
+#endif
+
+SWIGRUNTIMEINLINE int
+SwigPyObject_Check(PyObject *op) {
+#ifdef SWIGPYTHON_BUILTIN
+  PyTypeObject *target_tp = SwigPyObject_type();
+  if (PyType_IsSubtype(op->ob_type, target_tp))
+    return 1;
+  return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
+#else
+  return (Py_TYPE(op) == SwigPyObject_type())
+    || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
+#endif
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+SwigPyObject_dealloc(PyObject *v)
+{
+  SwigPyObject *sobj = (SwigPyObject *) v;
+  PyObject *next = sobj->next;
+  if (sobj->own == SWIG_POINTER_OWN) {
+    swig_type_info *ty = sobj->ty;
+    SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+    PyObject *destroy = data ? data->destroy : 0;
+    if (destroy) {
+      /* destroy is always a VARARGS method */
+      PyObject *res;
+      if (data->delargs) {
+       /* we need to create a temporary object to carry the destroy operation */
+       PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
+       res = SWIG_Python_CallFunctor(destroy, tmp);
+       Py_DECREF(tmp);
+      } else {
+       PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+       PyObject *mself = PyCFunction_GET_SELF(destroy);
+       res = ((*meth)(mself, v));
+      }
+      Py_XDECREF(res);
+    } 
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+    else {
+      const char *name = SWIG_TypePrettyName(ty);
+      printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
+    }
+#endif
+  } 
+  Py_XDECREF(next);
+  PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject* 
+SwigPyObject_append(PyObject* v, PyObject* next)
+{
+  SwigPyObject *sobj = (SwigPyObject *) v;
+#ifndef METH_O
+  PyObject *tmp = 0;
+  if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+  next = tmp;
+#endif
+  if (!SwigPyObject_Check(next)) {
+    return NULL;
+  }
+  sobj->next = next;
+  Py_INCREF(next);
+  return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject* 
+#ifdef METH_NOARGS
+SwigPyObject_next(PyObject* v)
+#else
+SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  SwigPyObject *sobj = (SwigPyObject *) v;
+  if (sobj->next) {    
+    Py_INCREF(sobj->next);
+    return sobj->next;
+  } else {
+    return SWIG_Py_Void();
+  }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_disown(PyObject *v)
+#else
+SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  SwigPyObject *sobj = (SwigPyObject *)v;
+  sobj->own = 0;
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_acquire(PyObject *v)
+#else
+SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  SwigPyObject *sobj = (SwigPyObject *)v;
+  sobj->own = SWIG_POINTER_OWN;
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+SwigPyObject_own(PyObject *v, PyObject *args)
+{
+  PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+  if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#elif (PY_VERSION_HEX < 0x02050000)
+  if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
+#else
+  if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) 
+#endif
+    {
+      return NULL;
+    } 
+  else
+    {
+      SwigPyObject *sobj = (SwigPyObject *)v;
+      PyObject *obj = PyBool_FromLong(sobj->own);
+      if (val) {
+#ifdef METH_NOARGS
+       if (PyObject_IsTrue(val)) {
+         SwigPyObject_acquire(v);
+       } else {
+         SwigPyObject_disown(v);
+       }
+#else
+       if (PyObject_IsTrue(val)) {
+         SwigPyObject_acquire(v,args);
+       } else {
+         SwigPyObject_disown(v,args);
+       }
+#endif
+      } 
+      return obj;
+    }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS,  (char *)"acquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_O,       (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
+  {0, 0, 0, 0}  
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
+  {0, 0, 0, 0}  
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+SwigPyObject_getattr(SwigPyObject *sobj,char *name)
+{
+  return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_TypeOnce(void) {
+  static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+
+  static PyNumberMethods SwigPyObject_as_number = {
+    (binaryfunc)0, /*nb_add*/
+    (binaryfunc)0, /*nb_subtract*/
+    (binaryfunc)0, /*nb_multiply*/
+    /* nb_divide removed in Python 3 */
+#if PY_VERSION_HEX < 0x03000000
+    (binaryfunc)0, /*nb_divide*/
+#endif
+    (binaryfunc)0, /*nb_remainder*/
+    (binaryfunc)0, /*nb_divmod*/
+    (ternaryfunc)0,/*nb_power*/
+    (unaryfunc)0,  /*nb_negative*/
+    (unaryfunc)0,  /*nb_positive*/
+    (unaryfunc)0,  /*nb_absolute*/
+    (inquiry)0,    /*nb_nonzero*/
+    0,            /*nb_invert*/
+    0,            /*nb_lshift*/
+    0,            /*nb_rshift*/
+    0,            /*nb_and*/
+    0,            /*nb_xor*/
+    0,            /*nb_or*/
+#if PY_VERSION_HEX < 0x03000000
+    0,   /*nb_coerce*/
+#endif
+    (unaryfunc)SwigPyObject_long, /*nb_int*/
+#if PY_VERSION_HEX < 0x03000000
+    (unaryfunc)SwigPyObject_long, /*nb_long*/
+#else
+    0, /*nb_reserved*/
+#endif
+    (unaryfunc)0,                 /*nb_float*/
+#if PY_VERSION_HEX < 0x03000000
+    (unaryfunc)SwigPyObject_oct,  /*nb_oct*/
+    (unaryfunc)SwigPyObject_hex,  /*nb_hex*/
+#endif
+#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
+#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+    0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+  };
+
+  static PyTypeObject swigpyobject_type;
+  static int type_init = 0;
+  if (!type_init) {
+    const PyTypeObject tmp = {
+      /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+      PyVarObject_HEAD_INIT(NULL, 0)
+#else
+      PyObject_HEAD_INIT(NULL)
+      0,                                    /* ob_size */
+#endif
+      (char *)"SwigPyObject",               /* tp_name */
+      sizeof(SwigPyObject),                 /* tp_basicsize */
+      0,                                    /* tp_itemsize */
+      (destructor)SwigPyObject_dealloc,     /* tp_dealloc */
+      0,                                   /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+      (getattrfunc)SwigPyObject_getattr,    /* tp_getattr */
+#else
+      (getattrfunc)0,                       /* tp_getattr */
+#endif
+      (setattrfunc)0,                       /* tp_setattr */
+#if PY_VERSION_HEX >= 0x03000000
+    0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+#else
+      (cmpfunc)SwigPyObject_compare,        /* tp_compare */
+#endif
+      (reprfunc)SwigPyObject_repr,          /* tp_repr */
+      &SwigPyObject_as_number,              /* tp_as_number */
+      0,                                    /* tp_as_sequence */
+      0,                                    /* tp_as_mapping */
+      (hashfunc)0,                          /* tp_hash */
+      (ternaryfunc)0,                       /* tp_call */
+      0,                                   /* tp_str */
+      PyObject_GenericGetAttr,              /* tp_getattro */
+      0,                                    /* tp_setattro */
+      0,                                    /* tp_as_buffer */
+      Py_TPFLAGS_DEFAULT,                   /* tp_flags */
+      swigobject_doc,                       /* tp_doc */
+      0,                                    /* tp_traverse */
+      0,                                    /* tp_clear */
+      (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
+      0,                                    /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+      0,                                    /* tp_iter */
+      0,                                    /* tp_iternext */
+      swigobject_methods,                   /* tp_methods */
+      0,                                    /* tp_members */
+      0,                                    /* tp_getset */
+      0,                                    /* tp_base */
+      0,                                    /* tp_dict */
+      0,                                    /* tp_descr_get */
+      0,                                    /* tp_descr_set */
+      0,                                    /* tp_dictoffset */
+      0,                                    /* tp_init */
+      0,                                    /* tp_alloc */
+      0,                                    /* tp_new */
+      0,                                    /* tp_free */
+      0,                                    /* tp_is_gc */
+      0,                                    /* tp_bases */
+      0,                                    /* tp_mro */
+      0,                                    /* tp_cache */
+      0,                                    /* tp_subclasses */
+      0,                                    /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+      0,                                    /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+      0,                                    /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+      0,0,0,0                               /* tp_alloc -> tp_next */
+#endif
+    };
+    swigpyobject_type = tmp;
+    type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+    swigpyobject_type.ob_type = &PyType_Type;
+#else
+    if (PyType_Ready(&swigpyobject_type) < 0)
+      return NULL;
+#endif
+  }
+  return &swigpyobject_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
+{
+  SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
+  if (sobj) {
+    sobj->ptr  = ptr;
+    sobj->ty   = ty;
+    sobj->own  = own;
+    sobj->next = 0;
+  }
+  return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+  PyObject_HEAD
+  void *pack;
+  swig_type_info *ty;
+  size_t size;
+} SwigPyPacked;
+
+SWIGRUNTIME int
+SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+  char result[SWIG_BUFFER_SIZE];
+  fputs("<Swig Packed ", fp); 
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+    fputs("at ", fp); 
+    fputs(result, fp); 
+  }
+  fputs(v->ty->name,fp); 
+  fputs(">", fp);
+  return 0; 
+}
+  
+SWIGRUNTIME PyObject *
+SwigPyPacked_repr(SwigPyPacked *v)
+{
+  char result[SWIG_BUFFER_SIZE];
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+    return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+  } else {
+    return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
+  }  
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_str(SwigPyPacked *v)
+{
+  char result[SWIG_BUFFER_SIZE];
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+    return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
+  } else {
+    return SWIG_Python_str_FromChar(v->ty->name);
+  }  
+}
+
+SWIGRUNTIME int
+SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
+{
+  size_t i = v->size;
+  size_t j = w->size;
+  int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+  return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
+  return type;
+}
+
+SWIGRUNTIMEINLINE int
+SwigPyPacked_Check(PyObject *op) {
+  return ((op)->ob_type == SwigPyPacked_TypeOnce()) 
+    || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
+}
+
+SWIGRUNTIME void
+SwigPyPacked_dealloc(PyObject *v)
+{
+  if (SwigPyPacked_Check(v)) {
+    SwigPyPacked *sobj = (SwigPyPacked *) v;
+    free(sobj->pack);
+  }
+  PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_TypeOnce(void) {
+  static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+  static PyTypeObject swigpypacked_type;
+  static int type_init = 0;
+  if (!type_init) {
+    const PyTypeObject tmp = {
+      /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX>=0x03000000
+      PyVarObject_HEAD_INIT(NULL, 0)
+#else
+      PyObject_HEAD_INIT(NULL)
+      0,                                    /* ob_size */
+#endif
+      (char *)"SwigPyPacked",               /* tp_name */
+      sizeof(SwigPyPacked),                 /* tp_basicsize */
+      0,                                    /* tp_itemsize */
+      (destructor)SwigPyPacked_dealloc,     /* tp_dealloc */
+      (printfunc)SwigPyPacked_print,        /* tp_print */
+      (getattrfunc)0,                       /* tp_getattr */
+      (setattrfunc)0,                       /* tp_setattr */
+#if PY_VERSION_HEX>=0x03000000
+      0, /* tp_reserved in 3.0.1 */
+#else
+      (cmpfunc)SwigPyPacked_compare,        /* tp_compare */
+#endif
+      (reprfunc)SwigPyPacked_repr,          /* tp_repr */
+      0,                                    /* tp_as_number */
+      0,                                    /* tp_as_sequence */
+      0,                                    /* tp_as_mapping */
+      (hashfunc)0,                          /* tp_hash */
+      (ternaryfunc)0,                       /* tp_call */
+      (reprfunc)SwigPyPacked_str,           /* tp_str */
+      PyObject_GenericGetAttr,              /* tp_getattro */
+      0,                                    /* tp_setattro */
+      0,                                    /* tp_as_buffer */
+      Py_TPFLAGS_DEFAULT,                   /* tp_flags */
+      swigpacked_doc,                       /* tp_doc */
+      0,                                    /* tp_traverse */
+      0,                                    /* tp_clear */
+      0,                                    /* tp_richcompare */
+      0,                                    /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+      0,                                    /* tp_iter */
+      0,                                    /* tp_iternext */
+      0,                                    /* tp_methods */
+      0,                                    /* tp_members */
+      0,                                    /* tp_getset */
+      0,                                    /* tp_base */
+      0,                                    /* tp_dict */
+      0,                                    /* tp_descr_get */
+      0,                                    /* tp_descr_set */
+      0,                                    /* tp_dictoffset */
+      0,                                    /* tp_init */
+      0,                                    /* tp_alloc */
+      0,                                    /* tp_new */
+      0,                                    /* tp_free */
+      0,                                    /* tp_is_gc */
+      0,                                    /* tp_bases */
+      0,                                    /* tp_mro */
+      0,                                    /* tp_cache */
+      0,                                    /* tp_subclasses */
+      0,                                    /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+      0,                                    /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+      0,                                    /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+      0,0,0,0                               /* tp_alloc -> tp_next */
+#endif
+    };
+    swigpypacked_type = tmp;
+    type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+    swigpypacked_type.ob_type = &PyType_Type;
+#else
+    if (PyType_Ready(&swigpypacked_type) < 0)
+      return NULL;
+#endif
+  }
+  return &swigpypacked_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+  SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
+  if (sobj) {
+    void *pack = malloc(size);
+    if (pack) {
+      memcpy(pack, ptr, size);
+      sobj->pack = pack;
+      sobj->ty   = ty;
+      sobj->size = size;
+    } else {
+      PyObject_DEL((PyObject *) sobj);
+      sobj = 0;
+    }
+  }
+  return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+  if (SwigPyPacked_Check(obj)) {
+    SwigPyPacked *sobj = (SwigPyPacked *)obj;
+    if (sobj->size != size) return 0;
+    memcpy(ptr, sobj->pack, size);
+    return sobj->ty;
+  } else {
+    return 0;
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+    return SWIG_Python_str_FromChar("this");
+}
+
+static PyObject *swig_this = NULL;
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
+  return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+/* TODO: I don't know how to implement the fast getset in Python 3 right now */
+#if PY_VERSION_HEX>=0x03000000
+#define SWIG_PYTHON_SLOW_GETSET_THIS 
+#endif
+
+SWIGRUNTIME SwigPyObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj) 
+{
+  PyObject *obj;
+
+  if (SwigPyObject_Check(pyobj))
+    return (SwigPyObject *) pyobj;
+
+#ifdef SWIGPYTHON_BUILTIN
+  (void)obj;
+# ifdef PyWeakref_CheckProxy
+  if (PyWeakref_CheckProxy(pyobj)) {
+    pyobj = PyWeakref_GET_OBJECT(pyobj);
+    if (pyobj && SwigPyObject_Check(pyobj))
+      return (SwigPyObject*) pyobj;
+  }
+# endif
+  return NULL;
+#else
+
+  obj = 0;
+
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+  if (PyInstance_Check(pyobj)) {
+    obj = _PyInstance_Lookup(pyobj, SWIG_This());      
+  } else {
+    PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+    if (dictptr != NULL) {
+      PyObject *dict = *dictptr;
+      obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+    } else {
+#ifdef PyWeakref_CheckProxy
+      if (PyWeakref_CheckProxy(pyobj)) {
+       PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+       return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+      }
+#endif
+      obj = PyObject_GetAttr(pyobj,SWIG_This());
+      if (obj) {
+       Py_DECREF(obj);
+      } else {
+       if (PyErr_Occurred()) PyErr_Clear();
+       return 0;
+      }
+    }
+  }
+#else
+  obj = PyObject_GetAttr(pyobj,SWIG_This());
+  if (obj) {
+    Py_DECREF(obj);
+  } else {
+    if (PyErr_Occurred()) PyErr_Clear();
+    return 0;
+  }
+#endif
+  if (obj && !SwigPyObject_Check(obj)) {
+    /* a PyObject is called 'this', try to get the 'real this'
+       SwigPyObject from it */ 
+    return SWIG_Python_GetSwigThis(obj);
+  }
+  return (SwigPyObject *)obj;
+#endif
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+  if (own == SWIG_POINTER_OWN) {
+    SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
+    if (sobj) {
+      int oldown = sobj->own;
+      sobj->own = own;
+      return oldown;
+    }
+  }
+  return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+  int res;
+  SwigPyObject *sobj;
+  int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
+
+  if (!obj)
+    return SWIG_ERROR;
+  if (obj == Py_None && !implicit_conv) {
+    if (ptr)
+      *ptr = 0;
+    return SWIG_OK;
+  }
+
+  res = SWIG_ERROR;
+
+  sobj = SWIG_Python_GetSwigThis(obj);
+  if (own)
+    *own = 0;
+  while (sobj) {
+    void *vptr = sobj->ptr;
+    if (ty) {
+      swig_type_info *to = sobj->ty;
+      if (to == ty) {
+        /* no type cast needed */
+        if (ptr) *ptr = vptr;
+        break;
+      } else {
+        swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+        if (!tc) {
+          sobj = (SwigPyObject *)sobj->next;
+        } else {
+          if (ptr) {
+            int newmemory = 0;
+            *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+            if (newmemory == SWIG_CAST_NEW_MEMORY) {
+              assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
+              if (own)
+                *own = *own | SWIG_CAST_NEW_MEMORY;
+            }
+          }
+          break;
+        }
+      }
+    } else {
+      if (ptr) *ptr = vptr;
+      break;
+    }
+  }
+  if (sobj) {
+    if (own)
+      *own = *own | sobj->own;
+    if (flags & SWIG_POINTER_DISOWN) {
+      sobj->own = 0;
+    }
+    res = SWIG_OK;
+  } else {
+    if (implicit_conv) {
+      SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+      if (data && !data->implicitconv) {
+        PyObject *klass = data->klass;
+        if (klass) {
+          PyObject *impconv;
+          data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+          impconv = SWIG_Python_CallFunctor(klass, obj);
+          data->implicitconv = 0;
+          if (PyErr_Occurred()) {
+            PyErr_Clear();
+            impconv = 0;
+          }
+          if (impconv) {
+            SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
+            if (iobj) {
+              void *vptr;
+              res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+              if (SWIG_IsOK(res)) {
+                if (ptr) {
+                  *ptr = vptr;
+                  /* transfer the ownership to 'ptr' */
+                  iobj->own = 0;
+                  res = SWIG_AddCast(res);
+                  res = SWIG_AddNewMask(res);
+                } else {
+                  res = SWIG_AddCast(res);                 
+                }
+              }
+            }
+            Py_DECREF(impconv);
+          }
+        }
+      }
+    }
+    if (!SWIG_IsOK(res) && obj == Py_None) {
+      if (ptr)
+        *ptr = 0;
+      if (PyErr_Occurred())
+        PyErr_Clear();
+      res = SWIG_OK;
+    }
+  }
+  return res;
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+  if (!PyCFunction_Check(obj)) {
+    return SWIG_ConvertPtr(obj, ptr, ty, 0);
+  } else {
+    void *vptr = 0;
+    
+    /* here we get the method pointer for callbacks */
+    const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+    const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+    if (desc)
+      desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+    if (!desc) 
+      return SWIG_ERROR;
+    if (ty) {
+      swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+      if (tc) {
+        int newmemory = 0;
+        *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+        assert(!newmemory); /* newmemory handling not yet implemented */
+      } else {
+        return SWIG_ERROR;
+      }
+    } else {
+      *ptr = vptr;
+    }
+    return SWIG_OK;
+  }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+  swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
+  if (!to) return SWIG_ERROR;
+  if (ty) {
+    if (to != ty) {
+      /* check type cast? */
+      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+      if (!tc) return SWIG_ERROR;
+    }
+  }
+  return SWIG_OK;
+}  
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+  Create a new instance object, without calling __init__, and set the
+  'this' attribute.
+*/
+
+SWIGRUNTIME PyObject* 
+SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+  PyObject *inst = 0;
+  PyObject *newraw = data->newraw;
+  if (newraw) {
+    inst = PyObject_Call(newraw, data->newargs, NULL);
+    if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+      PyObject **dictptr = _PyObject_GetDictPtr(inst);
+      if (dictptr != NULL) {
+       PyObject *dict = *dictptr;
+       if (dict == NULL) {
+         dict = PyDict_New();
+         *dictptr = dict;
+         PyDict_SetItem(dict, SWIG_This(), swig_this);
+       }
+      }
+#else
+      PyObject *key = SWIG_This();
+      PyObject_SetAttr(inst, key, swig_this);
+#endif
+    }
+  } else {
+#if PY_VERSION_HEX >= 0x03000000
+    inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
+    if (inst) {
+      PyObject_SetAttr(inst, SWIG_This(), swig_this);
+      Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+    }
+#else
+    PyObject *dict = PyDict_New();
+    if (dict) {
+      PyDict_SetItem(dict, SWIG_This(), swig_this);
+      inst = PyInstance_NewRaw(data->newargs, dict);
+      Py_DECREF(dict);
+    }
+#endif
+  }
+  return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+  PyObject *inst = 0;
+  PyObject *dict = PyDict_New();
+  if (dict) {
+    PyDict_SetItem(dict, SWIG_This(), swig_this);
+    inst = PyInstance_NewRaw(data->newargs, dict);
+    Py_DECREF(dict);
+  }
+  return (PyObject *) inst;
+#else
+  PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+  if (inst == NULL) {
+    return NULL;
+  }
+  inst->in_class = (PyClassObject *)data->newargs;
+  Py_INCREF(inst->in_class);
+  inst->in_dict = PyDict_New();
+  if (inst->in_dict == NULL) {
+    Py_DECREF(inst);
+    return NULL;
+  }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+  inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+  PyObject_GC_Init(inst);
+#endif
+  PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+  return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+   dict = *dictptr;
+   if (dict == NULL) {
+     dict = PyDict_New();
+     *dictptr = dict;
+   }
+   PyDict_SetItem(dict, SWIG_This(), swig_this);
+   return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+} 
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+  PyObject *obj[2];
+  if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
+    return NULL;
+  } else {
+    SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+    if (sthis) {
+      SwigPyObject_append((PyObject*) sthis, obj[1]);
+    } else {
+      SWIG_Python_SetSwigThis(obj[0], obj[1]);
+    }
+    return SWIG_Py_Void();
+  }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
+  SwigPyClientData *clientdata;
+  PyObject * robj;
+  int own;
+
+  if (!ptr)
+    return SWIG_Py_Void();
+
+  clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
+  own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+  if (clientdata && clientdata->pytype) {
+    SwigPyObject *newobj;
+    if (flags & SWIG_BUILTIN_TP_INIT) {
+      newobj = (SwigPyObject*) self;
+      if (newobj->ptr) {
+        PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
+        while (newobj->next)
+         newobj = (SwigPyObject *) newobj->next;
+        newobj->next = next_self;
+        newobj = (SwigPyObject *)next_self;
+      }
+    } else {
+      newobj = PyObject_New(SwigPyObject, clientdata->pytype);
+    }
+    if (newobj) {
+      newobj->ptr = ptr;
+      newobj->ty = type;
+      newobj->own = own;
+      newobj->next = 0;
+#ifdef SWIGPYTHON_BUILTIN
+      newobj->dict = 0;
+#endif
+      return (PyObject*) newobj;
+    }
+    return SWIG_Py_Void();
+  }
+
+  assert(!(flags & SWIG_BUILTIN_TP_INIT));
+
+  robj = SwigPyObject_New(ptr, type, own);
+  if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+    PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+    Py_DECREF(robj);
+    robj = inst;
+  }
+  return robj;
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+  return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ *  Get type list 
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
+  static void *type_pointer = (void *)0;
+  /* first check if module already created */
+  if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+    type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+# ifdef SWIGPY_USE_CAPSULE
+    type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
+# else
+    type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+                                   (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+# endif
+    if (PyErr_Occurred()) {
+      PyErr_Clear();
+      type_pointer = (void *)0;
+    }
+#endif
+  }
+  return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0.  The following function
+   is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+  PyObject *dict;
+  if (!PyModule_Check(m)) {
+    PyErr_SetString(PyExc_TypeError,
+                   "PyModule_AddObject() needs module as first arg");
+    return SWIG_ERROR;
+  }
+  if (!o) {
+    PyErr_SetString(PyExc_TypeError,
+                   "PyModule_AddObject() needs non-NULL value");
+    return SWIG_ERROR;
+  }
+  
+  dict = PyModule_GetDict(m);
+  if (dict == NULL) {
+    /* Internal error -- modules must have a dict! */
+    PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+                PyModule_GetName(m));
+    return SWIG_ERROR;
+  }
+  if (PyDict_SetItemString(dict, name, o))
+    return SWIG_ERROR;
+  Py_DECREF(o);
+  return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+#ifdef SWIGPY_USE_CAPSULE
+SWIG_Python_DestroyModule(PyObject *obj)
+#else
+SWIG_Python_DestroyModule(void *vptr)
+#endif
+{
+#ifdef SWIGPY_USE_CAPSULE
+  swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
+#else
+  swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
+  swig_type_info **types = swig_module->types;
+  size_t i;
+  for (i =0; i < swig_module->size; ++i) {
+    swig_type_info *ty = types[i];
+    if (ty->owndata) {
+      SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+      if (data) SwigPyClientData_Del(data);
+    }
+  }
+  Py_DECREF(SWIG_This());
+  swig_this = NULL;
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+#if PY_VERSION_HEX >= 0x03000000
+ /* Add a dummy module object into sys.modules */
+  PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
+#else
+  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
+  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
+#endif
+#ifdef SWIGPY_USE_CAPSULE
+  PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
+  if (pointer && module) {
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+  } else {
+    Py_XDECREF(pointer);
+  }
+#else
+  PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+  if (pointer && module) {
+    PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+  } else {
+    Py_XDECREF(pointer);
+  }
+#endif
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+  static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+  return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+  PyObject *cache = SWIG_Python_TypeCache();
+  PyObject *key = SWIG_Python_str_FromChar(type); 
+  PyObject *obj = PyDict_GetItem(cache, key);
+  swig_type_info *descriptor;
+  if (obj) {
+#ifdef SWIGPY_USE_CAPSULE
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
+#else
+    descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
+  } else {
+    swig_module_info *swig_module = SWIG_GetModule(0);
+    descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+    if (descriptor) {
+#ifdef SWIGPY_USE_CAPSULE
+      obj = PyCapsule_New((void*) descriptor, NULL, NULL);
+#else
+      obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
+      PyDict_SetItem(cache, key, obj);
+      Py_DECREF(obj);
+    }
+  }
+  Py_DECREF(key);
+  return descriptor;
+}
+
+/* 
+   For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION  0
+#define SWIG_arg_fail(arg)      SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{  
+  if (PyErr_Occurred()) {
+    PyObject *type = 0;
+    PyObject *value = 0;
+    PyObject *traceback = 0;
+    PyErr_Fetch(&type, &value, &traceback);
+    if (value) {
+      char *tmp;
+      PyObject *old_str = PyObject_Str(value);
+      Py_XINCREF(type);
+      PyErr_Clear();
+      if (infront) {
+       PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
+      } else {
+       PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+      }
+      SWIG_Python_str_DelForPy3(tmp);
+      Py_DECREF(old_str);
+    }
+    return 1;
+  } else {
+    return 0;
+  }
+}
+  
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+  if (PyErr_Occurred()) {
+    /* add information about failing argument */
+    char mesg[256];
+    PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+    return SWIG_Python_AddErrMesg(mesg, 1);
+  } else {
+    return 0;
+  }
+}
+
+SWIGRUNTIMEINLINE const char *
+SwigPyObject_GetDesc(PyObject *self)
+{
+  SwigPyObject *v = (SwigPyObject *)self;
+  swig_type_info *ty = v ? v->ty : 0;
+  return ty ? ty->str : "";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+  if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+    if (obj && SwigPyObject_Check(obj)) {
+      const char *otype = (const char *) SwigPyObject_GetDesc(obj);
+      if (otype) {
+       PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
+                    type, otype);
+       return;
+      }
+    } else 
+#endif      
+    {
+      const char *otype = (obj ? obj->ob_type->tp_name : 0); 
+      if (otype) {
+       PyObject *str = PyObject_Str(obj);
+       const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
+       if (cstr) {
+         PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+                      type, otype, cstr);
+          SWIG_Python_str_DelForPy3(cstr);
+       } else {
+         PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+                      type, otype);
+       }
+       Py_XDECREF(str);
+       return;
+      }
+    }   
+    PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+  } else {
+    PyErr_Format(PyExc_TypeError, "unexpected type is received");
+  }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
+  void *result;
+  if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+    PyErr_Clear();
+#if SWIG_POINTER_EXCEPTION
+    if (flags) {
+      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+      SWIG_Python_ArgFail(argnum);
+    }
+#endif
+  }
+  return result;
+}
+
+#ifdef SWIGPYTHON_BUILTIN
+SWIGRUNTIME int
+SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
+  PyTypeObject *tp = obj->ob_type;
+  PyObject *descr;
+  PyObject *encoded_name;
+  descrsetfunc f;
+  int res = -1;
+
+# ifdef Py_USING_UNICODE
+  if (PyString_Check(name)) {
+    name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
+    if (!name)
+      return -1;
+  } else if (!PyUnicode_Check(name))
+# else
+  if (!PyString_Check(name))
+# endif
+  {
+    PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
+    return -1;
+  } else {
+    Py_INCREF(name);
+  }
+
+  if (!tp->tp_dict) {
+    if (PyType_Ready(tp) < 0)
+      goto done;
+  }
+
+  descr = _PyType_Lookup(tp, name);
+  f = NULL;
+  if (descr != NULL)
+    f = descr->ob_type->tp_descr_set;
+  if (!f) {
+    if (PyString_Check(name)) {
+      encoded_name = name;
+      Py_INCREF(name);
+    } else {
+      encoded_name = PyUnicode_AsUTF8String(name);
+    }
+    PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
+    Py_DECREF(encoded_name);
+  } else {
+    res = f(descr, obj, value);
+  }
+  
+  done:
+  Py_DECREF(name);
+  return res;
+}
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
+
+
+
+  #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_allocator_type swig_types[0]
+#define SWIGTYPE_p_char swig_types[1]
+#define SWIGTYPE_p_difference_type swig_types[2]
+#define SWIGTYPE_p_double swig_types[3]
+#define SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double swig_types[4]
+#define SWIGTYPE_p_int swig_types[5]
+#define SWIGTYPE_p_nlopt__forced_stop swig_types[6]
+#define SWIGTYPE_p_nlopt__opt swig_types[7]
+#define SWIGTYPE_p_nlopt__roundoff_limited swig_types[8]
+#define SWIGTYPE_p_nlopt_func swig_types[9]
+#define SWIGTYPE_p_nlopt_mfunc swig_types[10]
+#define SWIGTYPE_p_nlopt_opt swig_types[11]
+#define SWIGTYPE_p_nlopt_result swig_types[12]
+#define SWIGTYPE_p_p_PyObject swig_types[13]
+#define SWIGTYPE_p_size_type swig_types[14]
+#define SWIGTYPE_p_std__allocatorT_double_t swig_types[15]
+#define SWIGTYPE_p_std__invalid_argument swig_types[16]
+#define SWIGTYPE_p_std__runtime_error swig_types[17]
+#define SWIGTYPE_p_std__vectorT__Tp__Alloc_t swig_types[18]
+#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[19]
+#define SWIGTYPE_p_swig__SwigPyIterator swig_types[20]
+#define SWIGTYPE_p_value_type swig_types[21]
+static swig_type_info *swig_types[23];
+static swig_module_info swig_module = {swig_types, 22, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+#if (PY_VERSION_HEX <= 0x02000000)
+# if !defined(SWIG_PYTHON_CLASSIC)
+#  error "This python version requires swig to be run with the '-classic' option"
+# endif
+#endif
+
+/*-----------------------------------------------
+              @(target):= _nlopt.so
+  ------------------------------------------------*/
+#if PY_VERSION_HEX >= 0x03000000
+#  define SWIG_init    PyInit__nlopt
+
+#else
+#  define SWIG_init    init_nlopt
+
+#endif
+#define SWIG_name    "_nlopt"
+
+#define SWIGVERSION 0x020012 
+#define SWIG_VERSION SWIGVERSION
+
+
+#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) 
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) 
+
+
+#include <stdexcept>
+
+
+namespace swig {
+  class SwigPtr_PyObject {
+  protected:
+    PyObject *_obj;
+
+  public:
+    SwigPtr_PyObject() :_obj(0)
+    {
+    }
+
+    SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
+    {
+      Py_XINCREF(_obj);      
+    }
+    
+    SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
+    {
+      if (initial_ref) {
+        Py_XINCREF(_obj);
+      }
+    }
+    
+    SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) 
+    {
+      Py_XINCREF(item._obj);
+      Py_XDECREF(_obj);
+      _obj = item._obj;
+      return *this;      
+    }
+    
+    ~SwigPtr_PyObject() 
+    {
+      Py_XDECREF(_obj);
+    }
+    
+    operator PyObject *() const
+    {
+      return _obj;
+    }
+
+    PyObject *operator->() const
+    {
+      return _obj;
+    }
+  };
+}
+
+
+namespace swig {
+  struct SwigVar_PyObject : SwigPtr_PyObject {
+    SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
+    
+    SwigVar_PyObject & operator = (PyObject* obj)
+    {
+      Py_XDECREF(_obj);
+      _obj = obj;
+      return *this;      
+    }
+  };
+}
+
+
+#include "nlopt.hpp"
+
+
+#include <iostream>
+
+#if PY_VERSION_HEX >= 0x03020000
+# define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj))
+#else
+# define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj))
+#endif
+
+
+#include <stdexcept>
+
+
+#if defined(__GNUC__)
+#  if __GNUC__ == 2 && __GNUC_MINOR <= 96
+#     define SWIG_STD_NOMODERN_STL
+#  endif
+#endif
+
+
+#include <string>
+#include <stdexcept>
+#include <stddef.h>
+
+
+  #include <stddef.h>
+
+
+namespace swig {
+  struct stop_iteration {
+  };
+
+  struct SwigPyIterator {
+  private:
+    SwigPtr_PyObject _seq;
+
+  protected:
+    SwigPyIterator(PyObject *seq) : _seq(seq)
+    {
+    }
+      
+  public:
+    virtual ~SwigPyIterator() {}
+
+    // Access iterator method, required by Python
+    virtual PyObject *value() const = 0;
+
+    // Forward iterator method, required by Python
+    virtual SwigPyIterator *incr(size_t n = 1) = 0;
+    
+    // Backward iterator method, very common in C++, but not required in Python
+    virtual SwigPyIterator *decr(size_t /*n*/ = 1)
+    {
+      throw stop_iteration();
+    }
+
+    // Random access iterator methods, but not required in Python
+    virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const
+    {
+      throw std::invalid_argument("operation not supported");
+    }
+
+    virtual bool equal (const SwigPyIterator &/*x*/) const
+    {
+      throw std::invalid_argument("operation not supported");
+    }
+    
+    // C++ common/needed methods
+    virtual SwigPyIterator *copy() const = 0;
+
+    PyObject *next()     
+    {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
+      PyObject *obj = value();
+      incr();       
+      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
+      return obj;     
+    }
+
+    /* Make an alias for Python 3.x */
+    PyObject *__next__()
+    {
+      return next();
+    }
+
+    PyObject *previous()
+    {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
+      decr();
+      PyObject *obj = value();
+      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads       
+      return obj;
+    }
+
+    SwigPyIterator *advance(ptrdiff_t n)
+    {
+      return  (n > 0) ?  incr(n) : decr(-n);
+    }
+      
+    bool operator == (const SwigPyIterator& x)  const
+    {
+      return equal(x);
+    }
+      
+    bool operator != (const SwigPyIterator& x) const
+    {
+      return ! operator==(x);
+    }
+      
+    SwigPyIterator& operator += (ptrdiff_t n)
+    {
+      return *advance(n);
+    }
+
+    SwigPyIterator& operator -= (ptrdiff_t n)
+    {
+      return *advance(-n);
+    }
+      
+    SwigPyIterator* operator + (ptrdiff_t n) const
+    {
+      return copy()->advance(n);
+    }
+
+    SwigPyIterator* operator - (ptrdiff_t n) const
+    {
+      return copy()->advance(-n);
+    }
+      
+    ptrdiff_t operator - (const SwigPyIterator& x) const
+    {
+      return x.distance(*this);
+    }
+      
+    static swig_type_info* descriptor() {
+      static int init = 0;
+      static swig_type_info* desc = 0;
+      if (!init) {
+       desc = SWIG_TypeQuery("swig::SwigPyIterator *");
+       init = 1;
+      }        
+      return desc;
+    }    
+  };
+
+#if defined(SWIGPYTHON_BUILTIN)
+  inline PyObject* make_output_iterator_builtin (PyObject *pyself)
+  {
+    Py_INCREF(pyself);
+    return pyself;
+  }
+#endif
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_double (PyObject *obj, double *val)
+{
+  int res = SWIG_TypeError;
+  if (PyFloat_Check(obj)) {
+    if (val) *val = PyFloat_AsDouble(obj);
+    return SWIG_OK;
+  } else if (PyInt_Check(obj)) {
+    if (val) *val = PyInt_AsLong(obj);
+    return SWIG_OK;
+  } else if (PyLong_Check(obj)) {
+    double v = PyLong_AsDouble(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    double d = PyFloat_AsDouble(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = d;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      long v = PyLong_AsLong(obj);
+      if (!PyErr_Occurred()) {
+       if (val) *val = v;
+       return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
+      } else {
+       PyErr_Clear();
+      }
+    }
+  }
+#endif
+  return res;
+}
+
+
+#include <float.h>
+
+
+#include <math.h>
+
+
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+  double x = *d;
+  if ((min <= x && x <= max)) {
+   double fx = floor(x);
+   double cx = ceil(x);
+   double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+   if ((errno == EDOM) || (errno == ERANGE)) {
+     errno = 0;
+   } else {
+     double summ, reps, diff;
+     if (rd < x) {
+       diff = x - rd;
+     } else if (rd > x) {
+       diff = rd - x;
+     } else {
+       return 1;
+     }
+     summ = rd + x;
+     reps = diff/summ;
+     if (reps < 8*DBL_EPSILON) {
+       *d = rd;
+       return 1;
+     }
+   }
+  }
+  return 0;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) 
+{
+#if PY_VERSION_HEX < 0x03000000
+  if (PyInt_Check(obj)) {
+    long v = PyInt_AsLong(obj);
+    if (v >= 0) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      return SWIG_OverflowError;
+    }
+  } else
+#endif
+  if (PyLong_Check(obj)) {
+    unsigned long v = PyLong_AsUnsignedLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+#if PY_VERSION_HEX >= 0x03000000
+      {
+        long v = PyLong_AsLong(obj);
+        if (!PyErr_Occurred()) {
+          if (v < 0) {
+            return SWIG_OverflowError;
+          }
+        } else {
+          PyErr_Clear();
+        }
+      }
+#endif
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    unsigned long v = PyLong_AsUnsignedLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      double d;
+      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+       if (val) *val = (unsigned long)(d);
+       return res;
+      }
+    }
+  }
+#endif
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERNINLINE int
+SWIG_AsVal_size_t (PyObject * obj, size_t *val)
+{
+  unsigned long v;
+  int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
+  if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
+  return res;
+}
+
+
+  #define SWIG_From_long   PyLong_FromLong 
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_ptrdiff_t  (ptrdiff_t value)
+{    
+  return SWIG_From_long  (static_cast< long >(value));
+}
+
+
+SWIGINTERNINLINE PyObject*
+  SWIG_From_bool  (bool value)
+{
+  return PyBool_FromLong(value ? 1 : 0);
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_long (PyObject *obj, long* val)
+{
+  if (PyInt_Check(obj)) {
+    if (val) *val = PyInt_AsLong(obj);
+    return SWIG_OK;
+  } else if (PyLong_Check(obj)) {
+    long v = PyLong_AsLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    long v = PyInt_AsLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      double d;
+      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+       if (val) *val = (long)(d);
+       return res;
+      }
+    }
+  }
+#endif
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERNINLINE int
+SWIG_AsVal_ptrdiff_t (PyObject * obj, ptrdiff_t *val)
+{
+  long v;
+  int res = SWIG_AsVal_long (obj, val ? &v : 0);
+  if (SWIG_IsOK(res) && val) *val = static_cast< ptrdiff_t >(v);
+  return res;
+}
+
+
+#include <stdexcept>
+
+
+#include <algorithm>
+
+
+#include <vector>
+
+
+namespace swig {  
+  template <class Type>
+  struct noconst_traits {
+    typedef Type noconst_type;
+  };
+
+  template <class Type>
+  struct noconst_traits<const Type> {
+    typedef Type noconst_type;
+  };
+
+  /*
+    type categories
+  */
+  struct pointer_category { };  
+  struct value_category { };
+
+  /*
+    General traits that provides type_name and type_info
+  */
+  template <class Type> struct traits { };
+
+  template <class Type>
+  inline const char* type_name() {
+    return traits<typename noconst_traits<Type >::noconst_type >::type_name();
+  }
+
+  template <class Type> 
+  struct traits_info {
+    static swig_type_info *type_query(std::string name) {
+      name += " *";
+      return SWIG_TypeQuery(name.c_str());
+    }    
+    static swig_type_info *type_info() {
+      static swig_type_info *info = type_query(type_name<Type>());
+      return info;
+    }
+  };
+
+  template <class Type>
+  inline swig_type_info *type_info() {
+    return traits_info<Type>::type_info();
+  }
+
+  /*
+    Partial specialization for pointers
+  */
+  template <class Type> struct traits <Type *> {
+    typedef pointer_category category;
+    static std::string make_ptr_name(const char* name) {
+      std::string ptrname = name;
+      ptrname += " *";
+      return ptrname;
+    }    
+    static const char* type_name() {
+      static std::string name = make_ptr_name(swig::type_name<Type>());
+      return name.c_str();
+    }
+  };
+
+  template <class Type, class Category> 
+  struct traits_as { };
+  template <class Type, class Category> 
+  struct traits_check { };
+
+}
+
+
+namespace swig {  
+  /*
+    Traits that provides the from method
+  */
+  template <class Type> struct traits_from_ptr {
+    static PyObject *from(Type *val, int owner = 0) {
+      return SWIG_InternalNewPointerObj(val, type_info<Type>(), owner);
+    }
+  };
+
+  template <class Type> struct traits_from {
+    static PyObject *from(const Type& val) {
+      return traits_from_ptr<Type>::from(new Type(val), 1);
+    }
+  };
+
+  template <class Type> struct traits_from<Type *> {
+    static PyObject *from(Type* val) {
+      return traits_from_ptr<Type>::from(val, 0);
+    }
+  };
+
+  template <class Type> struct traits_from<const Type *> {
+    static PyObject *from(const Type* val) {
+      return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
+    }
+  };
+
+
+  template <class Type>
+  inline PyObject *from(const Type& val) {
+    return traits_from<Type>::from(val);
+  }
+
+  template <class Type>
+  inline PyObject *from_ptr(Type* val, int owner) {
+    return traits_from_ptr<Type>::from(val, owner);
+  }
+
+  /*
+    Traits that provides the asval/as/check method
+  */
+  template <class Type>
+  struct traits_asptr {   
+    static int asptr(PyObject *obj, Type **val) {
+      Type *p;
+      int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
+      if (SWIG_IsOK(res)) {
+       if (val) *val = p;
+      }
+      return res;
+    }
+  }; 
+
+  template <class Type>
+  inline int asptr(PyObject *obj, Type **vptr) {
+    return traits_asptr<Type>::asptr(obj, vptr);
+  }
+
+  template <class Type> 
+  struct traits_asval {
+    static int asval(PyObject *obj, Type *val) {
+      if (val) {
+       Type *p = 0;
+       int res = traits_asptr<Type>::asptr(obj, &p);
+       if (!SWIG_IsOK(res)) return res;        
+       if (p) {
+         typedef typename noconst_traits<Type>::noconst_type noconst_type;
+         *(const_cast<noconst_type*>(val)) = *p;
+         if (SWIG_IsNewObj(res)){
+           delete p;
+           res = SWIG_DelNewMask(res);
+         }
+         return res;
+       } else {
+         return SWIG_ERROR;
+       }
+      } else {
+       return traits_asptr<Type>::asptr(obj, (Type **)(0));
+      }
+    }
+  };
+
+  template <class Type> struct traits_asval<Type*> {
+    static int asval(PyObject *obj, Type **val) {
+      if (val) {
+        typedef typename noconst_traits<Type>::noconst_type noconst_type;
+        noconst_type *p = 0;
+        int res = traits_asptr<noconst_type>::asptr(obj,  &p);
+        if (SWIG_IsOK(res)) {
+          *(const_cast<noconst_type**>(val)) = p;
+       }
+       return res;
+      } else {
+       return traits_asptr<Type>::asptr(obj, (Type **)(0));
+      }
+    }
+  };
+  
+  template <class Type>
+  inline int asval(PyObject *obj, Type *val) {
+    return traits_asval<Type>::asval(obj, val);
+  }
+
+  template <class Type> 
+  struct traits_as<Type, value_category> {
+    static Type as(PyObject *obj, bool throw_error) {
+      Type v;
+      int res = asval(obj, &v);
+      if (!obj || !SWIG_IsOK(res)) {
+       if (!PyErr_Occurred()) {
+         ::SWIG_Error(SWIG_TypeError,  swig::type_name<Type>());
+       }
+       if (throw_error) throw std::invalid_argument("bad type");
+      }
+      return v;
+    }
+  };
+
+  template <class Type> 
+  struct traits_as<Type, pointer_category> {
+    static Type as(PyObject *obj, bool throw_error) {
+      Type *v = 0;      
+      int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
+      if (SWIG_IsOK(res) && v) {
+       if (SWIG_IsNewObj(res)) {
+         Type r(*v);
+         delete v;
+         return r;
+       } else {
+         return *v;
+       }
+      } else {
+       // Uninitialized return value, no Type() constructor required.
+       static Type *v_def = (Type*) malloc(sizeof(Type));
+       if (!PyErr_Occurred()) {
+         SWIG_Error(SWIG_TypeError,  swig::type_name<Type>());
+       }
+       if (throw_error) throw std::invalid_argument("bad type");
+       memset(v_def,0,sizeof(Type));
+       return *v_def;
+      }
+    }
+  };
+
+  template <class Type> 
+  struct traits_as<Type*, pointer_category> {
+    static Type* as(PyObject *obj, bool throw_error) {
+      Type *v = 0;      
+      int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
+      if (SWIG_IsOK(res)) {
+       return v;
+      } else {
+       if (!PyErr_Occurred()) {
+         SWIG_Error(SWIG_TypeError,  swig::type_name<Type>());
+       }
+       if (throw_error) throw std::invalid_argument("bad type");
+       return 0;
+      }
+    }
+  };
+    
+  template <class Type>
+  inline Type as(PyObject *obj, bool te = false) {
+    return traits_as<Type, typename traits<Type>::category>::as(obj, te);
+  }
+
+  template <class Type> 
+  struct traits_check<Type, value_category> {
+    static bool check(PyObject *obj) {
+      int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR;
+      return SWIG_IsOK(res) ? true : false;
+    }
+  };
+
+  template <class Type> 
+  struct traits_check<Type, pointer_category> {
+    static bool check(PyObject *obj) {
+      int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR;
+      return SWIG_IsOK(res) ? true : false;
+    }
+  };
+
+  template <class Type>
+  inline bool check(PyObject *obj) {
+    return traits_check<Type, typename traits<Type>::category>::check(obj);
+  }
+}
+
+
+#include <functional>
+
+namespace std {
+  template <>
+  struct less <PyObject *>: public binary_function<PyObject *, PyObject *, bool>
+  {
+    bool
+    operator()(PyObject * v, PyObject *w) const
+    { 
+      bool res;
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+      res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false;
+      /* This may fall into a case of inconsistent
+               eg. ObjA > ObjX > ObjB
+               but ObjA < ObjB
+      */
+      if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) )
+      {
+        /* Objects can't be compared, this mostly occurred in Python 3.0 */
+        /* Compare their ptr directly for a workaround */
+        res = (v < w);
+        PyErr_Clear();
+      }
+      SWIG_PYTHON_THREAD_END_BLOCK;
+      return res;
+    }
+  };
+
+  template <>
+  struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
+  {
+    bool
+    operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
+    {
+      return std::less<PyObject *>()(v, w);
+    }
+  };
+
+  template <>
+  struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
+  {
+    bool
+    operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
+    {
+      return std::less<PyObject *>()(v, w);
+    }
+  };
+
+}
+
+namespace swig {
+  template <> struct traits<PyObject *> {
+    typedef value_category category;
+    static const char* type_name() { return "PyObject *"; }
+  };  
+
+  template <>  struct traits_asval<PyObject * > {   
+    typedef PyObject * value_type;
+    static int asval(PyObject *obj, value_type *val) {
+      if (val) *val = obj;
+      return SWIG_OK;
+    }
+  };
+
+  template <> 
+  struct traits_check<PyObject *, value_category> {
+    static bool check(PyObject *) {
+      return true;
+    }
+  };
+
+  template <>  struct traits_from<PyObject *> {
+    typedef PyObject * value_type;
+    static PyObject *from(const value_type& val) {
+      Py_XINCREF(val);
+      return val;
+    }
+  };
+  
+}
+
+namespace swig {
+  template <class Difference>
+  inline size_t
+  check_index(Difference i, size_t size, bool insert = false) {
+    if ( i < 0 ) {
+      if ((size_t) (-i) <= size)
+       return (size_t) (i + size);
+    } else if ( (size_t) i < size ) {
+      return (size_t) i;
+    } else if (insert && ((size_t) i == size)) {
+      return size;
+    }
+    throw std::out_of_range("index out of range");
+  }
+
+  template <class Difference>
+  void
+  slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) {
+    if (step == 0) {
+      throw std::invalid_argument("slice step cannot be zero");
+    } else if (step > 0) {
+      // Required range: 0 <= i < size, 0 <= j < size
+      if (i < 0) {
+        ii = 0;
+      } else if (i < (Difference)size) {
+        ii = i;
+      } else if (insert && (i >= (Difference)size)) {
+        ii = (Difference)size;
+      }
+      if ( j < 0 ) {
+        jj = 0;
+      } else {
+        jj = (j < (Difference)size) ? j : (Difference)size;
+      }
+    } else {
+      // Required range: -1 <= i < size-1, -1 <= j < size-1
+      if (i < -1) {
+        ii = -1;
+      } else if (i < (Difference) size) {
+        ii = i;
+      } else if (i >= (Difference)(size-1)) {
+        ii = (Difference)(size-1);
+      }
+      if (j < -1) {
+        jj = -1;
+      } else {
+        jj = (j < (Difference)size ) ? j : (Difference)(size-1);
+      }
+    }
+  }
+
+  template <class Sequence, class Difference>
+  inline typename Sequence::iterator
+  getpos(Sequence* self, Difference i)  {
+    typename Sequence::iterator pos = self->begin();
+    std::advance(pos, check_index(i,self->size()));
+    return pos;
+  }
+
+  template <class Sequence, class Difference>
+  inline typename Sequence::const_iterator
+  cgetpos(const Sequence* self, Difference i)  {
+    typename Sequence::const_iterator pos = self->begin();
+    std::advance(pos, check_index(i,self->size()));
+    return pos;
+  }
+
+  template <class Sequence, class Difference>
+  inline Sequence*
+  getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
+    typename Sequence::size_type size = self->size();
+    Difference ii = 0;
+    Difference jj = 0;
+    swig::slice_adjust(i, j, step, size, ii, jj);
+
+    if (step > 0) {
+      typename Sequence::const_iterator sb = self->begin();
+      typename Sequence::const_iterator se = self->begin();
+      std::advance(sb,ii);
+      std::advance(se,jj);
+      if (step == 1) {
+        return new Sequence(sb, se);
+      } else {
+        Sequence *sequence = new Sequence();
+        typename Sequence::const_iterator it = sb;
+        while (it!=se) {
+          sequence->push_back(*it);
+          for (Py_ssize_t c=0; c<step && it!=se; ++c)
+            it++;
+        }
+        return sequence;
+      } 
+    } else {
+      Sequence *sequence = new Sequence();
+      if (ii > jj) {
+        typename Sequence::const_reverse_iterator sb = self->rbegin();
+        typename Sequence::const_reverse_iterator se = self->rbegin();
+        std::advance(sb,size-ii-1);
+        std::advance(se,size-jj-1);
+        typename Sequence::const_reverse_iterator it = sb;
+        while (it!=se) {
+          sequence->push_back(*it);
+          for (Py_ssize_t c=0; c<-step && it!=se; ++c)
+            it++;
+        }
+      }
+      return sequence;
+    }
+  }
+
+  template <class Sequence, class Difference, class InputSeq>
+  inline void
+  setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) {
+    typename Sequence::size_type size = self->size();
+    Difference ii = 0;
+    Difference jj = 0;
+    swig::slice_adjust(i, j, step, size, ii, jj, true);
+    if (step > 0) {
+      if (jj < ii)
+        jj = ii;
+      if (step == 1) {
+        size_t ssize = jj - ii;
+        if (ssize <= is.size()) {
+          // expanding/staying the same size
+          typename Sequence::iterator sb = self->begin();
+          typename InputSeq::const_iterator isit = is.begin();
+          std::advance(sb,ii);
+          std::advance(isit, jj - ii);
+          self->insert(std::copy(is.begin(), isit, sb), isit, is.end());
+        } else {
+          // shrinking
+          typename Sequence::iterator sb = self->begin();
+          typename Sequence::iterator se = self->begin();
+          std::advance(sb,ii);
+          std::advance(se,jj);
+          self->erase(sb,se);
+          sb = self->begin();
+          std::advance(sb,ii);
+          self->insert(sb, is.begin(), is.end());
+        }
+      } else {
+        size_t replacecount = (jj - ii + step - 1) / step;
+        if (is.size() != replacecount) {
+          char msg[1024];
+          sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
+          throw std::invalid_argument(msg);
+        }
+        typename Sequence::const_iterator isit = is.begin();
+        typename Sequence::iterator it = self->begin();
+        std::advance(it,ii);
+        for (size_t rc=0; rc<replacecount; ++rc) {
+          *it++ = *isit++;
+          for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
+            it++;
+        }
+      }
+    } else {
+      if (jj > ii)
+        jj = ii;
+      size_t replacecount = (ii - jj - step - 1) / -step;
+      if (is.size() != replacecount) {
+        char msg[1024];
+        sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
+        throw std::invalid_argument(msg);
+      }
+      typename Sequence::const_iterator isit = is.begin();
+      typename Sequence::reverse_iterator it = self->rbegin();
+      std::advance(it,size-ii-1);
+      for (size_t rc=0; rc<replacecount; ++rc) {
+        *it++ = *isit++;
+        for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
+          it++;
+      }
+    }
+  }
+
+  template <class Sequence, class Difference>
+  inline void
+  delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) {
+    typename Sequence::size_type size = self->size();
+    Difference ii = 0;
+    Difference jj = 0;
+    swig::slice_adjust(i, j, step, size, ii, jj, true);
+    if (step > 0) {
+      if (jj > ii) {
+        typename Sequence::iterator sb = self->begin();
+        std::advance(sb,ii);
+        if (step == 1) {
+          typename Sequence::iterator se = self->begin();
+          std::advance(se,jj);
+          self->erase(sb,se);
+        } else {
+          typename Sequence::iterator it = sb;
+          size_t delcount = (jj - ii + step - 1) / step;
+          while (delcount) {
+            it = self->erase(it);
+            for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
+              it++;
+            delcount--;
+          }
+        }
+      }
+    } else {
+      if (ii > jj) {
+        typename Sequence::reverse_iterator sb = self->rbegin();
+        std::advance(sb,size-ii-1);
+        typename Sequence::reverse_iterator it = sb;
+        size_t delcount = (ii - jj - step - 1) / -step;
+        while (delcount) {
+          it = typename Sequence::reverse_iterator(self->erase((++it).base()));
+          for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
+            it++;
+          delcount--;
+        }
+      }
+    }
+  }
+}
+
+
+#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
+#  if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL)
+#    define SWIG_STD_NOITERATOR_TRAITS_STL
+#  endif
+#endif
+
+#if !defined(SWIG_STD_NOITERATOR_TRAITS_STL)
+#include <iterator>
+#else
+namespace std {
+  template <class Iterator>
+  struct iterator_traits {
+    typedef ptrdiff_t difference_type;
+    typedef typename Iterator::value_type value_type;
+  };
+
+  template <class Iterator, class Category,class T, class Reference, class Pointer, class Distance>
+  struct iterator_traits<__reverse_bi_iterator<Iterator,Category,T,Reference,Pointer,Distance> > {
+    typedef Distance difference_type;
+    typedef T value_type;
+  };
+
+  template <class T>
+  struct iterator_traits<T*> {
+    typedef T value_type;
+    typedef ptrdiff_t difference_type;
+  };
+
+  template<typename _InputIterator>
+  inline typename iterator_traits<_InputIterator>::difference_type
+  distance(_InputIterator __first, _InputIterator __last)
+  {
+    typename iterator_traits<_InputIterator>::difference_type __n = 0;
+    while (__first != __last) {
+      ++__first; ++__n;
+    }
+    return __n;
+  }
+}
+#endif
+
+
+namespace swig {
+  template<typename OutIterator>
+  class SwigPyIterator_T :  public SwigPyIterator
+  {
+  public:
+    typedef OutIterator out_iterator;
+    typedef typename std::iterator_traits<out_iterator>::value_type value_type;    
+    typedef SwigPyIterator_T<out_iterator> self_type;
+
+    SwigPyIterator_T(out_iterator curr, PyObject *seq)
+      : SwigPyIterator(seq), current(curr)
+    {
+    }
+
+    const out_iterator& get_current() const
+    {
+      return current;
+    }
+
+    
+    bool equal (const SwigPyIterator &iter) const
+    {
+      const self_type *iters = dynamic_cast<const self_type *>(&iter);
+      if (iters) {
+       return (current == iters->get_current());
+      } else {
+       throw std::invalid_argument("bad iterator type");
+      }
+    }
+    
+    ptrdiff_t distance(const SwigPyIterator &iter) const
+    {
+      const self_type *iters = dynamic_cast<const self_type *>(&iter);
+      if (iters) {
+       return std::distance(current, iters->get_current());
+      } else {
+       throw std::invalid_argument("bad iterator type");
+      }
+    }    
+    
+  protected:
+    out_iterator current;
+  };
+  
+  template <class ValueType>
+  struct from_oper 
+  {
+    typedef const ValueType& argument_type;
+    typedef PyObject *result_type;
+    result_type operator()(argument_type v) const
+    {
+      return swig::from(v);
+    }
+  };
+
+  template<typename OutIterator, 
+          typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+          typename FromOper = from_oper<ValueType> >
+  class SwigPyIteratorOpen_T :  public SwigPyIterator_T<OutIterator>
+  {
+  public:
+    FromOper from;
+    typedef OutIterator out_iterator;
+    typedef ValueType value_type;
+    typedef SwigPyIterator_T<out_iterator>  base;
+    typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
+    
+    SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
+      : SwigPyIterator_T<OutIterator>(curr, seq)
+    {
+    }
+    
+    PyObject *value() const {
+      return from(static_cast<const value_type&>(*(base::current)));
+    }
+    
+    SwigPyIterator *copy() const
+    {
+      return new self_type(*this);
+    }
+
+    SwigPyIterator *incr(size_t n = 1)
+    {
+      while (n--) {
+       ++base::current;
+      }
+      return this;
+    }
+
+    SwigPyIterator *decr(size_t n = 1)
+    {
+      while (n--) {
+       --base::current;
+      }
+      return this;
+    }
+  };
+
+  template<typename OutIterator, 
+          typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+          typename FromOper = from_oper<ValueType> >
+  class SwigPyIteratorClosed_T :  public SwigPyIterator_T<OutIterator>
+  {
+  public:
+    FromOper from;
+    typedef OutIterator out_iterator;
+    typedef ValueType value_type;
+    typedef SwigPyIterator_T<out_iterator>  base;    
+    typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
+    
+    SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
+      : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
+    {
+    }
+    
+    PyObject *value() const {
+      if (base::current == end) {
+       throw stop_iteration();
+      } else {
+       return from(static_cast<const value_type&>(*(base::current)));
+      }
+    }
+    
+    SwigPyIterator *copy() const
+    {
+      return new self_type(*this);
+    }
+
+    SwigPyIterator *incr(size_t n = 1)
+    {
+      while (n--) {
+       if (base::current == end) {
+         throw stop_iteration();
+       } else {
+         ++base::current;
+       }
+      }
+      return this;
+    }
+
+    SwigPyIterator *decr(size_t n = 1)
+    {
+      while (n--) {
+       if (base::current == begin) {
+         throw stop_iteration();
+       } else {
+         --base::current;
+       }
+      }
+      return this;
+    }
+
+  private:
+    out_iterator begin;
+    out_iterator end;
+  };
+
+  template<typename OutIter>
+  inline SwigPyIterator*
+  make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
+  {
+    return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
+  }
+
+  template<typename OutIter>
+  inline SwigPyIterator*
+  make_output_iterator(const OutIter& current, PyObject *seq = 0)
+  {
+    return new SwigPyIteratorOpen_T<OutIter>(current, seq);
+  }
+
+}
+
+
+namespace swig
+{
+  template <class T>
+  struct SwigPySequence_Ref
+  {
+    SwigPySequence_Ref(PyObject* seq, int index)
+      : _seq(seq), _index(index)
+    {
+    }
+    
+    operator T () const
+    {
+      swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
+      try {
+       return swig::as<T>(item, true);
+      } catch (std::exception& e) {
+       char msg[1024];
+       sprintf(msg, "in sequence element %d ", _index);
+       if (!PyErr_Occurred()) {
+         ::SWIG_Error(SWIG_TypeError,  swig::type_name<T>());
+       }
+       SWIG_Python_AddErrorMsg(msg);
+       SWIG_Python_AddErrorMsg(e.what());
+       throw;
+      }
+    }
+
+    SwigPySequence_Ref& operator=(const T& v)
+    {
+      PySequence_SetItem(_seq, _index, swig::from<T>(v));
+      return *this;
+    }
+
+  private:
+    PyObject* _seq;
+    int _index;
+  };
+
+  template <class T>
+  struct SwigPySequence_ArrowProxy
+  {
+    SwigPySequence_ArrowProxy(const T& x): m_value(x) {}
+    const T* operator->() const { return &m_value; }
+    operator const T*() const { return &m_value; }
+    T m_value;
+  };
+
+  template <class T, class Reference >
+  struct SwigPySequence_InputIterator
+  {
+    typedef SwigPySequence_InputIterator<T, Reference > self;
+
+    typedef std::random_access_iterator_tag iterator_category;
+    typedef Reference reference;
+    typedef T value_type;
+    typedef T* pointer;
+    typedef int difference_type;
+
+    SwigPySequence_InputIterator()
+    {
+    }
+
+    SwigPySequence_InputIterator(PyObject* seq, int index)
+      : _seq(seq), _index(index)
+    {
+    }
+
+    reference operator*() const
+    {
+      return reference(_seq, _index);
+    }
+
+    SwigPySequence_ArrowProxy<T>
+    operator->() const {
+      return SwigPySequence_ArrowProxy<T>(operator*());
+    }
+
+    bool operator==(const self& ri) const
+    {
+      return (_index == ri._index) && (_seq == ri._seq);
+    }
+
+    bool operator!=(const self& ri) const
+    {
+      return !(operator==(ri));
+    }
+
+    self& operator ++ ()
+    {
+      ++_index;
+      return *this;
+    }
+
+    self& operator -- ()
+    {
+      --_index;
+      return *this;
+    }
+
+    self& operator += (difference_type n)
+    {
+      _index += n;
+      return *this;
+    }
+
+    self operator +(difference_type n) const
+    {
+      return self(_seq, _index + n);
+    }
+
+    self& operator -= (difference_type n)
+    {
+      _index -= n;
+      return *this;
+    }
+
+    self operator -(difference_type n) const
+    {
+      return self(_seq, _index - n);
+    }
+
+    difference_type operator - (const self& ri) const
+    {
+      return _index - ri._index;
+    }
+
+    bool operator < (const self& ri) const
+    {
+      return _index < ri._index;
+    }
+
+    reference
+    operator[](difference_type n) const
+    {
+      return reference(_seq, _index + n);
+    }
+
+  private:
+    PyObject* _seq;
+    difference_type _index;
+  };
+
+  template <class T>
+  struct SwigPySequence_Cont
+  {
+    typedef SwigPySequence_Ref<T> reference;
+    typedef const SwigPySequence_Ref<T> const_reference;
+    typedef T value_type;
+    typedef T* pointer;
+    typedef int difference_type;
+    typedef int size_type;
+    typedef const pointer const_pointer;
+    typedef SwigPySequence_InputIterator<T, reference> iterator;
+    typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
+
+    SwigPySequence_Cont(PyObject* seq) : _seq(0)
+    {
+      if (!PySequence_Check(seq)) {
+       throw std::invalid_argument("a sequence is expected");
+      }
+      _seq = seq;
+      Py_INCREF(_seq);
+    }
+
+    ~SwigPySequence_Cont()
+    {
+      Py_XDECREF(_seq);
+    }
+
+    size_type size() const
+    {
+      return static_cast<size_type>(PySequence_Size(_seq));
+    }
+
+    bool empty() const
+    {
+      return size() == 0;
+    }
+
+    iterator begin()
+    {
+      return iterator(_seq, 0);
+    }
+
+    const_iterator begin() const
+    {
+      return const_iterator(_seq, 0);
+    }
+
+    iterator end()
+    {
+      return iterator(_seq, size());
+    }
+
+    const_iterator end() const
+    {
+      return const_iterator(_seq, size());
+    }
+
+    reference operator[](difference_type n)
+    {
+      return reference(_seq, n);
+    }
+
+    const_reference operator[](difference_type n)  const
+    {
+      return const_reference(_seq, n);
+    }
+
+    bool check(bool set_err = true) const
+    {
+      int s = size();
+      for (int i = 0; i < s; ++i) {
+       swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
+       if (!swig::check<value_type>(item)) {
+         if (set_err) {
+           char msg[1024];
+           sprintf(msg, "in sequence element %d", i);
+           SWIG_Error(SWIG_RuntimeError, msg);
+         }
+         return false;
+       }
+      }
+      return true;
+    }
+
+  private:
+    PyObject* _seq;
+  };
+
+}
+
+
+  #define SWIG_From_double   PyFloat_FromDouble 
+
+
+namespace swig {
+  template <> struct traits<double > {
+    typedef value_category category;
+    static const char* type_name() { return"double"; }
+  };  
+  template <>  struct traits_asval<double > {   
+    typedef double value_type;
+    static int asval(PyObject *obj, value_type *val) { 
+      return SWIG_AsVal_double (obj, val);
+    }
+  };
+  template <>  struct traits_from<double > {
+    typedef double value_type;
+    static PyObject *from(const value_type& val) {
+      return SWIG_From_double  (val);
+    }
+  };
+}
+
+
+namespace swig {
+  template <class SwigPySeq, class Seq>
+  inline void
+  assign(const SwigPySeq& swigpyseq, Seq* seq) {
+    // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+    typedef typename SwigPySeq::value_type value_type;
+    typename SwigPySeq::const_iterator it = swigpyseq.begin();
+    for (;it != swigpyseq.end(); ++it) {
+      seq->insert(seq->end(),(value_type)(*it));
+    }
+  }
+
+  template <class Seq, class T = typename Seq::value_type >
+  struct traits_asptr_stdseq {
+    typedef Seq sequence;
+    typedef T value_type;
+
+    static int asptr(PyObject *obj, sequence **seq) {
+      if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
+       sequence *p;
+       if (::SWIG_ConvertPtr(obj,(void**)&p,
+                             swig::type_info<sequence>(),0) == SWIG_OK) {
+         if (seq) *seq = p;
+         return SWIG_OLDOBJ;
+       }
+      } else if (PySequence_Check(obj)) {
+       try {
+         SwigPySequence_Cont<value_type> swigpyseq(obj);
+         if (seq) {
+           sequence *pseq = new sequence();
+           assign(swigpyseq, pseq);
+           *seq = pseq;
+           return SWIG_NEWOBJ;
+         } else {
+           return swigpyseq.check() ? SWIG_OK : SWIG_ERROR;
+         }
+       } catch (std::exception& e) {
+         if (seq) {
+           if (!PyErr_Occurred()) {
+             PyErr_SetString(PyExc_TypeError, e.what());
+           }
+         }
+         return SWIG_ERROR;
+       }
+      }
+      return SWIG_ERROR;
+    }
+  };
+
+  template <class Seq, class T = typename Seq::value_type >
+  struct traits_from_stdseq {
+    typedef Seq sequence;
+    typedef T value_type;
+    typedef typename Seq::size_type size_type;
+    typedef typename sequence::const_iterator const_iterator;
+
+    static PyObject *from(const sequence& seq) {
+#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS
+      swig_type_info *desc = swig::type_info<sequence>();
+      if (desc && desc->clientdata) {
+       return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
+      }
+#endif
+      size_type size = seq.size();
+      if (size <= (size_type)INT_MAX) {
+       PyObject *obj = PyTuple_New((int)size);
+       int i = 0;
+       for (const_iterator it = seq.begin();
+            it != seq.end(); ++it, ++i) {
+         PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
+       }
+       return obj;
+      } else {
+       PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python");
+       return NULL;
+      }
+    }
+  };
+}
+
+
+  namespace swig {
+    template <class T>
+    struct traits_asptr<std::vector<T> >  {
+      static int asptr(PyObject *obj, std::vector<T> **vec) {
+       return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
+      }
+    };
+    
+    template <class T>
+    struct traits_from<std::vector<T> > {
+      static PyObject *from(const std::vector<T>& vec) {
+       return traits_from_stdseq<std::vector<T> >::from(vec);
+      }
+    };
+  }
+
+
+      namespace swig {
+       template <>  struct traits<std::vector<double, std::allocator< double > > > {
+         typedef pointer_category category;
+         static const char* type_name() {
+           return "std::vector<" "double" "," "std::allocator< double >" " >";
+         }
+       };
+      }
+    
+SWIGINTERN swig::SwigPyIterator *std_vector_Sl_double_Sg__iterator(std::vector< double > *self,PyObject **PYTHON_SELF){
+      return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+    }
+SWIGINTERN bool std_vector_Sl_double_Sg____nonzero__(std::vector< double > const *self){
+      return !(self->empty());
+    }
+SWIGINTERN bool std_vector_Sl_double_Sg____bool__(std::vector< double > const *self){
+      return !(self->empty());
+    }
+SWIGINTERN std::vector< double >::size_type std_vector_Sl_double_Sg____len__(std::vector< double > const *self){
+      return self->size();
+    }
+
+SWIGINTERNINLINE PyObject* 
+SWIG_From_unsigned_SS_long  (unsigned long value)
+{
+  return (value > LONG_MAX) ?
+    PyLong_FromUnsignedLong(value) : PyLong_FromLong(static_cast< long >(value)); 
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_size_t  (size_t value)
+{    
+  return SWIG_From_unsigned_SS_long  (static_cast< unsigned long >(value));
+}
+
+SWIGINTERN std::vector< double >::value_type std_vector_Sl_double_Sg__pop(std::vector< double > *self){
+      if (self->size() == 0)
+       throw std::out_of_range("pop from empty container");
+      std::vector<double,std::allocator< double > >::value_type x = self->back();
+      self->pop_back();
+      return x;
+    }
+SWIGINTERN std::vector< double,std::allocator< double > > *std_vector_Sl_double_Sg____getslice__(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j){
+      return swig::getslice(self, i, j, 1);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____setslice____SWIG_0(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j,std::vector< double,std::allocator< double > > const &v=std::vector< double,std::allocator< double > >()){
+      swig::setslice(self, i, j, 1, v);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____delslice__(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j){
+      swig::delslice(self, i, j, 1);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____delitem____SWIG_0(std::vector< double > *self,std::vector< double >::difference_type i){
+      self->erase(swig::getpos(self,i));
+    }
+SWIGINTERN std::vector< double,std::allocator< double > > *std_vector_Sl_double_Sg____getitem____SWIG_0(std::vector< double > *self,PySliceObject *slice){
+      Py_ssize_t i, j, step;
+      if( !PySlice_Check(slice) ) {
+        SWIG_Error(SWIG_TypeError, "Slice object expected.");
+        return NULL;
+      }
+      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
+      std::vector<double,std::allocator< double > >::difference_type id = i;
+      std::vector<double,std::allocator< double > >::difference_type jd = j;
+      return swig::getslice(self, id, jd, step);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_0(std::vector< double > *self,PySliceObject *slice,std::vector< double,std::allocator< double > > const &v){
+      Py_ssize_t i, j, step;
+      if( !PySlice_Check(slice) ) {
+        SWIG_Error(SWIG_TypeError, "Slice object expected.");
+        return;
+      }
+      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
+      std::vector<double,std::allocator< double > >::difference_type id = i;
+      std::vector<double,std::allocator< double > >::difference_type jd = j;
+      swig::setslice(self, id, jd, step, v);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_1(std::vector< double > *self,PySliceObject *slice){
+      Py_ssize_t i, j, step;
+      if( !PySlice_Check(slice) ) {
+        SWIG_Error(SWIG_TypeError, "Slice object expected.");
+        return;
+      }
+      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
+      std::vector<double,std::allocator< double > >::difference_type id = i;
+      std::vector<double,std::allocator< double > >::difference_type jd = j;
+      swig::delslice(self, id, jd, step);
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____delitem____SWIG_1(std::vector< double > *self,PySliceObject *slice){
+      Py_ssize_t i, j, step;
+      if( !PySlice_Check(slice) ) {
+        SWIG_Error(SWIG_TypeError, "Slice object expected.");
+        return;
+      }
+      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
+      std::vector<double,std::allocator< double > >::difference_type id = i;
+      std::vector<double,std::allocator< double > >::difference_type jd = j;
+      swig::delslice(self, id, jd, step);
+    }
+SWIGINTERN std::vector< double >::value_type const &std_vector_Sl_double_Sg____getitem____SWIG_1(std::vector< double > const *self,std::vector< double >::difference_type i){
+      return *(swig::cgetpos(self, i));
+    }
+SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_2(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::value_type const &x){
+      *(swig::getpos(self,i)) = x;
+    }
+SWIGINTERN void std_vector_Sl_double_Sg__append(std::vector< double > *self,std::vector< double >::value_type const &x){
+      self->push_back(x);
+    }
+SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__erase__SWIG_0(std::vector< double > *self,std::vector< double >::iterator pos){ return self->erase(pos); }
+SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__erase__SWIG_1(std::vector< double > *self,std::vector< double >::iterator first,std::vector< double >::iterator last){ return self->erase(first, last); }
+SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__insert__SWIG_0(std::vector< double > *self,std::vector< double >::iterator pos,std::vector< double >::value_type const &x){ return self->insert(pos, x); }
+SWIGINTERN void std_vector_Sl_double_Sg__insert__SWIG_1(std::vector< double > *self,std::vector< double >::iterator pos,std::vector< double >::size_type n,std::vector< double >::value_type const &x){ self->insert(pos, n, x); }
+
+
+#define ExceptionSubclass(EXCNAME, EXCDOC)                             \
+  static PyTypeObject MyExc_ ## EXCNAME = {                            \
+    PyVarObject_HEAD_INIT(NULL, 0)                                             \
+      "nlopt." # EXCNAME,                                              \
+      sizeof(PyBaseExceptionObject),                                   \
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                  \
+      Py_TPFLAGS_DEFAULT,                                              \
+      PyDoc_STR(EXCDOC)                                                        \
+  };                                                                   \
+  static void init_ ## EXCNAME(PyObject *m) {                          \
+    MyExc_ ## EXCNAME .tp_base = (PyTypeObject *) PyExc_Exception;     \
+    PyType_Ready(&MyExc_ ## EXCNAME);                                  \
+    Py_INCREF(&MyExc_ ## EXCNAME);                                     \
+    PyModule_AddObject(m, # EXCNAME, (PyObject *) &MyExc_ ## EXCNAME); \
+  }
+
+
+ExceptionSubclass(ForcedStop,
+                 "Python version of nlopt::forced_stop exception.")
+
+ExceptionSubclass(RoundoffLimited,
+                 "Python version of nlopt::roundoff_limited exception.")
+
+
+
+#define SWIG_FILE_WITH_INIT
+
+
+#ifndef SWIG_FILE_WITH_INIT
+#define NO_IMPORT_ARRAY
+#endif
+#include "stdio.h"
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/arrayobject.h>
+
+
+static void *free_pyfunc(void *p) { Py_DECREF((PyObject*) p); return p; }
+static void *dup_pyfunc(void *p) { Py_INCREF((PyObject*) p); return p; }
+
+#if NPY_API_VERSION < 0x00000007
+#  define NPY_ARRAY_C_CONTIGUOUS NPY_C_CONTIGUOUS
+#  define NPY_ARRAY_ALIGNED NPY_ALIGNED
+#endif
+
+static double func_python(unsigned n, const double *x, double *grad, void *f)
+{
+  npy_intp sz = npy_intp(n), sz0 = 0, stride1 = sizeof(double);
+  PyObject *xpy = PyArray_New(&PyArray_Type, 1, &sz, NPY_DOUBLE, &stride1,
+                             const_cast<double*>(x), // not NPY_WRITEABLE
+                             0, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED, NULL);
+  PyObject *gradpy = grad
+    ? PyArray_SimpleNewFromData(1, &sz, NPY_DOUBLE, grad)
+    : PyArray_SimpleNew(1, &sz0, NPY_DOUBLE);
+  
+  PyObject *arglist = Py_BuildValue("OO", xpy, gradpy);
+  PyObject *result = PyEval_CallObject((PyObject *) f, arglist);
+  Py_DECREF(arglist);
+
+  Py_DECREF(gradpy);
+  Py_DECREF(xpy);
+
+  double val = HUGE_VAL;
+  if (PyErr_Occurred()) {
+    Py_XDECREF(result);
+    throw nlopt::forced_stop(); // just stop, don't call PyErr_Clear()
+  }
+  else if (result && PyFloat_Check(result)) {
+    val = PyFloat_AsDouble(result);
+    Py_DECREF(result);
+  }
+  else {
+    Py_XDECREF(result);
+    throw std::invalid_argument("invalid result passed to nlopt");
+  }
+  return val;
+}
+
+static void mfunc_python(unsigned m, double *result,
+                        unsigned n, const double *x, double *grad, void *f)
+{
+  npy_intp nsz = npy_intp(n), msz = npy_intp(m);
+  npy_intp mnsz[2] = {msz, nsz};
+  npy_intp sz0 = 0, stride1 = sizeof(double);
+  PyObject *xpy = PyArray_New(&PyArray_Type, 1, &nsz, NPY_DOUBLE, &stride1,
+                             const_cast<double*>(x), // not NPY_WRITEABLE
+                             0, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED, NULL);
+  PyObject *rpy = PyArray_SimpleNewFromData(1, &msz, NPY_DOUBLE, result);
+  PyObject *gradpy = grad
+    ? PyArray_SimpleNewFromData(2, mnsz, NPY_DOUBLE, grad)
+    : PyArray_SimpleNew(1, &sz0, NPY_DOUBLE);
+  
+  PyObject *arglist = Py_BuildValue("OOO", rpy, xpy, gradpy);
+  PyObject *res = PyEval_CallObject((PyObject *) f, arglist);
+  Py_XDECREF(res);
+  Py_DECREF(arglist);
+
+  Py_DECREF(gradpy);
+  Py_DECREF(rpy);
+  Py_DECREF(xpy);
+
+  if (PyErr_Occurred()) {
+    throw nlopt::forced_stop(); // just stop, don't call PyErr_Clear()
+  }
+}
+
+
+SWIGINTERNINLINE PyObject*
+  SWIG_From_int  (int value)
+{
+  return PyInt_FromLong((long) value);
+}
+
+
+#include <limits.h>
+#if !defined(SWIG_NO_LLONG_MAX)
+# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
+#   define LLONG_MAX __LONG_LONG_MAX__
+#   define LLONG_MIN (-LLONG_MAX - 1LL)
+#   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
+# endif
+#endif
+
+
+SWIGINTERN int
+SWIG_AsVal_int (PyObject * obj, int *val)
+{
+  long v;
+  int res = SWIG_AsVal_long (obj, &v);
+  if (SWIG_IsOK(res)) {
+    if ((v < INT_MIN || v > INT_MAX)) {
+      return SWIG_OverflowError;
+    } else {
+      if (val) *val = static_cast< int >(v);
+    }
+  }  
+  return res;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
+{
+  unsigned long v;
+  int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+  if (SWIG_IsOK(res)) {
+    if ((v > UINT_MAX)) {
+      return SWIG_OverflowError;
+    } else {
+      if (val) *val = static_cast< unsigned int >(v);
+    }
+  }  
+  return res;
+}
+
+
+#if NPY_API_VERSION < 0x00000007
+#define NPY_ARRAY_DEFAULT NPY_DEFAULT
+#define NPY_ARRAY_FARRAY  NPY_FARRAY
+#define NPY_FORTRANORDER  NPY_FORTRAN
+#endif
+
+
+/* Macros to extract array attributes.
+ */
+#if NPY_API_VERSION < 0x00000007
+#define is_array(a)            ((a) && PyArray_Check((PyArrayObject*)a))
+#define array_type(a)          (int)(PyArray_TYPE((PyArrayObject*)a))
+#define array_numdims(a)       (((PyArrayObject*)a)->nd)
+#define array_dimensions(a)    (((PyArrayObject*)a)->dimensions)
+#define array_size(a,i)        (((PyArrayObject*)a)->dimensions[i])
+#define array_strides(a)       (((PyArrayObject*)a)->strides)
+#define array_stride(a,i)      (((PyArrayObject*)a)->strides[i])
+#define array_data(a)          (((PyArrayObject*)a)->data)
+#define array_descr(a)         (((PyArrayObject*)a)->descr)
+#define array_flags(a)         (((PyArrayObject*)a)->flags)
+#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f
+#else
+#define is_array(a)            ((a) && PyArray_Check(a))
+#define array_type(a)          PyArray_TYPE((PyArrayObject*)a)
+#define array_numdims(a)       PyArray_NDIM((PyArrayObject*)a)
+#define array_dimensions(a)    PyArray_DIMS((PyArrayObject*)a)
+#define array_strides(a)       PyArray_STRIDES((PyArrayObject*)a)
+#define array_stride(a,i)      PyArray_STRIDE((PyArrayObject*)a,i)
+#define array_size(a,i)        PyArray_DIM((PyArrayObject*)a,i)
+#define array_data(a)          PyArray_DATA((PyArrayObject*)a)
+#define array_descr(a)         PyArray_DESCR((PyArrayObject*)a)
+#define array_flags(a)         PyArray_FLAGS((PyArrayObject*)a)
+#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f)
+#endif
+#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
+#define array_is_native(a)     (PyArray_ISNOTSWAPPED((PyArrayObject*)a))
+#define array_is_fortran(a)    (PyArray_ISFORTRAN((PyArrayObject*)a))
+
+
+  /* Given a PyObject, return a string describing its type.
+   */
+  const char* pytype_string(PyObject* py_obj)
+  {
+    if (py_obj == NULL          ) return "C NULL value";
+    if (py_obj == Py_None       ) return "Python None" ;
+    if (PyCallable_Check(py_obj)) return "callable"    ;
+    if (PyString_Check(  py_obj)) return "string"      ;
+    if (PyInt_Check(     py_obj)) return "int"         ;
+    if (PyFloat_Check(   py_obj)) return "float"       ;
+    if (PyDict_Check(    py_obj)) return "dict"        ;
+    if (PyList_Check(    py_obj)) return "list"        ;
+    if (PyTuple_Check(   py_obj)) return "tuple"       ;
+#if PY_MAJOR_VERSION < 3
+    if (PyFile_Check(    py_obj)) return "file"        ;
+    if (PyModule_Check(  py_obj)) return "module"      ;
+    if (PyInstance_Check(py_obj)) return "instance"    ;
+#endif
+
+    return "unkown type";
+  }
+
+  /* Given a NumPy typecode, return a string describing the type.
+   */
+  const char* typecode_string(int typecode)
+  {
+    static const char* type_names[25] = {"bool",
+                                         "byte",
+                                         "unsigned byte",
+                                         "short",
+                                         "unsigned short",
+                                         "int",
+                                         "unsigned int",
+                                         "long",
+                                         "unsigned long",
+                                         "long long",
+                                         "unsigned long long",
+                                         "float",
+                                         "double",
+                                         "long double",
+                                         "complex float",
+                                         "complex double",
+                                         "complex long double",
+                                         "object",
+                                         "string",
+                                         "unicode",
+                                         "void",
+                                         "ntypes",
+                                         "notype",
+                                         "char",
+                                         "unknown"};
+    return typecode < 24 ? type_names[typecode] : type_names[24];
+  }
+
+  /* Make sure input has correct numpy type.  This now just calls
+     PyArray_EquivTypenums().
+   */
+  int type_match(int actual_type,
+                 int desired_type)
+  {
+    return PyArray_EquivTypenums(actual_type, desired_type);
+  }
+
+#ifdef SWIGPY_USE_CAPSULE
+  void free_cap(PyObject * cap)
+  {
+    void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
+    if (array != NULL) free(array);
+  }
+#endif
+
+
+
+
+  /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
+   * legal.  If not, set the python error string appropriately and
+   * return NULL.
+   */
+  PyArrayObject* obj_to_array_no_conversion(PyObject* input,
+                                            int        typecode)
+  {
+    PyArrayObject* ary = NULL;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input), typecode)))
+    {
+      ary = (PyArrayObject*) input;
+    }
+    else if is_array(input)
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = typecode_string(array_type(input));
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  Array of type '%s' given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    else
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = pytype_string(input);
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  A '%s' was given",
+                   desired_type,
+                   actual_type);
+      ary = NULL;
+    }
+    return ary;
+  }
+
+  /* Convert the given PyObject to a NumPy array with the given
+   * typecode.  On success, return a valid PyArrayObject* with the
+   * correct type.  On failure, the python error string will be set and
+   * the routine returns NULL.
+   */
+  PyArrayObject* obj_to_array_allow_conversion(PyObject* input,
+                                               int       typecode,
+                                               int*      is_new_object)
+  {
+    PyArrayObject* ary = NULL;
+    PyObject*      py_obj;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input),typecode)))
+    {
+      ary = (PyArrayObject*) input;
+      *is_new_object = 0;
+    }
+    else
+    {
+      py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT);
+      /* If NULL, PyArray_FromObject will have set python error value.*/
+      ary = (PyArrayObject*) py_obj;
+      *is_new_object = 1;
+    }
+    return ary;
+  }
+
+  /* Given a PyArrayObject, check to see if it is contiguous.  If so,
+   * return the input pointer and flag it as not a new object.  If it is
+   * not contiguous, create a new PyArrayObject using the original data,
+   * flag it as a new object and return the pointer.
+   */
+  PyArrayObject* make_contiguous(PyArrayObject* ary,
+                                 int*           is_new_object,
+                                 int            min_dims,
+                                 int            max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_contiguous(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
+                                                              array_type(ary),
+                                                              min_dims,
+                                                              max_dims);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
+   * If so, return the input pointer, but do not flag it as not a new
+   * object.  If it is not Fortran-contiguous, create a new
+   * PyArrayObject using the original data, flag it as a new object
+   * and return the pointer.
+   */
+  PyArrayObject* make_fortran(PyArrayObject* ary,
+                              int*           is_new_object)
+  {
+    PyArrayObject* result;
+    if (array_is_fortran(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      Py_INCREF(array_descr(ary));
+      result = (PyArrayObject*) PyArray_FromArray(ary,
+                                                  array_descr(ary),
+                                                  NPY_FORTRANORDER);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Convert a given PyObject to a contiguous PyArrayObject of the
+   * specified type.  If the input object is not a contiguous
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
+                                                          int       typecode,
+                                                          int*      is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+                                                        typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_contiguous(ary1, &is_new2, 0, 0);
+      if ( is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+  /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
+   * specified type.  If the input object is not a Fortran-ordered
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
+                                                       int       typecode,
+                                                       int*      is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+                                                        typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_fortran(ary1, &is_new2);
+      if (is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+
+  /* Test whether a python object is contiguous.  If array is
+   * contiguous, return 1.  Otherwise, set the python error string and
+   * return 0.
+   */
+  int require_contiguous(PyArrayObject* ary)
+  {
+    int contiguous = 1;
+    if (!array_is_contiguous(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must be contiguous.  A non-contiguous array was given");
+      contiguous = 0;
+    }
+    return contiguous;
+  }
+
+  /* Require that a numpy array is not byte-swapped.  If the array is
+   * not byte-swapped, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_native(PyArrayObject* ary)
+  {
+    int native = 1;
+    if (!array_is_native(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must have native byteorder.  "
+                      "A byte-swapped array was given");
+      native = 0;
+    }
+    return native;
+  }
+
+  /* Require the given PyArrayObject to have a specified number of
+   * dimensions.  If the array has the specified number of dimensions,
+   * return 1.  Otherwise, set the python error string and return 0.
+   */
+  int require_dimensions(PyArrayObject* ary,
+                         int            exact_dimensions)
+  {
+    int success = 1;
+    if (array_numdims(ary) != exact_dimensions)
+    {
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %d dimensions.  Given array has %d dimensions",
+                   exact_dimensions,
+                   array_numdims(ary));
+      success = 0;
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have one of a list of specified
+   * number of dimensions.  If the array has one of the specified number
+   * of dimensions, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_dimensions_n(PyArrayObject* ary,
+                           int*           exact_dimensions,
+                           int            n)
+  {
+    int success = 0;
+    int i;
+    char dims_str[255] = "";
+    char s[255];
+    for (i = 0; i < n && !success; i++)
+    {
+      if (array_numdims(ary) == exact_dimensions[i])
+      {
+        success = 1;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n-1; i++)
+      {
+        sprintf(s, "%d, ", exact_dimensions[i]);
+        strcat(dims_str,s);
+      }
+      sprintf(s, " or %d", exact_dimensions[n-1]);
+      strcat(dims_str,s);
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %s dimensions.  Given array has %d dimensions",
+                   dims_str,
+                   array_numdims(ary));
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have a specified shape.  If the
+   * array has the specified shape, return 1.  Otherwise, set the python
+   * error string and return 0.
+   */
+  int require_size(PyArrayObject* ary,
+                   npy_intp*      size,
+                   int            n)
+  {
+    int i;
+    int success = 1;
+    int len;
+    char desired_dims[255] = "[";
+    char s[255];
+    char actual_dims[255] = "[";
+    for(i=0; i < n;i++)
+    {
+      if (size[i] != -1 &&  size[i] != array_size(ary,i))
+      {
+        success = 0;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n; i++)
+      {
+        if (size[i] == -1)
+        {
+          sprintf(s, "*,");
+        }
+        else
+        {
+          sprintf(s, "%ld,", (long int)size[i]);
+        }
+        strcat(desired_dims,s);
+      }
+      len = strlen(desired_dims);
+      desired_dims[len-1] = ']';
+      for (i = 0; i < n; i++)
+      {
+        sprintf(s, "%ld,", (long int)array_size(ary,i));
+        strcat(actual_dims,s);
+      }
+      len = strlen(actual_dims);
+      actual_dims[len-1] = ']';
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have shape of %s.  Given array has shape of %s",
+                   desired_dims,
+                   actual_dims);
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to to be Fortran ordered.  If the
+   * the PyArrayObject is already Fortran ordered, do nothing.  Else,
+   * set the Fortran ordering flag and recompute the strides.
+   */
+  int require_fortran(PyArrayObject* ary)
+  {
+    int success = 1;
+    int nd = array_numdims(ary);
+    int i;
+    npy_intp * strides = array_strides(ary);
+    if (array_is_fortran(ary)) return success;
+    /* Set the Fortran ordered flag */
+    array_enableflags(ary,NPY_ARRAY_FARRAY);
+    /* Recompute the strides */
+    strides[0] = strides[nd-1];
+    for (i=1; i < nd; ++i)
+      strides[i] = strides[i-1] * array_size(ary,i-1);
+    return success;
+  }
+
+
+
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor(void)
+{
+  static int init = 0;
+  static swig_type_info* info = 0;
+  if (!init) {
+    info = SWIG_TypeQuery("_p_char");
+    init = 1;
+  }
+  return info;
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+  if (carray) {
+    if (size > INT_MAX) {
+      swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+      return pchar_descriptor ? 
+       SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
+    } else {
+#if PY_VERSION_HEX >= 0x03000000
+      return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
+#else
+      return PyString_FromStringAndSize(carray, static_cast< int >(size));
+#endif
+    }
+  } else {
+    return SWIG_Py_Void();
+  }
+}
+
+
+SWIGINTERNINLINE PyObject * 
+SWIG_FromCharPtr(const char *cptr)
+{ 
+  return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
+}
+
+
+SWIGINTERNINLINE PyObject*
+  SWIG_From_unsigned_SS_int  (unsigned int value)
+{
+  return PyInt_FromSize_t((size_t) value);
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SWIGINTERN PyObject *_wrap_delete_SwigPyIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_SwigPyIterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SwigPyIterator" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_value(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_value",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_value" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (PyObject *)((swig::SwigPyIterator const *)arg1)->value();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_incr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_incr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_incr" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *)(arg1)->incr(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_incr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_incr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (swig::SwigPyIterator *)(arg1)->incr();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_incr(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_SwigPyIterator_incr__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_SwigPyIterator_incr__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'SwigPyIterator_incr'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    swig::SwigPyIterator::incr(size_t)\n"
+    "    swig::SwigPyIterator::incr()\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_decr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_decr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_decr" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *)(arg1)->decr(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_decr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_decr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (swig::SwigPyIterator *)(arg1)->decr();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_decr(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_SwigPyIterator_decr__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_SwigPyIterator_decr__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'SwigPyIterator_decr'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    swig::SwigPyIterator::decr(size_t)\n"
+    "    swig::SwigPyIterator::decr()\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_distance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::SwigPyIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  ptrdiff_t result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_distance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_distance" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator_distance" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator_distance" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  try {
+    result = ((swig::SwigPyIterator const *)arg1)->distance((swig::SwigPyIterator const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
+  }
+  
+  resultobj = SWIG_From_ptrdiff_t(static_cast< ptrdiff_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_equal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::SwigPyIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_equal",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_equal" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator_equal" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator_equal" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  try {
+    result = (bool)((swig::SwigPyIterator const *)arg1)->equal((swig::SwigPyIterator const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
+  }
+  
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_copy",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_copy" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->copy();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_next",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_next" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (PyObject *)(arg1)->next();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___next__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator___next__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___next__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (PyObject *)(arg1)->__next__();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_previous(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_previous",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_previous" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  try {
+    result = (PyObject *)(arg1)->previous();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator_advance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_advance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_advance" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_advance" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *)(arg1)->advance(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::SwigPyIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___eq__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___eq__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___eq__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___eq__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  result = (bool)((swig::SwigPyIterator const *)arg1)->operator ==((swig::SwigPyIterator const &)*arg2);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::SwigPyIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___ne__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___ne__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___ne__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___ne__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  result = (bool)((swig::SwigPyIterator const *)arg1)->operator !=((swig::SwigPyIterator const &)*arg2);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___iadd__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___iadd__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___iadd__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *) &(arg1)->operator +=(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___isub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___isub__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___isub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *) &(arg1)->operator -=(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___add__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___add__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___add__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->operator +(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___sub__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->operator -(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::SwigPyIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  ptrdiff_t result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___sub__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  result = ((swig::SwigPyIterator const *)arg1)->operator -((swig::SwigPyIterator const &)*arg2);
+  resultobj = SWIG_From_ptrdiff_t(static_cast< ptrdiff_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_SwigPyIterator___sub__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_swig__SwigPyIterator, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_SwigPyIterator___sub____SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_SwigPyIterator___sub____SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  Py_INCREF(Py_NotImplemented);
+  return Py_NotImplemented;
+}
+
+
+SWIGINTERN PyObject *SwigPyIterator_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_swig__SwigPyIterator, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  PyObject **arg2 = (PyObject **) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::SwigPyIterator *result = 0 ;
+  
+  arg2 = &obj0;
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_iterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_iterator" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (swig::SwigPyIterator *)std_vector_Sl_double_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___nonzero__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (bool)std_vector_Sl_double_Sg____nonzero__((std::vector< double > const *)arg1);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector___bool__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___bool__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (bool)std_vector_Sl_double_Sg____bool__((std::vector< double > const *)arg1);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::size_type result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector___len__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___len__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = std_vector_Sl_double_Sg____len__((std::vector< double > const *)arg1);
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::value_type result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_pop",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_pop" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  try {
+    result = (std::vector< double >::value_type)std_vector_Sl_double_Sg__pop(arg1);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  std::vector< double >::difference_type arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  std::vector< double,std::allocator< double > > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___getslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___getslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector___getslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  try {
+    result = (std::vector< double,std::allocator< double > > *)std_vector_Sl_double_Sg____getslice__(arg1,arg2,arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  std::vector< double >::difference_type arg3 ;
+  std::vector< double,std::allocator< double > > *arg4 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  int res4 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:nlopt_doublevector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___setslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___setslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector___setslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  {
+    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    res4 = swig::asptr(obj3, &ptr);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "nlopt_doublevector___setslice__" "', argument " "4"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "nlopt_doublevector___setslice__" "', argument " "4"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    arg4 = ptr;
+  }
+  try {
+    std_vector_Sl_double_Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< double,std::allocator< double > > const &)*arg4);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res4)) delete arg4;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res4)) delete arg4;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  std::vector< double >::difference_type arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___setslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___setslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector___setslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  try {
+    std_vector_Sl_double_Sg____setslice____SWIG_0(arg1,arg2,arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setslice__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_doublevector___setslice____SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          int res = swig::asptr(argv[3], (std::vector<double,std::allocator< double > >**)(0));
+          _v = SWIG_CheckState(res);
+          if (_v) {
+            return _wrap_nlopt_doublevector___setslice____SWIG_0(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector___setslice__'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::__setslice__(std::vector< double >::difference_type,std::vector< double >::difference_type,std::vector< double,std::allocator< double > > const &)\n"
+    "    std::vector< double >::__setslice__(std::vector< double >::difference_type,std::vector< double >::difference_type)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  std::vector< double >::difference_type arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___delslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___delslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector___delslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  try {
+    std_vector_Sl_double_Sg____delslice__(arg1,arg2,arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___delitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___delitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  try {
+    std_vector_Sl_double_Sg____delitem____SWIG_0(arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double,std::allocator< double > > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___getitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  {
+    if (!PySlice_Check(obj1)) {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    }
+    arg2 = (PySliceObject *) obj1;
+  }
+  try {
+    result = (std::vector< double,std::allocator< double > > *)std_vector_Sl_double_Sg____getitem____SWIG_0(arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector< double,std::allocator< double > > *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  {
+    if (!PySlice_Check(obj1)) {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    }
+    arg2 = (PySliceObject *) obj1;
+  }
+  {
+    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    res3 = swig::asptr(obj2, &ptr);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "nlopt_doublevector___setitem__" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "nlopt_doublevector___setitem__" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+    }
+    arg3 = ptr;
+  }
+  try {
+    std_vector_Sl_double_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< double,std::allocator< double > > const &)*arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector___setitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  {
+    if (!PySlice_Check(obj1)) {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    }
+    arg2 = (PySliceObject *) obj1;
+  }
+  try {
+    std_vector_Sl_double_Sg____setitem____SWIG_1(arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___delitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  {
+    if (!PySlice_Check(obj1)) {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    }
+    arg2 = (PySliceObject *) obj1;
+  }
+  try {
+    std_vector_Sl_double_Sg____delitem____SWIG_1(arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___delitem__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PySlice_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector___delitem____SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector___delitem____SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector___delitem__'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::__delitem__(std::vector< double >::difference_type)\n"
+    "    std::vector< double >::__delitem__(PySliceObject *)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double >::value_type *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___getitem__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___getitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  try {
+    result = (std::vector< double >::value_type *) &std_vector_Sl_double_Sg____getitem____SWIG_1((std::vector< double > const *)arg1,arg2);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_From_double(static_cast< double >(*result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___getitem__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PySlice_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector___getitem____SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector___getitem____SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector___getitem__'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::__getitem__(PySliceObject *)\n"
+    "    std::vector< double >::__getitem__(std::vector< double >::difference_type) const\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::difference_type arg2 ;
+  std::vector< double >::value_type *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  std::vector< double >::value_type temp3 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector___setitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_double(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector___setitem__" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  arg3 = &temp3;
+  try {
+    std_vector_Sl_double_Sg____setitem____SWIG_2(arg1,arg2,(double const &)*arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector___setitem__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PySlice_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector___setitem____SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PySlice_Check(argv[1]);
+      }
+      if (_v) {
+        int res = swig::asptr(argv[2], (std::vector<double,std::allocator< double > >**)(0));
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_nlopt_doublevector___setitem____SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_double(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_doublevector___setitem____SWIG_2(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector___setitem__'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::__setitem__(PySliceObject *,std::vector< double,std::allocator< double > > const &)\n"
+    "    std::vector< double >::__setitem__(PySliceObject *)\n"
+    "    std::vector< double >::__setitem__(std::vector< double >::difference_type,std::vector< double >::value_type const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::value_type *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::vector< double >::value_type temp2 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_append",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_append" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_append" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp2 = static_cast< std::vector< double >::value_type >(val2);
+  arg2 = &temp2;
+  std_vector_Sl_double_Sg__append(arg1,(double const &)*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_nlopt_doublevector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_nlopt_doublevector")) SWIG_fail;
+  result = (std::vector< double > *)new std::vector< double >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_nlopt_doublevector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  std::vector< double > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_nlopt_doublevector",&obj0)) SWIG_fail;
+  {
+    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_nlopt_doublevector" "', argument " "1"" of type '" "std::vector< double > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_nlopt_doublevector" "', argument " "1"" of type '" "std::vector< double > const &""'"); 
+    }
+    arg1 = ptr;
+  }
+  result = (std::vector< double > *)new std::vector< double >((std::vector< double > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_empty" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (bool)((std::vector< double > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::size_type result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_size" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = ((std::vector< double > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_clear" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  (arg1)->clear();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_swap" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "nlopt_doublevector_swap" "', argument " "2"" of type '" "std::vector< double > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "nlopt_doublevector_swap" "', argument " "2"" of type '" "std::vector< double > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double > * >(argp2);
+  (arg1)->swap(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  SwigValueWrapper< std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_get_allocator" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = ((std::vector< double > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector< double >::allocator_type(static_cast< const std::vector< double >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_double_t, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_begin" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_end" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::reverse_iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_rbegin" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::reverse_iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::reverse_iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_rend" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::reverse_iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_nlopt_doublevector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double >::size_type arg1 ;
+  size_t val1 ;
+  int ecode1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_nlopt_doublevector",&obj0)) SWIG_fail;
+  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_nlopt_doublevector" "', argument " "1"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg1 = static_cast< std::vector< double >::size_type >(val1);
+  result = (std::vector< double > *)new std::vector< double >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_pop_back",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_pop_back" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  (arg1)->pop_back();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::size_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_resize",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_resize" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_resize" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  (arg1)->resize(arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::iterator arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  swig::SwigPyIterator *iter2 = 0 ;
+  int res2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double >::iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_erase",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_erase" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+  } else {
+    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    }
+  }
+  result = std_vector_Sl_double_Sg__erase__SWIG_0(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::iterator arg2 ;
+  std::vector< double >::iterator arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  swig::SwigPyIterator *iter2 = 0 ;
+  int res2 ;
+  swig::SwigPyIterator *iter3 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  std::vector< double >::iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_erase" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+  } else {
+    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res3) || !iter3) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "3"" of type '" "std::vector< double >::iterator""'");
+  } else {
+    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter3);
+    if (iter_t) {
+      arg3 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_erase" "', argument " "3"" of type '" "std::vector< double >::iterator""'");
+    }
+  }
+  result = std_vector_Sl_double_Sg__erase__SWIG_1(arg1,arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_erase(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::SwigPyIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      if (_v) {
+        return _wrap_nlopt_doublevector_erase__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::SwigPyIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      if (_v) {
+        swig::SwigPyIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+        if (_v) {
+          return _wrap_nlopt_doublevector_erase__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector_erase'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::erase(std::vector< double >::iterator)\n"
+    "    std::vector< double >::erase(std::vector< double >::iterator,std::vector< double >::iterator)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_nlopt_doublevector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double >::size_type arg1 ;
+  std::vector< double >::value_type *arg2 = 0 ;
+  size_t val1 ;
+  int ecode1 = 0 ;
+  std::vector< double >::value_type temp2 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:new_nlopt_doublevector",&obj0,&obj1)) SWIG_fail;
+  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_nlopt_doublevector" "', argument " "1"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg1 = static_cast< std::vector< double >::size_type >(val1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_nlopt_doublevector" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp2 = static_cast< std::vector< double >::value_type >(val2);
+  arg2 = &temp2;
+  result = (std::vector< double > *)new std::vector< double >(arg1,(std::vector< double >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_nlopt_doublevector(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 0) {
+    return _wrap_new_nlopt_doublevector__SWIG_0(self, args);
+  }
+  if (argc == 1) {
+    int _v;
+    {
+      int res = SWIG_AsVal_size_t(argv[0], NULL);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      return _wrap_new_nlopt_doublevector__SWIG_2(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_new_nlopt_doublevector__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      int res = SWIG_AsVal_size_t(argv[0], NULL);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        int res = SWIG_AsVal_double(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_new_nlopt_doublevector__SWIG_3(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_nlopt_doublevector'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::vector()\n"
+    "    std::vector< double >::vector(std::vector< double > const &)\n"
+    "    std::vector< double >::vector(std::vector< double >::size_type)\n"
+    "    std::vector< double >::vector(std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::value_type *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::vector< double >::value_type temp2 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_push_back",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_push_back" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_push_back" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp2 = static_cast< std::vector< double >::value_type >(val2);
+  arg2 = &temp2;
+  (arg1)->push_back((std::vector< double >::value_type const &)*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::value_type *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_front",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_front" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (std::vector< double >::value_type *) &((std::vector< double > const *)arg1)->front();
+  resultobj = SWIG_From_double(static_cast< double >(*result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::value_type *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_back",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_back" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = (std::vector< double >::value_type *) &((std::vector< double > const *)arg1)->back();
+  resultobj = SWIG_From_double(static_cast< double >(*result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::size_type arg2 ;
+  std::vector< double >::value_type *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  std::vector< double >::value_type temp3 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_assign" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_assign" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  ecode3 = SWIG_AsVal_double(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector_assign" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  arg3 = &temp3;
+  (arg1)->assign(arg2,(std::vector< double >::value_type const &)*arg3);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::size_type arg2 ;
+  std::vector< double >::value_type *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  std::vector< double >::value_type temp3 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_resize" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_resize" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  ecode3 = SWIG_AsVal_double(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector_resize" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  arg3 = &temp3;
+  (arg1)->resize(arg2,(std::vector< double >::value_type const &)*arg3);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_resize(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_nlopt_doublevector_resize__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_double(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_doublevector_resize__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector_resize'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::resize(std::vector< double >::size_type)\n"
+    "    std::vector< double >::resize(std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::iterator arg2 ;
+  std::vector< double >::value_type *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  swig::SwigPyIterator *iter2 = 0 ;
+  int res2 ;
+  std::vector< double >::value_type temp3 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  std::vector< double >::iterator result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:nlopt_doublevector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_insert" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+  } else {
+    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    }
+  }
+  ecode3 = SWIG_AsVal_double(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector_insert" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  arg3 = &temp3;
+  result = std_vector_Sl_double_Sg__insert__SWIG_0(arg1,arg2,(double const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
+    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::iterator arg2 ;
+  std::vector< double >::size_type arg3 ;
+  std::vector< double >::value_type *arg4 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  swig::SwigPyIterator *iter2 = 0 ;
+  int res2 ;
+  size_t val3 ;
+  int ecode3 = 0 ;
+  std::vector< double >::value_type temp4 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:nlopt_doublevector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_insert" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+  } else {
+    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "nlopt_doublevector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    }
+  }
+  ecode3 = SWIG_AsVal_size_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "nlopt_doublevector_insert" "', argument " "3"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg3 = static_cast< std::vector< double >::size_type >(val3);
+  ecode4 = SWIG_AsVal_double(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "nlopt_doublevector_insert" "', argument " "4"" of type '" "std::vector< double >::value_type""'");
+  } 
+  temp4 = static_cast< std::vector< double >::value_type >(val4);
+  arg4 = &temp4;
+  std_vector_Sl_double_Sg__insert__SWIG_1(arg1,arg2,arg3,(double const &)*arg4);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_insert(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::SwigPyIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      if (_v) {
+        {
+          int res = SWIG_AsVal_double(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_nlopt_doublevector_insert__SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::SwigPyIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      if (_v) {
+        {
+          int res = SWIG_AsVal_size_t(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          {
+            int res = SWIG_AsVal_double(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_nlopt_doublevector_insert__SWIG_1(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'nlopt_doublevector_insert'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    std::vector< double >::insert(std::vector< double >::iterator,std::vector< double >::value_type const &)\n"
+    "    std::vector< double >::insert(std::vector< double >::iterator,std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector< double >::size_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_doublevector_reserve",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_reserve" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nlopt_doublevector_reserve" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  (arg1)->reserve(arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_nlopt_doublevector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double >::size_type result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:nlopt_doublevector_capacity",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_doublevector_capacity" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  result = ((std::vector< double > const *)arg1)->capacity();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_nlopt_doublevector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_nlopt_doublevector",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_nlopt_doublevector" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *nlopt_doublevector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_nlopt_get_initial_step(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt_opt arg1 ;
+  double *arg2 = (double *) 0 ;
+  void *argp1 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  nlopt_result result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:nlopt_get_initial_step",&obj0,&obj1)) SWIG_fail;
+  {
+    res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_nlopt_opt,  0  | 0);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "nlopt_get_initial_step" "', argument " "1"" of type '" "nlopt_opt const""'"); 
+    }  
+    if (!argp1) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "nlopt_get_initial_step" "', argument " "1"" of type '" "nlopt_opt const""'");
+    } else {
+      nlopt_opt * temp = reinterpret_cast< nlopt_opt * >(argp1);
+      arg1 = *temp;
+      if (SWIG_IsNewObj(res1)) delete temp;
+    }
+  }
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_double, 0 |  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "nlopt_get_initial_step" "', argument " "2"" of type '" "double *""'"); 
+  }
+  arg2 = reinterpret_cast< double * >(argp2);
+  result = nlopt_get_initial_step(arg1,arg2);
+  resultobj = SWIG_NewPointerObj((new nlopt_result(static_cast< const nlopt_result& >(result))), SWIGTYPE_p_nlopt_result, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_roundoff_limited(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::roundoff_limited *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_roundoff_limited")) SWIG_fail;
+  result = (nlopt::roundoff_limited *)new nlopt::roundoff_limited();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nlopt__roundoff_limited, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_roundoff_limited(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::roundoff_limited *arg1 = (nlopt::roundoff_limited *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_roundoff_limited",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__roundoff_limited, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_roundoff_limited" "', argument " "1"" of type '" "nlopt::roundoff_limited *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::roundoff_limited * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *roundoff_limited_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_nlopt__roundoff_limited, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_forced_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::forced_stop *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_forced_stop")) SWIG_fail;
+  result = (nlopt::forced_stop *)new nlopt::forced_stop();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nlopt__forced_stop, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_forced_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::forced_stop *arg1 = (nlopt::forced_stop *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_forced_stop",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__forced_stop, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_forced_stop" "', argument " "1"" of type '" "nlopt::forced_stop *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::forced_stop * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *forced_stop_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_nlopt__forced_stop, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_opt__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_opt")) SWIG_fail;
+  try {
+    result = (nlopt::opt *)new nlopt::opt();
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nlopt__opt, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_opt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_opt",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_opt" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_opt__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::algorithm arg1 ;
+  unsigned int arg2 ;
+  int val1 ;
+  int ecode1 = 0 ;
+  unsigned int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  nlopt::opt *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:new_opt",&obj0,&obj1)) SWIG_fail;
+  ecode1 = SWIG_AsVal_int(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_opt" "', argument " "1"" of type '" "nlopt::algorithm""'");
+  } 
+  arg1 = static_cast< nlopt::algorithm >(val1);
+  ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_opt" "', argument " "2"" of type '" "unsigned int""'");
+  } 
+  arg2 = static_cast< unsigned int >(val2);
+  try {
+    result = (nlopt::opt *)new nlopt::opt(arg1,arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nlopt__opt, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_opt__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  nlopt::opt *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_opt",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_nlopt__opt,  0  | 0);
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_opt" "', argument " "1"" of type '" "nlopt::opt const &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_opt" "', argument " "1"" of type '" "nlopt::opt const &""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  try {
+    result = (nlopt::opt *)new nlopt::opt((nlopt::opt const &)*arg1);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nlopt__opt, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_opt(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 0) {
+    return _wrap_new_opt__SWIG_0(self, args);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_new_opt__SWIG_2(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      int res = SWIG_AsVal_int(argv[0], NULL);
+      _v = SWIG_CheckState(res);
+    }
+    if (_v) {
+      {
+        int res = SWIG_AsVal_unsigned_SS_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_new_opt__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_opt'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::opt()\n"
+    "    nlopt::opt::opt(nlopt::algorithm,unsigned int)\n"
+    "    nlopt::opt::opt(nlopt::opt const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_optimize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  double *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  nlopt::result result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_optimize",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_optimize" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_optimize" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_optimize" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_double,  0 );
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_optimize" "', argument " "3"" of type '" "double &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_optimize" "', argument " "3"" of type '" "double &""'"); 
+  }
+  arg3 = reinterpret_cast< double * >(argp3);
+  try {
+    result = (nlopt::result)(arg1)->optimize(*arg2,*arg3);
+  }
+  catch(nlopt::roundoff_limited &_e) {
+    PyErr_SetString((PyObject*)&MyExc_RoundoffLimited, "NLopt roundoff-limited");
+    SWIG_fail;
+    
+  }
+  catch(nlopt::forced_stop &_e) {
+    if (!PyErr_Occurred())
+    PyErr_SetString((PyObject*)&MyExc_ForcedStop, "NLopt forced stop");
+    SWIG_fail;
+    
+  }
+  catch(std::runtime_error &_e) {
+    SWIG_exception_fail(SWIG_RuntimeError, (&_e)->what());
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_optimize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_optimize",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_optimize" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    result = (arg1)->optimize((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(nlopt::roundoff_limited &_e) {
+    PyErr_SetString((PyObject*)&MyExc_RoundoffLimited, "NLopt roundoff-limited");
+    SWIG_fail;
+    
+  }
+  catch(nlopt::forced_stop &_e) {
+    if (!PyErr_Occurred())
+    PyErr_SetString((PyObject*)&MyExc_ForcedStop, "NLopt forced stop");
+    SWIG_fail;
+    
+  }
+  catch(std::runtime_error &_e) {
+    SWIG_exception_fail(SWIG_RuntimeError, (&_e)->what());
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_optimize(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_opt_optimize__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *vptr = 0;
+      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *vptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_double, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_optimize__SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_optimize'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::optimize(std::vector< double,std::allocator< double > > &,double &)\n"
+    "    nlopt::opt::optimize(std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_last_optimize_result(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  nlopt::result result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_last_optimize_result",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_last_optimize_result" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (nlopt::result)((nlopt::opt const *)arg1)->last_optimize_result();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_last_optimum_value(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_last_optimum_value",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_last_optimum_value" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->last_optimum_value();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_algorithm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  nlopt::algorithm result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_algorithm",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_algorithm" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (nlopt::algorithm)((nlopt::opt const *)arg1)->get_algorithm();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_algorithm_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  char *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_algorithm_name",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_algorithm_name" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (char *)((nlopt::opt const *)arg1)->get_algorithm_name();
+  resultobj = SWIG_FromCharPtr((const char *)result);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_dimension(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  unsigned int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_dimension",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_dimension" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_dimension();
+  resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_min_objective__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_set_min_objective",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_min_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_set_min_objective" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_set_min_objective" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_set_min_objective" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_min_objective__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_set_min_objective",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_min_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_set_min_objective" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_set_min_objective" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_max_objective__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_set_max_objective",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_max_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_set_max_objective" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_set_max_objective" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_set_max_objective" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_max_objective__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_set_max_objective",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_max_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_set_max_objective" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_set_max_objective" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_min_objective__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_min_objective",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_min_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  try {
+    (arg1)->set_min_objective(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_min_objective(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_opt_set_min_objective__SWIG_2(self, args);
+        }
+        if (argc <= 3) {
+          return _wrap_opt_set_min_objective__SWIG_2(self, args);
+        }
+        if (argc <= 4) {
+          return _wrap_opt_set_min_objective__SWIG_2(self, args);
+        }
+        return _wrap_opt_set_min_objective__SWIG_2(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_set_min_objective__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_set_min_objective__SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_min_objective'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_min_objective(nlopt::func,void *)\n"
+    "    nlopt::opt::set_min_objective(nlopt::vfunc,void *)\n"
+    "    nlopt::opt::set_min_objective(nlopt::func,void *,nlopt_munge,nlopt_munge)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_max_objective__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_max_objective",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_max_objective" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  try {
+    (arg1)->set_max_objective(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_max_objective(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_opt_set_max_objective__SWIG_2(self, args);
+        }
+        if (argc <= 3) {
+          return _wrap_opt_set_max_objective__SWIG_2(self, args);
+        }
+        if (argc <= 4) {
+          return _wrap_opt_set_max_objective__SWIG_2(self, args);
+        }
+        return _wrap_opt_set_max_objective__SWIG_2(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_set_max_objective__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_set_max_objective__SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_max_objective'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_max_objective(nlopt::func,void *)\n"
+    "    nlopt::opt::set_max_objective(nlopt::vfunc,void *)\n"
+    "    nlopt::opt::set_max_objective(nlopt::func,void *,nlopt_munge,nlopt_munge)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_remove_inequality_constraints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_remove_inequality_constraints",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_remove_inequality_constraints" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  try {
+    (arg1)->remove_inequality_constraints();
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_inequality_constraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_inequality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  ecode4 = SWIG_AsVal_double(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "opt_add_inequality_constraint" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_inequality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_inequality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_inequality_constraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_inequality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  ecode4 = SWIG_AsVal_double(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "opt_add_inequality_constraint" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_inequality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_add_inequality_constraint" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_inequality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_mconstraint__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  std::vector< double,std::allocator< double > > *arg4 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyArrayObject *array4 = NULL ;
+  int is_new_object4 = 0 ;
+  std::vector< double > arrayv4 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_inequality_mconstraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_mconstraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_mfunc,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_inequality_mconstraint" "', argument " "2"" of type '" "nlopt::mfunc""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_inequality_mconstraint" "', argument " "2"" of type '" "nlopt::mfunc""'");
+    } else {
+      nlopt::mfunc * temp = reinterpret_cast< nlopt::mfunc * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_inequality_mconstraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array4 = obj_to_array_allow_conversion(obj3, NPY_DOUBLE, &is_new_object4);
+    if (!array4 || !require_dimensions(array4, 1) ||
+      !require_size(array4, size, 1)) SWIG_fail;
+    arrayv4 = std::vector<double>(array_size(array4,0));
+    arg4 = &arrayv4;
+    {
+      double *arr_data = (double *) array_data(array4);
+      int arr_i, arr_s = array_stride(array4,0) / sizeof(double);
+      int arr_sz = array_size(array4,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv4[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->add_inequality_mconstraint(arg2,arg3,(std::vector< double,std::allocator< double > > const &)*arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object4 && array4)
+    {
+      Py_DECREF(array4); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object4 && array4)
+    {
+      Py_DECREF(array4); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_remove_equality_constraints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_remove_equality_constraints",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_remove_equality_constraints" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  try {
+    (arg1)->remove_equality_constraints();
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_equality_constraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_equality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  ecode4 = SWIG_AsVal_double(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "opt_add_equality_constraint" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_equality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_func,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::func""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::func""'");
+    } else {
+      nlopt::func * temp = reinterpret_cast< nlopt::func * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_equality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_equality_constraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_equality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  ecode4 = SWIG_AsVal_double(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "opt_add_equality_constraint" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::vfunc arg2 = (nlopt::vfunc) 0 ;
+  void *arg3 = (void *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_equality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+    if (!SWIG_IsOK(res)) {
+      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "opt_add_equality_constraint" "', argument " "2"" of type '" "nlopt::vfunc""'"); 
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_equality_constraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_mconstraint__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  std::vector< double,std::allocator< double > > *arg4 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  int res3 ;
+  PyArrayObject *array4 = NULL ;
+  int is_new_object4 = 0 ;
+  std::vector< double > arrayv4 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:opt_add_equality_mconstraint",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_mconstraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt_mfunc,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_add_equality_mconstraint" "', argument " "2"" of type '" "nlopt::mfunc""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_add_equality_mconstraint" "', argument " "2"" of type '" "nlopt::mfunc""'");
+    } else {
+      nlopt::mfunc * temp = reinterpret_cast< nlopt::mfunc * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_add_equality_mconstraint" "', argument " "3"" of type '" "void *""'"); 
+  }
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array4 = obj_to_array_allow_conversion(obj3, NPY_DOUBLE, &is_new_object4);
+    if (!array4 || !require_dimensions(array4, 1) ||
+      !require_size(array4, size, 1)) SWIG_fail;
+    arrayv4 = std::vector<double>(array_size(array4,0));
+    arg4 = &arrayv4;
+    {
+      double *arr_data = (double *) array_data(array4);
+      int arr_i, arr_s = array_stride(array4,0) / sizeof(double);
+      int arr_sz = array_size(array4,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv4[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->add_equality_mconstraint(arg2,arg3,(std::vector< double,std::allocator< double > > const &)*arg4);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object4 && array4)
+    {
+      Py_DECREF(array4); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object4 && array4)
+    {
+      Py_DECREF(array4); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  double arg6 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val6 ;
+  int ecode6 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_inequality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  ecode6 = SWIG_AsVal_double(obj2, &val6);
+  if (!SWIG_IsOK(ecode6)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "opt_add_inequality_constraint" "', argument " "6"" of type '" "double""'");
+  } 
+  arg6 = static_cast< double >(val6);
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4,arg5,arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_add_inequality_constraint",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  try {
+    (arg1)->add_inequality_constraint(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_constraint(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_opt_add_inequality_constraint__SWIG_5(self, args);
+        }
+        if (argc <= 3) {
+          return _wrap_opt_add_inequality_constraint__SWIG_5(self, args);
+        }
+        if (argc <= 4) {
+          return _wrap_opt_add_inequality_constraint__SWIG_5(self, args);
+        }
+        return _wrap_opt_add_inequality_constraint__SWIG_5(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_add_inequality_constraint__SWIG_3(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_double(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_opt_add_inequality_constraint__SWIG_4(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_add_inequality_constraint__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            int res = SWIG_AsVal_double(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_opt_add_inequality_constraint__SWIG_2(self, args);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            int res = SWIG_AsVal_double(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_opt_add_inequality_constraint__SWIG_0(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_add_inequality_constraint'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::func,void *,double)\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::func,void *)\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::vfunc,void *,double)\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::vfunc,void *)\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::func,void *,nlopt_munge,nlopt_munge,double)\n"
+    "    nlopt::opt::add_inequality_constraint(nlopt::func,void *,nlopt_munge,nlopt_munge)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  double arg6 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val6 ;
+  int ecode6 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_equality_constraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  ecode6 = SWIG_AsVal_double(obj2, &val6);
+  if (!SWIG_IsOK(ecode6)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "opt_add_equality_constraint" "', argument " "6"" of type '" "double""'");
+  } 
+  arg6 = static_cast< double >(val6);
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4,arg5,arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::func arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_add_equality_constraint",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_constraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = func_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  try {
+    (arg1)->add_equality_constraint(arg2,arg3,arg4,arg5);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_constraint(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        if (argc <= 2) {
+          return _wrap_opt_add_equality_constraint__SWIG_5(self, args);
+        }
+        if (argc <= 3) {
+          return _wrap_opt_add_equality_constraint__SWIG_5(self, args);
+        }
+        if (argc <= 4) {
+          return _wrap_opt_add_equality_constraint__SWIG_5(self, args);
+        }
+        return _wrap_opt_add_equality_constraint__SWIG_5(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_add_equality_constraint__SWIG_3(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        {
+          int res = SWIG_AsVal_double(argv[2], NULL);
+          _v = SWIG_CheckState(res);
+        }
+        if (_v) {
+          return _wrap_opt_add_equality_constraint__SWIG_4(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_add_equality_constraint__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *ptr = 0;
+      int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            int res = SWIG_AsVal_double(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_opt_add_equality_constraint__SWIG_2(self, args);
+          }
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_func, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            int res = SWIG_AsVal_double(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_opt_add_equality_constraint__SWIG_0(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_add_equality_constraint'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::func,void *,double)\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::func,void *)\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::vfunc,void *,double)\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::vfunc,void *)\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::func,void *,nlopt_munge,nlopt_munge,double)\n"
+    "    nlopt::opt::add_equality_constraint(nlopt::func,void *,nlopt_munge,nlopt_munge)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_mconstraint__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  std::vector< double,std::allocator< double > > *arg6 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array6 = NULL ;
+  int is_new_object6 = 0 ;
+  std::vector< double > arrayv6 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_inequality_mconstraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_inequality_mconstraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = mfunc_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array6 = obj_to_array_allow_conversion(obj2, NPY_DOUBLE, &is_new_object6);
+    if (!array6 || !require_dimensions(array6, 1) ||
+      !require_size(array6, size, 1)) SWIG_fail;
+    arrayv6 = std::vector<double>(array_size(array6,0));
+    arg6 = &arrayv6;
+    {
+      double *arr_data = (double *) array_data(array6);
+      int arr_i, arr_s = array_stride(array6,0) / sizeof(double);
+      int arr_sz = array_size(array6,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv6[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->add_inequality_mconstraint(arg2,arg3,arg4,arg5,(std::vector< double,std::allocator< double > > const &)*arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object6 && array6)
+    {
+      Py_DECREF(array6); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object6 && array6)
+    {
+      Py_DECREF(array6); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_inequality_mconstraint(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        {
+          _v = is_array(argv[2]) || PySequence_Check(argv[2]);
+        }
+        if (_v) {
+          return _wrap_opt_add_inequality_mconstraint__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_mfunc, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            _v = is_array(argv[3]) || PySequence_Check(argv[3]);
+          }
+          if (_v) {
+            return _wrap_opt_add_inequality_mconstraint__SWIG_0(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_add_inequality_mconstraint'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::add_inequality_mconstraint(nlopt::mfunc,void *,std::vector< double,std::allocator< double > > const &)\n"
+    "    nlopt::opt::add_inequality_mconstraint(nlopt::mfunc,void *,nlopt_munge,nlopt_munge,std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_mconstraint__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::mfunc arg2 ;
+  void *arg3 = (void *) 0 ;
+  nlopt_munge arg4 ;
+  nlopt_munge arg5 ;
+  std::vector< double,std::allocator< double > > *arg6 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array6 = NULL ;
+  int is_new_object6 = 0 ;
+  std::vector< double > arrayv6 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_add_equality_mconstraint",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_add_equality_mconstraint" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    arg2 = mfunc_python;
+    arg3 = dup_pyfunc((void*) obj1);
+    arg4 = free_pyfunc;
+    arg5 = dup_pyfunc;
+  }
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array6 = obj_to_array_allow_conversion(obj2, NPY_DOUBLE, &is_new_object6);
+    if (!array6 || !require_dimensions(array6, 1) ||
+      !require_size(array6, size, 1)) SWIG_fail;
+    arrayv6 = std::vector<double>(array_size(array6,0));
+    arg6 = &arrayv6;
+    {
+      double *arr_data = (double *) array_data(array6);
+      int arr_i, arr_s = array_stride(array6,0) / sizeof(double);
+      int arr_sz = array_size(array6,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv6[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->add_equality_mconstraint(arg2,arg3,arg4,arg5,(std::vector< double,std::allocator< double > > const &)*arg6);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object6 && array6)
+    {
+      Py_DECREF(array6); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object6 && array6)
+    {
+      Py_DECREF(array6); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_add_equality_mconstraint(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[5];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = PyCallable_Check(argv[1]);
+      }
+      if (_v) {
+        {
+          _v = is_array(argv[2]) || PySequence_Check(argv[2]);
+        }
+        if (_v) {
+          return _wrap_opt_add_equality_mconstraint__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_nlopt_mfunc, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        void *ptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &ptr, 0, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            _v = is_array(argv[3]) || PySequence_Check(argv[3]);
+          }
+          if (_v) {
+            return _wrap_opt_add_equality_mconstraint__SWIG_0(self, args);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_add_equality_mconstraint'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::add_equality_mconstraint(nlopt::mfunc,void *,std::vector< double,std::allocator< double > > const &)\n"
+    "    nlopt::opt::add_equality_mconstraint(nlopt::mfunc,void *,nlopt_munge,nlopt_munge,std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_lower_bounds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_lower_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_lower_bounds" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_lower_bounds" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_lower_bounds(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_lower_bounds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_get_lower_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_lower_bounds" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_get_lower_bounds" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_get_lower_bounds" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  ((nlopt::opt const *)arg1)->get_lower_bounds(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_lower_bounds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_lower_bounds",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_lower_bounds" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = ((nlopt::opt const *)arg1)->get_lower_bounds();
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_lower_bounds(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_opt_get_lower_bounds__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *vptr = 0;
+      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_opt_get_lower_bounds__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_get_lower_bounds'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::get_lower_bounds(std::vector< double,std::allocator< double > > &) const\n"
+    "    nlopt::opt::get_lower_bounds() const\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_lower_bounds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_lower_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_lower_bounds" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->set_lower_bounds((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_lower_bounds(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_opt_set_lower_bounds__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_double(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_opt_set_lower_bounds__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_lower_bounds'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_lower_bounds(double)\n"
+    "    nlopt::opt::set_lower_bounds(std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_upper_bounds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_upper_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_upper_bounds" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_upper_bounds" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_upper_bounds(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_upper_bounds__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_get_upper_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_upper_bounds" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_get_upper_bounds" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_get_upper_bounds" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  ((nlopt::opt const *)arg1)->get_upper_bounds(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_upper_bounds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_upper_bounds",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_upper_bounds" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = ((nlopt::opt const *)arg1)->get_upper_bounds();
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_upper_bounds(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_opt_get_upper_bounds__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *vptr = 0;
+      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_opt_get_upper_bounds__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_get_upper_bounds'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::get_upper_bounds(std::vector< double,std::allocator< double > > &) const\n"
+    "    nlopt::opt::get_upper_bounds() const\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_upper_bounds__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_upper_bounds",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_upper_bounds" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->set_upper_bounds((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_upper_bounds(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_opt_set_upper_bounds__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_double(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_opt_set_upper_bounds__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_upper_bounds'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_upper_bounds(double)\n"
+    "    nlopt::opt::set_upper_bounds(std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_stopval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_stopval",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_stopval" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->get_stopval();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_stopval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_stopval",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_stopval" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_stopval" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_stopval(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_ftol_rel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_ftol_rel",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_ftol_rel" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->get_ftol_rel();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_ftol_rel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_ftol_rel",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_ftol_rel" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_ftol_rel" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_ftol_rel(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_ftol_abs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_ftol_abs",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_ftol_abs" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->get_ftol_abs();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_ftol_abs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_ftol_abs",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_ftol_abs" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_ftol_abs" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_ftol_abs(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_xtol_rel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_xtol_rel",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_xtol_rel" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->get_xtol_rel();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_xtol_rel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_xtol_rel",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_xtol_rel" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_xtol_rel" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_xtol_rel(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_xtol_abs__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_xtol_abs",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_xtol_abs" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_xtol_abs" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_xtol_abs(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_xtol_abs__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_get_xtol_abs",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_xtol_abs" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_get_xtol_abs" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_get_xtol_abs" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  ((nlopt::opt const *)arg1)->get_xtol_abs(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_xtol_abs__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_xtol_abs",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_xtol_abs" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = ((nlopt::opt const *)arg1)->get_xtol_abs();
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_xtol_abs(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_opt_get_xtol_abs__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *vptr = 0;
+      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_opt_get_xtol_abs__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_get_xtol_abs'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::get_xtol_abs(std::vector< double,std::allocator< double > > &) const\n"
+    "    nlopt::opt::get_xtol_abs() const\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_xtol_abs__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_xtol_abs",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_xtol_abs" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->set_xtol_abs((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_xtol_abs(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_opt_set_xtol_abs__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_double(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_opt_set_xtol_abs__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_xtol_abs'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_xtol_abs(double)\n"
+    "    nlopt::opt::set_xtol_abs(std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_maxeval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_maxeval",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_maxeval" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (int)((nlopt::opt const *)arg1)->get_maxeval();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_maxeval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  int arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_maxeval",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_maxeval" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_maxeval" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  try {
+    (arg1)->set_maxeval(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_maxtime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  double result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_maxtime",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_maxtime" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (double)((nlopt::opt const *)arg1)->get_maxtime();
+  resultobj = SWIG_From_double(static_cast< double >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_maxtime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_maxtime",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_maxtime" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_maxtime" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_maxtime(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_force_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_force_stop",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_force_stop" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (int)((nlopt::opt const *)arg1)->get_force_stop();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_force_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  int arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_force_stop",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_force_stop" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_force_stop" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  try {
+    (arg1)->set_force_stop(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_force_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_force_stop",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_force_stop" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  try {
+    (arg1)->force_stop();
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_local_optimizer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  nlopt::opt *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_local_optimizer",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_local_optimizer" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_nlopt__opt,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_set_local_optimizer" "', argument " "2"" of type '" "nlopt::opt const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_set_local_optimizer" "', argument " "2"" of type '" "nlopt::opt const &""'"); 
+  }
+  arg2 = reinterpret_cast< nlopt::opt * >(argp2);
+  try {
+    (arg1)->set_local_optimizer((nlopt::opt const &)*arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_population(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  unsigned int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_population",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_population" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_population();
+  resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_population(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  unsigned int arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  unsigned int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_population",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_population" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_population" "', argument " "2"" of type '" "unsigned int""'");
+  } 
+  arg2 = static_cast< unsigned int >(val2);
+  try {
+    (arg1)->set_population(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_vector_storage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  unsigned int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_vector_storage",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_vector_storage" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = (unsigned int)((nlopt::opt const *)arg1)->get_vector_storage();
+  resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_vector_storage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  unsigned int arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  unsigned int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_vector_storage",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_vector_storage" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_vector_storage" "', argument " "2"" of type '" "unsigned int""'");
+  } 
+  arg2 = static_cast< unsigned int >(val2);
+  try {
+    (arg1)->set_vector_storage(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_initial_step__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  double arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_initial_step",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_initial_step" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "opt_set_initial_step" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  try {
+    (arg1)->set_initial_step(arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_initial_step__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_get_initial_step",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_initial_step" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "opt_get_initial_step" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_get_initial_step" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  ((nlopt::opt const *)arg1)->get_initial_step(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_initial_step__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:opt_get_initial_step",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_initial_step" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  result = ((nlopt::opt const *)arg1)->get_initial_step();
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_initial_step__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_initial_step",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_initial_step" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->set_initial_step((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_initial_step(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        return _wrap_opt_set_initial_step__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_double(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_opt_set_initial_step__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_set_initial_step'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::set_initial_step(double)\n"
+    "    nlopt::opt::set_initial_step(std::vector< double,std::allocator< double > > const &)\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_set_default_initial_step(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_set_default_initial_step",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_set_default_initial_step" "', argument " "1"" of type '" "nlopt::opt *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  try {
+    (arg1)->set_default_initial_step((std::vector< double,std::allocator< double > > const &)*arg2);
+  }
+  catch(std::bad_alloc &_e) {
+    PyErr_SetString(PyExc_MemoryError, (_e).what());
+    SWIG_fail;
+    
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_initial_step__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  std::vector< double,std::allocator< double > > *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:opt_get_initial_step",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_initial_step" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "opt_get_initial_step" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "opt_get_initial_step" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > &""'"); 
+  }
+  arg3 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp3);
+  ((nlopt::opt const *)arg1)->get_initial_step((std::vector< double,std::allocator< double > > const &)*arg2,*arg3);
+  resultobj = SWIG_Py_Void();
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_initial_step(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = args ? (int)PyObject_Length(args) : 0;
+  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_opt_get_initial_step__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      void *vptr = 0;
+      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_opt_get_initial_step__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_nlopt__opt, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        _v = is_array(argv[1]) || PySequence_Check(argv[1]);
+      }
+      if (_v) {
+        void *vptr = 0;
+        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_opt_get_initial_step__SWIG_2(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'opt_get_initial_step'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    nlopt::opt::get_initial_step(std::vector< double,std::allocator< double > > &) const\n"
+    "    nlopt::opt::get_initial_step() const\n"
+    "    nlopt::opt::get_initial_step(std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > &) const\n");
+  return 0;
+}
+
+
+SWIGINTERN PyObject *_wrap_opt_get_initial_step_(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::opt *arg1 = (nlopt::opt *) 0 ;
+  std::vector< double,std::allocator< double > > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyArrayObject *array2 = NULL ;
+  int is_new_object2 = 0 ;
+  std::vector< double > arrayv2 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:opt_get_initial_step_",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_nlopt__opt, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "opt_get_initial_step_" "', argument " "1"" of type '" "nlopt::opt const *""'"); 
+  }
+  arg1 = reinterpret_cast< nlopt::opt * >(argp1);
+  {
+    npy_intp size[1] = {
+      -1 
+    };
+    array2 = obj_to_array_allow_conversion(obj1, NPY_DOUBLE, &is_new_object2);
+    if (!array2 || !require_dimensions(array2, 1) ||
+      !require_size(array2, size, 1)) SWIG_fail;
+    arrayv2 = std::vector<double>(array_size(array2,0));
+    arg2 = &arrayv2;
+    {
+      double *arr_data = (double *) array_data(array2);
+      int arr_i, arr_s = array_stride(array2,0) / sizeof(double);
+      int arr_sz = array_size(array2,0);
+      for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv2[arr_i] = arr_data[arr_i * arr_s];
+    }
+  }
+  result = ((nlopt::opt const *)arg1)->get_initial_step_((std::vector< double,std::allocator< double > > const &)*arg2);
+  {
+    npy_intp sz = (&result)->size();
+    resultobj = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+    std::memcpy(array_data(resultobj), (&result)->empty() ? NULL : &result[0],
+      sizeof(double) * sz);
+  }
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return resultobj;
+fail:
+  {
+    if (is_new_object2 && array2)
+    {
+      Py_DECREF(array2); 
+    }
+  }
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *opt_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_nlopt__opt, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_srand(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  unsigned long arg1 ;
+  unsigned long val1 ;
+  int ecode1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:srand",&obj0)) SWIG_fail;
+  ecode1 = SWIG_AsVal_unsigned_SS_long(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "srand" "', argument " "1"" of type '" "unsigned long""'");
+  } 
+  arg1 = static_cast< unsigned long >(val1);
+  nlopt::srand(arg1);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_srand_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  
+  if (!PyArg_ParseTuple(args,(char *)":srand_time")) SWIG_fail;
+  nlopt::srand_time();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_version(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  int *arg1 = 0 ;
+  int *arg2 = 0 ;
+  int *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:version",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_int,  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "version" "', argument " "1"" of type '" "int &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "version" "', argument " "1"" of type '" "int &""'"); 
+  }
+  arg1 = reinterpret_cast< int * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_int,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "version" "', argument " "2"" of type '" "int &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "version" "', argument " "2"" of type '" "int &""'"); 
+  }
+  arg2 = reinterpret_cast< int * >(argp2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_int,  0 );
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "version" "', argument " "3"" of type '" "int &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "version" "', argument " "3"" of type '" "int &""'"); 
+  }
+  arg3 = reinterpret_cast< int * >(argp3);
+  nlopt::version(*arg1,*arg2,*arg3);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_version_major(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)":version_major")) SWIG_fail;
+  result = (int)nlopt::version_major();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_version_minor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)":version_minor")) SWIG_fail;
+  result = (int)nlopt::version_minor();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_version_bugfix(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  int result;
+  
+  if (!PyArg_ParseTuple(args,(char *)":version_bugfix")) SWIG_fail;
+  result = (int)nlopt::version_bugfix();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_algorithm_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  nlopt::algorithm arg1 ;
+  int val1 ;
+  int ecode1 = 0 ;
+  PyObject * obj0 = 0 ;
+  char *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:algorithm_name",&obj0)) SWIG_fail;
+  ecode1 = SWIG_AsVal_int(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "algorithm_name" "', argument " "1"" of type '" "nlopt::algorithm""'");
+  } 
+  arg1 = static_cast< nlopt::algorithm >(val1);
+  result = (char *)nlopt::algorithm_name(arg1);
+  resultobj = SWIG_FromCharPtr((const char *)result);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+static PyMethodDef SwigMethods[] = {
+        { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
+        { (char *)"delete_SwigPyIterator", _wrap_delete_SwigPyIterator, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_value", _wrap_SwigPyIterator_value, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_incr", _wrap_SwigPyIterator_incr, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_decr", _wrap_SwigPyIterator_decr, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_distance", _wrap_SwigPyIterator_distance, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_equal", _wrap_SwigPyIterator_equal, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_copy", _wrap_SwigPyIterator_copy, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_next", _wrap_SwigPyIterator_next, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___next__", _wrap_SwigPyIterator___next__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_previous", _wrap_SwigPyIterator_previous, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_advance", _wrap_SwigPyIterator_advance, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___eq__", _wrap_SwigPyIterator___eq__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___ne__", _wrap_SwigPyIterator___ne__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___iadd__", _wrap_SwigPyIterator___iadd__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___isub__", _wrap_SwigPyIterator___isub__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___add__", _wrap_SwigPyIterator___add__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator___sub__", _wrap_SwigPyIterator___sub__, METH_VARARGS, NULL},
+        { (char *)"SwigPyIterator_swigregister", SwigPyIterator_swigregister, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_iterator", _wrap_nlopt_doublevector_iterator, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___nonzero__", _wrap_nlopt_doublevector___nonzero__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___bool__", _wrap_nlopt_doublevector___bool__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___len__", _wrap_nlopt_doublevector___len__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_pop", _wrap_nlopt_doublevector_pop, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___getslice__", _wrap_nlopt_doublevector___getslice__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___setslice__", _wrap_nlopt_doublevector___setslice__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___delslice__", _wrap_nlopt_doublevector___delslice__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___delitem__", _wrap_nlopt_doublevector___delitem__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___getitem__", _wrap_nlopt_doublevector___getitem__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector___setitem__", _wrap_nlopt_doublevector___setitem__, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_append", _wrap_nlopt_doublevector_append, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_empty", _wrap_nlopt_doublevector_empty, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_size", _wrap_nlopt_doublevector_size, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_clear", _wrap_nlopt_doublevector_clear, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_swap", _wrap_nlopt_doublevector_swap, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_get_allocator", _wrap_nlopt_doublevector_get_allocator, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_begin", _wrap_nlopt_doublevector_begin, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_end", _wrap_nlopt_doublevector_end, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_rbegin", _wrap_nlopt_doublevector_rbegin, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_rend", _wrap_nlopt_doublevector_rend, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_pop_back", _wrap_nlopt_doublevector_pop_back, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_erase", _wrap_nlopt_doublevector_erase, METH_VARARGS, NULL},
+        { (char *)"new_nlopt_doublevector", _wrap_new_nlopt_doublevector, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_push_back", _wrap_nlopt_doublevector_push_back, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_front", _wrap_nlopt_doublevector_front, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_back", _wrap_nlopt_doublevector_back, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_assign", _wrap_nlopt_doublevector_assign, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_resize", _wrap_nlopt_doublevector_resize, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_insert", _wrap_nlopt_doublevector_insert, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_reserve", _wrap_nlopt_doublevector_reserve, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_capacity", _wrap_nlopt_doublevector_capacity, METH_VARARGS, NULL},
+        { (char *)"delete_nlopt_doublevector", _wrap_delete_nlopt_doublevector, METH_VARARGS, NULL},
+        { (char *)"nlopt_doublevector_swigregister", nlopt_doublevector_swigregister, METH_VARARGS, NULL},
+        { (char *)"nlopt_get_initial_step", _wrap_nlopt_get_initial_step, METH_VARARGS, NULL},
+        { (char *)"new_roundoff_limited", _wrap_new_roundoff_limited, METH_VARARGS, NULL},
+        { (char *)"delete_roundoff_limited", _wrap_delete_roundoff_limited, METH_VARARGS, NULL},
+        { (char *)"roundoff_limited_swigregister", roundoff_limited_swigregister, METH_VARARGS, NULL},
+        { (char *)"new_forced_stop", _wrap_new_forced_stop, METH_VARARGS, NULL},
+        { (char *)"delete_forced_stop", _wrap_delete_forced_stop, METH_VARARGS, NULL},
+        { (char *)"forced_stop_swigregister", forced_stop_swigregister, METH_VARARGS, NULL},
+        { (char *)"delete_opt", _wrap_delete_opt, METH_VARARGS, NULL},
+        { (char *)"new_opt", _wrap_new_opt, METH_VARARGS, NULL},
+        { (char *)"opt_optimize", _wrap_opt_optimize, METH_VARARGS, NULL},
+        { (char *)"opt_last_optimize_result", _wrap_opt_last_optimize_result, METH_VARARGS, NULL},
+        { (char *)"opt_last_optimum_value", _wrap_opt_last_optimum_value, METH_VARARGS, NULL},
+        { (char *)"opt_get_algorithm", _wrap_opt_get_algorithm, METH_VARARGS, NULL},
+        { (char *)"opt_get_algorithm_name", _wrap_opt_get_algorithm_name, METH_VARARGS, NULL},
+        { (char *)"opt_get_dimension", _wrap_opt_get_dimension, METH_VARARGS, NULL},
+        { (char *)"opt_set_min_objective", _wrap_opt_set_min_objective, METH_VARARGS, NULL},
+        { (char *)"opt_set_max_objective", _wrap_opt_set_max_objective, METH_VARARGS, NULL},
+        { (char *)"opt_remove_inequality_constraints", _wrap_opt_remove_inequality_constraints, METH_VARARGS, NULL},
+        { (char *)"opt_remove_equality_constraints", _wrap_opt_remove_equality_constraints, METH_VARARGS, NULL},
+        { (char *)"opt_add_inequality_constraint", _wrap_opt_add_inequality_constraint, METH_VARARGS, NULL},
+        { (char *)"opt_add_equality_constraint", _wrap_opt_add_equality_constraint, METH_VARARGS, NULL},
+        { (char *)"opt_add_inequality_mconstraint", _wrap_opt_add_inequality_mconstraint, METH_VARARGS, NULL},
+        { (char *)"opt_add_equality_mconstraint", _wrap_opt_add_equality_mconstraint, METH_VARARGS, NULL},
+        { (char *)"opt_get_lower_bounds", _wrap_opt_get_lower_bounds, METH_VARARGS, NULL},
+        { (char *)"opt_set_lower_bounds", _wrap_opt_set_lower_bounds, METH_VARARGS, NULL},
+        { (char *)"opt_get_upper_bounds", _wrap_opt_get_upper_bounds, METH_VARARGS, NULL},
+        { (char *)"opt_set_upper_bounds", _wrap_opt_set_upper_bounds, METH_VARARGS, NULL},
+        { (char *)"opt_get_stopval", _wrap_opt_get_stopval, METH_VARARGS, NULL},
+        { (char *)"opt_set_stopval", _wrap_opt_set_stopval, METH_VARARGS, NULL},
+        { (char *)"opt_get_ftol_rel", _wrap_opt_get_ftol_rel, METH_VARARGS, NULL},
+        { (char *)"opt_set_ftol_rel", _wrap_opt_set_ftol_rel, METH_VARARGS, NULL},
+        { (char *)"opt_get_ftol_abs", _wrap_opt_get_ftol_abs, METH_VARARGS, NULL},
+        { (char *)"opt_set_ftol_abs", _wrap_opt_set_ftol_abs, METH_VARARGS, NULL},
+        { (char *)"opt_get_xtol_rel", _wrap_opt_get_xtol_rel, METH_VARARGS, NULL},
+        { (char *)"opt_set_xtol_rel", _wrap_opt_set_xtol_rel, METH_VARARGS, NULL},
+        { (char *)"opt_get_xtol_abs", _wrap_opt_get_xtol_abs, METH_VARARGS, NULL},
+        { (char *)"opt_set_xtol_abs", _wrap_opt_set_xtol_abs, METH_VARARGS, NULL},
+        { (char *)"opt_get_maxeval", _wrap_opt_get_maxeval, METH_VARARGS, NULL},
+        { (char *)"opt_set_maxeval", _wrap_opt_set_maxeval, METH_VARARGS, NULL},
+        { (char *)"opt_get_maxtime", _wrap_opt_get_maxtime, METH_VARARGS, NULL},
+        { (char *)"opt_set_maxtime", _wrap_opt_set_maxtime, METH_VARARGS, NULL},
+        { (char *)"opt_get_force_stop", _wrap_opt_get_force_stop, METH_VARARGS, NULL},
+        { (char *)"opt_set_force_stop", _wrap_opt_set_force_stop, METH_VARARGS, NULL},
+        { (char *)"opt_force_stop", _wrap_opt_force_stop, METH_VARARGS, NULL},
+        { (char *)"opt_set_local_optimizer", _wrap_opt_set_local_optimizer, METH_VARARGS, NULL},
+        { (char *)"opt_get_population", _wrap_opt_get_population, METH_VARARGS, NULL},
+        { (char *)"opt_set_population", _wrap_opt_set_population, METH_VARARGS, NULL},
+        { (char *)"opt_get_vector_storage", _wrap_opt_get_vector_storage, METH_VARARGS, NULL},
+        { (char *)"opt_set_vector_storage", _wrap_opt_set_vector_storage, METH_VARARGS, NULL},
+        { (char *)"opt_set_initial_step", _wrap_opt_set_initial_step, METH_VARARGS, NULL},
+        { (char *)"opt_set_default_initial_step", _wrap_opt_set_default_initial_step, METH_VARARGS, NULL},
+        { (char *)"opt_get_initial_step", _wrap_opt_get_initial_step, METH_VARARGS, NULL},
+        { (char *)"opt_get_initial_step_", _wrap_opt_get_initial_step_, METH_VARARGS, NULL},
+        { (char *)"opt_swigregister", opt_swigregister, METH_VARARGS, NULL},
+        { (char *)"srand", _wrap_srand, METH_VARARGS, NULL},
+        { (char *)"srand_time", _wrap_srand_time, METH_VARARGS, NULL},
+        { (char *)"version", _wrap_version, METH_VARARGS, NULL},
+        { (char *)"version_major", _wrap_version_major, METH_VARARGS, NULL},
+        { (char *)"version_minor", _wrap_version_minor, METH_VARARGS, NULL},
+        { (char *)"version_bugfix", _wrap_version_bugfix, METH_VARARGS, NULL},
+        { (char *)"algorithm_name", _wrap_algorithm_name, METH_VARARGS, NULL},
+        { NULL, NULL, 0, NULL }
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static void *_p_nlopt__roundoff_limitedTo_p_std__runtime_error(void *x, int *SWIGUNUSEDPARM(newmemory)) {
+    return (void *)((std::runtime_error *)  ((nlopt::roundoff_limited *) x));
+}
+static void *_p_nlopt__forced_stopTo_p_std__runtime_error(void *x, int *SWIGUNUSEDPARM(newmemory)) {
+    return (void *)((std::runtime_error *)  ((nlopt::forced_stop *) x));
+}
+static swig_type_info _swigt__p_allocator_type = {"_p_allocator_type", "allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_difference_type = {"_p_difference_type", "difference_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double = {"_p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double", "nlopt::vfunc|double (*)(std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > &,void *)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__forced_stop = {"_p_nlopt__forced_stop", "nlopt::forced_stop *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__opt = {"_p_nlopt__opt", "nlopt::opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt__roundoff_limited = {"_p_nlopt__roundoff_limited", "nlopt::roundoff_limited *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_func = {"_p_nlopt_func", "nlopt::func *|nlopt_func *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_mfunc = {"_p_nlopt_mfunc", "nlopt_mfunc *|nlopt::mfunc *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_opt = {"_p_nlopt_opt", "nlopt_opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nlopt_result = {"_p_nlopt_result", "nlopt_result *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_p_PyObject = {"_p_p_PyObject", "PyObject **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_size_type = {"_p_size_type", "size_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__allocatorT_double_t = {"_p_std__allocatorT_double_t", "std::vector< double >::allocator_type *|std::allocator< double > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__invalid_argument = {"_p_std__invalid_argument", "std::invalid_argument *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__runtime_error = {"_p_std__runtime_error", "std::runtime_error *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorT__Tp__Alloc_t = {"_p_std__vectorT__Tp__Alloc_t", "std::vector< _Tp,_Alloc > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorT_double_std__allocatorT_double_t_t = {"_p_std__vectorT_double_std__allocatorT_double_t_t", "std::vector< double,std::allocator< double > > *|std::vector< double > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_swig__SwigPyIterator = {"_p_swig__SwigPyIterator", "swig::SwigPyIterator *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_value_type = {"_p_value_type", "value_type *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+  &_swigt__p_allocator_type,
+  &_swigt__p_char,
+  &_swigt__p_difference_type,
+  &_swigt__p_double,
+  &_swigt__p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double,
+  &_swigt__p_int,
+  &_swigt__p_nlopt__forced_stop,
+  &_swigt__p_nlopt__opt,
+  &_swigt__p_nlopt__roundoff_limited,
+  &_swigt__p_nlopt_func,
+  &_swigt__p_nlopt_mfunc,
+  &_swigt__p_nlopt_opt,
+  &_swigt__p_nlopt_result,
+  &_swigt__p_p_PyObject,
+  &_swigt__p_size_type,
+  &_swigt__p_std__allocatorT_double_t,
+  &_swigt__p_std__invalid_argument,
+  &_swigt__p_std__runtime_error,
+  &_swigt__p_std__vectorT__Tp__Alloc_t,
+  &_swigt__p_std__vectorT_double_std__allocatorT_double_t_t,
+  &_swigt__p_swig__SwigPyIterator,
+  &_swigt__p_value_type,
+};
+
+static swig_cast_info _swigc__p_allocator_type[] = {  {&_swigt__p_allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_difference_type[] = {  {&_swigt__p_difference_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_double[] = {  {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double[] = {  {&_swigt__p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__forced_stop[] = {  {&_swigt__p_nlopt__forced_stop, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__opt[] = {  {&_swigt__p_nlopt__opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt__roundoff_limited[] = {  {&_swigt__p_nlopt__roundoff_limited, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_func[] = {  {&_swigt__p_nlopt_func, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_mfunc[] = {  {&_swigt__p_nlopt_mfunc, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_opt[] = {  {&_swigt__p_nlopt_opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nlopt_result[] = {  {&_swigt__p_nlopt_result, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_p_PyObject[] = {  {&_swigt__p_p_PyObject, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_size_type[] = {  {&_swigt__p_size_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__allocatorT_double_t[] = {  {&_swigt__p_std__allocatorT_double_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__invalid_argument[] = {  {&_swigt__p_std__invalid_argument, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__runtime_error[] = {  {&_swigt__p_std__runtime_error, 0, 0, 0},  {&_swigt__p_nlopt__roundoff_limited, _p_nlopt__roundoff_limitedTo_p_std__runtime_error, 0, 0},  {&_swigt__p_nlopt__forced_stop, _p_nlopt__forced_stopTo_p_std__runtime_error, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorT__Tp__Alloc_t[] = {  {&_swigt__p_std__vectorT__Tp__Alloc_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorT_double_std__allocatorT_double_t_t[] = {  {&_swigt__p_std__vectorT_double_std__allocatorT_double_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_swig__SwigPyIterator[] = {  {&_swigt__p_swig__SwigPyIterator, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_value_type[] = {  {&_swigt__p_value_type, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+  _swigc__p_allocator_type,
+  _swigc__p_char,
+  _swigc__p_difference_type,
+  _swigc__p_double,
+  _swigc__p_f_r_q_const__std__vector__double_std__allocator__double_____r_std__vector__double_std__allocator__double_____p_void__double,
+  _swigc__p_int,
+  _swigc__p_nlopt__forced_stop,
+  _swigc__p_nlopt__opt,
+  _swigc__p_nlopt__roundoff_limited,
+  _swigc__p_nlopt_func,
+  _swigc__p_nlopt_mfunc,
+  _swigc__p_nlopt_opt,
+  _swigc__p_nlopt_result,
+  _swigc__p_p_PyObject,
+  _swigc__p_size_type,
+  _swigc__p_std__allocatorT_double_t,
+  _swigc__p_std__invalid_argument,
+  _swigc__p_std__runtime_error,
+  _swigc__p_std__vectorT__Tp__Alloc_t,
+  _swigc__p_std__vectorT_double_std__allocatorT_double_t_t,
+  _swigc__p_swig__SwigPyIterator,
+  _swigc__p_value_type,
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+static swig_const_info swig_const_table[] = {
+{0, 0, 0, 0.0, 0, 0}};
+
+#ifdef __cplusplus
+}
+#endif
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ *  1) If the cast->type has already been loaded AND the type we are adding
+ *     casting info to has not been loaded (it is in this module), THEN we
+ *     replace the cast->type pointer with the type pointer that has already
+ *     been loaded.
+ *  2) If BOTH types (the one we are adding casting info to, and the
+ *     cast->type) are loaded, THEN the cast info has already been loaded by
+ *     the previous module so we just ignore it.
+ *  3) Finally, if cast->type has not already been loaded, then we add that
+ *     swig_cast_info to the linked list (because the cast->type) pointer will
+ *     be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+  size_t i;
+  swig_module_info *module_head, *iter;
+  int found, init;
+  
+  /* check to see if the circular list has been setup, if not, set it up */
+  if (swig_module.next==0) {
+    /* Initialize the swig_module */
+    swig_module.type_initial = swig_type_initial;
+    swig_module.cast_initial = swig_cast_initial;
+    swig_module.next = &swig_module;
+    init = 1;
+  } else {
+    init = 0;
+  }
+  
+  /* Try and load any already created modules */
+  module_head = SWIG_GetModule(clientdata);
+  if (!module_head) {
+    /* This is the first module loaded for this interpreter */
+    /* so set the swig module into the interpreter */
+    SWIG_SetModule(clientdata, &swig_module);
+    module_head = &swig_module;
+  } else {
+    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+    found=0;
+    iter=module_head;
+    do {
+      if (iter==&swig_module) {
+        found=1;
+        break;
+      }
+      iter=iter->next;
+    } while (iter!= module_head);
+    
+    /* if the is found in the list, then all is done and we may leave */
+    if (found) return;
+    /* otherwise we must add out module into the list */
+    swig_module.next = module_head->next;
+    module_head->next = &swig_module;
+  }
+  
+  /* When multiple interpreters are used, a module could have already been initialized in
+       a different interpreter, but not yet have a pointer in this interpreter.
+       In this case, we do not want to continue adding types... everything should be
+       set up already */
+  if (init == 0) return;
+  
+  /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+  for (i = 0; i < swig_module.size; ++i) {
+    swig_type_info *type = 0;
+    swig_type_info *ret;
+    swig_cast_info *cast;
+    
+#ifdef SWIGRUNTIME_DEBUG
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+    
+    /* if there is another module already loaded */
+    if (swig_module.next != &swig_module) {
+      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+    }
+    if (type) {
+      /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+      if (swig_module.type_initial[i]->clientdata) {
+        type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+      }
+    } else {
+      type = swig_module.type_initial[i];
+    }
+    
+    /* Insert casting types */
+    cast = swig_module.cast_initial[i];
+    while (cast->type) {
+      /* Don't need to add information already in the list */
+      ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+      if (swig_module.next != &swig_module) {
+        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+        if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+      }
+      if (ret) {
+        if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+          printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+          cast->type = ret;
+          ret = 0;
+        } else {
+          /* Check for casting already in the list */
+          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+          if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+          if (!ocast) ret = 0;
+        }
+      }
+      
+      if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+        if (type->cast) {
+          type->cast->prev = cast;
+          cast->next = type->cast;
+        }
+        type->cast = cast;
+      }
+      cast++;
+    }
+    /* Set entry in modules->types array equal to the type */
+    swig_module.types[i] = type;
+  }
+  swig_module.types[i] = 0;
+  
+#ifdef SWIGRUNTIME_DEBUG
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+  for (i = 0; i < swig_module.size; ++i) {
+    int j = 0;
+    swig_cast_info *cast = swig_module.cast_initial[i];
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+    while (cast->type) {
+      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+      cast++;
+      ++j;
+    }
+    printf("---- Total casts: %d\n",j);
+  }
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types.  It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+  size_t i;
+  swig_cast_info *equiv;
+  static int init_run = 0;
+  
+  if (init_run) return;
+  init_run = 1;
+  
+  for (i = 0; i < swig_module.size; i++) {
+    if (swig_module.types[i]->clientdata) {
+      equiv = swig_module.types[i]->cast;
+      while (equiv) {
+        if (!equiv->converter) {
+          if (equiv->type && !equiv->type->clientdata)
+          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+        }
+        equiv = equiv->next;
+      }
+    }
+  }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+  /* c-mode */
+#endif
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+  /* Python-specific SWIG API */
+#define SWIG_newvarlink()                             SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr)  SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants)           SWIG_Python_InstallConstants(d, constants)
+  
+  /* -----------------------------------------------------------------------------
+   * global variable support code.
+   * ----------------------------------------------------------------------------- */
+  
+  typedef struct swig_globalvar {
+    char       *name;                  /* Name of global variable */
+    PyObject *(*get_attr)(void);       /* Return the current value */
+    int       (*set_attr)(PyObject *); /* Set the value */
+    struct swig_globalvar *next;
+  } swig_globalvar;
+  
+  typedef struct swig_varlinkobject {
+    PyObject_HEAD
+    swig_globalvar *vars;
+  } swig_varlinkobject;
+  
+  SWIGINTERN PyObject *
+  swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+#if PY_VERSION_HEX >= 0x03000000
+    return PyUnicode_InternFromString("<Swig global variables>");
+#else
+    return PyString_FromString("<Swig global variables>");
+#endif
+  }
+  
+  SWIGINTERN PyObject *
+  swig_varlink_str(swig_varlinkobject *v) {
+#if PY_VERSION_HEX >= 0x03000000
+    PyObject *str = PyUnicode_InternFromString("(");
+    PyObject *tail;
+    PyObject *joined;
+    swig_globalvar *var;
+    for (var = v->vars; var; var=var->next) {
+      tail = PyUnicode_FromString(var->name);
+      joined = PyUnicode_Concat(str, tail);
+      Py_DecRef(str);
+      Py_DecRef(tail);
+      str = joined;
+      if (var->next) {
+        tail = PyUnicode_InternFromString(", ");
+        joined = PyUnicode_Concat(str, tail);
+        Py_DecRef(str);
+        Py_DecRef(tail);
+        str = joined;
+      }
+    }
+    tail = PyUnicode_InternFromString(")");
+    joined = PyUnicode_Concat(str, tail);
+    Py_DecRef(str);
+    Py_DecRef(tail);
+    str = joined;
+#else
+    PyObject *str = PyString_FromString("(");
+    swig_globalvar *var;
+    for (var = v->vars; var; var=var->next) {
+      PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+      if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+    }
+    PyString_ConcatAndDel(&str,PyString_FromString(")"));
+#endif
+    return str;
+  }
+  
+  SWIGINTERN int
+  swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+    char *tmp;
+    PyObject *str = swig_varlink_str(v);
+    fprintf(fp,"Swig global variables ");
+    fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
+    SWIG_Python_str_DelForPy3(tmp);
+    Py_DECREF(str);
+    return 0;
+  }
+  
+  SWIGINTERN void
+  swig_varlink_dealloc(swig_varlinkobject *v) {
+    swig_globalvar *var = v->vars;
+    while (var) {
+      swig_globalvar *n = var->next;
+      free(var->name);
+      free(var);
+      var = n;
+    }
+  }
+  
+  SWIGINTERN PyObject *
+  swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+    PyObject *res = NULL;
+    swig_globalvar *var = v->vars;
+    while (var) {
+      if (strcmp(var->name,n) == 0) {
+        res = (*var->get_attr)();
+        break;
+      }
+      var = var->next;
+    }
+    if (res == NULL && !PyErr_Occurred()) {
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+    }
+    return res;
+  }
+  
+  SWIGINTERN int
+  swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+    int res = 1;
+    swig_globalvar *var = v->vars;
+    while (var) {
+      if (strcmp(var->name,n) == 0) {
+        res = (*var->set_attr)(p);
+        break;
+      }
+      var = var->next;
+    }
+    if (res == 1 && !PyErr_Occurred()) {
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+    }
+    return res;
+  }
+  
+  SWIGINTERN PyTypeObject*
+  swig_varlink_type(void) {
+    static char varlink__doc__[] = "Swig var link object";
+    static PyTypeObject varlink_type;
+    static int type_init = 0;
+    if (!type_init) {
+      const PyTypeObject tmp = {
+        /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+        PyVarObject_HEAD_INIT(NULL, 0)
+#else
+        PyObject_HEAD_INIT(NULL)
+        0,                                  /* ob_size */
+#endif
+        (char *)"swigvarlink",              /* tp_name */
+        sizeof(swig_varlinkobject),         /* tp_basicsize */
+        0,                                  /* tp_itemsize */
+        (destructor) swig_varlink_dealloc,  /* tp_dealloc */
+        (printfunc) swig_varlink_print,     /* tp_print */
+        (getattrfunc) swig_varlink_getattr, /* tp_getattr */
+        (setattrfunc) swig_varlink_setattr, /* tp_setattr */
+        0,                                  /* tp_compare */
+        (reprfunc) swig_varlink_repr,       /* tp_repr */
+        0,                                  /* tp_as_number */
+        0,                                  /* tp_as_sequence */
+        0,                                  /* tp_as_mapping */
+        0,                                  /* tp_hash */
+        0,                                  /* tp_call */
+        (reprfunc) swig_varlink_str,        /* tp_str */
+        0,                                  /* tp_getattro */
+        0,                                  /* tp_setattro */
+        0,                                  /* tp_as_buffer */
+        0,                                  /* tp_flags */
+        varlink__doc__,                     /* tp_doc */
+        0,                                  /* tp_traverse */
+        0,                                  /* tp_clear */
+        0,                                  /* tp_richcompare */
+        0,                                  /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+        0,                                  /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+        0,                                  /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+        0,0,0,0                             /* tp_alloc -> tp_next */
+#endif
+      };
+      varlink_type = tmp;
+      type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+      varlink_type.ob_type = &PyType_Type;
+#else
+      if (PyType_Ready(&varlink_type) < 0)
+      return NULL;
+#endif
+    }
+    return &varlink_type;
+  }
+  
+  /* Create a variable linking object for use later */
+  SWIGINTERN PyObject *
+  SWIG_Python_newvarlink(void) {
+    swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+    if (result) {
+      result->vars = 0;
+    }
+    return ((PyObject*) result);
+  }
+  
+  SWIGINTERN void 
+  SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+    swig_varlinkobject *v = (swig_varlinkobject *) p;
+    swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+    if (gv) {
+      size_t size = strlen(name)+1;
+      gv->name = (char *)malloc(size);
+      if (gv->name) {
+        strncpy(gv->name,name,size);
+        gv->get_attr = get_attr;
+        gv->set_attr = set_attr;
+        gv->next = v->vars;
+      }
+    }
+    v->vars = gv;
+  }
+  
+  SWIGINTERN PyObject *
+  SWIG_globals(void) {
+    static PyObject *_SWIG_globals = 0; 
+    if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();  
+    return _SWIG_globals;
+  }
+  
+  /* -----------------------------------------------------------------------------
+   * constants/methods manipulation
+   * ----------------------------------------------------------------------------- */
+  
+  /* Install Constants */
+  SWIGINTERN void
+  SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+    PyObject *obj = 0;
+    size_t i;
+    for (i = 0; constants[i].type; ++i) {
+      switch(constants[i].type) {
+      case SWIG_PY_POINTER:
+        obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+        break;
+      case SWIG_PY_BINARY:
+        obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+        break;
+      default:
+        obj = 0;
+        break;
+      }
+      if (obj) {
+        PyDict_SetItemString(d, constants[i].name, obj);
+        Py_DECREF(obj);
+      }
+    }
+  }
+  
+  /* -----------------------------------------------------------------------------*/
+  /* Fix SwigMethods to carry the callback ptrs when needed */
+  /* -----------------------------------------------------------------------------*/
+  
+  SWIGINTERN void
+  SWIG_Python_FixMethods(PyMethodDef *methods,
+    swig_const_info *const_table,
+    swig_type_info **types,
+    swig_type_info **types_initial) {
+    size_t i;
+    for (i = 0; methods[i].ml_name; ++i) {
+      const char *c = methods[i].ml_doc;
+      if (c && (c = strstr(c, "swig_ptr: "))) {
+        int j;
+        swig_const_info *ci = 0;
+        const char *name = c + 10;
+        for (j = 0; const_table[j].type; ++j) {
+          if (strncmp(const_table[j].name, name, 
+              strlen(const_table[j].name)) == 0) {
+            ci = &(const_table[j]);
+            break;
+          }
+        }
+        if (ci) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
+              strncpy(buff, methods[i].ml_doc, ldoc);
+              buff += ldoc;
+              strncpy(buff, "swig_ptr: ", 10);
+              buff += 10;
+              SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+              methods[i].ml_doc = ndoc;
+            }
+          }
+        }
+      }
+    }
+  } 
+  
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ *  Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+SWIGEXPORT 
+#if PY_VERSION_HEX >= 0x03000000
+PyObject*
+#else
+void
+#endif
+SWIG_init(void) {
+  PyObject *m, *d, *md;
+#if PY_VERSION_HEX >= 0x03000000
+  static struct PyModuleDef SWIG_module = {
+# if PY_VERSION_HEX >= 0x03020000
+    PyModuleDef_HEAD_INIT,
+# else
+    {
+      PyObject_HEAD_INIT(NULL)
+      NULL, /* m_init */
+      0,    /* m_index */
+      NULL, /* m_copy */
+    },
+# endif
+    (char *) SWIG_name,
+    NULL,
+    -1,
+    SwigMethods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+  };
+#endif
+  
+#if defined(SWIGPYTHON_BUILTIN)
+  static SwigPyClientData SwigPyObject_clientdata = {
+    0, 0, 0, 0, 0, 0, 0
+  };
+  static PyGetSetDef this_getset_def = {
+    (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
+  };
+  static SwigPyGetSet thisown_getset_closure = {
+    (PyCFunction) SwigPyObject_own,
+    (PyCFunction) SwigPyObject_own
+  };
+  static PyGetSetDef thisown_getset_def = {
+    (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
+  };
+  PyObject *metatype_args;
+  PyTypeObject *builtin_pytype;
+  int builtin_base_count;
+  swig_type_info *builtin_basetype;
+  PyObject *tuple;
+  PyGetSetDescrObject *static_getset;
+  PyTypeObject *metatype;
+  SwigPyClientData *cd;
+  PyObject *public_interface, *public_symbol;
+  PyObject *this_descr;
+  PyObject *thisown_descr;
+  int i;
+  
+  (void)builtin_pytype;
+  (void)builtin_base_count;
+  (void)builtin_basetype;
+  (void)tuple;
+  (void)static_getset;
+  
+  /* metatype is used to implement static member variables. */
+  metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
+  assert(metatype_args);
+  metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);
+  assert(metatype);
+  Py_DECREF(metatype_args);
+  metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
+  assert(PyType_Ready(metatype) >= 0);
+#endif
+  
+  /* Fix SwigMethods to carry the callback ptrs when needed */
+  SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+  
+#if PY_VERSION_HEX >= 0x03000000
+  m = PyModule_Create(&SWIG_module);
+#else
+  m = Py_InitModule((char *) SWIG_name, SwigMethods);
+#endif
+  md = d = PyModule_GetDict(m);
+  (void)md;
+  
+  SWIG_InitializeModule(0);
+  
+#ifdef SWIGPYTHON_BUILTIN
+  SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
+  assert(SwigPyObject_stype);
+  cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+  if (!cd) {
+    SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
+    SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();
+  } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {
+    PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
+# if PY_VERSION_HEX >= 0x03000000
+    return NULL;
+# else
+    return;
+# endif
+  }
+  
+  /* All objects have a 'this' attribute */
+  this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
+  (void)this_descr;
+  
+  /* All objects have a 'thisown' attribute */
+  thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
+  (void)thisown_descr;
+  
+  public_interface = PyList_New(0);
+  public_symbol = 0;
+  (void)public_symbol;
+  
+  PyDict_SetItemString(md, "__all__", public_interface);
+  Py_DECREF(public_interface);
+  for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
+  SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
+  for (i = 0; swig_const_table[i].name != 0; ++i)
+  SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
+#endif
+  
+  SWIG_InstallConstants(d,swig_const_table);
+  
+  
+  init_ForcedStop(m);
+  init_RoundoffLimited(m);
+  
+  
+  import_array();
+  
+  SWIG_Python_SetConstant(d, "GN_DIRECT",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT)));
+  SWIG_Python_SetConstant(d, "GN_DIRECT_L",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT_L)));
+  SWIG_Python_SetConstant(d, "GN_DIRECT_L_RAND",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT_L_RAND)));
+  SWIG_Python_SetConstant(d, "GN_DIRECT_NOSCAL",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT_NOSCAL)));
+  SWIG_Python_SetConstant(d, "GN_DIRECT_L_NOSCAL",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT_L_NOSCAL)));
+  SWIG_Python_SetConstant(d, "GN_DIRECT_L_RAND_NOSCAL",SWIG_From_int(static_cast< int >(nlopt::GN_DIRECT_L_RAND_NOSCAL)));
+  SWIG_Python_SetConstant(d, "GN_ORIG_DIRECT",SWIG_From_int(static_cast< int >(nlopt::GN_ORIG_DIRECT)));
+  SWIG_Python_SetConstant(d, "GN_ORIG_DIRECT_L",SWIG_From_int(static_cast< int >(nlopt::GN_ORIG_DIRECT_L)));
+  SWIG_Python_SetConstant(d, "GD_STOGO",SWIG_From_int(static_cast< int >(nlopt::GD_STOGO)));
+  SWIG_Python_SetConstant(d, "GD_STOGO_RAND",SWIG_From_int(static_cast< int >(nlopt::GD_STOGO_RAND)));
+  SWIG_Python_SetConstant(d, "LD_LBFGS_NOCEDAL",SWIG_From_int(static_cast< int >(nlopt::LD_LBFGS_NOCEDAL)));
+  SWIG_Python_SetConstant(d, "LD_LBFGS",SWIG_From_int(static_cast< int >(nlopt::LD_LBFGS)));
+  SWIG_Python_SetConstant(d, "LN_PRAXIS",SWIG_From_int(static_cast< int >(nlopt::LN_PRAXIS)));
+  SWIG_Python_SetConstant(d, "LD_VAR1",SWIG_From_int(static_cast< int >(nlopt::LD_VAR1)));
+  SWIG_Python_SetConstant(d, "LD_VAR2",SWIG_From_int(static_cast< int >(nlopt::LD_VAR2)));
+  SWIG_Python_SetConstant(d, "LD_TNEWTON",SWIG_From_int(static_cast< int >(nlopt::LD_TNEWTON)));
+  SWIG_Python_SetConstant(d, "LD_TNEWTON_RESTART",SWIG_From_int(static_cast< int >(nlopt::LD_TNEWTON_RESTART)));
+  SWIG_Python_SetConstant(d, "LD_TNEWTON_PRECOND",SWIG_From_int(static_cast< int >(nlopt::LD_TNEWTON_PRECOND)));
+  SWIG_Python_SetConstant(d, "LD_TNEWTON_PRECOND_RESTART",SWIG_From_int(static_cast< int >(nlopt::LD_TNEWTON_PRECOND_RESTART)));
+  SWIG_Python_SetConstant(d, "GN_CRS2_LM",SWIG_From_int(static_cast< int >(nlopt::GN_CRS2_LM)));
+  SWIG_Python_SetConstant(d, "GN_MLSL",SWIG_From_int(static_cast< int >(nlopt::GN_MLSL)));
+  SWIG_Python_SetConstant(d, "GD_MLSL",SWIG_From_int(static_cast< int >(nlopt::GD_MLSL)));
+  SWIG_Python_SetConstant(d, "GN_MLSL_LDS",SWIG_From_int(static_cast< int >(nlopt::GN_MLSL_LDS)));
+  SWIG_Python_SetConstant(d, "GD_MLSL_LDS",SWIG_From_int(static_cast< int >(nlopt::GD_MLSL_LDS)));
+  SWIG_Python_SetConstant(d, "LD_MMA",SWIG_From_int(static_cast< int >(nlopt::LD_MMA)));
+  SWIG_Python_SetConstant(d, "LN_COBYLA",SWIG_From_int(static_cast< int >(nlopt::LN_COBYLA)));
+  SWIG_Python_SetConstant(d, "LN_NEWUOA",SWIG_From_int(static_cast< int >(nlopt::LN_NEWUOA)));
+  SWIG_Python_SetConstant(d, "LN_NEWUOA_BOUND",SWIG_From_int(static_cast< int >(nlopt::LN_NEWUOA_BOUND)));
+  SWIG_Python_SetConstant(d, "LN_NELDERMEAD",SWIG_From_int(static_cast< int >(nlopt::LN_NELDERMEAD)));
+  SWIG_Python_SetConstant(d, "LN_SBPLX",SWIG_From_int(static_cast< int >(nlopt::LN_SBPLX)));
+  SWIG_Python_SetConstant(d, "LN_AUGLAG",SWIG_From_int(static_cast< int >(nlopt::LN_AUGLAG)));
+  SWIG_Python_SetConstant(d, "LD_AUGLAG",SWIG_From_int(static_cast< int >(nlopt::LD_AUGLAG)));
+  SWIG_Python_SetConstant(d, "LN_AUGLAG_EQ",SWIG_From_int(static_cast< int >(nlopt::LN_AUGLAG_EQ)));
+  SWIG_Python_SetConstant(d, "LD_AUGLAG_EQ",SWIG_From_int(static_cast< int >(nlopt::LD_AUGLAG_EQ)));
+  SWIG_Python_SetConstant(d, "LN_BOBYQA",SWIG_From_int(static_cast< int >(nlopt::LN_BOBYQA)));
+  SWIG_Python_SetConstant(d, "GN_ISRES",SWIG_From_int(static_cast< int >(nlopt::GN_ISRES)));
+  SWIG_Python_SetConstant(d, "AUGLAG",SWIG_From_int(static_cast< int >(nlopt::AUGLAG)));
+  SWIG_Python_SetConstant(d, "AUGLAG_EQ",SWIG_From_int(static_cast< int >(nlopt::AUGLAG_EQ)));
+  SWIG_Python_SetConstant(d, "G_MLSL",SWIG_From_int(static_cast< int >(nlopt::G_MLSL)));
+  SWIG_Python_SetConstant(d, "G_MLSL_LDS",SWIG_From_int(static_cast< int >(nlopt::G_MLSL_LDS)));
+  SWIG_Python_SetConstant(d, "LD_SLSQP",SWIG_From_int(static_cast< int >(nlopt::LD_SLSQP)));
+  SWIG_Python_SetConstant(d, "LD_CCSAQ",SWIG_From_int(static_cast< int >(nlopt::LD_CCSAQ)));
+  SWIG_Python_SetConstant(d, "GN_ESCH",SWIG_From_int(static_cast< int >(nlopt::GN_ESCH)));
+  SWIG_Python_SetConstant(d, "NUM_ALGORITHMS",SWIG_From_int(static_cast< int >(nlopt::NUM_ALGORITHMS)));
+  SWIG_Python_SetConstant(d, "FAILURE",SWIG_From_int(static_cast< int >(nlopt::FAILURE)));
+  SWIG_Python_SetConstant(d, "INVALID_ARGS",SWIG_From_int(static_cast< int >(nlopt::INVALID_ARGS)));
+  SWIG_Python_SetConstant(d, "OUT_OF_MEMORY",SWIG_From_int(static_cast< int >(nlopt::OUT_OF_MEMORY)));
+  SWIG_Python_SetConstant(d, "ROUNDOFF_LIMITED",SWIG_From_int(static_cast< int >(nlopt::ROUNDOFF_LIMITED)));
+  SWIG_Python_SetConstant(d, "FORCED_STOP",SWIG_From_int(static_cast< int >(nlopt::FORCED_STOP)));
+  SWIG_Python_SetConstant(d, "SUCCESS",SWIG_From_int(static_cast< int >(nlopt::SUCCESS)));
+  SWIG_Python_SetConstant(d, "STOPVAL_REACHED",SWIG_From_int(static_cast< int >(nlopt::STOPVAL_REACHED)));
+  SWIG_Python_SetConstant(d, "FTOL_REACHED",SWIG_From_int(static_cast< int >(nlopt::FTOL_REACHED)));
+  SWIG_Python_SetConstant(d, "XTOL_REACHED",SWIG_From_int(static_cast< int >(nlopt::XTOL_REACHED)));
+  SWIG_Python_SetConstant(d, "MAXEVAL_REACHED",SWIG_From_int(static_cast< int >(nlopt::MAXEVAL_REACHED)));
+  SWIG_Python_SetConstant(d, "MAXTIME_REACHED",SWIG_From_int(static_cast< int >(nlopt::MAXTIME_REACHED)));
+#if PY_VERSION_HEX >= 0x03000000
+  return m;
+#else
+  return;
+#endif
+}
+
diff --git a/swig/nlopt-python.i b/swig/nlopt-python.i
new file mode 100644 (file)
index 0000000..185507b
--- /dev/null
@@ -0,0 +1,206 @@
+// -*- C++ -*-
+
+//////////////////////////////////////////////////////////////////////////////
+// Converting NLopt/C++ exceptions to Python exceptions
+
+%{
+
+#define ExceptionSubclass(EXCNAME, EXCDOC)                             \
+  static PyTypeObject MyExc_ ## EXCNAME = {                            \
+    PyVarObject_HEAD_INIT(NULL, 0)                                             \
+      "nlopt." # EXCNAME,                                              \
+      sizeof(PyBaseExceptionObject),                                   \
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                  \
+      Py_TPFLAGS_DEFAULT,                                              \
+      PyDoc_STR(EXCDOC)                                                        \
+  };                                                                   \
+  static void init_ ## EXCNAME(PyObject *m) {                          \
+    MyExc_ ## EXCNAME .tp_base = (PyTypeObject *) PyExc_Exception;     \
+    PyType_Ready(&MyExc_ ## EXCNAME);                                  \
+    Py_INCREF(&MyExc_ ## EXCNAME);                                     \
+    PyModule_AddObject(m, # EXCNAME, (PyObject *) &MyExc_ ## EXCNAME); \
+  }
+
+
+ExceptionSubclass(ForcedStop,
+                 "Python version of nlopt::forced_stop exception.")
+
+ExceptionSubclass(RoundoffLimited,
+                 "Python version of nlopt::roundoff_limited exception.")
+
+%}
+
+%init %{
+  init_ForcedStop(m);
+  init_RoundoffLimited(m);
+%}
+%pythoncode %{
+  ForcedStop = _nlopt.ForcedStop
+  RoundoffLimited = _nlopt.RoundoffLimited
+  __version__ = str(_nlopt.version_major())+'.'+str(_nlopt.version_minor())+'.'+str(_nlopt.version_bugfix())
+%}
+
+%typemap(throws) std::bad_alloc %{
+  PyErr_SetString(PyExc_MemoryError, ($1).what());
+  SWIG_fail;
+%}
+
+%typemap(throws) nlopt::forced_stop %{
+  if (!PyErr_Occurred())
+    PyErr_SetString((PyObject*)&MyExc_ForcedStop, "NLopt forced stop");
+  SWIG_fail;
+%}
+
+%typemap(throws) nlopt::roundoff_limited %{
+  PyErr_SetString((PyObject*)&MyExc_RoundoffLimited, "NLopt roundoff-limited");
+  SWIG_fail;
+%}
+
+//////////////////////////////////////////////////////////////////////////////
+
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "numpy.i"
+%init %{
+  import_array();
+%}
+%numpy_typemaps(double, NPY_DOUBLE, unsigned)
+
+//////////////////////////////////////////////////////////////////////////////
+// numpy.i does not include maps for std::vector<double>, so I add them here,
+// taking advantage of the conversion functions provided by numpy.i
+
+// Typemap for input arguments of type const std::vector<double> &
+%typecheck(SWIG_TYPECHECK_POINTER, fragment="NumPy_Macros")
+  const std::vector<double> &
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in, fragment="NumPy_Fragments")
+  const std::vector<double> &
+(PyArrayObject* array=NULL, int is_new_object=0, std::vector<double> arrayv)
+{
+  npy_intp size[1] = { -1 };
+  array = obj_to_array_allow_conversion($input, NPY_DOUBLE, &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  arrayv = std::vector<double>(array_size(array,0));
+  $1 = &arrayv;
+  {
+    double *arr_data = (double *) array_data(array);
+    int arr_i, arr_s = array_stride(array,0) / sizeof(double);
+    int arr_sz = array_size(array,0);
+    for (arr_i = 0; arr_i < arr_sz; ++arr_i)
+      arrayv[arr_i] = arr_data[arr_i * arr_s];
+  }
+}
+%typemap(freearg)
+  const std::vector<double> &
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+// Typemap for return values of type std::vector<double>
+%typemap(out, fragment="NumPy_Fragments") std::vector<double>
+{
+  npy_intp sz = $1.size();
+  $result = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
+  std::memcpy(array_data($result), $1.empty() ? NULL : &$1[0],
+             sizeof(double) * sz);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Wrapper for objective function callbacks
+
+%{
+static void *free_pyfunc(void *p) { Py_DECREF((PyObject*) p); return p; }
+static void *dup_pyfunc(void *p) { Py_INCREF((PyObject*) p); return p; }
+
+#if NPY_API_VERSION < 0x00000007
+#  define NPY_ARRAY_C_CONTIGUOUS NPY_C_CONTIGUOUS
+#  define NPY_ARRAY_ALIGNED NPY_ALIGNED
+#endif
+
+static double func_python(unsigned n, const double *x, double *grad, void *f)
+{
+  npy_intp sz = npy_intp(n), sz0 = 0, stride1 = sizeof(double);
+  PyObject *xpy = PyArray_New(&PyArray_Type, 1, &sz, NPY_DOUBLE, &stride1,
+                             const_cast<double*>(x), // not NPY_WRITEABLE
+                             0, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED, NULL);
+  PyObject *gradpy = grad
+    ? PyArray_SimpleNewFromData(1, &sz, NPY_DOUBLE, grad)
+    : PyArray_SimpleNew(1, &sz0, NPY_DOUBLE);
+  
+  PyObject *arglist = Py_BuildValue("OO", xpy, gradpy);
+  PyObject *result = PyEval_CallObject((PyObject *) f, arglist);
+  Py_DECREF(arglist);
+
+  Py_DECREF(gradpy);
+  Py_DECREF(xpy);
+
+  double val = HUGE_VAL;
+  if (PyErr_Occurred()) {
+    Py_XDECREF(result);
+    throw nlopt::forced_stop(); // just stop, don't call PyErr_Clear()
+  }
+  else if (result && PyFloat_Check(result)) {
+    val = PyFloat_AsDouble(result);
+    Py_DECREF(result);
+  }
+  else {
+    Py_XDECREF(result);
+    throw std::invalid_argument("invalid result passed to nlopt");
+  }
+  return val;
+}
+
+static void mfunc_python(unsigned m, double *result,
+                        unsigned n, const double *x, double *grad, void *f)
+{
+  npy_intp nsz = npy_intp(n), msz = npy_intp(m);
+  npy_intp mnsz[2] = {msz, nsz};
+  npy_intp sz0 = 0, stride1 = sizeof(double);
+  PyObject *xpy = PyArray_New(&PyArray_Type, 1, &nsz, NPY_DOUBLE, &stride1,
+                             const_cast<double*>(x), // not NPY_WRITEABLE
+                             0, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED, NULL);
+  PyObject *rpy = PyArray_SimpleNewFromData(1, &msz, NPY_DOUBLE, result);
+  PyObject *gradpy = grad
+    ? PyArray_SimpleNewFromData(2, mnsz, NPY_DOUBLE, grad)
+    : PyArray_SimpleNew(1, &sz0, NPY_DOUBLE);
+  
+  PyObject *arglist = Py_BuildValue("OOO", rpy, xpy, gradpy);
+  PyObject *res = PyEval_CallObject((PyObject *) f, arglist);
+  Py_XDECREF(res);
+  Py_DECREF(arglist);
+
+  Py_DECREF(gradpy);
+  Py_DECREF(rpy);
+  Py_DECREF(xpy);
+
+  if (PyErr_Occurred()) {
+    throw nlopt::forced_stop(); // just stop, don't call PyErr_Clear()
+  }
+}
+%}
+
+%typemap(in)(nlopt::func f, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = func_python;
+  $2 = dup_pyfunc((void*) $input);
+  $3 = free_pyfunc;
+  $4 = dup_pyfunc;
+}
+%typecheck(SWIG_TYPECHECK_POINTER)(nlopt::func f, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = PyCallable_Check($input);
+}
+
+%typemap(in)(nlopt::mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = mfunc_python;
+  $2 = dup_pyfunc((void*) $input);
+  $3 = free_pyfunc;
+  $4 = dup_pyfunc;
+}
+%typecheck(SWIG_TYPECHECK_POINTER)(nlopt::mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc) {
+  $1 = PyCallable_Check($input);
+}
diff --git a/swig/nlopt.i b/swig/nlopt.i
new file mode 100644 (file)
index 0000000..5645f42
--- /dev/null
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+
+%define DOCSTRING
+"NLopt is a multi-language library for nonlinear optimization (local or
+global, with or without derivatives, and supporting nonlinear
+constraints).  Complete documentation, including a Python tutorial,
+can be found at the NLopt web page: http://ab-initio.mit.edu/nlopt"
+%enddef
+
+%module(docstring=DOCSTRING) nlopt
+%{
+#include "nlopt.hpp"
+%}
+
+%include "std_vector.i"
+namespace std {
+  %template(nlopt_doublevector) vector<double>;
+};
+
+// prepend "nlopt_" in Guile to substitute for namespace
+#if defined(SWIGGUILE)
+%rename(nlopt_opt) nlopt::opt;
+%rename(nlopt_roundoff_limited) nlopt::roundoff_limited;
+%rename(nlopt_forced_stop) nlopt::forced_stop;
+%rename(nlopt_srand) nlopt::srand;
+%rename(nlopt_srand_time) nlopt::srand_time;
+%rename(nlopt_version) nlopt::version;
+%rename(nlopt_version_major) nlopt::version_major;
+%rename(nlopt_version_minor) nlopt::version_minor;
+%rename(nlopt_version_bugfix) nlopt::version_bugfix;
+%rename(nlopt_algorithm_name) nlopt::algorithm_name;
+%include "nlopt-enum-renames.i"
+#endif
+
+%include "nlopt-exceptions.i"
+
+#ifdef SWIGGUILE
+%include "nlopt-guile.i"
+#endif
+
+#ifdef SWIGPYTHON
+%include "nlopt-python.i"
+#endif
+
+%include "nlopt.hpp"
diff --git a/swig/nlopt.py b/swig/nlopt.py
new file mode 100644 (file)
index 0000000..a116350
--- /dev/null
@@ -0,0 +1,337 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 2.0.12
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+
+
+
+
+"""
+NLopt is a multi-language library for nonlinear optimization (local or
+global, with or without derivatives, and supporting nonlinear
+constraints).  Complete documentation, including a Python tutorial,
+can be found at the NLopt web page: http://ab-initio.mit.edu/nlopt
+"""
+
+
+from sys import version_info
+if version_info >= (2,6,0):
+    def swig_import_helper():
+        from os.path import dirname
+        import imp
+        fp = None
+        try:
+            fp, pathname, description = imp.find_module('_nlopt', [dirname(__file__)])
+        except ImportError:
+            import _nlopt
+            return _nlopt
+        if fp is not None:
+            try:
+                _mod = imp.load_module('_nlopt', fp, pathname, description)
+            finally:
+                fp.close()
+            return _mod
+    _nlopt = swig_import_helper()
+    del swig_import_helper
+else:
+    import _nlopt
+del version_info
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+    if (name == "thisown"): return self.this.own(value)
+    if (name == "this"):
+        if type(value).__name__ == 'SwigPyObject':
+            self.__dict__[name] = value
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    if (not static):
+        self.__dict__[name] = value
+    else:
+        raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+    return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+    if (name == "thisown"): return self.this.own()
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError(name)
+
+def _swig_repr(self):
+    try: strthis = "proxy of " + self.this.__repr__()
+    except: strthis = ""
+    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+    _object = object
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+
+
+class SwigPyIterator(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
+    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
+    __repr__ = _swig_repr
+    __swig_destroy__ = _nlopt.delete_SwigPyIterator
+    __del__ = lambda self : None;
+    def value(self): return _nlopt.SwigPyIterator_value(self)
+    def incr(self, n=1): return _nlopt.SwigPyIterator_incr(self, n)
+    def decr(self, n=1): return _nlopt.SwigPyIterator_decr(self, n)
+    def distance(self, *args): return _nlopt.SwigPyIterator_distance(self, *args)
+    def equal(self, *args): return _nlopt.SwigPyIterator_equal(self, *args)
+    def copy(self): return _nlopt.SwigPyIterator_copy(self)
+    def next(self): return _nlopt.SwigPyIterator_next(self)
+    def __next__(self): return _nlopt.SwigPyIterator___next__(self)
+    def previous(self): return _nlopt.SwigPyIterator_previous(self)
+    def advance(self, *args): return _nlopt.SwigPyIterator_advance(self, *args)
+    def __eq__(self, *args): return _nlopt.SwigPyIterator___eq__(self, *args)
+    def __ne__(self, *args): return _nlopt.SwigPyIterator___ne__(self, *args)
+    def __iadd__(self, *args): return _nlopt.SwigPyIterator___iadd__(self, *args)
+    def __isub__(self, *args): return _nlopt.SwigPyIterator___isub__(self, *args)
+    def __add__(self, *args): return _nlopt.SwigPyIterator___add__(self, *args)
+    def __sub__(self, *args): return _nlopt.SwigPyIterator___sub__(self, *args)
+    def __iter__(self): return self
+SwigPyIterator_swigregister = _nlopt.SwigPyIterator_swigregister
+SwigPyIterator_swigregister(SwigPyIterator)
+
+class nlopt_doublevector(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, nlopt_doublevector, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, nlopt_doublevector, name)
+    __repr__ = _swig_repr
+    def iterator(self): return _nlopt.nlopt_doublevector_iterator(self)
+    def __iter__(self): return self.iterator()
+    def __nonzero__(self): return _nlopt.nlopt_doublevector___nonzero__(self)
+    def __bool__(self): return _nlopt.nlopt_doublevector___bool__(self)
+    def __len__(self): return _nlopt.nlopt_doublevector___len__(self)
+    def pop(self): return _nlopt.nlopt_doublevector_pop(self)
+    def __getslice__(self, *args): return _nlopt.nlopt_doublevector___getslice__(self, *args)
+    def __setslice__(self, *args): return _nlopt.nlopt_doublevector___setslice__(self, *args)
+    def __delslice__(self, *args): return _nlopt.nlopt_doublevector___delslice__(self, *args)
+    def __delitem__(self, *args): return _nlopt.nlopt_doublevector___delitem__(self, *args)
+    def __getitem__(self, *args): return _nlopt.nlopt_doublevector___getitem__(self, *args)
+    def __setitem__(self, *args): return _nlopt.nlopt_doublevector___setitem__(self, *args)
+    def append(self, *args): return _nlopt.nlopt_doublevector_append(self, *args)
+    def empty(self): return _nlopt.nlopt_doublevector_empty(self)
+    def size(self): return _nlopt.nlopt_doublevector_size(self)
+    def clear(self): return _nlopt.nlopt_doublevector_clear(self)
+    def swap(self, *args): return _nlopt.nlopt_doublevector_swap(self, *args)
+    def get_allocator(self): return _nlopt.nlopt_doublevector_get_allocator(self)
+    def begin(self): return _nlopt.nlopt_doublevector_begin(self)
+    def end(self): return _nlopt.nlopt_doublevector_end(self)
+    def rbegin(self): return _nlopt.nlopt_doublevector_rbegin(self)
+    def rend(self): return _nlopt.nlopt_doublevector_rend(self)
+    def pop_back(self): return _nlopt.nlopt_doublevector_pop_back(self)
+    def erase(self, *args): return _nlopt.nlopt_doublevector_erase(self, *args)
+    def __init__(self, *args): 
+        this = _nlopt.new_nlopt_doublevector(*args)
+        try: self.this.append(this)
+        except: self.this = this
+    def push_back(self, *args): return _nlopt.nlopt_doublevector_push_back(self, *args)
+    def front(self): return _nlopt.nlopt_doublevector_front(self)
+    def back(self): return _nlopt.nlopt_doublevector_back(self)
+    def assign(self, *args): return _nlopt.nlopt_doublevector_assign(self, *args)
+    def resize(self, *args): return _nlopt.nlopt_doublevector_resize(self, *args)
+    def insert(self, *args): return _nlopt.nlopt_doublevector_insert(self, *args)
+    def reserve(self, *args): return _nlopt.nlopt_doublevector_reserve(self, *args)
+    def capacity(self): return _nlopt.nlopt_doublevector_capacity(self)
+    __swig_destroy__ = _nlopt.delete_nlopt_doublevector
+    __del__ = lambda self : None;
+nlopt_doublevector_swigregister = _nlopt.nlopt_doublevector_swigregister
+nlopt_doublevector_swigregister(nlopt_doublevector)
+
+ForcedStop = _nlopt.ForcedStop
+RoundoffLimited = _nlopt.RoundoffLimited
+__version__ = str(_nlopt.version_major())+'.'+str(_nlopt.version_minor())+'.'+str(_nlopt.version_bugfix())
+
+
+def nlopt_get_initial_step(*args):
+  return _nlopt.nlopt_get_initial_step(*args)
+nlopt_get_initial_step = _nlopt.nlopt_get_initial_step
+GN_DIRECT = _nlopt.GN_DIRECT
+GN_DIRECT_L = _nlopt.GN_DIRECT_L
+GN_DIRECT_L_RAND = _nlopt.GN_DIRECT_L_RAND
+GN_DIRECT_NOSCAL = _nlopt.GN_DIRECT_NOSCAL
+GN_DIRECT_L_NOSCAL = _nlopt.GN_DIRECT_L_NOSCAL
+GN_DIRECT_L_RAND_NOSCAL = _nlopt.GN_DIRECT_L_RAND_NOSCAL
+GN_ORIG_DIRECT = _nlopt.GN_ORIG_DIRECT
+GN_ORIG_DIRECT_L = _nlopt.GN_ORIG_DIRECT_L
+GD_STOGO = _nlopt.GD_STOGO
+GD_STOGO_RAND = _nlopt.GD_STOGO_RAND
+LD_LBFGS_NOCEDAL = _nlopt.LD_LBFGS_NOCEDAL
+LD_LBFGS = _nlopt.LD_LBFGS
+LN_PRAXIS = _nlopt.LN_PRAXIS
+LD_VAR1 = _nlopt.LD_VAR1
+LD_VAR2 = _nlopt.LD_VAR2
+LD_TNEWTON = _nlopt.LD_TNEWTON
+LD_TNEWTON_RESTART = _nlopt.LD_TNEWTON_RESTART
+LD_TNEWTON_PRECOND = _nlopt.LD_TNEWTON_PRECOND
+LD_TNEWTON_PRECOND_RESTART = _nlopt.LD_TNEWTON_PRECOND_RESTART
+GN_CRS2_LM = _nlopt.GN_CRS2_LM
+GN_MLSL = _nlopt.GN_MLSL
+GD_MLSL = _nlopt.GD_MLSL
+GN_MLSL_LDS = _nlopt.GN_MLSL_LDS
+GD_MLSL_LDS = _nlopt.GD_MLSL_LDS
+LD_MMA = _nlopt.LD_MMA
+LN_COBYLA = _nlopt.LN_COBYLA
+LN_NEWUOA = _nlopt.LN_NEWUOA
+LN_NEWUOA_BOUND = _nlopt.LN_NEWUOA_BOUND
+LN_NELDERMEAD = _nlopt.LN_NELDERMEAD
+LN_SBPLX = _nlopt.LN_SBPLX
+LN_AUGLAG = _nlopt.LN_AUGLAG
+LD_AUGLAG = _nlopt.LD_AUGLAG
+LN_AUGLAG_EQ = _nlopt.LN_AUGLAG_EQ
+LD_AUGLAG_EQ = _nlopt.LD_AUGLAG_EQ
+LN_BOBYQA = _nlopt.LN_BOBYQA
+GN_ISRES = _nlopt.GN_ISRES
+AUGLAG = _nlopt.AUGLAG
+AUGLAG_EQ = _nlopt.AUGLAG_EQ
+G_MLSL = _nlopt.G_MLSL
+G_MLSL_LDS = _nlopt.G_MLSL_LDS
+LD_SLSQP = _nlopt.LD_SLSQP
+LD_CCSAQ = _nlopt.LD_CCSAQ
+GN_ESCH = _nlopt.GN_ESCH
+NUM_ALGORITHMS = _nlopt.NUM_ALGORITHMS
+FAILURE = _nlopt.FAILURE
+INVALID_ARGS = _nlopt.INVALID_ARGS
+OUT_OF_MEMORY = _nlopt.OUT_OF_MEMORY
+ROUNDOFF_LIMITED = _nlopt.ROUNDOFF_LIMITED
+FORCED_STOP = _nlopt.FORCED_STOP
+SUCCESS = _nlopt.SUCCESS
+STOPVAL_REACHED = _nlopt.STOPVAL_REACHED
+FTOL_REACHED = _nlopt.FTOL_REACHED
+XTOL_REACHED = _nlopt.XTOL_REACHED
+MAXEVAL_REACHED = _nlopt.MAXEVAL_REACHED
+MAXTIME_REACHED = _nlopt.MAXTIME_REACHED
+class roundoff_limited(Exception):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, roundoff_limited, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, roundoff_limited, name)
+    __repr__ = _swig_repr
+    def __init__(self): 
+        this = _nlopt.new_roundoff_limited()
+        try: self.this.append(this)
+        except: self.this = this
+    __swig_destroy__ = _nlopt.delete_roundoff_limited
+    __del__ = lambda self : None;
+roundoff_limited_swigregister = _nlopt.roundoff_limited_swigregister
+roundoff_limited_swigregister(roundoff_limited)
+
+class forced_stop(Exception):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, forced_stop, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, forced_stop, name)
+    __repr__ = _swig_repr
+    def __init__(self): 
+        this = _nlopt.new_forced_stop()
+        try: self.this.append(this)
+        except: self.this = this
+    __swig_destroy__ = _nlopt.delete_forced_stop
+    __del__ = lambda self : None;
+forced_stop_swigregister = _nlopt.forced_stop_swigregister
+forced_stop_swigregister(forced_stop)
+
+class opt(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, opt, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, opt, name)
+    __repr__ = _swig_repr
+    __swig_destroy__ = _nlopt.delete_opt
+    __del__ = lambda self : None;
+    def __init__(self, *args): 
+        this = _nlopt.new_opt(*args)
+        try: self.this.append(this)
+        except: self.this = this
+    def optimize(self, *args): return _nlopt.opt_optimize(self, *args)
+    def last_optimize_result(self): return _nlopt.opt_last_optimize_result(self)
+    def last_optimum_value(self): return _nlopt.opt_last_optimum_value(self)
+    def get_algorithm(self): return _nlopt.opt_get_algorithm(self)
+    def get_algorithm_name(self): return _nlopt.opt_get_algorithm_name(self)
+    def get_dimension(self): return _nlopt.opt_get_dimension(self)
+    def set_min_objective(self, *args): return _nlopt.opt_set_min_objective(self, *args)
+    def set_max_objective(self, *args): return _nlopt.opt_set_max_objective(self, *args)
+    def remove_inequality_constraints(self): return _nlopt.opt_remove_inequality_constraints(self)
+    def remove_equality_constraints(self): return _nlopt.opt_remove_equality_constraints(self)
+    def add_inequality_constraint(self, *args): return _nlopt.opt_add_inequality_constraint(self, *args)
+    def add_equality_constraint(self, *args): return _nlopt.opt_add_equality_constraint(self, *args)
+    def add_inequality_mconstraint(self, *args): return _nlopt.opt_add_inequality_mconstraint(self, *args)
+    def add_equality_mconstraint(self, *args): return _nlopt.opt_add_equality_mconstraint(self, *args)
+    def get_lower_bounds(self, *args): return _nlopt.opt_get_lower_bounds(self, *args)
+    def set_lower_bounds(self, *args): return _nlopt.opt_set_lower_bounds(self, *args)
+    def get_upper_bounds(self, *args): return _nlopt.opt_get_upper_bounds(self, *args)
+    def set_upper_bounds(self, *args): return _nlopt.opt_set_upper_bounds(self, *args)
+    def get_stopval(self): return _nlopt.opt_get_stopval(self)
+    def set_stopval(self, *args): return _nlopt.opt_set_stopval(self, *args)
+    def get_ftol_rel(self): return _nlopt.opt_get_ftol_rel(self)
+    def set_ftol_rel(self, *args): return _nlopt.opt_set_ftol_rel(self, *args)
+    def get_ftol_abs(self): return _nlopt.opt_get_ftol_abs(self)
+    def set_ftol_abs(self, *args): return _nlopt.opt_set_ftol_abs(self, *args)
+    def get_xtol_rel(self): return _nlopt.opt_get_xtol_rel(self)
+    def set_xtol_rel(self, *args): return _nlopt.opt_set_xtol_rel(self, *args)
+    def get_xtol_abs(self, *args): return _nlopt.opt_get_xtol_abs(self, *args)
+    def set_xtol_abs(self, *args): return _nlopt.opt_set_xtol_abs(self, *args)
+    def get_maxeval(self): return _nlopt.opt_get_maxeval(self)
+    def set_maxeval(self, *args): return _nlopt.opt_set_maxeval(self, *args)
+    def get_maxtime(self): return _nlopt.opt_get_maxtime(self)
+    def set_maxtime(self, *args): return _nlopt.opt_set_maxtime(self, *args)
+    def get_force_stop(self): return _nlopt.opt_get_force_stop(self)
+    def set_force_stop(self, *args): return _nlopt.opt_set_force_stop(self, *args)
+    def force_stop(self): return _nlopt.opt_force_stop(self)
+    def set_local_optimizer(self, *args): return _nlopt.opt_set_local_optimizer(self, *args)
+    def get_population(self): return _nlopt.opt_get_population(self)
+    def set_population(self, *args): return _nlopt.opt_set_population(self, *args)
+    def get_vector_storage(self): return _nlopt.opt_get_vector_storage(self)
+    def set_vector_storage(self, *args): return _nlopt.opt_set_vector_storage(self, *args)
+    def set_initial_step(self, *args): return _nlopt.opt_set_initial_step(self, *args)
+    def set_default_initial_step(self, *args): return _nlopt.opt_set_default_initial_step(self, *args)
+    def get_initial_step(self, *args): return _nlopt.opt_get_initial_step(self, *args)
+    def get_initial_step_(self, *args): return _nlopt.opt_get_initial_step_(self, *args)
+opt_swigregister = _nlopt.opt_swigregister
+opt_swigregister(opt)
+
+
+def srand(*args):
+  return _nlopt.srand(*args)
+srand = _nlopt.srand
+
+def srand_time():
+  return _nlopt.srand_time()
+srand_time = _nlopt.srand_time
+
+def version(*args):
+  return _nlopt.version(*args)
+version = _nlopt.version
+
+def version_major():
+  return _nlopt.version_major()
+version_major = _nlopt.version_major
+
+def version_minor():
+  return _nlopt.version_minor()
+version_minor = _nlopt.version_minor
+
+def version_bugfix():
+  return _nlopt.version_bugfix()
+version_bugfix = _nlopt.version_bugfix
+
+def algorithm_name(*args):
+  return _nlopt.algorithm_name(*args)
+algorithm_name = _nlopt.algorithm_name
+# This file is compatible with both classic and new-style classes.
+
+
diff --git a/swig/nlopt.scm.in b/swig/nlopt.scm.in
new file mode 100644 (file)
index 0000000..fea1109
--- /dev/null
@@ -0,0 +1,220 @@
+;;; This file was automatically generated by SWIG (http://www.swig.org).
+;;; Version 2.0.12
+;;;
+;;; Do not make changes to this file unless you know what you are doing--modify
+;;; the SWIG interface file instead.
+
+(define-module (nlopt))
+
+(load-extension "libnlopt@NLOPT_SUFFIX@_guile.so" "SWIG_init")
+
+(set! NLOPT-GN-DIRECT (NLOPT-GN-DIRECT))
+(set! NLOPT-GN-DIRECT-L (NLOPT-GN-DIRECT-L))
+(set! NLOPT-GN-DIRECT-L-RAND (NLOPT-GN-DIRECT-L-RAND))
+(set! NLOPT-GN-DIRECT-NOSCAL (NLOPT-GN-DIRECT-NOSCAL))
+(set! NLOPT-GN-DIRECT-L-NOSCAL (NLOPT-GN-DIRECT-L-NOSCAL))
+(set! NLOPT-GN-DIRECT-L-RAND-NOSCAL (NLOPT-GN-DIRECT-L-RAND-NOSCAL))
+(set! NLOPT-GN-ORIG-DIRECT (NLOPT-GN-ORIG-DIRECT))
+(set! NLOPT-GN-ORIG-DIRECT-L (NLOPT-GN-ORIG-DIRECT-L))
+(set! NLOPT-GD-STOGO (NLOPT-GD-STOGO))
+(set! NLOPT-GD-STOGO-RAND (NLOPT-GD-STOGO-RAND))
+(set! NLOPT-LD-LBFGS-NOCEDAL (NLOPT-LD-LBFGS-NOCEDAL))
+(set! NLOPT-LD-LBFGS (NLOPT-LD-LBFGS))
+(set! NLOPT-LN-PRAXIS (NLOPT-LN-PRAXIS))
+(set! NLOPT-LD-VAR1 (NLOPT-LD-VAR1))
+(set! NLOPT-LD-VAR2 (NLOPT-LD-VAR2))
+(set! NLOPT-LD-TNEWTON (NLOPT-LD-TNEWTON))
+(set! NLOPT-LD-TNEWTON-RESTART (NLOPT-LD-TNEWTON-RESTART))
+(set! NLOPT-LD-TNEWTON-PRECOND (NLOPT-LD-TNEWTON-PRECOND))
+(set! NLOPT-LD-TNEWTON-PRECOND-RESTART (NLOPT-LD-TNEWTON-PRECOND-RESTART))
+(set! NLOPT-GN-CRS2-LM (NLOPT-GN-CRS2-LM))
+(set! NLOPT-GN-MLSL (NLOPT-GN-MLSL))
+(set! NLOPT-GD-MLSL (NLOPT-GD-MLSL))
+(set! NLOPT-GN-MLSL-LDS (NLOPT-GN-MLSL-LDS))
+(set! NLOPT-GD-MLSL-LDS (NLOPT-GD-MLSL-LDS))
+(set! NLOPT-LD-MMA (NLOPT-LD-MMA))
+(set! NLOPT-LN-COBYLA (NLOPT-LN-COBYLA))
+(set! NLOPT-LN-NEWUOA (NLOPT-LN-NEWUOA))
+(set! NLOPT-LN-NEWUOA-BOUND (NLOPT-LN-NEWUOA-BOUND))
+(set! NLOPT-LN-NELDERMEAD (NLOPT-LN-NELDERMEAD))
+(set! NLOPT-LN-SBPLX (NLOPT-LN-SBPLX))
+(set! NLOPT-LN-AUGLAG (NLOPT-LN-AUGLAG))
+(set! NLOPT-LD-AUGLAG (NLOPT-LD-AUGLAG))
+(set! NLOPT-LN-AUGLAG-EQ (NLOPT-LN-AUGLAG-EQ))
+(set! NLOPT-LD-AUGLAG-EQ (NLOPT-LD-AUGLAG-EQ))
+(set! NLOPT-LN-BOBYQA (NLOPT-LN-BOBYQA))
+(set! NLOPT-GN-ISRES (NLOPT-GN-ISRES))
+(set! NLOPT-AUGLAG (NLOPT-AUGLAG))
+(set! NLOPT-AUGLAG-EQ (NLOPT-AUGLAG-EQ))
+(set! NLOPT-G-MLSL (NLOPT-G-MLSL))
+(set! NLOPT-G-MLSL-LDS (NLOPT-G-MLSL-LDS))
+(set! NLOPT-LD-SLSQP (NLOPT-LD-SLSQP))
+(set! NLOPT-LD-CCSAQ (NLOPT-LD-CCSAQ))
+(set! NLOPT-GN-ESCH (NLOPT-GN-ESCH))
+(set! NLOPT-NUM-ALGORITHMS (NLOPT-NUM-ALGORITHMS))
+(set! NLOPT-FAILURE (NLOPT-FAILURE))
+(set! NLOPT-INVALID-ARGS (NLOPT-INVALID-ARGS))
+(set! NLOPT-OUT-OF-MEMORY (NLOPT-OUT-OF-MEMORY))
+(set! NLOPT-ROUNDOFF-LIMITED (NLOPT-ROUNDOFF-LIMITED))
+(set! NLOPT-FORCED-STOP (NLOPT-FORCED-STOP))
+(set! NLOPT-SUCCESS (NLOPT-SUCCESS))
+(set! NLOPT-STOPVAL-REACHED (NLOPT-STOPVAL-REACHED))
+(set! NLOPT-FTOL-REACHED (NLOPT-FTOL-REACHED))
+(set! NLOPT-XTOL-REACHED (NLOPT-XTOL-REACHED))
+(set! NLOPT-MAXEVAL-REACHED (NLOPT-MAXEVAL-REACHED))
+(set! NLOPT-MAXTIME-REACHED (NLOPT-MAXTIME-REACHED))
+
+(export new-nlopt-doublevector
+        new-nlopt-doublevector
+        new-nlopt-doublevector
+        new-nlopt-doublevector
+        nlopt-doublevector-length
+        nlopt-doublevector-empty?
+        nlopt-doublevector-clear!
+        nlopt-doublevector-push!
+        nlopt-doublevector-pop!
+        nlopt-doublevector-ref
+        nlopt-doublevector-set!
+        delete-nlopt-doublevector
+        nlopt-get-initial-step
+        NLOPT-GN-DIRECT
+        NLOPT-GN-DIRECT-L
+        NLOPT-GN-DIRECT-L-RAND
+        NLOPT-GN-DIRECT-NOSCAL
+        NLOPT-GN-DIRECT-L-NOSCAL
+        NLOPT-GN-DIRECT-L-RAND-NOSCAL
+        NLOPT-GN-ORIG-DIRECT
+        NLOPT-GN-ORIG-DIRECT-L
+        NLOPT-GD-STOGO
+        NLOPT-GD-STOGO-RAND
+        NLOPT-LD-LBFGS-NOCEDAL
+        NLOPT-LD-LBFGS
+        NLOPT-LN-PRAXIS
+        NLOPT-LD-VAR1
+        NLOPT-LD-VAR2
+        NLOPT-LD-TNEWTON
+        NLOPT-LD-TNEWTON-RESTART
+        NLOPT-LD-TNEWTON-PRECOND
+        NLOPT-LD-TNEWTON-PRECOND-RESTART
+        NLOPT-GN-CRS2-LM
+        NLOPT-GN-MLSL
+        NLOPT-GD-MLSL
+        NLOPT-GN-MLSL-LDS
+        NLOPT-GD-MLSL-LDS
+        NLOPT-LD-MMA
+        NLOPT-LN-COBYLA
+        NLOPT-LN-NEWUOA
+        NLOPT-LN-NEWUOA-BOUND
+        NLOPT-LN-NELDERMEAD
+        NLOPT-LN-SBPLX
+        NLOPT-LN-AUGLAG
+        NLOPT-LD-AUGLAG
+        NLOPT-LN-AUGLAG-EQ
+        NLOPT-LD-AUGLAG-EQ
+        NLOPT-LN-BOBYQA
+        NLOPT-GN-ISRES
+        NLOPT-AUGLAG
+        NLOPT-AUGLAG-EQ
+        NLOPT-G-MLSL
+        NLOPT-G-MLSL-LDS
+        NLOPT-LD-SLSQP
+        NLOPT-LD-CCSAQ
+        NLOPT-GN-ESCH
+        NLOPT-NUM-ALGORITHMS
+        NLOPT-FAILURE
+        NLOPT-INVALID-ARGS
+        NLOPT-OUT-OF-MEMORY
+        NLOPT-ROUNDOFF-LIMITED
+        NLOPT-FORCED-STOP
+        NLOPT-SUCCESS
+        NLOPT-STOPVAL-REACHED
+        NLOPT-FTOL-REACHED
+        NLOPT-XTOL-REACHED
+        NLOPT-MAXEVAL-REACHED
+        NLOPT-MAXTIME-REACHED
+        new-nlopt-roundoff-limited
+        delete-nlopt-roundoff-limited
+        new-nlopt-forced-stop
+        delete-nlopt-forced-stop
+        new-nlopt-opt
+        delete-nlopt-opt
+        new-nlopt-opt
+        new-nlopt-opt
+        nlopt-opt-optimize
+        nlopt-opt-optimize
+        nlopt-opt-last-optimize-result
+        nlopt-opt-last-optimum-value
+        nlopt-opt-get-algorithm
+        nlopt-opt-get-algorithm-name
+        nlopt-opt-get-dimension
+        nlopt-opt-set-min-objective
+        nlopt-opt-set-min-objective
+        nlopt-opt-set-max-objective
+        nlopt-opt-set-max-objective
+        nlopt-opt-set-min-objective
+        nlopt-opt-set-max-objective
+        nlopt-opt-remove-inequality-constraints
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-inequality-mconstraint
+        nlopt-opt-remove-equality-constraints
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-equality-mconstraint
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-inequality-constraint
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-equality-constraint
+        nlopt-opt-add-inequality-mconstraint
+        nlopt-opt-add-equality-mconstraint
+        nlopt-opt-set-lower-bounds
+        nlopt-opt-get-lower-bounds
+        nlopt-opt-get-lower-bounds
+        nlopt-opt-set-lower-bounds
+        nlopt-opt-set-upper-bounds
+        nlopt-opt-get-upper-bounds
+        nlopt-opt-get-upper-bounds
+        nlopt-opt-set-upper-bounds
+        nlopt-opt-get-stopval
+        nlopt-opt-set-stopval
+        nlopt-opt-get-ftol-rel
+        nlopt-opt-set-ftol-rel
+        nlopt-opt-get-ftol-abs
+        nlopt-opt-set-ftol-abs
+        nlopt-opt-get-xtol-rel
+        nlopt-opt-set-xtol-rel
+        nlopt-opt-set-xtol-abs
+        nlopt-opt-get-xtol-abs
+        nlopt-opt-get-xtol-abs
+        nlopt-opt-set-xtol-abs
+        nlopt-opt-get-maxeval
+        nlopt-opt-set-maxeval
+        nlopt-opt-get-maxtime
+        nlopt-opt-set-maxtime
+        nlopt-opt-get-force-stop
+        nlopt-opt-set-force-stop
+        nlopt-opt-force-stop
+        nlopt-opt-set-local-optimizer
+        nlopt-opt-get-population
+        nlopt-opt-set-population
+        nlopt-opt-get-vector-storage
+        nlopt-opt-set-vector-storage
+        nlopt-opt-set-initial-step
+        nlopt-opt-get-initial-step
+        nlopt-opt-get-initial-step
+        nlopt-opt-set-initial-step
+        nlopt-opt-set-default-initial-step
+        nlopt-opt-get-initial-step
+        nlopt-opt-get-initial-step-
+        nlopt-srand
+        nlopt-srand-time
+        nlopt-version
+        nlopt-version-major
+        nlopt-version-minor
+        nlopt-version-bugfix
+        nlopt-algorithm-name)
diff --git a/swig/numpy.i b/swig/numpy.i
new file mode 100644 (file)
index 0000000..f2714cc
--- /dev/null
@@ -0,0 +1,3085 @@
+/* -*- C -*-  (not really, but good for syntax highlighting) */
+#ifdef SWIGPYTHON
+
+%{
+#ifndef SWIG_FILE_WITH_INIT
+#define NO_IMPORT_ARRAY
+#endif
+#include "stdio.h"
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/arrayobject.h>
+%}
+
+/**********************************************************************/
+
+%fragment("NumPy_Backward_Compatibility", "header")
+{
+%#if NPY_API_VERSION < 0x00000007
+%#define NPY_ARRAY_DEFAULT NPY_DEFAULT
+%#define NPY_ARRAY_FARRAY  NPY_FARRAY
+%#define NPY_FORTRANORDER  NPY_FORTRAN
+%#endif
+}
+
+/**********************************************************************/
+
+/* The following code originally appeared in
+ * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
+ * translated from C++ to C by John Hunter.  Bill Spotz has modified
+ * it to fix some minor bugs, upgrade from Numeric to numpy (all
+ * versions), add some comments and functionality, and convert from
+ * direct code insertion to SWIG fragments.
+ */
+
+%fragment("NumPy_Macros", "header")
+{
+/* Macros to extract array attributes.
+ */
+%#if NPY_API_VERSION < 0x00000007
+%#define is_array(a)            ((a) && PyArray_Check((PyArrayObject*)a))
+%#define array_type(a)          (int)(PyArray_TYPE((PyArrayObject*)a))
+%#define array_numdims(a)       (((PyArrayObject*)a)->nd)
+%#define array_dimensions(a)    (((PyArrayObject*)a)->dimensions)
+%#define array_size(a,i)        (((PyArrayObject*)a)->dimensions[i])
+%#define array_strides(a)       (((PyArrayObject*)a)->strides)
+%#define array_stride(a,i)      (((PyArrayObject*)a)->strides[i])
+%#define array_data(a)          (((PyArrayObject*)a)->data)
+%#define array_descr(a)         (((PyArrayObject*)a)->descr)
+%#define array_flags(a)         (((PyArrayObject*)a)->flags)
+%#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f
+%#else
+%#define is_array(a)            ((a) && PyArray_Check(a))
+%#define array_type(a)          PyArray_TYPE((PyArrayObject*)a)
+%#define array_numdims(a)       PyArray_NDIM((PyArrayObject*)a)
+%#define array_dimensions(a)    PyArray_DIMS((PyArrayObject*)a)
+%#define array_strides(a)       PyArray_STRIDES((PyArrayObject*)a)
+%#define array_stride(a,i)      PyArray_STRIDE((PyArrayObject*)a,i)
+%#define array_size(a,i)        PyArray_DIM((PyArrayObject*)a,i)
+%#define array_data(a)          PyArray_DATA((PyArrayObject*)a)
+%#define array_descr(a)         PyArray_DESCR((PyArrayObject*)a)
+%#define array_flags(a)         PyArray_FLAGS((PyArrayObject*)a)
+%#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f)
+%#endif
+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
+%#define array_is_native(a)     (PyArray_ISNOTSWAPPED((PyArrayObject*)a))
+%#define array_is_fortran(a)    (PyArray_ISFORTRAN((PyArrayObject*)a))
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Utilities",
+          "header")
+{
+  /* Given a PyObject, return a string describing its type.
+   */
+  const char* pytype_string(PyObject* py_obj)
+  {
+    if (py_obj == NULL          ) return "C NULL value";
+    if (py_obj == Py_None       ) return "Python None" ;
+    if (PyCallable_Check(py_obj)) return "callable"    ;
+    if (PyString_Check(  py_obj)) return "string"      ;
+    if (PyInt_Check(     py_obj)) return "int"         ;
+    if (PyFloat_Check(   py_obj)) return "float"       ;
+    if (PyDict_Check(    py_obj)) return "dict"        ;
+    if (PyList_Check(    py_obj)) return "list"        ;
+    if (PyTuple_Check(   py_obj)) return "tuple"       ;
+%#if PY_MAJOR_VERSION < 3
+    if (PyFile_Check(    py_obj)) return "file"        ;
+    if (PyModule_Check(  py_obj)) return "module"      ;
+    if (PyInstance_Check(py_obj)) return "instance"    ;
+%#endif
+
+    return "unkown type";
+  }
+
+  /* Given a NumPy typecode, return a string describing the type.
+   */
+  const char* typecode_string(int typecode)
+  {
+    static const char* type_names[25] = {"bool",
+                                         "byte",
+                                         "unsigned byte",
+                                         "short",
+                                         "unsigned short",
+                                         "int",
+                                         "unsigned int",
+                                         "long",
+                                         "unsigned long",
+                                         "long long",
+                                         "unsigned long long",
+                                         "float",
+                                         "double",
+                                         "long double",
+                                         "complex float",
+                                         "complex double",
+                                         "complex long double",
+                                         "object",
+                                         "string",
+                                         "unicode",
+                                         "void",
+                                         "ntypes",
+                                         "notype",
+                                         "char",
+                                         "unknown"};
+    return typecode < 24 ? type_names[typecode] : type_names[24];
+  }
+
+  /* Make sure input has correct numpy type.  This now just calls
+     PyArray_EquivTypenums().
+   */
+  int type_match(int actual_type,
+                 int desired_type)
+  {
+    return PyArray_EquivTypenums(actual_type, desired_type);
+  }
+
+%#ifdef SWIGPY_USE_CAPSULE
+  void free_cap(PyObject * cap)
+  {
+    void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
+    if (array != NULL) free(array);
+  }
+%#endif
+
+
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Object_to_Array",
+          "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities")
+{
+  /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
+   * legal.  If not, set the python error string appropriately and
+   * return NULL.
+   */
+  PyArrayObject* obj_to_array_no_conversion(PyObject* input,
+                                            int        typecode)
+  {
+    PyArrayObject* ary = NULL;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input), typecode)))
+    {
+      ary = (PyArrayObject*) input;
+    }
+    else if is_array(input)
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = typecode_string(array_type(input));
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  Array of type '%s' given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    else
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = pytype_string(input);
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  A '%s' was given",
+                   desired_type,
+                   actual_type);
+      ary = NULL;
+    }
+    return ary;
+  }
+
+  /* Convert the given PyObject to a NumPy array with the given
+   * typecode.  On success, return a valid PyArrayObject* with the
+   * correct type.  On failure, the python error string will be set and
+   * the routine returns NULL.
+   */
+  PyArrayObject* obj_to_array_allow_conversion(PyObject* input,
+                                               int       typecode,
+                                               int*      is_new_object)
+  {
+    PyArrayObject* ary = NULL;
+    PyObject*      py_obj;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input),typecode)))
+    {
+      ary = (PyArrayObject*) input;
+      *is_new_object = 0;
+    }
+    else
+    {
+      py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT);
+      /* If NULL, PyArray_FromObject will have set python error value.*/
+      ary = (PyArrayObject*) py_obj;
+      *is_new_object = 1;
+    }
+    return ary;
+  }
+
+  /* Given a PyArrayObject, check to see if it is contiguous.  If so,
+   * return the input pointer and flag it as not a new object.  If it is
+   * not contiguous, create a new PyArrayObject using the original data,
+   * flag it as a new object and return the pointer.
+   */
+  PyArrayObject* make_contiguous(PyArrayObject* ary,
+                                 int*           is_new_object,
+                                 int            min_dims,
+                                 int            max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_contiguous(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
+                                                              array_type(ary),
+                                                              min_dims,
+                                                              max_dims);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
+   * If so, return the input pointer, but do not flag it as not a new
+   * object.  If it is not Fortran-contiguous, create a new
+   * PyArrayObject using the original data, flag it as a new object
+   * and return the pointer.
+   */
+  PyArrayObject* make_fortran(PyArrayObject* ary,
+                              int*           is_new_object)
+  {
+    PyArrayObject* result;
+    if (array_is_fortran(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      Py_INCREF(array_descr(ary));
+      result = (PyArrayObject*) PyArray_FromArray(ary,
+                                                  array_descr(ary),
+                                                  NPY_FORTRANORDER);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Convert a given PyObject to a contiguous PyArrayObject of the
+   * specified type.  If the input object is not a contiguous
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
+                                                          int       typecode,
+                                                          int*      is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+                                                        typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_contiguous(ary1, &is_new2, 0, 0);
+      if ( is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+  /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
+   * specified type.  If the input object is not a Fortran-ordered
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
+                                                       int       typecode,
+                                                       int*      is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+                                                        typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_fortran(ary1, &is_new2);
+      if (is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+} /* end fragment */
+
+/**********************************************************************/
+
+%fragment("NumPy_Array_Requirements",
+          "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros")
+{
+  /* Test whether a python object is contiguous.  If array is
+   * contiguous, return 1.  Otherwise, set the python error string and
+   * return 0.
+   */
+  int require_contiguous(PyArrayObject* ary)
+  {
+    int contiguous = 1;
+    if (!array_is_contiguous(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must be contiguous.  A non-contiguous array was given");
+      contiguous = 0;
+    }
+    return contiguous;
+  }
+
+  /* Require that a numpy array is not byte-swapped.  If the array is
+   * not byte-swapped, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_native(PyArrayObject* ary)
+  {
+    int native = 1;
+    if (!array_is_native(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must have native byteorder.  "
+                      "A byte-swapped array was given");
+      native = 0;
+    }
+    return native;
+  }
+
+  /* Require the given PyArrayObject to have a specified number of
+   * dimensions.  If the array has the specified number of dimensions,
+   * return 1.  Otherwise, set the python error string and return 0.
+   */
+  int require_dimensions(PyArrayObject* ary,
+                         int            exact_dimensions)
+  {
+    int success = 1;
+    if (array_numdims(ary) != exact_dimensions)
+    {
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %d dimensions.  Given array has %d dimensions",
+                   exact_dimensions,
+                   array_numdims(ary));
+      success = 0;
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have one of a list of specified
+   * number of dimensions.  If the array has one of the specified number
+   * of dimensions, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_dimensions_n(PyArrayObject* ary,
+                           int*           exact_dimensions,
+                           int            n)
+  {
+    int success = 0;
+    int i;
+    char dims_str[255] = "";
+    char s[255];
+    for (i = 0; i < n && !success; i++)
+    {
+      if (array_numdims(ary) == exact_dimensions[i])
+      {
+        success = 1;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n-1; i++)
+      {
+        sprintf(s, "%d, ", exact_dimensions[i]);
+        strcat(dims_str,s);
+      }
+      sprintf(s, " or %d", exact_dimensions[n-1]);
+      strcat(dims_str,s);
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %s dimensions.  Given array has %d dimensions",
+                   dims_str,
+                   array_numdims(ary));
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have a specified shape.  If the
+   * array has the specified shape, return 1.  Otherwise, set the python
+   * error string and return 0.
+   */
+  int require_size(PyArrayObject* ary,
+                   npy_intp*      size,
+                   int            n)
+  {
+    int i;
+    int success = 1;
+    int len;
+    char desired_dims[255] = "[";
+    char s[255];
+    char actual_dims[255] = "[";
+    for(i=0; i < n;i++)
+    {
+      if (size[i] != -1 &&  size[i] != array_size(ary,i))
+      {
+        success = 0;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n; i++)
+      {
+        if (size[i] == -1)
+        {
+          sprintf(s, "*,");
+        }
+        else
+        {
+          sprintf(s, "%ld,", (long int)size[i]);
+        }
+        strcat(desired_dims,s);
+      }
+      len = strlen(desired_dims);
+      desired_dims[len-1] = ']';
+      for (i = 0; i < n; i++)
+      {
+        sprintf(s, "%ld,", (long int)array_size(ary,i));
+        strcat(actual_dims,s);
+      }
+      len = strlen(actual_dims);
+      actual_dims[len-1] = ']';
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have shape of %s.  Given array has shape of %s",
+                   desired_dims,
+                   actual_dims);
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to to be Fortran ordered.  If the
+   * the PyArrayObject is already Fortran ordered, do nothing.  Else,
+   * set the Fortran ordering flag and recompute the strides.
+   */
+  int require_fortran(PyArrayObject* ary)
+  {
+    int success = 1;
+    int nd = array_numdims(ary);
+    int i;
+    npy_intp * strides = array_strides(ary);
+    if (array_is_fortran(ary)) return success;
+    /* Set the Fortran ordered flag */
+    array_enableflags(ary,NPY_ARRAY_FARRAY);
+    /* Recompute the strides */
+    strides[0] = strides[nd-1];
+    for (i=1; i < nd; ++i)
+      strides[i] = strides[i-1] * array_size(ary,i-1);
+    return success;
+  }
+}
+
+/* Combine all NumPy fragments into one for convenience */
+%fragment("NumPy_Fragments",
+          "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities",
+          fragment="NumPy_Object_to_Array",
+          fragment="NumPy_Array_Requirements")
+{
+}
+
+/* End John Hunter translation (with modifications by Bill Spotz)
+ */
+
+/* %numpy_typemaps() macro
+ *
+ * This macro defines a family of 74 typemaps that allow C arguments
+ * of the form
+ *
+ *    1. (DATA_TYPE IN_ARRAY1[ANY])
+ *    2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ *    3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ *
+ *    4. (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ *    5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *    6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ *    7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *    8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ *
+ *    9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ *   10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   11. (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   12. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+ *   13. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   14. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ *
+ *   15. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
+ *   16. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   17. (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
+ *   19. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   20. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
+ *
+ *   21. (DATA_TYPE INPLACE_ARRAY1[ANY])
+ *   22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ *   23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ *
+ *   24. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ *   25. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *   26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ *   27. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *   28. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ *
+ *   29. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ *   30. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   31. (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   32. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+ *   33. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *   34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ *
+ *   35. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
+ *   36. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   37. (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   38. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
+ *   39. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+ *   40. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
+ *
+ *   41. (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ *   42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ *   43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ *
+ *   44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ *
+ *   45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *
+ *   46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
+ *
+ *   47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ *   48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ *
+ *   49. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *   50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ *   51. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *   52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ *
+ *   53. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *   54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ *   55. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *   56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ *
+ *   57. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ *   58. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
+ *   59. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ *   60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
+ *
+ *   61. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
+ *   62. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
+ *
+ *   63. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *   64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
+ *   65. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *   66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
+ *
+ *   67. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *   68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
+ *   69. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *   70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
+ *
+ *   71. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ *   72. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+ *   73. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ *   74. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+ *
+ * where "DATA_TYPE" is any type supported by the NumPy module, and
+ * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
+ * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
+ * that the "FARRAY" typemaps expect Fortran ordering of
+ * multidimensional arrays.  In python, the dimensions will not need
+ * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
+ * typemaps).  The IN_ARRAYs can be a numpy array or any sequence that
+ * can be converted to a numpy array of the specified type.  The
+ * INPLACE_ARRAYs must be numpy arrays of the appropriate type.  The
+ * ARGOUT_ARRAYs will be returned as new numpy arrays of the
+ * appropriate type.
+ *
+ * These typemaps can be applied to existing functions using the
+ * %apply directive.  For example:
+ *
+ *     %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
+ *     double prod(double* series, int length);
+ *
+ *     %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
+ *           {(int rows, int cols, double* matrix        )};
+ *     void floor(int rows, int cols, double* matrix, double f);
+ *
+ *     %apply (double IN_ARRAY3[ANY][ANY][ANY])
+ *           {(double tensor[2][2][2]         )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double low[2][2][2]                )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double upp[2][2][2]                )};
+ *     void luSplit(double tensor[2][2][2],
+ *                  double low[2][2][2],
+ *                  double upp[2][2][2]    );
+ *
+ * or directly with
+ *
+ *     double prod(double* IN_ARRAY1, int DIM1);
+ *
+ *     void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
+ *
+ *     void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY]);
+ */
+
+%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
+
+/************************/
+/* Input Array Typemaps */
+/************************/
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY1[ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { -1 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = {-1};
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input,
+                                                DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  /* for now, only concerned with lists */
+  $1 = PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
+{
+  npy_intp size[2] = { -1, -1 };
+  PyArrayObject* temp_array;
+  Py_ssize_t i;
+  int is_new_object;
+
+  /* length of the list */
+  $2 = PyList_Size($input);
+
+  /* the arrays */
+  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
+  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
+  is_new_object_array = (int *)calloc($2,sizeof(int));
+
+  if (array == NULL || object_array == NULL || is_new_object_array == NULL)
+  {
+    SWIG_fail;
+  }
+
+  for (i=0; i<$2; i++)
+  {
+    temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
+
+    /* the new array must be stored so that it can be destroyed in freearg */
+    object_array[i] = temp_array;
+    is_new_object_array[i] = is_new_object;
+
+    if (!temp_array || !require_dimensions(temp_array, 2)) SWIG_fail;
+
+    /* store the size of the first array in the list, then use that for comparison. */
+    if (i == 0)
+    {
+      size[0] = array_size(temp_array,0);
+      size[1] = array_size(temp_array,1);
+    }
+    
+    if (!require_size(temp_array, size, 2)) SWIG_fail;
+
+    array[i] = (DATA_TYPE*) array_data(temp_array);
+  }
+
+  $1 = (DATA_TYPE**) array;
+  $3 = (DIM_TYPE) size[0];
+  $4 = (DIM_TYPE) size[1];
+}
+%typemap(freearg)
+  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  Py_ssize_t i;
+
+  if (array$argnum!=NULL) free(array$argnum);
+
+  /*freeing the individual arrays if needed */
+  if (object_array$argnum!=NULL)
+  {
+    if (is_new_object_array$argnum!=NULL)
+    {
+      for (i=0; i<$2; i++)
+      {
+        if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
+        { Py_DECREF(object_array$argnum[i]); }
+      }
+      free(is_new_object_array$argnum);
+    }
+    free(object_array$argnum);
+  }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input,
+                                                   DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3};
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 4) ||
+      !require_size(array, size, 4)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[4] = { -1, -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 4) ||
+      !require_size(array, size, 4)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+  $5 = (DIM_TYPE) array_size(array,3);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  /* for now, only concerned with lists */
+  $1 = PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  PyArrayObject* temp_array;
+  Py_ssize_t i;
+  int is_new_object;
+
+  /* length of the list */
+  $2 = PyList_Size($input);
+
+  /* the arrays */
+  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
+  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
+  is_new_object_array = (int *)calloc($2,sizeof(int));
+
+  if (array == NULL || object_array == NULL || is_new_object_array == NULL)
+  {
+    SWIG_fail;
+  }
+
+  for (i=0; i<$2; i++)
+  {
+    temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
+
+    /* the new array must be stored so that it can be destroyed in freearg */
+    object_array[i] = temp_array;
+    is_new_object_array[i] = is_new_object;
+
+    if (!temp_array || !require_dimensions(temp_array, 3)) SWIG_fail;
+
+    /* store the size of the first array in the list, then use that for comparison. */
+    if (i == 0)
+    {
+      size[0] = array_size(temp_array,0);
+      size[1] = array_size(temp_array,1);
+      size[2] = array_size(temp_array,2);
+    }
+    
+    if (!require_size(temp_array, size, 3)) SWIG_fail;
+
+    array[i] = (DATA_TYPE*) array_data(temp_array);
+  }
+
+  $1 = (DATA_TYPE**) array;
+  $3 = (DIM_TYPE) size[0];
+  $4 = (DIM_TYPE) size[1];
+  $5 = (DIM_TYPE) size[2];
+}
+%typemap(freearg)
+  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  Py_ssize_t i;
+
+  if (array$argnum!=NULL) free(array$argnum);
+
+  /*freeing the individual arrays if needed */
+  if (object_array$argnum!=NULL)
+  {
+    if (is_new_object_array$argnum!=NULL)
+    {
+      for (i=0; i<$2; i++)
+      {
+        if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
+        { Py_DECREF(object_array$argnum[i]); }
+      }
+      free(is_new_object_array$argnum);
+    }
+    free(object_array$argnum);
+  }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
+ *                    DATA_TYPE* IN_ARRAY4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[4] = { -1, -1, -1 , -1};
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 4) ||
+      !require_size(array, size, 4)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DIM_TYPE) array_size(array,3);
+  $5 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[4] = { -1, -1, -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 4) ||
+      !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+  $5 = (DIM_TYPE) array_size(array,3);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
+ *                    DATA_TYPE* IN_FARRAY4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[4] = { -1, -1, -1 , -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 4) ||
+      !require_size(array, size, 4) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DIM_TYPE) array_size(array,3);
+  $5 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/***************************/
+/* In-Place Array Typemaps */
+/***************************/
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int i=1)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = 1;
+  for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+  (PyArrayObject* array=NULL, int i=0)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = 1;
+  for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
+{
+  npy_intp size[2] = { -1, -1 };
+  PyArrayObject* temp_array;
+  Py_ssize_t i;
+
+  /* length of the list */
+  $2 = PyList_Size($input);
+
+  /* the arrays */
+  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
+  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
+
+  if (array == NULL || object_array == NULL)
+  {
+    SWIG_fail;
+  }
+
+  for (i=0; i<$2; i++)
+  {
+    temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
+
+    /* the new array must be stored so that it can be destroyed in freearg */
+    object_array[i] = temp_array;
+
+    if ( !temp_array || !require_dimensions(temp_array, 2) ||
+      !require_contiguous(temp_array) ||
+      !require_native(temp_array) ||
+      !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
+    ) SWIG_fail;
+
+    /* store the size of the first array in the list, then use that for comparison. */
+    if (i == 0)
+    {
+      size[0] = array_size(temp_array,0);
+      size[1] = array_size(temp_array,1);
+    }
+    
+    if (!require_size(temp_array, size, 2)) SWIG_fail;
+
+    array[i] = (DATA_TYPE*) array_data(temp_array);
+  }
+
+  $1 = (DATA_TYPE**) array;
+  $3 = (DIM_TYPE) size[0];
+  $4 = (DIM_TYPE) size[1];
+}
+%typemap(freearg)
+  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (array$argnum!=NULL) free(array$argnum);
+  if (object_array$argnum!=NULL) free(object_array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+  $5 = (DIM_TYPE) array_size(array,3);
+}
+
+/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  $1 = PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  PyArrayObject* temp_array;
+  Py_ssize_t i;
+
+  /* length of the list */
+  $2 = PyList_Size($input);
+
+  /* the arrays */
+  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
+  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
+
+  if (array == NULL || object_array == NULL)
+  {
+    SWIG_fail;
+  }
+
+  for (i=0; i<$2; i++)
+  {
+    temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
+
+    /* the new array must be stored so that it can be destroyed in freearg */
+    object_array[i] = temp_array;
+
+    if ( !temp_array || !require_dimensions(temp_array, 3) ||
+      !require_contiguous(temp_array) ||
+      !require_native(temp_array) ||
+      !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
+    ) SWIG_fail;
+
+    /* store the size of the first array in the list, then use that for comparison. */
+    if (i == 0)
+    {
+      size[0] = array_size(temp_array,0);
+      size[1] = array_size(temp_array,1);
+      size[2] = array_size(temp_array,2);
+    }
+    
+    if (!require_size(temp_array, size, 3)) SWIG_fail;
+
+    array[i] = (DATA_TYPE*) array_data(temp_array);
+  }
+
+  $1 = (DATA_TYPE**) array;
+  $3 = (DIM_TYPE) size[0];
+  $4 = (DIM_TYPE) size[1];
+  $5 = (DIM_TYPE) size[2];
+}
+%typemap(freearg)
+  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  if (array$argnum!=NULL) free(array$argnum);
+  if (object_array$argnum!=NULL) free(object_array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
+ *                    DATA_TYPE* INPLACE_ARRAY4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,4) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DIM_TYPE) array_size(array,3);
+  $5 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+  $5 = (DIM_TYPE) array_size(array,3);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_FARRAY4)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,4) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DIM_TYPE) array_size(array,3);
+  $5 = (DATA_TYPE*) array_data(array);
+}
+
+/*************************/
+/* Argout Array Typemaps */
+/*************************/
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+  (PyObject* array = NULL)
+{
+  npy_intp dims[1] = { $1_dim0 };
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+  (PyObject* array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $2 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $2;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+  (PyObject* array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $1 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $1;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+  (PyObject* array = NULL)
+{
+  npy_intp dims[2] = { $1_dim0, $1_dim1 };
+  array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+  (PyObject* array = NULL)
+{
+  npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
+  (PyObject* array = NULL)
+{
+  npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 };
+  array = PyArray_SimpleNew(4, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
+}
+
+/*****************************/
+/* Argoutview Array Typemaps */
+/*****************************/
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1    )
+  (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+{
+  npy_intp dims[1] = { *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEW_ARRAY1)
+  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL )
+{
+  $1 = &dim_temp;
+  $2 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+{
+  npy_intp dims[1] = { *$1 };
+  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_ARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_FARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
+  (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL)
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
+  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEW_FARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEW_ARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_ARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL  )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEW_FARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_FARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/*************************************/
+/* Managed Argoutview Array Typemaps */
+/*************************************/
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1    )
+  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
+{
+  npy_intp dims[1] = { *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+  
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEWM_ARRAY1)
+  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL  )
+{
+  $1 = &dim_temp;
+  $2 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
+{
+  npy_intp dims[1] = { *$1 };
+  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+  
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_ARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp = NULL   , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || !require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_FARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || !require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
+  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEWM_ARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_ARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject* obj= PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
+  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEWM_FARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_FARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL    )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
+  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+  $5 = &dim4_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
+{
+  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
+                      DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &dim4_temp;
+  $5 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
+{
+  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
+  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
+  PyArrayObject* array = (PyArrayObject*) obj;
+
+  if (!array || require_fortran(array)) SWIG_fail;
+
+%#ifdef SWIGPY_USE_CAPSULE
+    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
+%#else
+    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
+%#endif
+
+%#if NPY_API_VERSION < 0x00000007
+  PyArray_BASE(array) = cap;
+%#else
+  PyArray_SetBaseObject(array,cap);
+%#endif
+
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+%enddef    /* %numpy_typemaps() macro */
+/* *************************************************************** */
+
+/* Concrete instances of the %numpy_typemaps() macro: Each invocation
+ * below applies all of the typemaps above to the specified data type.
+ */
+%numpy_typemaps(signed char       , NPY_BYTE     , int)
+%numpy_typemaps(unsigned char     , NPY_UBYTE    , int)
+%numpy_typemaps(short             , NPY_SHORT    , int)
+%numpy_typemaps(unsigned short    , NPY_USHORT   , int)
+%numpy_typemaps(int               , NPY_INT      , int)
+%numpy_typemaps(unsigned int      , NPY_UINT     , int)
+%numpy_typemaps(long              , NPY_LONG     , int)
+%numpy_typemaps(unsigned long     , NPY_ULONG    , int)
+%numpy_typemaps(long long         , NPY_LONGLONG , int)
+%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
+%numpy_typemaps(float             , NPY_FLOAT    , int)
+%numpy_typemaps(double            , NPY_DOUBLE   , int)
+
+/* ***************************************************************
+ * The follow macro expansion does not work, because C++ bool is 4
+ * bytes and NPY_BOOL is 1 byte
+ *
+ *    %numpy_typemaps(bool, NPY_BOOL, int)
+ */
+
+/* ***************************************************************
+ * On my Mac, I get the following warning for this macro expansion:
+ * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
+ *
+ *    %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
+ */
+
+/* ***************************************************************
+ * Swig complains about a syntax error for the following macro
+ * expansions:
+ *
+ *    %numpy_typemaps(complex float,  NPY_CFLOAT , int)
+ *
+ *    %numpy_typemaps(complex double, NPY_CDOUBLE, int)
+ *
+ *    %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
+ */
+
+#endif /* SWIGPYTHON */
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644 (file)
index 0000000..f0b3f47
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util
+
+noinst_PROGRAMS = testopt
+
+testopt_SOURCES = testfuncs.c testfuncs.h testopt.cpp
+testopt_LDADD = $(top_builddir)/libnlopt@NLOPT_SUFFIX@.la
+EXTRA_DIST = test_std.py
+
diff --git a/test/Makefile.in b/test/Makefile.in
new file mode 100644 (file)
index 0000000..d6be505
--- /dev/null
@@ -0,0 +1,646 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+noinst_PROGRAMS = testopt$(EXEEXT)
+subdir = test
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_testopt_OBJECTS = testfuncs.$(OBJEXT) testopt.$(OBJEXT)
+testopt_OBJECTS = $(am_testopt_OBJECTS)
+testopt_DEPENDENCIES = $(top_builddir)/libnlopt@NLOPT_SUFFIX@.la
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+SOURCES = $(testopt_SOURCES)
+DIST_SOURCES = $(testopt_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util
+testopt_SOURCES = testfuncs.c testfuncs.h testopt.cpp
+testopt_LDADD = $(top_builddir)/libnlopt@NLOPT_SUFFIX@.la
+EXTRA_DIST = test_std.py
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu test/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+
+testopt$(EXEEXT): $(testopt_OBJECTS) $(testopt_DEPENDENCIES) $(EXTRA_testopt_DEPENDENCIES) 
+       @rm -f testopt$(EXEEXT)
+       $(AM_V_CXXLD)$(CXXLINK) $(testopt_OBJECTS) $(testopt_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testfuncs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testopt.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+.cpp.o:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/test_std.py b/test/test_std.py
new file mode 100644 (file)
index 0000000..3264c5d
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+import nlopt
+import numpy as np
+
+print ('nlopt version='+nlopt.__version__)
+
+def f(x, grad):
+    F=x[0]
+    L=x[1]
+    E=x[2]
+    I=x[3]
+    D=F*L**3/(3.*E*I)
+    return D
+
+n = 4
+opt = nlopt.opt(nlopt.LN_COBYLA, n)
+opt.set_min_objective(f)
+lb = np.array([40., 50., 30e3, 1.])
+ub = np.array([60., 60., 40e3, 10.])
+x = (lb+ub)/2.
+opt.set_lower_bounds(lb)
+opt.set_upper_bounds(ub)
+opt.set_xtol_rel(1e-3)
+opt.set_ftol_rel(1e-3)
+xopt = opt.optimize(x)
+
+opt_val = opt.last_optimum_value()
+result = opt.last_optimize_result()
+print ('opt_result='+str(result))
+print ('optimizer='+str(xopt))
+print ('opt_val='+str(opt_val))
diff --git a/test/testfuncs.c b/test/testfuncs.c
new file mode 100644 (file)
index 0000000..6c89ee1
--- /dev/null
@@ -0,0 +1,505 @@
+#include <stdio.h>
+#include <math.h>
+
+#include "testfuncs.h"
+#include "config.h"
+
+#define UNUSED(x) (void) x
+
+static double sqr(double x) { return x * x; }
+
+int testfuncs_verbose = 0;
+int testfuncs_counter = 0;
+
+static double testfuncs_status(unsigned n, const double *x, double f)
+{
+     ++testfuncs_counter;
+     if (testfuncs_verbose) {
+         unsigned i;
+         printf("f_%d (%g", testfuncs_counter, x[0]);
+         for (i = 1; i < n; ++i) printf(", %g", x[i]);
+         printf(") = %g\n", f);
+     }
+     return f;
+}
+
+#define RETURN(f) return testfuncs_status(n, x, f);
+
+#define PI2 6.283185307179586 /* 2*pi */
+#define PI3 9.424777960769379 /* 3*pi */
+#define PI4 12.5663706143592 /* 4*pi */
+
+/****************************************************************************/
+static double rosenbrock_f(unsigned n, const double *x, double *grad, void *data)
+{
+     double a = x[1] - x[0] * x[0], b = 1 - x[0];
+     UNUSED(data);
+     if (grad) {
+         grad[0] = -400 * a * x[0] - 2*b;
+         grad[1] = 200 * a;
+     }
+     RETURN(100 * sqr(a) + sqr(b));
+}
+
+static const double rosenbrock_lb[2] = {-2, -2};
+static const double rosenbrock_ub[2] = {2, 2};
+static const double rosenbrock_xmin[2] = {1, 1};
+
+/****************************************************************************/
+static double mccormic_f(unsigned n, const double *x, double *grad, void *data)
+{
+     double a = x[0] + x[1], b = x[0] - x[1];
+     UNUSED(data);
+     if (grad) {
+         grad[0] = cos(a) + 2*b - 1.5;
+         grad[1] = cos(a) - 2*b + 2.5;
+     }
+     RETURN(sin(a) + sqr(b) - 1.5*x[0] + 2.5*x[1] + 1);
+}
+
+static const double mccormic_lb[2] = {-1.5, -3};
+static const double mccormic_ub[2] = {4, 4};
+static const double mccormic_xmin[2] = {-0.547197553, -1.54719756};
+
+/****************************************************************************/
+static double boxbetts_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double f = 0;
+     UNUSED(data);
+     if (grad)
+         grad[0] = grad[1] = grad[2] = 0;
+     for (i = 1; i <= 10; ++i) {
+         double e0 = exp(-0.1*i*x[0]);
+         double e1 = exp(-0.1*i*x[1]);
+         double e2 = exp(-0.1*i) - exp((double) -i);
+         double g = e0 - e1 - e2 * x[2];
+         f += sqr(g);
+         if (grad) {
+              grad[0] += (2 * g) * (-0.1*i*e0);
+              grad[1] += (2 * g) * (0.1*i*e1);
+              grad[2] += -(2 * g) * e2;
+         }
+     }
+     RETURN(f);
+}
+
+static const double boxbetts_lb[3] = {0.9,9,0.9};
+static const double boxbetts_ub[3] = {1.2,11.2,1.2};
+static const double boxbetts_xmin[3] = {1,10,1};
+
+/****************************************************************************/
+static double paviani_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double f = 0, prod = 1;
+     UNUSED(data);
+     if (grad) for (i = 0; i < 10; ++i) grad[i] = 0;
+     for (i = 0; i < 10; ++i) {
+         double ln1 = log(x[i] - 2);
+         double ln2 = log(10 - x[i]);
+         f += sqr(ln1) + sqr(ln2);
+         if (grad)
+              grad[i] += 2 * ln1 / (x[i] - 2) - 2 * ln2 / (10 - x[i]);
+         prod *= x[i];
+     }
+     f -= (prod = pow(prod, 0.2));
+     if (grad)
+         for (i = 0; i < 10; ++i)
+              grad[i] -= 0.2 * prod / x[i];
+     RETURN(f);
+}
+
+static const double paviani_lb[10] = {2.001,2.001,2.001,2.001,2.001,2.001,2.001,2.001,2.001,2.001};
+static const double paviani_ub[10] = {9.999,9.999,9.999,9.999,9.999,9.999,9.999,9.999,9.999,9.999};
+static const double paviani_xmin[10] = {9.35026583,9.35026583,9.35026583,9.35026583,9.35026583,9.35026583,9.35026583,9.35026583,9.35026583,9.35026583};
+
+/****************************************************************************/
+static double grosenbrock_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double f = 0;
+     UNUSED(data);
+     if (grad) grad[0] = 0;
+     for (i = 0; i < 29; ++i) {
+         double a = x[i+1] - x[i] * x[i], b = 1 - x[i];
+         if (grad) {
+              grad[i] += -400 * a * x[i] - 2*b;
+              grad[i+1] = 200 * a;
+         }
+         f += 100 * sqr(a) + sqr(b);
+     }
+     RETURN(f);
+}
+
+static const double grosenbrock_lb[30] = {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30};
+static const double grosenbrock_ub[30] = {30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30};
+static const double grosenbrock_xmin[30] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+
+/****************************************************************************/
+static double goldsteinprice_f(unsigned n, const double *x, double *grad, void *data)
+{
+     double x0, x1, a1, a12, a2, b1, b12, b2;
+     UNUSED(data);
+     x0 = x[0]; x1 = x[1];
+     a1 = x0+x1+1; a12 = sqr(a1);
+     a2 = 19 - 14*x0 + 3*x0*x0 - 14*x1 + 6*x0*x1 + 3*x1*x1;
+     b1 = 2*x0-3*x1; b12 = sqr(b1);
+     b2 = 18 - 32*x0 + 12*x0*x0 + 48*x1 - 36*x0*x1 + 27*x1*x1;
+     if (grad) {
+         grad[0] = (1 + a12 * a2) * (2 * b1 * 2 * b2 
+                                     + b12 * (-32 + 24*x0 - 36*x1))
+              + (2 * a1 * a2 + a12 * (-14 + 6*x0 + 6*x1)) * (30 + b12 * b2);
+         grad[1] = (1 + a12 * a2) * (2 * b1 * (-3) * b2
+                                     + b12 * (48 - 36*x0 + 54 * x1))
+              + (2 * a1 * a2 + a12 * (-14 + 6*x0 + 6*x1)) * (30 + b12 * b2);
+     }
+     RETURN((1 + a12 * a2) * (30 + b12 * b2));
+}
+
+static const double goldsteinprice_lb[2] = {-2, -2};
+static const double goldsteinprice_ub[2] = {2, 2};
+static const double goldsteinprice_xmin[2] = {0, -1};
+
+/****************************************************************************/
+static double shekel_f(unsigned n, const double *x, double *grad, void *data)
+{
+     static const double A[10][4] = { {4,4,4,4},
+                                     {1,1,1,1},
+                                     {8,8,8,8},
+                                     {6,6,6,6},
+                                     {3,7,3,7},
+                                     {2,9,2,9},
+                                     {5,5,3,3},
+                                     {8,1,8,1},
+                                     {6,2,6,2},
+                                     {7,3.6,7,3.6} };
+     static const double c[10] = {.1,.2,.2,.4,.4,.6,.3,.7,.5,.5};
+     unsigned i;
+     double f = 0;
+     if (grad) for (i = 0; i < n; ++i) grad[i] = 0;
+     unsigned m = *((unsigned *) data);
+     for (i = 0; i < m; ++i) {
+         double fi = 1.0 / (c[i] 
+                            + sqr(x[0]-A[i][0])
+                            + sqr(x[1]-A[i][1])
+                            + sqr(x[2]-A[i][2])
+                            + sqr(x[3]-A[i][3]));
+         f -= fi;
+         if (grad) {
+              grad[0] += (2*fi*fi) * (x[0]-A[i][0]);
+              grad[1] += (2*fi*fi) * (x[1]-A[i][1]);
+              grad[2] += (2*fi*fi) * (x[2]-A[i][2]);
+              grad[3] += (2*fi*fi) * (x[3]-A[i][3]);
+         }
+     }
+     RETURN(f);
+}
+
+static unsigned shekel_m[3] = {5,7,10};
+static const double shekel_lb[4] = {0,0,0,0};
+static const double shekel_ub[4] = {10,10,10,10};
+static const double shekel0_xmin[4] = {4.000037154,4.000133276,4.000037154,4.000133276};
+static const double shekel1_xmin[4] = {4.000572917,4.000689366,3.999489709,3.999606158};
+static const double shekel2_xmin[4] = {4.000746531,4.000592935,3.999663399,3.999509801};
+
+/****************************************************************************/
+static double levy_f(unsigned n, const double *x, double *grad, void *data)
+{
+     UNUSED(data);
+     unsigned i;
+     double a = x[n-1] - 1, b = 1 + sqr(sin(PI2*x[n-1]));
+     double f = sqr(sin(PI3*x[0])) + a * b;
+     if (grad) {
+         for (i = 0; i < n; ++i) grad[i] = 0;
+         grad[0] = 2 * PI3 * sin(PI3*x[0]) * cos(PI3*x[0]);
+         grad[n-1] += b + a * 2 * PI2 * sin(PI2*x[n-1]) * cos(PI2*x[n-1]);
+     }
+     for (i = 0; i < n-1; ++i) {
+         a = x[i] - 1;
+         b = 1 + sqr(sin(PI3*x[i+1]));
+         f += sqr(a) * b;
+         if (grad) {
+              grad[i] += 2 * a * b;
+              grad[i+1] += 2*PI3 * sqr(a) * sin(PI3*x[i+1])*cos(PI3*x[i+1]);
+         }
+     }
+     RETURN(f);
+}
+
+static const double levy_lb[7] = {-5,-5,-5,-5,-5,-5,-5};
+static const double levy_ub[7] = {5,5,5,5,5,5,5};
+static const double levy_xmin[7] = {1,1,1,1,1,1,-4.75440246};
+static const double levy4_lb[4] = {-10,-10,-10,-10};
+static const double levy4_ub[4] = {10,10,10,10};
+static const double levy4_xmin[4] = {1,1,1,-9.75235596};
+
+/****************************************************************************/
+static double griewank_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double f = 1, p = 1;
+     UNUSED(data);
+     for (i = 0; i < n; ++i) {
+         f += sqr(x[i]) * 0.00025;
+         p *= cos(x[i] / sqrt(i + 1.));
+         if (grad) grad[i] = x[i] * 0.0005;
+     }
+     f -= p;
+     if (grad)
+         for (i = 0; i < n; ++i)
+              grad[i] += p * tan(x[i] / sqrt(i + 1.)) / sqrt(i + 1.);
+     RETURN(f);
+}
+
+static const double griewank_lb[10] = {-500,-500,-500,-500,-500,-500,-500,-500,-500,-500};
+static const double griewank_ub[10] = {600,600,600,600,600,600,600,600,600,600};
+static const double griewank_xmin[10] = {0,0,0,0,0,0,0,0,0,0};
+
+/****************************************************************************/
+static double sixhumpcamel_f(unsigned n, const double *x, double *grad, void *data)
+{
+     UNUSED(data);
+     if (grad) {
+         grad[0] = 8*x[0] - 2.1*4*pow(x[0],3.) + 2*pow(x[0],5.) + x[1];
+         grad[1] = x[0] - 8*x[1] + 16*pow(x[1],3.);
+     }
+     RETURN(4*sqr(x[0]) - 2.1 * pow(x[0],4.) + pow(x[0],6.)/3. 
+           + x[0]*x[1] - 4*sqr(x[1]) + 4*pow(x[1],4.));
+}
+
+static const double sixhumpcamel_lb[2] = {-5,-5};
+static const double sixhumpcamel_ub[2] = {5,5};
+static const double sixhumpcamel_xmin[2] = {0.08984201317, -0.7126564032};
+
+/****************************************************************************/
+static double convexcosh_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double f = 1;
+     UNUSED(data);
+     for (i = 0; i < n; ++i)
+         f *= cosh((x[i] - i) * (i+1));
+     if (grad)
+         for (i = 0; i < n; ++i)
+              grad[i] = f * tanh((x[i] - i) * (i+1)) * (i+1);
+     RETURN(f);
+}
+
+static const double convexcosh_lb[10] = {-1,0,0,0,0,0,0,0,0,0};
+static const double convexcosh_ub[10] = {2,3,6,7,8,10,11,13,14,16};
+static const double convexcosh_xmin[10] = {0,1,2,3,4,5,6,7,8,9};
+
+/****************************************************************************/
+static double branin_f(unsigned n, const double *x, double *grad, void *data)
+{
+     double a = 1 - 2*x[1] + 0.05 * sin(PI4 * x[1]) - x[0];
+     double b = x[1] - 0.5 * sin(PI2 * x[0]);
+     UNUSED(data);
+     if (grad) {
+         grad[0] = -2*a - cos(PI2 * x[0]) * PI2 * b;
+         grad[1] = 2*a*(0.05 * PI4 * cos(PI4*x[1]) - 2) + 2*b;
+     }
+     RETURN(sqr(a) + sqr(b));
+}
+
+static const double branin_lb[2] = {-10,-10};
+static const double branin_ub[2] = {10,10};
+static const double branin_xmin[2] = {1,0};
+
+/****************************************************************************/
+static double shubert_f(unsigned n, const double *x, double *grad, void *data)
+{
+     UNUSED(data);
+     unsigned i, j;
+     double f = 0;
+     for (j = 1; j <= 5; ++j)
+         for (i = 0; i < n; ++i)
+              f -= j * sin((j+1) * x[i] + j);
+     if (grad) {
+         for (i = 0; i < n; ++i) {
+              grad[i] = 0;
+              for (j = 1; j <= 5; ++j)
+                   grad[i] -= j * (j+1) * cos((j+1) * x[i] + j);
+         }
+     }
+     RETURN(f);
+}
+
+static const double shubert_lb[2] = {-10,-10};
+static const double shubert_ub[2] = {10,10};
+static const double shubert_xmin[2] = {-6.774576143, -6.774576143};
+
+/****************************************************************************/
+static double hansen_f(unsigned n, const double *x, double *grad, void *data)
+{
+     unsigned i;
+     double a = 0, b = 0;
+     UNUSED(data);
+     for (i = 1; i <= 5; ++i)
+         a += i * cos((i-1) * x[0] + i);
+     for (i = 1; i <= 5; ++i)
+         b += i * cos((i+1) * x[1] + i);
+     if (grad) {
+         grad[0] = 0;
+         for (i = 1; i <= 5; ++i)
+              grad[0] -= i * (i-1) * sin((i-1) * x[0] + i);
+         grad[0] *= b;
+         grad[1] = 0;
+         for (i = 1; i <= 5; ++i)
+              grad[1] -= i * (i+1) * sin((i+1) * x[1] + i);
+         grad[1] *= a;
+     }
+     RETURN(a*b);
+}
+
+static const double hansen_lb[2] = {-10,-10};
+static const double hansen_ub[2] = {10,10};
+static const double hansen_xmin[2] = {-1.306707704,-1.425128429};
+
+/****************************************************************************/
+static double osc1d_f(unsigned n, const double *x, double *grad, void *data)
+{
+     double y = *x - 1.23456789;
+     UNUSED(data);
+     if (grad) grad[0] = y*0.02 + sin(y - 2*sin(3*y)) * (1 - 6*cos(3*y));
+     RETURN(sqr(y*0.1) - cos(y - 2*sin(3*y)));
+}
+
+static const double osc1d_lb[1] = {-5};
+static const double osc1d_ub[1] = {5};
+static const double osc1d_xmin[1] = {1.23456789};
+
+/****************************************************************************/
+static double corner4d_f(unsigned n, const double *x, double *grad, void *data)
+{
+     UNUSED(data);
+     UNUSED(n);
+     double u = x[0] + x[1] * x[2] * sin(2 * x[3]);
+     double v = x[0] + 2*sin(u);
+     if (grad) {
+         grad[0] = 2*v * (1 + 2*cos(u));
+         grad[1] = 2*v * 2*cos(u) * x[2] * sin(2*x[3]) + 0.1;
+         grad[2] = 2*v * 2*cos(u) * x[1] * sin(2*x[3]) + 0.1;
+         grad[3] = 2*v * 2*cos(u) * x[1]*x[2] * cos(2*x[3]) * 2 + 0.1;
+     }
+     RETURN(1 + v*v + 0.1*(x[1]+x[2]+x[3]));
+}
+
+static const double corner4d_lb[4] = {0,0,0,0};
+static const double corner4d_ub[4] = {1,1,1,1};
+static const double corner4d_xmin[4] = {0,0,0,0};
+
+/****************************************************************************/
+static double side4d_f(unsigned n, const double *x, double *grad, void *data)
+{
+     UNUSED(data);
+     UNUSED(n);
+     double x0, x1, x2, x3, d0,d1,d2,d3;
+     const double w0 = 0.1, w1 = 0.2, w2 = 0.3, w3 = 0.4;
+     x0 = +0.4977 * x[0] - 0.3153 * x[1] - 0.5066 * x[2] - 0.4391 * x[3];
+     x1 = -0.3153 * x[0] + 0.3248 * x[1] - 0.4382 * x[2] - 0.4096 * x[3];
+     x2 = -0.5066 * x[0] - 0.4382 * x[1] + 0.3807 * x[2] - 0.4543 * x[3];
+     x3 = -0.4391 * x[0] - 0.4096 * x[1] - 0.4543 * x[2] + 0.5667 * x[3];
+
+     d0 = -1. / (x0*x0 + w0*w0);
+     d1 = -1. / (x1*x1 + w1*w1);
+     d2 = -1. / (x2*x2 + w2*w2);
+     d3 = -1. / (x3*x3 + w3*w3);
+
+     if (grad) {
+         grad[0] = 2 * (x0*d0*d0 * +0.4977 +
+                        x1*d1*d1 * -0.3153 +
+                        x2*d2*d2 * -0.5066 +
+                        x3*d3*d3 * -0.4391);
+         grad[1] = 2 * (x0*d0*d0 * -0.3153 +
+                        x1*d1*d1 * +0.3248 +
+                        x2*d2*d2 * -0.4382 +
+                        x3*d3*d3 * -0.4096);
+         grad[2] = 2 * (x0*d0*d0 * -0.5066 +
+                        x1*d1*d1 * -0.4382 +
+                        x2*d2*d2 * +0.3807 +
+                        x3*d3*d3 * -0.4543);
+         grad[3] = 2 * (x0*d0*d0 * -0.4391 +
+                        x1*d1*d1 * -0.4096 +
+                        x2*d2*d2 * -0.4543 +
+                        x3*d3*d3 * +0.5667);
+     }
+     RETURN(d0 + d1 + d2 + d3);
+}
+
+static const double side4d_lb[4] = {0.1,-1,-1,-1};
+static const double side4d_ub[4] = {1,1,1,1};
+static const double side4d_xmin[4] = {0.1,0.102971169,0.0760520641,-0.0497098571};
+
+/****************************************************************************/
+/****************************************************************************/
+
+const testfunc testfuncs[NTESTFUNCS] = {
+     { rosenbrock_f, NULL, 1, 2,
+       rosenbrock_lb, rosenbrock_ub, rosenbrock_xmin,
+       0.0, "Rosenbrock function" },
+     { mccormic_f, NULL, 1, 2,
+       mccormic_lb, mccormic_ub, mccormic_xmin,
+       -1.91322295, "McCormic function" },
+     { boxbetts_f, NULL, 1, 3,
+       boxbetts_lb, boxbetts_ub, boxbetts_xmin,
+       0.0, "Box and Betts exponential quadratic sum" },
+     { paviani_f, NULL, 1, 10,
+       paviani_lb, paviani_ub, paviani_xmin,
+       -45.7784697, "Paviani function" },
+     { grosenbrock_f, NULL, 1, 30,
+       grosenbrock_lb, grosenbrock_ub, grosenbrock_xmin,
+       0.0, "Generalized Rosenbrock function" },
+     { goldsteinprice_f, NULL, 1, 2,
+       goldsteinprice_lb, goldsteinprice_ub, goldsteinprice_xmin,
+       3.0, "Goldstein and Price function" },
+     { shekel_f, shekel_m + 0, 1, 4,
+       shekel_lb, shekel_ub, shekel0_xmin,
+       -10.15319968, "Shekel m=5 function" },
+     { shekel_f, shekel_m + 1, 1, 4,
+       shekel_lb, shekel_ub, shekel1_xmin,
+       -10.40294057, "Shekel m=7 function" },
+     { shekel_f, shekel_m + 2, 1, 4,
+       shekel_lb, shekel_ub, shekel2_xmin,
+       -10.53640982, "Shekel m=10 function" },
+     { levy_f, NULL, 1, 4,
+       levy4_lb, levy4_ub, levy4_xmin,
+       -21.50235596, "Levy n=4 function" },
+     { levy_f, NULL, 1, 5,
+       levy_lb, levy_ub, levy_xmin+2,
+       -11.50440302, "Levy n=5 function" },
+     { levy_f, NULL, 1, 6,
+       levy_lb, levy_ub, levy_xmin+1,
+       -11.50440302, "Levy n=6 function" },
+     { levy_f, NULL, 1, 7,
+       levy_lb, levy_ub, levy_xmin,
+       -11.50440302, "Levy n=7 function" },
+     { griewank_f, NULL, 1, 10,
+       griewank_lb, griewank_ub, griewank_xmin,
+       0.0, "Griewank function" },
+     { sixhumpcamel_f, NULL, 1, 2,
+       sixhumpcamel_lb, sixhumpcamel_ub, sixhumpcamel_xmin,
+       -1.031628453, "Six-hump camel back function" },
+     { convexcosh_f, NULL, 1, 10,
+       convexcosh_lb, convexcosh_ub, convexcosh_xmin,
+       1.0, "Convex product of cosh functions" },
+     { branin_f, NULL, 1, 2,
+       branin_lb, branin_ub, branin_xmin,
+       -.0, "Branin function" },
+     { shubert_f, NULL, 1, 2,
+       shubert_lb, shubert_ub, shubert_xmin,
+       -24.06249888, "Shubert function" },
+     { hansen_f, NULL, 1, 2,
+       hansen_lb, hansen_ub, hansen_xmin,
+       -176.5417931367, "Hansen function" },
+     { osc1d_f, NULL, 1, 1,
+       osc1d_lb, osc1d_ub, osc1d_xmin,
+       -1.0, "1d oscillating function with a single minimum" },
+     { corner4d_f, NULL, 1, 4,
+       corner4d_lb, corner4d_ub, corner4d_xmin,
+       1.0, "4d function with minimum at corner" },
+     { side4d_f, NULL, 1, 4,
+       side4d_lb, side4d_ub, side4d_xmin,
+       -141.285020472, "4d function with minimum at side" }
+};
diff --git a/test/testfuncs.h b/test/testfuncs.h
new file mode 100644 (file)
index 0000000..328d2e3
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef TESTFUNCS_H
+#define TESTFUNCS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+#include "nlopt.h"
+
+typedef struct {
+     nlopt_func f;
+     void *f_data;
+     int has_gradient;
+     int n;
+     const double *lb, *ub, *xmin;
+     double minf;
+     const char *name;
+} testfunc;
+
+#define NTESTFUNCS 22
+extern const testfunc testfuncs[NTESTFUNCS];
+
+extern int testfuncs_verbose;
+extern int testfuncs_counter;
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
diff --git a/test/testopt.cpp b/test/testopt.cpp
new file mode 100644 (file)
index 0000000..2400ebe
--- /dev/null
@@ -0,0 +1,388 @@
+/* Copyright (c) 2007-2011 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifdef HAVE_GETOPT_H
+#  include <getopt.h>
+#endif
+
+#define USE_FEENABLEEXCEPT 0
+#if USE_FEENABLEEXCEPT
+#  include <fenv.h>
+extern "C" int feenableexcept (int EXCEPTS);
+#endif
+
+
+#include "nlopt.h"
+#include "nlopt-util.h"
+#include "testfuncs.h"
+
+static nlopt_algorithm algorithm = NLOPT_GN_DIRECT_L;
+static double ftol_rel = 0, ftol_abs = 0, xtol_rel = 0, xtol_abs = 0, minf_max_delta = -HUGE_VAL;
+static int maxeval = 1000, iterations = 1, center_start = 0;
+static double maxtime = 0.0;
+static double xinit_tol = -1;
+static int force_constraints = 0;
+static int fix_bounds[100] = {0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0,
+                             0,0,0,0,0,0,0,0,0,0};
+
+static void listalgs(FILE *f)
+{
+  int i;
+  fprintf(f, "Available algorithms:\n");
+  for (i = 0; i < NLOPT_NUM_ALGORITHMS; ++i)
+    fprintf(f, "  %2d: %s\n", i, nlopt_algorithm_name((nlopt_algorithm) i));
+}
+
+static void listfuncs(FILE *f)
+{
+  int i;
+  fprintf(f, "Available objective functions:\n");
+  for (i = 0; i < NTESTFUNCS; ++i)
+    fprintf(f, "  %2d: %s (%d dims)\n", i, testfuncs[i].name, testfuncs[i].n);
+}
+
+typedef struct {
+  const double *lb, *ub;
+  nlopt_func f;
+  void *f_data;
+} bounds_wrap_data;
+
+static double bounds_wrap_func(int n, const double *x, double *grad, void *d_)
+{
+  bounds_wrap_data *d = (bounds_wrap_data *) d_;
+  int i;
+  double b = 0;
+  for (i = 0; i < n; ++i) {
+    if (x[i] < d->lb[i]) {
+      b = d->lb[i];
+      break; 
+    }
+    else if (x[i] > d->ub[i]) {
+      b = d->ub[i];
+      break;
+    }
+  }
+  if (i < n)
+    fprintf(stderr, "WARNING: bounds violated by x[%d] = %g = %g + %g\n",
+           i, x[i], b, x[i] - b);
+  return d->f(n, x, grad, d->f_data);
+}
+
+static int test_function(int ifunc)
+{
+  testfunc func;
+  int i, iter;
+  double *x, minf, minf_max, f0, *xtabs, *lb, *ub;
+  nlopt_result ret;
+  double start = nlopt_seconds();
+  int total_count = 0, max_count = 0, min_count = 1<<30;
+  double total_err = 0, max_err = 0;
+  bounds_wrap_data bw;
+  
+  if (ifunc < 0 || ifunc >= NTESTFUNCS) {
+    fprintf(stderr, "testopt: invalid function %d\n", ifunc);
+    listfuncs(stderr);
+    return 0;
+  }
+  func = testfuncs[ifunc];
+  x = (double *) malloc(sizeof(double) * func.n * 5);
+  if (!x) { fprintf(stderr, "testopt: Out of memory!\n"); return 0; }
+
+  lb = x + func.n * 3;
+  ub = lb + func.n;
+  xtabs = x + func.n * 2;
+  bw.lb = lb;
+  bw.ub = ub;
+  bw.f = func.f;
+  bw.f_data = func.f_data;
+
+  for (i = 0; i < func.n; ++i) xtabs[i] = xtol_abs;
+  minf_max = minf_max_delta > (-HUGE_VAL) ? minf_max_delta + func.minf : (-HUGE_VAL);
+  
+  printf("-----------------------------------------------------------\n");
+  printf("Optimizing %s (%d dims) using %s algorithm\n",
+        func.name, func.n, nlopt_algorithm_name(algorithm));
+  printf("lower bounds at lb = [");
+  for (i = 0; i < func.n; ++i) printf(" %g", func.lb[i]);
+  printf("]\n");
+  printf("upper bounds at ub = [");
+  for (i = 0; i < func.n; ++i) printf(" %g", func.ub[i]);
+  printf("]\n");
+  memcpy(lb, func.lb, func.n * sizeof(double));
+  memcpy(ub, func.ub, func.n * sizeof(double));
+  for (i = 0; i < func.n; ++i) if (fix_bounds[i]) {
+      printf("fixing bounds for dim[%d] to xmin[%d]=%g\n",
+            i, i, func.xmin[i]);
+      lb[i] = ub[i] = func.xmin[i];
+  }
+  if (force_constraints) {
+    for (i = 0; i < func.n; ++i) {
+      if (nlopt_iurand(2) == 0)
+       ub[i] = nlopt_urand(lb[i], func.xmin[i]);
+      else
+       lb[i] = nlopt_urand(func.xmin[i], ub[i]);
+    }
+    printf("adjusted lower bounds at lb = [");
+    for (i = 0; i < func.n; ++i) printf(" %g", lb[i]);
+    printf("]\n");
+    printf("adjusted upper bounds at ub = [");
+    for (i = 0; i < func.n; ++i) printf(" %g", ub[i]);
+    printf("]\n");
+  }
+
+  if (fabs(func.f(func.n, func.xmin, 0, func.f_data) - func.minf) > 1e-8) {
+    fprintf(stderr, "BUG: function does not achieve given lower bound!\n");
+    fprintf(stderr, "f(%g", func.xmin[0]);
+    for (i = 1; i < func.n; ++i) fprintf(stderr, ", %g", func.xmin[i]);
+    fprintf(stderr, ") = %0.16g instead of %0.16g, |diff| = %g\n", 
+           func.f(func.n, func.xmin, 0, func.f_data), func.minf,
+           fabs(func.f(func.n, func.xmin, 0, func.f_data) - func.minf));
+    return 0;
+  }
+
+  for (iter = 0; iter < iterations; ++iter) {
+    double val;
+    testfuncs_counter = 0;
+
+    printf("Starting guess x = [");
+    for (i = 0; i < func.n; ++i) {
+      if (center_start)
+       x[i] = (ub[i] + lb[i]) * 0.5;
+      else if (xinit_tol < 0) { /* random starting point near center of box */
+       double dx = (ub[i] - lb[i]) * 0.25;
+       double xm = 0.5 * (ub[i] + lb[i]);
+       x[i] = nlopt_urand(xm - dx, xm + dx);
+      }
+      else {
+       x[i] = nlopt_urand(-xinit_tol, xinit_tol)
+         + (1 + nlopt_urand(-xinit_tol, xinit_tol)) * func.xmin[i];
+       if (x[i] > ub[i]) x[i] = ub[i];
+       else if (x[i] < lb[i]) x[i] = lb[i];
+      }
+      printf(" %g", x[i]);
+    }
+    printf("]\n");
+    f0 = func.f(func.n, x, x + func.n, func.f_data);
+    printf("Starting function value = %g\n", f0);
+    
+    if (iter == 0 && testfuncs_verbose && func.has_gradient) {
+      printf("checking gradient:\n");
+      for (i = 0; i < func.n; ++i) {
+       double f;
+       x[i] *= 1 + 1e-6;
+       f = func.f(func.n, x, NULL, func.f_data);
+       x[i] /= 1 + 1e-6;
+       printf("  grad[%d] = %g vs. numerical derivative %g\n",
+              i, x[i + func.n], (f - f0) / (x[i] * 1e-6));
+      }
+    }
+    
+    testfuncs_counter = 0;
+    ret = nlopt_minimize(algorithm,
+                        func.n, bounds_wrap_func, &bw,
+                        lb, ub,
+                        x, &minf,
+                        minf_max, ftol_rel, ftol_abs, xtol_rel, xtabs,
+                        maxeval, maxtime);
+    printf("finished after %g seconds.\n", nlopt_seconds() - start);
+    printf("return code %d from nlopt_minimize\n", ret);
+    if (ret < 0 && ret != NLOPT_ROUNDOFF_LIMITED
+       && ret != NLOPT_FORCED_STOP) {
+      fprintf(stderr, "testopt: error in nlopt_minimize\n");
+      free(x);
+      return 0;
+    }
+    printf("Found minimum f = %g after %d evaluations.\n", 
+          minf, testfuncs_counter);
+    total_count += testfuncs_counter;
+    if (testfuncs_counter > max_count) max_count = testfuncs_counter;
+    if (testfuncs_counter < min_count) min_count = testfuncs_counter;
+    printf("Minimum at x = [");
+    for (i = 0; i < func.n; ++i) printf(" %g", x[i]);
+    printf("]\n");
+    if (func.minf == 0)
+      printf("|f - minf| = %g\n", fabs(minf - func.minf));
+    else
+      printf("|f - minf| = %g, |f - minf| / |minf| = %e\n",
+            fabs(minf - func.minf), fabs(minf - func.minf) / fabs(func.minf));
+    total_err += fabs(minf - func.minf);
+    if (fabs(minf - func.minf) > max_err)
+      max_err = fabs(minf - func.minf);
+    printf("vs. global minimum f = %g at x = [", func.minf);
+    for (i = 0; i < func.n; ++i) printf(" %g", func.xmin[i]);
+    printf("]\n");
+
+    val = func.f(func.n, x, NULL, func.f_data);
+    if (val != minf) {
+      fprintf(stderr, "Mismatch %g between returned minf=%g and f(x) = %g\n", 
+             minf - val, minf, val);
+      free(x);
+      return 0;
+    }
+  }
+  if (iterations > 1)
+    printf("average #evaluations = %g (%d-%d)\naverage |f-minf| = %g, max |f-minf| = %g\n", total_count * 1.0 / iterations, min_count, max_count, total_err / iterations, max_err);
+
+  free(x);
+  return 1;
+}
+
+static void usage(FILE *f)
+{
+  fprintf(f, "Usage: testopt [OPTIONS]\n"
+         "Options:\n"
+         "     -h : print this help\n"
+         "     -L : list available algorithms and objective functions\n"
+         "     -v : verbose mode\n"
+         " -a <n> : use optimization algorithm <n>\n"
+         " -o <n> : use objective function <n>\n"
+         " -0 <x> : starting guess within <x> + (1+<x>) * optimum\n"
+         " -b <dim0,dim1,...>: eliminate given dims by equating bounds\n"
+         "     -c : starting guess at center of cell\n"
+         "     -C : put optimum outside of bound constraints\n"
+         " -e <n> : use at most <n> evals (default: %d, 0 to disable)\n"
+         " -t <t> : use at most <t> seconds (default: disabled)\n"
+         " -x <t> : relative tolerance <t> on x (default: disabled)\n"
+         " -X <t> : absolute tolerance <t> on x (default: disabled)\n"
+         " -f <t> : relative tolerance <t> on f (default: disabled)\n"
+         " -F <t> : absolute tolerance <t> on f (default: disabled)\n"
+         " -m <m> : stop when minf+<m> is reached (default: disabled)\n"
+         " -i <n> : iterate optimization <n> times (default: 1)\n"
+         " -r <s> : use random seed <s> for starting guesses\n"
+         , maxeval);
+}
+
+int main(int argc, char **argv)
+{
+  int c;
+  
+  nlopt_srand_time();
+  testfuncs_verbose = 0;
+  
+  if (argc <= 1)
+    usage(stdout);
+
+#if USE_FEENABLEEXCEPT
+  feenableexcept(FE_INVALID);
+#endif
+  
+  while ((c = getopt(argc, argv, "hLvCc0:r:a:o:i:e:t:x:X:f:F:m:b:")) != -1)
+    switch (c) {
+    case 'h':
+      usage(stdout);
+      return EXIT_SUCCESS;
+    case 'L':
+      listalgs(stdout);
+      listfuncs(stdout);
+      return EXIT_SUCCESS;
+    case 'v':
+      testfuncs_verbose = 1;
+      break;
+    case 'C':
+      force_constraints = 1;
+      break;
+    case 'r':
+      nlopt_srand((unsigned long) atoi(optarg));
+      break;
+    case 'a':
+      c = atoi(optarg);
+      if (c < 0 || c >= NLOPT_NUM_ALGORITHMS) {
+       fprintf(stderr, "testopt: invalid algorithm %d\n", c);
+       listalgs(stderr);
+       return EXIT_FAILURE;
+      }
+      algorithm = (nlopt_algorithm) c;
+      break;
+    case 'o':
+      if (!test_function(atoi(optarg)))
+       return EXIT_FAILURE;
+      break;
+    case 'e':
+      maxeval = atoi(optarg);
+      break;
+    case 'i':
+      iterations = atoi(optarg);
+      break;
+    case 't':
+      maxtime = atof(optarg);
+      break;
+    case 'x':
+      xtol_rel = atof(optarg);
+      break;
+    case 'X':
+      xtol_abs = atof(optarg);
+      break;
+    case 'f':
+      ftol_rel = atof(optarg);
+      break;
+    case 'F':
+      ftol_abs = atof(optarg);
+      break;
+    case 'm':
+      minf_max_delta = atof(optarg);
+      break;
+    case 'c':
+      center_start = 1;
+      break;
+    case '0':
+      center_start = 0;
+      xinit_tol = atof(optarg);
+      break;
+    case 'b': {
+      const char *s = optarg;
+      while (s && *s) {
+       int b = atoi(s);
+       if (b < 0 || b >= 100) { 
+         fprintf(stderr, "invalid -b argument");
+         return EXIT_FAILURE;
+       }
+       fix_bounds[b] = 1;
+       s = strchr(s, ','); if (s) ++s;
+      }
+      break;
+    }
+    default:
+      fprintf(stderr, "harminv: invalid argument -%c\n", c);
+      usage(stderr);
+      return EXIT_FAILURE;
+    }
+  
+  return EXIT_SUCCESS;
+}
diff --git a/util/Makefile.am b/util/Makefile.am
new file mode 100644 (file)
index 0000000..ca4dff9
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -I$(top_srcdir)/api
+
+noinst_LTLIBRARIES = libutil.la
+libutil_la_SOURCES = mt19937ar.c sobolseq.c soboldata.h timer.c stop.c nlopt-util.h redblack.c redblack.h qsort_r.c rescale.c
+
+noinst_PROGRAMS = redblack_test
+redblack_test_SOURCES = redblack_test.c
+redblack_test_LDADD = libutil.la
diff --git a/util/Makefile.in b/util/Makefile.in
new file mode 100644 (file)
index 0000000..8062646
--- /dev/null
@@ -0,0 +1,634 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+noinst_PROGRAMS = redblack_test$(EXEEXT)
+subdir = util
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+       $(top_srcdir)/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c_threadlocal.m4 \
+       $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+       $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+       $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libutil_la_LIBADD =
+am_libutil_la_OBJECTS = mt19937ar.lo sobolseq.lo timer.lo stop.lo \
+       redblack.lo qsort_r.lo rescale.lo
+libutil_la_OBJECTS = $(am_libutil_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+PROGRAMS = $(noinst_PROGRAMS)
+am_redblack_test_OBJECTS = redblack_test.$(OBJEXT)
+redblack_test_OBJECTS = $(am_redblack_test_OBJECTS)
+redblack_test_DEPENDENCIES = libutil.la
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libutil_la_SOURCES) $(redblack_test_SOURCES)
+DIST_SOURCES = $(libutil_la_SOURCES) $(redblack_test_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GUILE = @GUILE@
+GUILE_CONFIG = @GUILE_CONFIG@
+GUILE_CPPFLAGS = @GUILE_CPPFLAGS@
+GUILE_INSTALL_DIR = @GUILE_INSTALL_DIR@
+GUILE_LIBS = @GUILE_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MATLAB = @MATLAB@
+MEX = @MEX@
+MEXSUFF = @MEXSUFF@
+MEX_INSTALL_DIR = @MEX_INSTALL_DIR@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+M_INSTALL_DIR = @M_INSTALL_DIR@
+NLOPT_SUFFIX = @NLOPT_SUFFIX@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCT_INSTALL_DIR = @OCT_INSTALL_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/api
+noinst_LTLIBRARIES = libutil.la
+libutil_la_SOURCES = mt19937ar.c sobolseq.c soboldata.h timer.c stop.c nlopt-util.h redblack.c redblack.h qsort_r.c rescale.c
+redblack_test_SOURCES = redblack_test.c
+redblack_test_LDADD = libutil.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu util/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu util/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
+libutil.la: $(libutil_la_OBJECTS) $(libutil_la_DEPENDENCIES) $(EXTRA_libutil_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK)  $(libutil_la_OBJECTS) $(libutil_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+
+redblack_test$(EXEEXT): $(redblack_test_OBJECTS) $(redblack_test_DEPENDENCIES) $(EXTRA_redblack_test_DEPENDENCIES) 
+       @rm -f redblack_test$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(redblack_test_OBJECTS) $(redblack_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mt19937ar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qsort_r.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/redblack.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/redblack_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rescale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sobolseq.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stop.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       set x; \
+       here=`pwd`; \
+       $(am__define_uniq_tagged_files); \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       if test -z '$(STRIP)'; then \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+             install; \
+       else \
+         $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+           install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+           "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+       fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \
+       cscopelist-am ctags ctags-am distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man install-pdf \
+       install-pdf-am install-ps install-ps-am install-strip \
+       installcheck installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/util/mt19937ar.c b/util/mt19937ar.c
new file mode 100644 (file)
index 0000000..f6d7f60
--- /dev/null
@@ -0,0 +1,253 @@
+/* 
+   A C-program for MT19937, with initialization improved 2002/1/26.
+   Coded by Takuji Nishimura and Makoto Matsumoto.
+
+   Before using, initialize the state by using init_genrand(seed)  
+   or init_by_array(init_key, key_length).
+
+   Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+   All rights reserved.                          
+
+   Modified 2007 by Steven G. Johnson for use with NLopt (to avoid
+   namespace pollution, use uint32_t instead of unsigned long,
+   and add the urand function).  Modified 2009 to add normal-distributed
+   random numbers.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+     1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+
+     3. The names of its contributors may not be used to endorse or promote 
+        products derived from this software without specific prior written 
+        permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+   OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+   Any feedback is very welcome.
+   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+   email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+*/
+
+#include "nlopt-util.h"
+
+#if defined(HAVE_STDINT_H)
+#  include <stdint.h>
+#endif
+
+#ifndef HAVE_UINT32_T
+#  if SIZEOF_UNSIGNED_LONG == 4
+      typedef unsigned long uint32_t;
+#  elif SIZEOF_UNSIGNED_INT == 4
+      typedef unsigned int uint32_t;
+#  else
+#    error No 32-bit unsigned integer type
+#  endif
+#endif
+
+/* Period parameters */  
+#define N 624
+#define M 397
+#define MATRIX_A 0x9908b0dfUL   /* constant vector a */
+#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
+#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
+
+/* SGJ 2010: make RNG thread-safe by declaring the RNG state as thread-local
+   storage, at least for GCC, MSVC, and Intel C++ */
+
+static THREADLOCAL uint32_t mt[N]; /* the array for the state vector  */
+static THREADLOCAL int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
+
+/* initializes mt[N] with a seed */
+void nlopt_init_genrand(unsigned long s)
+{
+    mt[0]= s & 0xffffffffUL;
+    for (mti=1; mti<N; mti++) {
+        mt[mti] = 
+           (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 
+        /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+        /* In the previous versions, MSBs of the seed affect   */
+        /* only MSBs of the array mt[].                        */
+        /* 2002/01/09 modified by Makoto Matsumoto             */
+        mt[mti] &= 0xffffffffUL;
+        /* for >32 bit machines */
+    }
+}
+
+/* generates a random number on [0,0xffffffff]-interval */
+static uint32_t nlopt_genrand_int32(void)
+{
+    uint32_t y;
+    static uint32_t mag01[2]={0x0UL, MATRIX_A};
+    /* mag01[x] = x * MATRIX_A  for x=0,1 */
+
+    if (mti >= N) { /* generate N words at one time */
+        int kk;
+
+        if (mti == N+1)   /* if init_genrand() has not been called, */
+           nlopt_init_genrand(5489UL); /* a default initial seed is used */
+
+        for (kk=0;kk<N-M;kk++) {
+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+            mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
+        }
+        for (;kk<N-1;kk++) {
+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+            mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
+        }
+        y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
+        mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
+
+        mti = 0;
+    }
+  
+    y = mt[mti++];
+
+    /* Tempering */
+    y ^= (y >> 11);
+    y ^= (y << 7) & 0x9d2c5680UL;
+    y ^= (y << 15) & 0xefc60000UL;
+    y ^= (y >> 18);
+
+    return y;
+}
+
+#if 0 /* not used in NLopt */
+
+/* initialize by an array with array-length */
+/* init_key is the array for initializing keys */
+/* key_length is its length */
+/* slight change for C++, 2004/2/26 */
+static void nlopt_init_by_array(uint32_t init_key[], int key_length)
+{
+    int i, j, k;
+    nlopt_init_genrand(19650218UL);
+    i=1; j=0;
+    k = (N>key_length ? N : key_length);
+    for (; k; k--) {
+        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
+          + init_key[j] + j; /* non linear */
+        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+        i++; j++;
+        if (i>=N) { mt[0] = mt[N-1]; i=1; }
+        if (j>=key_length) j=0;
+    }
+    for (k=N-1; k; k--) {
+        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
+          - i; /* non linear */
+        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+        i++;
+        if (i>=N) { mt[0] = mt[N-1]; i=1; }
+    }
+
+    mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ 
+}
+
+/* generates a random number on [0,0x7fffffff]-interval */
+static long nlopt_genrand_int31(void)
+{
+    return (long)(nlopt_genrand_int32()>>1);
+}
+
+/* generates a random number on [0,1]-real-interval */
+static double nlopt_genrand_real1(void)
+{
+    return nlopt_genrand_int32()*(1.0/4294967295.0); 
+    /* divided by 2^32-1 */ 
+}
+
+/* generates a random number on [0,1)-real-interval */
+static double nlopt_genrand_real2(void)
+{
+    return nlopt_genrand_int32()*(1.0/4294967296.0); 
+    /* divided by 2^32 */
+}
+
+/* generates a random number on (0,1)-real-interval */
+static double nlopt_genrand_real3(void)
+{
+    return (((double)nlopt_genrand_int32()) + 0.5)*(1.0/4294967296.0); 
+    /* divided by 2^32 */
+}
+
+#endif
+
+/* generates a random number on [0,1) with 53-bit resolution*/
+static double nlopt_genrand_res53(void) 
+{ 
+    uint32_t a=nlopt_genrand_int32()>>5, b=nlopt_genrand_int32()>>6; 
+    return(a*67108864.0+b)*(1.0/9007199254740992.0); 
+} 
+/* These real versions are due to Isaku Wada, 2002/01/09 added */
+
+/* generate uniform random number in [a,b) with 53-bit resolution,
+   added by SGJ */
+double nlopt_urand(double a, double b)
+{
+     return(a + (b - a) * nlopt_genrand_res53());
+}
+
+/* generate a uniform random number in [0,n), added by SGJ */
+int nlopt_iurand(int n)
+{
+     return(nlopt_genrand_int32() % n);
+}
+
+/* normal-distributed random numbers with the given mean and std. deviation,
+   added by SGJ */
+double nlopt_nrand(double mean, double stddev)
+{
+  // Box-Muller algorithm to generate Gaussian from uniform
+  // see Knuth vol II algorithm P, sec. 3.4.1
+  double v1, v2, s;
+  do {
+    v1 = nlopt_urand(-1, 1);
+    v2 = nlopt_urand(-1, 1);
+    s = v1*v1 + v2*v2;
+  } while (s >= 1.0);
+  if (s == 0) {
+    return mean;
+  }
+  else {
+    return mean + v1 * sqrt(-2 * log(s) / s) * stddev;
+  }
+}
+
+#if 0
+#include <stdio.h>
+int main(void)
+{
+    int i;
+    uint32_t init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
+    init_by_array(init, length);
+    printf("1000 outputs of nlopt_genrand_int32()\n");
+    for (i=0; i<1000; i++) {
+      printf("%10lu ", nlopt_genrand_int32());
+      if (i%5==4) printf("\n");
+    }
+    printf("\n1000 outputs of genrand_real2()\n");
+    for (i=0; i<1000; i++) {
+      printf("%10.8f ", genrand_real2());
+      if (i%5==4) printf("\n");
+    }
+    return 0;
+}
+#endif
diff --git a/util/nlopt-util.h b/util/nlopt-util.h
new file mode 100644 (file)
index 0000000..f460c2d
--- /dev/null
@@ -0,0 +1,136 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef NLOPT_UTIL_H
+#define NLOPT_UTIL_H
+
+#include <stdlib.h>
+#include <math.h>
+#include "config.h"
+
+#include "nlopt.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
+
+#ifndef HAVE_COPYSIGN
+   /* not quite right for y == -0, but good enough for us */
+#  define copysign(x, y) ((y) < 0 ? -fabs(x) : fabs(x))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+int nlopt_isinf(double x);
+
+/* re-entrant qsort */
+extern void nlopt_qsort_r(void *base_, size_t nmemb, size_t size, void *thunk,
+                         int (*compar)(void *, const void *, const void *));
+
+/* seconds timer */
+extern double nlopt_seconds(void);
+extern unsigned long nlopt_time_seed(void);
+
+/* pseudorandom number generation by Mersenne twister algorithm */
+extern void nlopt_init_genrand(unsigned long s);
+extern double nlopt_urand(double a, double b);
+extern int nlopt_iurand(int n);
+extern double nlopt_nrand(double mean, double stddev);
+
+/* Sobol' low-discrepancy-sequence generation */
+typedef struct nlopt_soboldata_s *nlopt_sobol;
+extern nlopt_sobol nlopt_sobol_create(unsigned sdim);
+extern void nlopt_sobol_destroy(nlopt_sobol s);
+extern void nlopt_sobol_next01(nlopt_sobol s, double *x);
+extern void nlopt_sobol_next(nlopt_sobol s, double *x,
+                           const double *lb, const double *ub);
+extern void nlopt_sobol_skip(nlopt_sobol s, unsigned n, double *x);
+
+/* stopping criteria */
+typedef struct {
+     unsigned n;
+     double minf_max;
+     double ftol_rel;
+     double ftol_abs;
+     double xtol_rel;
+     const double *xtol_abs;
+     int nevals, maxeval;
+     double maxtime, start;
+     int *force_stop;
+} nlopt_stopping;
+extern int nlopt_stop_f(const nlopt_stopping *stop, double f, double oldf);
+extern int nlopt_stop_ftol(const nlopt_stopping *stop, double f, double oldf);
+extern int nlopt_stop_x(const nlopt_stopping *stop, 
+                       const double *x, const double *oldx);
+extern int nlopt_stop_dx(const nlopt_stopping *stop, 
+                        const double *x, const double *dx);
+extern int nlopt_stop_xs(const nlopt_stopping *stop, 
+                        const double *xs, const double *oldxs,
+                        const double *scale_min, const double *scale_max);
+extern int nlopt_stop_evals(const nlopt_stopping *stop);
+extern int nlopt_stop_time_(double start, double maxtime);
+extern int nlopt_stop_time(const nlopt_stopping *stop);
+extern int nlopt_stop_evalstime(const nlopt_stopping *stop);
+extern int nlopt_stop_forced(const nlopt_stopping *stop);
+
+/* for local optimizations, temporarily setting eval/time limits */
+extern nlopt_result nlopt_optimize_limited(nlopt_opt opt, 
+                                          double *x, double *minf,
+                                          int maxevals, double maxtime);
+
+/* data structure for nonlinear inequality or equality constraint
+   (f <= 0 or f = 0, respectively).  tol (>= 0) is a tolerance
+   that is used for stopping criteria -- the point is considered
+   "feasible" for purposes of stopping if the constraint is violated
+   by at most tol. */
+typedef struct {
+     unsigned m; /* dimensional of constraint: mf maps R^n -> R^m */
+     nlopt_func f; /* one-dimensional constraint, requires m == 1 */
+     nlopt_mfunc mf;
+     nlopt_precond pre; /* preconditioner for f (NULL if none or if mf) */
+     void *f_data;
+     double *tol;
+} nlopt_constraint;
+
+extern unsigned nlopt_count_constraints(unsigned p, const nlopt_constraint *c);
+extern unsigned nlopt_max_constraint_dim(unsigned p, const nlopt_constraint *c);
+extern void nlopt_eval_constraint(double *result, double *grad,
+                                 const nlopt_constraint *c,
+                                 unsigned n, const double *x);
+
+/* rescale.c: */
+double *nlopt_compute_rescaling(unsigned n, const double *dx);
+double *nlopt_new_rescaled(unsigned n, const double *s, const double *x);
+void nlopt_rescale(unsigned n, const double *s, const double *x, double *xs);
+void nlopt_unscale(unsigned n, const double *s, const double *x, double *xs);
+void nlopt_reorder_bounds(unsigned n, double *lb, double *ub);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
diff --git a/util/qsort_r.c b/util/qsort_r.c
new file mode 100644 (file)
index 0000000..05098e9
--- /dev/null
@@ -0,0 +1,110 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include "nlopt-util.h"
+
+/* Simple replacement for the BSD qsort_r function (re-entrant sorting),
+   if it is not available.
+
+   (glibc 2.8 included a qsort_r function as well, but totally
+   *%&$#-ed things up by gratuitously changing the argument order, in
+   such a way as to allow code using the BSD ordering to compile but
+   die a flaming death at runtime.  Damn them all to Hell, I'll just
+   use my own implementation.)
+
+   (Actually, with glibc 2.3.6 on my Intel Core Duo, my implementation
+   below seems to be significantly faster than qsort.  Go figure.)
+*/
+
+#ifndef HAVE_QSORT_R_damn_it_use_my_own
+/* swap size bytes between a_ and b_ */
+static void swap(void *a_, void *b_, size_t size)
+{
+     if (a_ == b_) return;
+     {
+          size_t i, nlong = size / sizeof(long);
+          long *a = (long *) a_, *b = (long *) b_;
+          for (i = 0; i < nlong; ++i) {
+               long c = a[i];
+               a[i] = b[i];
+               b[i] = c;
+          }
+         a_ = (void*) (a + nlong);
+         b_ = (void*) (b + nlong);
+     }
+     {
+          size_t i;
+          char *a = (char *) a_, *b = (char *) b_;
+          size = size % sizeof(long);
+          for (i = 0; i < size; ++i) {
+               char c = a[i];
+               a[i] = b[i];
+               b[i] = c;
+          }
+     }
+}
+#endif /* HAVE_QSORT_R */
+
+void nlopt_qsort_r(void *base_, size_t nmemb, size_t size, void *thunk,
+                  int (*compar)(void *, const void *, const void *))
+{
+#ifdef HAVE_QSORT_R_damn_it_use_my_own
+     /* Even if we could detect glibc vs. BSD by appropriate
+       macrology, there is no way to make the calls compatible
+       without writing a wrapper for the compar function...screw
+       this. */
+     qsort_r(base_, nmemb, size, thunk, compar);
+#else
+     char *base = (char *) base_;
+     if (nmemb < 10) { /* use O(nmemb^2) algorithm for small enough nmemb */
+         size_t i, j;
+         for (i = 0; i+1 < nmemb; ++i)
+              for (j = i+1; j < nmemb; ++j)
+                   if (compar(thunk, base+i*size, base+j*size) > 0)
+                        swap(base+i*size, base+j*size, size);
+     }
+     else {
+         size_t i, pivot, npart;
+         /* pick median of first/middle/last elements as pivot */
+         {
+              const char *a = base, *b = base + (nmemb/2)*size, 
+                   *c = base + (nmemb-1)*size;
+              pivot = compar(thunk,a,b) < 0
+                   ? (compar(thunk,b,c) < 0 ? nmemb/2 :
+                      (compar(thunk,a,c) < 0 ? nmemb-1 : 0))
+                   : (compar(thunk,a,c) < 0 ? 0 :
+                      (compar(thunk,b,c) < 0 ? nmemb-1 : nmemb/2));
+         }
+         /* partition array */
+         swap(base + pivot*size, base + (nmemb-1) * size, size);
+         pivot = (nmemb - 1) * size;
+         for (i = npart = 0; i < nmemb-1; ++i)
+              if (compar(thunk, base+i*size, base+pivot) <= 0)
+                   swap(base+i*size, base+(npart++)*size, size);
+         swap(base+npart*size, base+pivot, size);
+         /* recursive sort of two partitions */
+         nlopt_qsort_r(base, npart, size, thunk, compar);
+         npart++; /* don't need to sort pivot */
+         nlopt_qsort_r(base+npart*size, nmemb-npart, size, thunk, compar);
+     }
+#endif /* !HAVE_QSORT_R */
+}
diff --git a/util/redblack.c b/util/redblack.c
new file mode 100644 (file)
index 0000000..267733b
--- /dev/null
@@ -0,0 +1,430 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* simple implementation of red-black trees optimized for use with DIRECT */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include "redblack.h"
+
+/* it is convenient to use an explicit node for NULL nodes ... we need
+   to be careful never to change this node indirectly via one of our
+   pointers!  */
+rb_node nil = {&nil, &nil, &nil, 0, BLACK};
+#define NIL (&nil)
+
+void rb_tree_init(rb_tree *t, rb_compare compare) {
+     t->compare = compare;
+     t->root = NIL;
+     t->N = 0;
+}
+
+static void destroy(rb_node *n)
+{
+     if (n != NIL) {
+         destroy(n->l); destroy(n->r);
+         free(n);
+     }
+}
+
+void rb_tree_destroy(rb_tree *t)
+{
+     destroy(t->root);
+     t->root = NIL;
+}
+
+void rb_tree_destroy_with_keys(rb_tree *t)
+{
+     rb_node *n = rb_tree_min(t);
+     while (n) {
+         free(n->k); n->k = NULL;
+         n = rb_tree_succ(n);
+     }
+     rb_tree_destroy(t);
+}
+
+static void rotate_left(rb_node *p, rb_tree *t)
+{
+     rb_node *n = p->r; /* must be non-NIL */
+     p->r = n->l;
+     n->l = p;
+     if (p->p != NIL) {
+         if (p == p->p->l) p->p->l = n;
+         else p->p->r = n;
+     }
+     else
+         t->root = n;
+     n->p = p->p;
+     p->p = n;
+     if (p->r != NIL) p->r->p = p;
+}
+
+static void rotate_right(rb_node *p, rb_tree *t)
+{
+     rb_node *n = p->l; /* must be non-NIL */
+     p->l = n->r;
+     n->r = p;
+     if (p->p != NIL) {
+         if (p == p->p->l) p->p->l = n;
+         else p->p->r = n;
+     }
+     else
+         t->root = n;
+     n->p = p->p;
+     p->p = n;
+     if (p->l != NIL) p->l->p = p;
+}
+
+static void insert_node(rb_tree *t, rb_node *n)
+{
+     rb_compare compare = t->compare;
+     rb_key k = n->k;
+     rb_node *p = t->root;
+     n->c = RED;
+     n->p = n->l = n->r = NIL;
+     t->N++;
+     if (p == NIL) {
+         t->root = n;
+         n->c = BLACK;
+         return;
+     }
+     /* insert (RED) node into tree */
+     while (1) {
+         if (compare(k, p->k) <= 0) { /* k <= p->k */
+              if (p->l != NIL)
+                   p = p->l;
+              else {
+                   p->l = n;
+                   n->p = p;
+                   break;
+              }
+         }
+         else {
+              if (p->r != NIL)
+                   p = p->r;
+              else {
+                   p->r = n;
+                   n->p = p;
+                   break;
+              }
+         }
+     }
+ fixtree:
+     if (n->p->c == RED) { /* red cannot have red child */
+         rb_node *u = p == p->p->l ? p->p->r : p->p->l;
+         if (u != NIL && u->c == RED) {
+              p->c = u->c = BLACK;
+              n = p->p;
+              if ((p = n->p) != NIL) {
+                   n->c = RED;
+                   goto fixtree;
+              }
+         }
+         else {
+              if (n == p->r && p == p->p->l) {
+                   rotate_left(p, t);
+                   p = n; n = n->l;
+              }
+              else if (n == p->l && p == p->p->r) {
+                   rotate_right(p, t);
+                   p = n; n = n->r;
+              }
+              p->c = BLACK;
+              p->p->c = RED;
+              if (n == p->l && p == p->p->l)
+                   rotate_right(p->p, t);
+              else if (n == p->r && p == p->p->r)
+                   rotate_left(p->p, t);
+         }
+             
+     }
+}
+
+rb_node *rb_tree_insert(rb_tree *t, rb_key k)
+{
+     rb_node *n = (rb_node *) malloc(sizeof(rb_node));
+     if (!n) return NULL;
+     n->k = k;
+     insert_node(t, n);
+     return n;
+}
+
+static int check_node(rb_node *n, int *nblack, rb_tree *t)
+{
+     int nbl, nbr;
+     rb_compare compare = t->compare;
+     if (n == NIL) { *nblack = 0; return 1; }
+     if (n->r != NIL && n->r->p != n) return 0;
+     if (n->r != NIL && compare(n->r->k, n->k) < 0)
+         return 0;
+     if (n->l != NIL && n->l->p != n) return 0;
+     if (n->l != NIL && compare(n->l->k, n->k) > 0)
+         return 0;
+     if (n->c == RED) {
+         if (n->r != NIL && n->r->c == RED) return 0;
+         if (n->l != NIL && n->l->c == RED) return 0;
+     }
+     if (!(check_node(n->r, &nbl, t) && check_node(n->l, &nbr, t))) 
+         return 0;
+     if (nbl != nbr) return 0;
+     *nblack = nbl + (n->c == BLACK);
+     return 1;
+}
+int rb_tree_check(rb_tree *t)
+{
+     int nblack;
+     if (nil.c != BLACK) return 0;
+     if (nil.p != NIL || nil.r != NIL || nil.l != NIL) return 0;
+     if (t->root == NIL) return 1;
+     if (t->root->c != BLACK) return 0;
+     return check_node(t->root, &nblack, t);
+}
+
+rb_node *rb_tree_find(rb_tree *t, rb_key k)
+{
+     rb_compare compare = t->compare;
+     rb_node *p = t->root;
+     while (p != NIL) {
+         int comp = compare(k, p->k);
+         if (!comp) return p;
+         p = comp <= 0 ? p->l : p->r;
+     }
+     return NULL;
+}
+
+/* find greatest point in subtree p that is <= k */
+static rb_node *find_le(rb_node *p, rb_key k, rb_tree *t)
+{
+     rb_compare compare = t->compare;
+     while (p != NIL) {
+         if (compare(p->k, k) <= 0) { /* p->k <= k */
+              rb_node *r = find_le(p->r, k, t);
+              if (r) return r;
+              else return p;
+         }
+         else /* p->k > k */
+              p = p->l;
+     }
+     return NULL; /* k < everything in subtree */
+}
+
+/* find greatest point in t <= k */
+rb_node *rb_tree_find_le(rb_tree *t, rb_key k)
+{
+     return find_le(t->root, k, t);
+}
+
+/* find greatest point in subtree p that is < k */
+static rb_node *find_lt(rb_node *p, rb_key k, rb_tree *t)
+{
+     rb_compare compare = t->compare;
+     while (p != NIL) {
+         if (compare(p->k, k) < 0) { /* p->k < k */
+              rb_node *r = find_lt(p->r, k, t);
+              if (r) return r;
+              else return p;
+         }
+         else /* p->k >= k */
+              p = p->l;
+     }
+     return NULL; /* k <= everything in subtree */
+}
+
+/* find greatest point in t < k */
+rb_node *rb_tree_find_lt(rb_tree *t, rb_key k)
+{
+     return find_lt(t->root, k, t);
+}
+
+/* find least point in subtree p that is > k */
+static rb_node *find_gt(rb_node *p, rb_key k, rb_tree *t)
+{
+     rb_compare compare = t->compare;
+     while (p != NIL) {
+         if (compare(p->k, k) > 0) { /* p->k > k */
+              rb_node *l = find_gt(p->l, k, t);
+              if (l) return l;
+              else return p;
+         }
+         else /* p->k <= k */
+              p = p->r;
+     }
+     return NULL; /* k >= everything in subtree */
+}
+
+/* find least point in t > k */
+rb_node *rb_tree_find_gt(rb_tree *t, rb_key k)
+{
+     return find_gt(t->root, k, t);
+}
+
+rb_node *rb_tree_min(rb_tree *t)
+{
+     rb_node *n = t->root;
+     while (n != NIL && n->l != NIL)
+         n = n->l;
+     return(n == NIL ? NULL : n);
+}
+
+rb_node *rb_tree_max(rb_tree *t)
+{
+     rb_node *n = t->root;
+     while (n != NIL && n->r != NIL)
+         n = n->r;
+     return(n == NIL ? NULL : n);
+}
+
+rb_node *rb_tree_succ(rb_node *n)
+{
+     if (!n) return NULL;
+     if (n->r == NIL) {
+         rb_node *prev;
+         do {
+              prev = n;
+              n = n->p;
+         } while (prev == n->r && n != NIL);
+         return n == NIL ? NULL : n;
+     }
+     else {
+         n = n->r;
+         while (n->l != NIL)
+              n = n->l;
+         return n;
+     }
+}
+
+rb_node *rb_tree_pred(rb_node *n)
+{
+     if (!n) return NULL;
+     if (n->l == NIL) {
+         rb_node *prev;
+         do {
+              prev = n;
+              n = n->p;
+         } while (prev == n->l && n != NIL);
+         return n == NIL ? NULL : n;
+     }
+     else {
+         n = n->l;
+         while (n->r != NIL)
+              n = n->r;
+         return n;
+     }
+}
+
+rb_node *rb_tree_remove(rb_tree *t, rb_node *n)
+{
+     rb_key k = n->k;
+     rb_node *m, *mp;
+     if (n->l != NIL && n->r != NIL) {
+         rb_node *lmax = n->l;
+         while (lmax->r != NIL) lmax = lmax->r;
+         n->k = lmax->k;
+         n = lmax;
+     }
+     m = n->l != NIL ? n->l : n->r;
+     if (n->p != NIL) {
+         if (n->p->r == n) n->p->r = m;
+         else n->p->l = m;
+     }
+     else
+         t->root = m;
+     mp = n->p;
+     if (m != NIL) m->p = mp;
+     if (n->c == BLACK) {
+         if (m->c == RED)
+              m->c = BLACK;
+         else {
+         deleteblack:
+              if (mp != NIL) {
+                   rb_node *s = m == mp->l ? mp->r : mp->l;
+                   if (s->c == RED) {
+                        mp->c = RED;
+                        s->c = BLACK;
+                        if (m == mp->l) rotate_left(mp, t);
+                        else rotate_right(mp, t);
+                        s = m == mp->l ? mp->r : mp->l;
+                   }
+                   if (mp->c == BLACK && s->c == BLACK
+                       && s->l->c == BLACK && s->r->c == BLACK) {
+                        if (s != NIL) s->c = RED;
+                        m = mp; mp = m->p;
+                        goto deleteblack;
+                   }
+                   else if (mp->c == RED && s->c == BLACK &&
+                            s->l->c == BLACK && s->r->c == BLACK) {
+                        if (s != NIL) s->c = RED;
+                        mp->c = BLACK;
+                   }
+                   else {
+                        if (m == mp->l && s->c == BLACK &&
+                            s->l->c == RED && s->r->c == BLACK) {
+                             s->c = RED;
+                             s->l->c = BLACK;
+                             rotate_right(s, t);
+                             s = m == mp->l ? mp->r : mp->l;
+                        }
+                        else if (m == mp->r && s->c == BLACK &&
+                                 s->r->c == RED && s->l->c == BLACK) {
+                             s->c = RED;
+                             s->r->c = BLACK;
+                             rotate_left(s, t);
+                             s = m == mp->l ? mp->r : mp->l;
+                        }
+                        s->c = mp->c;
+                        mp->c = BLACK;
+                        if (m == mp->l) {
+                             s->r->c = BLACK;
+                             rotate_left(mp, t);
+                        }
+                        else {
+                             s->l->c = BLACK;
+                             rotate_right(mp, t);
+                        }
+                   }
+              }
+         }
+     }
+     t->N--;
+     n->k = k; /* n may have changed during remove */
+     return n; /* the node that was deleted may be different from initial n */
+}
+
+rb_node *rb_tree_resort(rb_tree *t, rb_node *n)
+{
+     n = rb_tree_remove(t, n);
+     insert_node(t, n);
+     return n;
+}
+
+/* shift all key pointers by kshift ... this is useful when the keys
+   are pointers into another array, that has been resized with realloc */
+static void shift_keys(rb_node *n, ptrdiff_t kshift) /* assumes n != NIL */
+{
+     n->k += kshift;
+     if (n->l != NIL) shift_keys(n->l, kshift);
+     if (n->r != NIL) shift_keys(n->r, kshift);
+}
+void rb_tree_shift_keys(rb_tree *t, ptrdiff_t kshift)
+{
+     if (t->root != NIL) shift_keys(t->root, kshift);
+}
diff --git a/util/redblack.h b/util/redblack.h
new file mode 100644 (file)
index 0000000..01d585c
--- /dev/null
@@ -0,0 +1,77 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef REDBLACK_H
+#define REDBLACK_H
+
+#include <stddef.h> /* for ptrdiff_t */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef double *rb_key; /* key type ... double* is convenient for us,
+                          but of course this could be cast to anything
+                          desired (although void* would look more generic) */
+
+typedef enum { RED, BLACK } rb_color;
+typedef struct rb_node_s {
+     struct rb_node_s *p, *r, *l; /* parent, right, left */
+     rb_key k; /* key (and data) */
+     rb_color c;
+} rb_node;
+
+typedef int (*rb_compare)(rb_key k1, rb_key k2);
+
+typedef struct {
+     rb_compare compare;
+     rb_node *root;
+     int N; /* number of nodes */
+} rb_tree;
+
+extern void rb_tree_init(rb_tree *t, rb_compare compare);
+extern void rb_tree_destroy(rb_tree *t);
+extern void rb_tree_destroy_with_keys(rb_tree *t);
+extern rb_node *rb_tree_insert(rb_tree *t, rb_key k);
+extern int rb_tree_check(rb_tree *t);
+extern rb_node *rb_tree_find(rb_tree *t, rb_key k);
+extern rb_node *rb_tree_find_le(rb_tree *t, rb_key k);
+extern rb_node *rb_tree_find_lt(rb_tree *t, rb_key k);
+extern rb_node *rb_tree_find_gt(rb_tree *t, rb_key k);
+extern rb_node *rb_tree_resort(rb_tree *t, rb_node *n);
+extern rb_node *rb_tree_min(rb_tree *t);
+extern rb_node *rb_tree_max(rb_tree *t);
+extern rb_node *rb_tree_succ(rb_node *n);
+extern rb_node *rb_tree_pred(rb_node *n);
+extern void rb_tree_shift_keys(rb_tree *t, ptrdiff_t kshift);
+
+/* To change a key, use rb_tree_find+resort.  Removing a node
+   currently wastes memory unless you change the allocation scheme
+   in redblack.c */
+extern rb_node *rb_tree_remove(rb_tree *t, rb_node *n);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
diff --git a/util/redblack_test.c b/util/redblack_test.c
new file mode 100644 (file)
index 0000000..2d06fd4
--- /dev/null
@@ -0,0 +1,220 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#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;
+     if (*k1 > *k2) return +1;
+     return 0;
+}
+
+int main(int argc, char **argv)
+{
+     int N, M;
+     int *k;
+     double kd;
+     rb_tree t;
+     rb_node *n;
+     int i, j;
+
+     if (argc < 2) {
+         fprintf(stderr, "Usage: redblack_test Ntest [rand seed]\n");
+         return 1;
+     }
+
+     N = atoi(argv[1]);
+     k = (int *) malloc(N * sizeof(int));
+     rb_tree_init(&t, comp);
+
+     srand((unsigned) (argc > 2 ? atoi(argv[2]) : time(NULL)));
+     for (i = 0; i < N; ++i) {
+         double *newk = (double *) malloc(sizeof(double));
+         *newk = (k[i] = rand() % N);
+         if (!rb_tree_insert(&t, newk)) {
+              fprintf(stderr, "error in rb_tree_insert\n");
+              return 1;
+         }
+         if (!rb_tree_check(&t)) {
+              fprintf(stderr, "rb_tree_check_failed after insert!\n");
+              return 1;
+         }
+     }
+     
+     if (t.N != N) {
+         fprintf(stderr, "incorrect N (%d) in tree (vs. %d)\n", t.N, N);
+         return 1;
+     }
+
+     for (i = 0; i < N; ++i) {
+         kd = k[i];
+         if (!rb_tree_find(&t, &kd)) {
+              fprintf(stderr, "rb_tree_find lost %d!\n", k[i]);
+              return 1;
+         }
+     }
+     n = rb_tree_min(&t);
+     for (i = 0; i < N; ++i) {
+         if (!n) {
+              fprintf(stderr, "not enough successors %d\n!", i);
+              return 1;
+         }
+         printf("%d: %g\n", i, n->k[0]);
+         n = rb_tree_succ(n);
+     }
+     if (n) {
+         fprintf(stderr, "too many successors!\n");
+         return 1;
+     }
+     
+     n = rb_tree_max(&t);
+     for (i = 0; i < N; ++i) {
+         if (!n) {
+              fprintf(stderr, "not enough predecessors %d\n!", i);
+              return 1;
+         }
+         printf("%d: %g\n", i, n->k[0]);
+         n = rb_tree_pred(n);
+     }
+     if (n) {
+         fprintf(stderr, "too many predecessors!\n");
+         return 1;
+     }
+     
+     for (M = N; M > 0; --M) {
+         int knew = rand() % N; /* random new key */
+         j = rand() % M; /* random original key to replace */
+         for (i = 0; i < N; ++i)
+              if (k[i] >= 0)
+                   if (j-- == 0)
+                        break;
+         if (i >= N) abort();
+         kd = k[i];
+         if (!(n = rb_tree_find(&t, &kd))) {
+               fprintf(stderr, "rb_tree_find lost %d!\n", k[i]);
+               return 1;
+          }
+         n->k[0] = knew;
+         if (!rb_tree_resort(&t, n)) {
+              fprintf(stderr, "error in rb_tree_resort\n");
+              return 1;
+         }
+         if (!rb_tree_check(&t)) {
+              fprintf(stderr, "rb_tree_check_failed after change %d!\n",
+                      N - M + 1);
+              return 1;
+         }
+         k[i] = -1 - knew;
+     }
+
+     if (t.N != N) {
+         fprintf(stderr, "incorrect N (%d) in tree (vs. %d)\n", t.N, N);
+         return 1;
+     }
+
+     for (i = 0; i < N; ++i)
+         k[i] = -1 - k[i]; /* undo negation above */
+         
+     for (i = 0; i < N; ++i) {
+         rb_node *le, *gt;
+         kd = 0.01 * (rand() % (N * 150) - N*25);
+         le = rb_tree_find_le(&t, &kd);
+         gt = rb_tree_find_gt(&t, &kd);
+         n = rb_tree_min(&t);
+         double lek = le ? le->k[0] : -HUGE_VAL;
+         double gtk = gt ? gt->k[0] : +HUGE_VAL;
+         printf("%g <= %g < %g\n", lek, kd, gtk);
+         if (n->k[0] > kd) {
+              if (le) {
+                   fprintf(stderr, "found invalid le %g for %g\n", lek, kd);
+                   return 1;
+              }
+              if (gt != n) {
+                   fprintf(stderr, "gt is not first node for k=%g\n", kd);
+                   return 1;
+              }
+         }
+         else {
+              rb_node *succ = n;
+              do {
+                   n = succ;
+                   succ = rb_tree_succ(n);
+              } while (succ && succ->k[0] <= kd);
+              if (n != le) {
+                   fprintf(stderr,
+                           "rb_tree_find_le gave wrong result for k=%g\n",kd);
+                   return 1;
+              }
+              if (succ != gt) {
+                   fprintf(stderr,
+                           "rb_tree_find_gt gave wrong result for k=%g\n",kd);
+                   return 1;
+              }
+         }
+     }
+     
+     for (M = N; M > 0; --M) {
+         j = rand() % M;
+         for (i = 0; i < N; ++i)
+              if (k[i] >= 0)
+                   if (j-- == 0)
+                        break;
+         if (i >= N) abort();
+         kd = k[i];
+         if (!(n = rb_tree_find(&t, &kd))) {
+              fprintf(stderr, "rb_tree_find lost %d!\n", k[i]);
+              return 1;
+         }
+         n = rb_tree_remove(&t, n);
+         free(n->k); 
+         free(n);
+         if (!rb_tree_check(&t)) {
+              fprintf(stderr, "rb_tree_check_failed after remove!\n");
+              return 1;
+         }
+         k[i] = -1 - k[i];
+     }
+     
+     if (t.N != 0) {
+         fprintf(stderr, "nonzero N (%d) in tree at end\n", t.N);
+         return 1;
+     }
+
+     rb_tree_destroy(&t);
+     free(k);
+
+     printf("SUCCESS.\n");
+     return 0;
+}
diff --git a/util/rescale.c b/util/rescale.c
new file mode 100644 (file)
index 0000000..ecdbfb9
--- /dev/null
@@ -0,0 +1,82 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <stdlib.h>
+#include "nlopt-util.h"
+
+/* Return a new array of length n (> 0) that gives a rescaling factor
+   for each dimension, or NULL if out of memory, with dx being the
+   array of nonzero initial steps in each dimension.  */
+double *nlopt_compute_rescaling(unsigned n, const double *dx)
+{
+     double *s = (double *) malloc(sizeof(double) * n);
+     unsigned i;
+
+     if (!s) return NULL;
+     for (i = 0; i < n; ++i) s[i] = 1.0; /* default: no rescaling */
+     if (n == 1) return s;
+
+     for (i = 1; i < n && dx[i] == dx[i-1]; ++i) ;
+     if (i < n) { /* unequal initial steps, rescale to make equal to dx[0] */
+         for (i = 1; i < n; ++i)
+              s[i] = dx[i] / dx[0];
+     }
+     return s;
+}
+
+void nlopt_rescale(unsigned n, const double *s, const double *x, double *xs)
+{
+     unsigned i;
+     if (!s) { for (i = 0; i < n;++i) xs[i] = x[i]; }
+     else { for (i = 0; i < n;++i) xs[i] = x[i] / s[i]; }
+}
+
+void nlopt_unscale(unsigned n, const double *s, const double *x, double *xs)
+{
+     unsigned i;
+     if (!s) { for (i = 0; i < n;++i) xs[i] = x[i]; }
+     else { for (i = 0; i < n;++i) xs[i] = x[i] * s[i]; }
+}
+
+/* return a new array of length n equal to the original array
+   x divided by the scale factors s, or NULL on a memory error */
+double *nlopt_new_rescaled(unsigned n, const double *s, const double *x)
+{
+     double *xs = (double *) malloc(sizeof(double) * n);
+     if (!xs) return NULL;
+     nlopt_rescale(n, s, x, xs);
+     return xs;
+}
+
+/* since rescaling can flip the signs of the x components and the bounds,
+   we may have to re-order the bounds in order to ensure that they
+   remain in the correct order */
+void nlopt_reorder_bounds(unsigned n, double *lb, double *ub)
+{
+     unsigned i;
+     for (i = 0; i < n; ++i)
+         if (lb[i] > ub[i]) {
+              double t = lb[i];
+              lb[i] = ub[i];
+              ub[i] = t;
+         }
+}
diff --git a/util/soboldata.h b/util/soboldata.h
new file mode 100644 (file)
index 0000000..19efa5b
--- /dev/null
@@ -0,0 +1,880 @@
+/* Copyright (c) 2007 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#ifndef SOBOLSEQ_H
+#define SOBOLSEQ_H
+
+/* Data on the primitive binary polynomials (a) and the corresponding
+   starting values m, for Sobol sequences in up to 1111 dimensions,
+   taken from:
+        P. Bratley and B. L. Fox, Algorithm 659, ACM Trans.
+       Math. Soft. 14 (1), 88-100 (1988),
+   as modified by:
+        S. Joe and F. Y. Kuo, ACM Trans. Math. Soft 29 (1), 49-57 (2003). */
+
+#define MAXDIM 1111
+#define MAXDEG 12
+
+/* successive primitive binary-coefficient polynomials p(z)
+   = a_0 + a_1 z + a_2 z^2 + ... a_31 z^31, where a_i is the 
+     i-th bit of sobol_a[j] for the j-th polynomial. */
+static const uint32_t sobol_a[MAXDIM-1] = {
+     3,7,11,13,19,25,37,59,47,61,55,41,67,97,91,
+     109,103,115,131,193,137,145,143,241,157,185,167,229,171,213,
+     191,253,203,211,239,247,285,369,299,301,333,351,355,357,361,
+     391,397,425,451,463,487,501,529,539,545,557,563,601,607,617,
+     623,631,637,647,661,675,677,687,695,701,719,721,731,757,761,
+     787,789,799,803,817,827,847,859,865,875,877,883,895,901,911,
+     949,953,967,971,973,981,985,995,1001,1019,1033,1051,1063,
+     1069,1125,1135,1153,1163,1221,1239,1255,1267,1279,1293,1305,
+     1315,1329,1341,1347,1367,1387,1413,1423,1431,1441,1479,1509,
+     1527,1531,1555,1557,1573,1591,1603,1615,1627,1657,1663,1673,
+     1717,1729,1747,1759,1789,1815,1821,1825,1849,1863,1869,1877,
+     1881,1891,1917,1933,1939,1969,2011,2035,2041,2053,2071,2091,
+     2093,2119,2147,2149,2161,2171,2189,2197,2207,2217,2225,2255,
+     2257,2273,2279,2283,2293,2317,2323,2341,2345,2363,2365,2373,
+     2377,2385,2395,2419,2421,2431,2435,2447,2475,2477,2489,2503,
+     2521,2533,2551,2561,2567,2579,2581,2601,2633,2657,2669,
+     2681,2687,2693,2705,2717,2727,2731,2739,
+     2741,2773,2783,2793,2799,2801,2811,2819,2825,2833,2867,2879,
+     2881,2891,2905,2911,2917,2927,2941,2951,2955,2963,2965,2991,
+     2999,3005,3017,3035,3037,3047,3053,3083,3085,3097,3103,3159,
+     3169,3179,3187,3205,3209,3223,3227,3229,3251,3263,3271,3277,
+     3283,3285,3299,3305,3319,3331,3343,3357,3367,3373,3393,3399,
+     3413,3417,3427,3439,3441,3475,3487,3497,3515,3517,3529,3543,
+     3547,3553,3559,3573,3589,3613,3617,3623,3627,3635,3641,3655,
+     3659,3669,3679,3697,3707,3709,3713,3731,3743,3747,3771,3791,
+     3805,3827,3833,3851,3865,3889,3895,3933,3947,3949,3957,3971,
+     3985,3991,3995,4007,4013,4021,4045,4051,4069,4073,4179,4201,
+     4219,4221,4249,4305,4331,4359,4383,4387,4411,4431,4439,4449,
+     4459,4485,4531,4569,4575,4621,4663,4669,4711,4723,4735,4793,
+     4801,4811,4879,4893,4897,4921,4927,4941,4977,5017,5027,5033,
+     5127,5169,5175,5199,5213,5223,5237,5287,5293,5331,5391,5405,
+     5453,5523,5573,5591,5597,5611,5641,5703,5717,5721,5797,5821,
+     5909,5913,
+     5955,5957,6005,6025,6061,6067,6079,6081,
+     6231,6237,6289,6295,6329,6383,6427,6453,6465,6501,6523,6539,
+     6577,6589,6601,6607,6631,6683,6699,6707,6761,6795,6865,6881,
+     6901,6923,6931,6943,6999,7057,7079,7103,7105,7123,7173,7185,
+     7191,7207,7245,7303,7327,7333,7355,7365,7369,7375,7411,7431,
+     7459,7491,7505,7515,7541,7557,7561,7701,7705,7727,7749,7761,
+     7783,7795,7823,7907,7953,7963,7975,8049,8089,8123,8125,8137,
+     8219,8231,8245,8275,8293,8303,8331,8333,8351,8357,8367,8379,
+     8381,8387,8393,8417,8435,8461,8469,8489,8495,8507,8515,8551,
+     8555,8569,8585,8599,8605,8639,8641,8647,8653,8671,8675,8689,
+     8699,8729,8741,8759,8765,8771,8795,8797,8825,8831,8841,8855,
+     8859,8883,8895,8909,8943,8951,8955,8965,8999,9003,9031,9045,
+     9049,9071,9073,9085,9095,9101,9109,9123,9129,9137,9143,9147,
+     9185,9197,9209,9227,9235,9247,9253,9257,9277,9297,9303,9313,
+     9325,9343,9347,9371,9373,9397,9407,9409,9415,9419,9443,9481,
+     9495,9501,9505,9517,9529,9555,9557,9571,9585,9591,9607,9611,
+     9621,9625,
+     9631,9647,9661,9669,9679,9687,9707,9731,
+     9733,9745,9773,9791,9803,9811,9817,9833,9847,9851,9863,9875,
+     9881,9905,9911,9917,9923,9963,9973,10003,10025,10043,10063,
+     10071,10077,10091,10099,10105,10115,10129,10145,10169,10183,
+     10187,10207,10223,10225,10247,10265,10271,10275,10289,10299,
+     10301,10309,10343,10357,10373,10411,10413,10431,10445,10453,
+     10463,10467,10473,10491,10505,10511,10513,10523,10539,10549,
+     10559,10561,10571,10581,10615,10621,10625,10643,10655,10671,
+     10679,10685,10691,10711,10739,10741,10755,10767,10781,10785,
+     10803,10805,10829,10857,10863,10865,10875,10877,10917,10921,
+     10929,10949,10967,10971,10987,10995,11009,11029,11043,11045,
+     11055,11063,11075,11081,11117,11135,11141,11159,11163,11181,
+     11187,11225,11237,11261,11279,11297,11307,11309,11327,11329,
+     11341,11377,11403,11405,11413,11427,11439,11453,11461,11473,
+     11479,11489,11495,11499,11533,11545,11561,11567,11575,11579,
+     11589,11611,11623,11637,11657,11663,11687,11691,11701,11747,
+     11761,11773,11783,11795,11797,11817,11849,11855,11867,11869,
+     11873,11883,11919,
+     11921,11927,11933,11947,11955,11961,
+     11999,12027,12029,12037,12041,12049,12055,12095,12097,12107,
+     12109,12121,12127,12133,12137,12181,12197,12207,12209,12239,
+     12253,12263,12269,12277,12287,12295,12309,12313,12335,12361,
+     12367,12391,12409,12415,12433,12449,12469,12479,12481,12499,
+     12505,12517,12527,12549,12559,12597,12615,12621,12639,12643,
+     12657,12667,12707,12713,12727,12741,12745,12763,12769,12779,
+     12781,12787,12799,12809,12815,12829,12839,12857,12875,12883,
+     12889,12901,12929,12947,12953,12959,12969,12983,12987,12995,
+     13015,13019,13031,13063,13077,13103,13137,13149,13173,13207,
+     13211,13227,13241,13249,13255,13269,13283,13285,13303,13307,
+     13321,13339,13351,13377,13389,13407,13417,13431,13435,13447,
+     13459,13465,13477,13501,13513,13531,13543,13561,13581,13599,
+     13605,13617,13623,13637,13647,13661,13677,13683,13695,13725,
+     13729,13753,13773,13781,13785,13795,13801,13807,13825,13835,
+     13855,13861,13871,13883,13897,13905,13915,13939,13941,13969,
+     13979,13981,13997,14027,14035,14037,14051,14063,14085,14095,
+     14107,14113,14125,14137,14145,
+     14151,14163,14193,14199,14219,14229,
+     14233,14243,14277,14287,14289,14295,14301,14305,14323,14339,
+     14341,14359,14365,14375,14387,14411,14425,14441,14449,14499,
+     14513,14523,14537,14543,14561,14579,14585,14593,14599,14603,
+     14611,14641,14671,14695,14701,14723,14725,14743,14753,14759,
+     14765,14795,14797,14803,14831,14839,14845,14855,14889,14895,
+     14909,14929,14941,14945,14951,14963,14965,14985,15033,15039,
+     15053,15059,15061,15071,15077,15081,15099,15121,15147,15149,
+     15157,15167,15187,15193,15203,15205,15215,15217,15223,15243,
+     15257,15269,15273,15287,15291,15313,15335,15347,15359,15373,
+     15379,15381,15391,15395,15397,15419,15439,15453,15469,15491,
+     15503,15517,15527,15531,15545,15559,15593,15611,15613,15619,
+     15639,15643,15649,15661,15667,15669,15681,15693,15717,15721,
+     15741,15745,15765,15793,15799,15811,15825,15835,15847,15851,
+     15865,15877,15881,15887,15899,15915,15935,15937,15955,15973,
+     15977,16011,16035,16061,16069,16087,16093,16097,16121,16141,
+     16153,16159,16165,16183,16189,16195,16197,16201,16209,16215,
+     16225,16259,16265,16273,16299,
+     16309,16355,16375,16381,
+};
+
+/* starting direction #'s m[i] = sobol_minit[i][j] for i=0..d of the
+ * degree-d primitive polynomial sobol_a[j]. */
+static const uint32_t sobol_minit[MAXDEG+1][MAXDIM-1] = {
+     /* [0][*] */
+     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
+     /* [1][*] */
+     { 0,
+       1,3,1,3,1,3,3,1,3,1,3,1,3,1,1,3,1,3,1,3,
+     1,3,3,1,1,1,3,1,3,1,3,3,1,3,1,1,1,3,1,3,1,1,1,3,3,1,3,3,1,1,
+     3,3,1,3,3,3,1,3,1,3,1,1,3,3,1,1,1,1,3,1,1,3,1,1,1,3,3,1,3,3,
+     1,3,3,3,1,3,3,3,1,3,3,1,3,3,3,1,3,1,3,1,1,3,3,1,3,3,1,1,1,3,
+     3,1,3,3,1,3,1,1,3,3,3,1,1,1,3,1,1,3,1,1,3,3,1,3,1,3,3,3,3,1,
+     1,1,3,3,1,1,3,1,1,1,1,1,1,3,1,3,1,1,1,3,1,3,1,3,3,3,1,1,3,3,
+     1,3,1,3,1,1,3,1,3,1,3,1,3,1,1,1,3,3,1,3,3,1,3,1,1,1,3,1,3,1,
+     1,3,1,1,3,3,1,1,3,3,3,1,3,3,3,1,3,1,3,1,1,1,3,1,1,1,3,1,1,1,
+     1,1,3,3,3,1,1,1,1,3,3,3,1,3,3,1,1,1,1,3,1,1,3,1,3,3,1,1,3,3,
+     1,1,1,1,3,1,3,3,1,3,3,1,1,1,3,3,3,1,3,3,1,3,3,1,3,1,3,3,3,1,
+     3,1,1,3,1,3,1,1,1,3,3,3,1,1,3,1,3,1,1,1,1,1,1,3,1,1,3,1,3,3,
+     1,1,1,1,3,1,3,1,3,1,1,1,1,3,3,1,1,1,1,1,3,3,3,1,1,3,3,3,3,3,
+     1,3,3,1,3,3,3,3,1,1,1,1,1,1,3,1,1,3,1,1,1,3,1,1,1,3,3,3,1,3,
+     1,1,3,3,3,1,3,3,1,3,1,3,3,1,3,3,3,1,1,
+     3,3,1,3,1,3,1,1,1,3,3,3,3,1,3,1,1,3,1,
+     3,1,1,1,3,1,3,1,3,1,3,3,3,3,3,3,3,3,1,3,3,3,3,3,1,3,1,3,3,3,
+     1,3,1,3,1,3,3,1,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,3,3,1,1,3,3,1,
+     1,1,3,3,1,1,3,3,3,3,1,1,3,1,3,3,1,3,3,1,1,1,3,3,3,1,1,3,3,3,
+     3,3,1,1,1,3,1,3,3,1,3,3,3,3,1,1,3,1,1,3,1,3,1,3,1,3,3,1,1,3,
+     3,1,3,3,1,3,3,1,1,3,1,3,3,1,1,3,1,3,1,3,1,1,3,3,1,1,1,3,3,1,
+     3,1,1,3,3,1,1,3,1,3,1,1,1,1,1,3,1,1,1,1,3,1,3,1,1,3,3,1,1,3,
+     1,3,1,3,3,3,1,3,3,3,1,1,3,3,3,1,1,1,1,3,1,3,1,3,1,1,3,3,1,1,
+     1,3,3,1,3,1,3,1,1,1,1,1,1,3,1,3,3,1,3,3,3,1,3,1,1,3,3,1,1,3,
+     3,1,1,1,3,1,3,3,1,1,3,1,1,3,1,3,1,1,1,3,3,3,3,1,1,3,3,1,1,1,
+     1,3,1,1,3,3,3,1,1,3,3,1,3,3,1,1,3,3,3,3,3,3,3,1,3,3,1,3,1,3,
+     1,1,3,3,1,1,1,3,1,3,3,1,3,3,1,3,1,1,3,3,3,1,1,1,3,1,1,1,3,3,
+     3,1,3,3,1,3,1,1,3,3,3,1,3,3,1,1,1,3,1,3,3,3,3,3,3,3,3,1,3,3,
+     1,3,1,1,3,3,3,1,3,3,3,3,3,1,3,3,3,1,1,1,
+     3,3,1,3,3,1,3,1,3,1,3,1,3,3,3,3,3,3,
+     1,1,3,1,3,1,1,1,1,1,3,1,1,1,3,1,3,1,1,3,3,3,1,3,1,3,1,1,3,1,
+     3,3,1,3,1,3,3,1,3,3,1,3,3,3,3,3,3,1,3,1,1,3,3,3,1,1,3,3,3,3,
+     3,3,3,1,3,3,3,3,1,3,1,3,3,3,1,3,1,3,1,1,1,3,3,1,3,1,1,3,3,1,
+     3,1,1,1,1,3,1,3,1,1,3,1,3,1,3,3,3,3,3,3,1,3,3,3,3,1,3,3,1,3,
+     3,3,3,3,1,1,1,1,3,3,3,1,3,3,1,1,3,3,1,1,3,3,1,3,1,1,3,1,3,3,
+     3,3,3,1,3,1,1,3,3,3,3,1,3,1,1,3,3,3,3,3,3,1,1,3,1,3,1,1,3,1,
+     1,1,1,3,3,1,1,3,1,1,1,3,1,3,1,1,3,3,1,3,1,1,3,3,3,3,3,1,3,1,
+     1,1,3,1,1,1,3,1,1,3,1,3,3,3,3,3,1,1,1,3,3,3,3,1,3,3,3,3,1,1,
+     3,3,3,1,3,1,1,3,3,1,3,3,1,1,1,1,1,3,1,1,3,3,1,1,1,3,1,1,3,3,
+     1,3,3,3,3,3,3,3,3,1,1,3,3,1,1,3,1,3,3,3,3,3,1},
+     /* [2][*] */
+     { 0,0,
+       7,5,1,3,3,7,5,5,7,7,1,3,3,7,5,1,1,5,3,7,
+     1,7,5,1,3,7,7,1,1,1,5,7,7,5,1,3,3,7,5,5,5,3,3,3,1,1,5,1,1,5,
+     3,3,3,3,1,3,7,5,7,3,7,1,3,3,5,1,3,5,5,7,7,7,1,1,3,3,1,1,5,1,
+     5,7,5,1,7,5,3,3,1,5,7,1,7,5,1,7,3,1,7,1,7,3,3,5,7,3,3,5,1,3,
+     3,1,3,5,1,3,3,3,7,1,1,7,3,1,3,7,5,5,7,5,5,3,1,3,3,3,1,3,3,7,
+     3,3,1,7,5,1,7,7,5,7,5,1,3,1,7,3,7,3,5,7,3,1,3,3,3,1,5,7,3,3,
+     7,7,7,5,3,1,7,1,3,7,5,3,3,3,7,1,1,3,1,5,7,1,3,5,3,5,3,3,7,5,
+     5,3,3,1,3,7,7,7,1,5,7,1,3,1,1,7,1,3,1,7,1,5,3,5,3,1,1,5,5,3,
+     3,5,7,1,5,3,7,7,3,5,3,3,1,7,3,1,3,5,7,1,3,7,1,5,1,3,1,5,3,1,
+     7,1,5,5,5,3,7,1,1,7,3,1,1,7,5,7,5,7,7,3,7,1,3,7,7,3,5,1,1,7,
+     1,5,5,5,1,5,1,7,5,5,7,1,1,7,1,7,7,1,1,3,3,3,7,7,5,3,7,3,1,3,
+     7,5,3,3,5,7,1,1,5,5,7,7,1,1,1,1,5,5,5,7,5,7,1,1,3,5,1,3,3,7,
+     3,7,5,3,5,3,1,7,1,7,7,1,1,7,7,7,5,5,1,1,7,5,5,7,5,1,1,5,5,5,
+     5,5,5,1,3,1,5,7,3,3,5,7,3,7,1,7,7,1,3,
+     5,1,5,5,3,7,3,7,7,5,7,5,7,1,1,5,3,5,1,
+     5,3,7,1,5,7,7,3,5,1,3,5,1,5,3,3,3,7,3,5,1,3,7,7,3,7,5,3,3,1,
+     7,5,1,1,3,7,1,7,1,7,3,7,3,5,7,3,5,3,1,1,1,5,7,7,3,3,1,1,1,5,
+     5,7,3,1,1,3,3,7,3,3,5,1,3,7,3,3,7,3,5,7,5,7,7,3,3,5,1,3,5,3,
+     1,3,5,1,1,3,7,7,1,5,1,3,7,3,7,3,5,1,7,1,1,3,5,3,7,1,5,5,1,1,
+     3,1,3,3,7,1,7,3,1,7,3,1,7,3,5,3,5,7,3,3,3,5,1,7,7,1,3,1,3,7,
+     7,1,3,7,3,1,5,3,1,1,1,5,3,3,7,1,5,3,5,1,3,1,3,1,5,7,7,1,1,5,
+     3,1,5,1,1,7,7,3,5,5,1,7,1,5,1,1,3,1,5,7,5,7,7,1,5,1,1,3,5,1,
+     5,5,3,1,3,1,5,5,3,3,3,3,1,1,3,1,3,5,5,7,5,5,7,5,7,1,3,7,7,3,
+     5,5,7,5,5,3,3,3,1,7,1,5,5,5,3,3,5,1,3,1,3,3,3,7,1,7,7,3,7,1,
+     1,5,7,1,7,1,7,7,1,3,7,5,1,3,5,5,5,1,1,7,1,7,1,7,7,3,1,1,5,1,
+     5,1,5,3,5,5,5,5,5,3,3,7,3,3,5,5,3,7,1,5,7,5,1,5,5,3,5,5,7,5,
+     3,5,5,5,1,5,5,5,5,1,3,5,3,1,7,5,5,7,1,5,3,3,1,5,3,7,1,7,5,1,
+     1,3,1,1,7,1,5,5,3,7,3,7,5,3,1,1,3,1,3,5,
+     5,7,5,3,7,7,7,3,7,3,7,1,3,1,7,7,1,7,
+     3,7,3,7,3,7,3,5,1,1,7,3,1,5,5,7,1,5,5,5,7,1,5,5,1,5,5,3,1,3,
+     1,7,3,1,3,5,7,7,7,1,1,7,3,1,5,5,5,1,1,1,1,1,5,3,5,1,3,5,3,1,
+     1,1,1,3,7,3,7,5,7,1,5,5,7,5,3,3,7,5,3,1,1,3,1,3,1,1,3,7,1,7,
+     1,1,5,1,7,5,3,7,3,5,3,1,1,5,5,1,7,7,3,7,3,7,1,5,1,5,3,7,3,5,
+     7,7,7,3,3,1,1,5,5,3,7,1,1,1,3,5,3,1,1,3,3,7,5,1,1,3,7,1,5,7,
+     3,7,5,5,7,3,5,3,1,5,3,1,1,7,5,1,7,3,7,5,1,7,1,7,7,1,1,7,1,5,
+     5,1,1,7,5,7,1,5,3,5,3,3,7,1,5,1,1,5,5,3,3,7,5,5,1,1,1,3,1,5,
+     7,7,1,7,5,7,3,7,3,1,3,7,3,1,5,5,3,5,1,3,5,5,5,1,1,7,7,1,5,5,
+     1,3,5,1,5,3,5,3,3,7,5,7,3,7,3,1,3,7,7,3,3,1,1,3,3,3,3,3,5,5,
+     3,3,3,1,3,5,7,7,1,5,7,3,7,1,1,3,5,7,5,3,3,3},
+     /* [3][*] */
+     { 0,0,0,0,
+       1,7,9,13,11,1,3,7,9,5,13,13,11,3,15,5,3,
+     15,7,9,13,9,1,11,7,5,15,1,15,11,5,11,1,7,9,7,7,1,15,15,15,13,
+     3,3,15,5,9,7,13,3,7,5,11,9,1,9,1,5,7,13,9,9,1,7,3,5,1,11,11,
+     13,7,7,9,9,1,1,3,9,15,1,5,13,1,9,9,9,9,9,13,11,3,5,11,11,13,
+     5,3,15,1,11,11,7,13,15,11,13,9,11,15,15,13,3,15,7,9,11,13,11,
+     9,9,5,13,9,1,13,7,7,7,7,7,5,9,7,13,11,9,11,15,3,13,11,1,11,3,
+     3,9,11,1,7,1,15,15,3,1,9,1,7,13,11,3,13,11,7,3,3,5,13,11,5,
+     11,1,3,9,7,15,7,5,13,7,9,13,15,13,9,7,15,7,9,5,11,11,13,13,9,
+     3,5,13,9,11,15,11,7,1,7,13,3,13,3,13,9,15,7,13,13,3,13,15,15,
+     11,9,13,9,15,1,1,15,11,11,7,1,11,13,9,13,3,5,11,13,9,9,13,1,
+     11,15,13,3,13,7,15,1,15,3,3,11,7,13,7,7,9,7,5,15,9,5,5,7,15,
+     13,15,5,15,5,3,1,11,7,1,5,7,9,3,11,1,15,1,3,15,11,13,5,13,1,
+     7,1,15,7,5,1,1,15,13,11,11,13,5,11,7,9,7,1,5,3,9,5,5,11,5,1,
+     7,1,11,7,9,13,15,13,3,1,11,13,15,1,1,11,9,13,3,13,11,15,13,9,
+     9,9,5,5,5,5,1,15,5,9,
+     11,7,15,5,3,13,5,3,11,5,1,11,13,9,11,
+     3,7,13,15,1,7,11,1,13,1,15,1,9,7,3,9,11,1,9,13,13,3,11,7,9,1,
+     7,15,9,1,5,13,5,11,3,9,15,11,13,5,1,7,7,5,13,7,7,9,5,11,11,1,
+     1,15,3,13,9,13,9,9,11,5,5,13,15,3,9,15,3,11,11,15,15,3,11,15,
+     15,3,1,3,1,3,3,1,3,13,1,11,5,15,7,15,9,1,7,1,9,11,15,1,13,9,
+     13,11,7,3,7,3,13,7,9,7,7,3,3,9,9,7,5,11,13,13,7,7,15,9,5,5,3,
+     3,13,3,9,3,1,11,1,3,11,15,11,11,11,9,13,7,9,15,9,11,1,3,3,9,
+     7,15,13,13,7,15,9,13,9,15,13,15,9,13,1,11,7,11,3,13,5,1,7,15,
+     3,13,7,13,13,11,3,5,3,13,11,9,9,3,11,11,7,9,13,11,7,15,13,7,
+     5,3,1,5,15,15,3,11,1,7,3,15,11,5,5,3,5,5,1,15,5,1,5,3,7,5,11,
+     3,13,9,13,15,5,3,5,9,5,3,11,1,13,9,15,3,5,11,9,1,3,15,9,9,9,
+     11,7,5,13,1,15,3,13,9,13,5,1,5,1,13,13,7,7,1,9,5,11,9,11,13,
+     3,15,15,13,15,7,5,7,9,7,9,9,9,11,9,3,11,15,13,13,5,9,15,1,1,
+     9,5,13,3,13,15,3,1,3,11,13,1,15,9,9,3,1,9,1,9,1,13,11,15,7,
+     11,15,13,15,1,9,9,7,
+     3,5,11,7,3,9,5,15,7,5,3,13,7,1,1,9,
+     15,15,15,11,3,5,15,13,7,15,15,11,11,9,5,15,9,7,3,13,1,1,5,1,
+     3,1,7,1,1,5,1,11,11,9,9,5,13,7,7,7,1,1,9,9,11,11,15,7,5,5,3,
+     11,1,3,7,13,7,7,7,3,15,15,11,9,3,9,3,15,13,5,3,3,3,5,9,15,9,
+     9,1,5,9,9,15,5,15,7,9,1,9,9,5,11,5,15,15,11,7,7,7,1,1,11,11,
+     13,15,3,13,5,1,7,1,11,3,13,15,3,5,3,5,7,3,9,9,5,1,7,11,9,3,5,
+     11,13,13,13,9,15,5,7,1,15,11,9,15,15,13,13,13,1,11,9,15,9,5,
+     15,5,7,3,11,3,15,7,13,11,7,3,7,13,5,13,15,5,13,9,1,15,11,5,5,
+     1,11,3,3,7,1,9,7,15,9,9,3,11,15,7,1,3,1,1,1,9,1,5,15,15,7,5,
+     5,7,9,7,15,13,13,11,1,9,11,1,13,1,7,15,15,5,5,1,11,3,9,11,9,
+     9,9,1,9,3,5,15,1,1,9,7,3,3,1,9,9,11,9,9,13,13,3,13,11,13,5,1,
+     5,5,9,9,3,13,13,9,15,9,11,7,11,9,13,9,1,15,9,7,7,1,7,9,9,15,
+     1,11,1,13,13,15,9,13,7,15,3,9,3,1,13,7,5,9,3,1,7,1,1,13,3,3,
+     11,1,7,13,15,15,5,7,13,13,15,11,13,1,13,13,3,9,15,15,11,15,9,
+     15,1,13,15,1,1,5,
+     11,5,1,11,11,5,3,9,1,3,5,13,9,7,7,1,
+     9,9,15,7,5,5,15,13,9,7,13,3,13,11,13,7,9,13,13,13,15,9,5,5,3,
+     3,3,1,3,15},
+     /* [4][*] */
+     { 0,0,0,0,0,0,
+       9,3,27,15,29,21,23,19,11,25,7,13,17,1,
+     25,29,3,31,11,5,23,27,19,21,5,1,17,13,7,15,9,31,25,3,5,23,7,
+     3,17,23,3,3,21,25,25,23,11,19,3,11,31,7,9,5,17,23,17,17,25,
+     13,11,31,27,19,17,23,7,5,11,19,19,7,13,21,21,7,9,11,1,5,21,
+     11,13,25,9,7,7,27,15,25,15,21,17,19,19,21,5,11,3,5,29,31,29,
+     5,5,1,31,27,11,13,1,3,7,11,7,3,23,13,31,17,1,27,11,25,1,23,
+     29,17,25,7,25,27,17,13,17,23,5,17,5,13,11,21,5,11,5,9,31,19,
+     17,9,9,27,21,15,15,1,1,29,5,31,11,17,23,19,21,25,15,11,5,5,1,
+     19,19,19,7,13,21,17,17,25,23,19,23,15,13,5,19,25,9,7,3,21,17,
+     25,1,27,25,27,25,9,13,3,17,25,23,9,25,9,13,17,17,3,15,7,7,29,
+     3,19,29,29,19,29,13,15,25,27,1,3,9,9,13,31,29,31,5,15,29,1,
+     19,5,9,19,5,15,3,5,7,15,17,17,23,11,9,23,19,3,17,1,27,9,9,17,
+     13,25,29,23,29,11,31,25,21,29,19,27,31,3,5,3,3,13,21,9,29,3,
+     17,11,11,9,21,19,7,17,31,25,1,27,5,15,27,29,29,29,25,27,25,3,
+     21,17,25,13,15,17,13,23,9,3,11,7,9,9,7,17,7,1,
+     27,1,9,5,31,21,25,25,21,11,1,23,19,27,
+     15,3,5,23,9,25,7,29,11,9,13,5,11,1,3,31,27,3,17,27,11,13,15,
+     29,15,1,15,23,25,13,21,15,3,29,29,5,25,17,11,7,15,5,21,7,31,
+     13,11,23,5,7,23,27,21,29,15,7,27,27,19,7,15,27,27,19,19,9,15,
+     1,3,29,29,5,27,31,9,1,7,3,19,19,29,9,3,21,31,29,25,1,3,9,27,
+     5,27,25,21,11,29,31,27,21,29,17,9,17,13,11,25,15,21,11,19,31,
+     3,19,5,3,3,9,13,13,3,29,7,5,9,23,13,21,23,21,31,11,7,7,3,23,
+     1,23,5,9,17,21,1,17,29,7,5,17,13,25,17,9,19,9,5,7,21,19,13,9,
+     7,3,9,3,15,31,29,29,25,13,9,21,9,31,7,15,5,31,7,15,27,25,19,
+     9,9,25,25,23,1,9,7,11,15,19,15,27,17,11,11,31,13,25,25,9,7,
+     13,29,19,5,19,31,25,13,25,15,5,9,29,31,9,29,27,25,27,11,17,5,
+     17,3,23,15,9,9,17,17,31,11,19,25,13,23,15,25,21,31,19,3,11,
+     25,7,15,19,7,5,3,13,13,1,23,5,25,11,25,15,13,21,11,23,29,5,
+     17,27,9,19,15,5,29,23,19,1,27,3,23,21,19,27,11,17,13,27,11,
+     31,23,5,9,21,31,29,11,21,17,15,7,15,7,9,21,27,25,
+     29,11,3,21,13,23,19,27,17,29,25,17,9,
+     1,19,23,5,23,1,17,17,13,27,23,7,7,11,13,17,13,11,21,13,23,1,
+     27,13,9,7,1,27,29,5,13,25,21,3,31,15,13,3,19,13,1,27,15,17,1,
+     3,13,13,13,31,29,27,7,7,21,29,15,17,17,21,19,17,3,15,5,27,27,
+     3,31,31,7,21,3,13,11,17,27,25,1,9,7,29,27,21,23,13,25,29,15,
+     17,29,9,15,3,21,15,17,17,31,9,9,23,19,25,3,1,11,27,29,1,31,
+     29,25,29,1,23,29,25,13,3,31,25,5,5,11,3,21,9,23,7,11,23,11,1,
+     1,3,23,25,23,1,23,3,27,9,27,3,23,25,19,29,29,13,27,5,9,29,29,
+     13,17,3,23,19,7,13,3,19,23,5,29,29,13,13,5,19,5,17,9,11,11,
+     29,27,23,19,17,25,13,1,13,3,11,1,17,29,1,13,17,9,17,21,1,11,
+     1,1,25,5,7,29,29,19,19,1,29,13,3,1,31,15,13,3,1,11,19,5,29,
+     13,29,23,3,1,31,13,19,17,5,5,1,29,23,3,19,25,19,27,9,27,13,
+     15,29,23,13,25,25,17,19,17,15,27,3,25,17,27,3,27,31,23,13,31,
+     11,15,7,21,19,27,19,21,29,7,31,13,9,9,7,21,13,11,9,11,29,19,
+     11,19,21,5,29,13,7,19,19,27,23,31,1,27,21,7,3,7,11,
+     23,13,29,11,31,19,1,5,5,11,5,3,27,5,
+     7,11,31,1,27,31,31,23,5,21,27,9,25,3,15,19,1,19,9,5,25,21,15,
+     25,29,15,21,11,19,15,3,7,13,11,25,17,1,5,31,13,29,23,9,5,29,
+     7,17,27,7,17,31,9,31,9,9,7,21,3,3,3,9,11,21,11,31,9,25,5,1,
+     31,13,29,9,29,1,11,19,7,27,13,31,7,31,7,25,23,21,29,11,11,13,
+     11,27,1,23,31,21,23,21,19,31,5,31,25,25,19,17,11,25,7,13,1,
+     29,17,23,15,7,29,17,13,3,17},
+     /* [5][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,
+       37,33,7,5,11,39,63,59,17,15,23,29,3,21,
+     13,31,25,9,49,33,19,29,11,19,27,15,25,63,55,17,63,49,19,41,
+     59,3,57,33,49,53,57,57,39,21,7,53,9,55,15,59,19,49,31,3,39,5,
+     5,41,9,19,9,57,25,1,15,51,11,19,61,53,29,19,11,9,21,19,43,13,
+     13,41,25,31,9,11,19,5,53,37,7,51,45,7,7,61,23,45,7,59,41,1,
+     29,61,37,27,47,15,31,35,31,17,51,13,25,45,5,5,33,39,5,47,29,
+     35,47,63,45,37,47,59,21,59,33,51,9,27,13,25,43,3,17,21,59,61,
+     27,47,57,11,17,39,1,63,21,59,17,13,31,3,31,7,9,27,37,23,31,9,
+     45,43,31,63,21,39,51,27,7,53,11,1,59,39,23,49,23,7,55,59,3,
+     19,35,13,9,13,15,23,9,7,43,55,3,19,9,27,33,27,49,23,47,19,7,
+     11,55,27,35,5,5,55,35,37,9,33,29,47,25,11,47,53,61,59,3,53,
+     47,5,19,59,5,47,23,45,53,3,49,61,47,39,29,17,57,5,17,31,23,
+     41,39,5,27,7,29,29,33,31,41,31,29,17,29,29,9,9,31,27,53,35,5,
+     61,1,49,13,57,29,5,21,43,25,57,49,37,27,11,61,37,49,5,63,63,
+     3,45,37,63,21,21,19,27,59,21,45,23,13,15,3,43,63,39,19,
+     63,31,41,41,15,43,63,53,1,63,31,7,17,
+     11,61,31,51,37,29,59,25,63,59,47,15,27,19,29,45,35,55,39,19,
+     43,21,19,13,17,51,37,5,33,35,49,25,45,1,63,47,9,63,15,25,25,
+     15,41,13,3,19,51,49,37,25,49,13,53,47,23,35,29,33,21,35,23,3,
+     43,31,63,9,1,61,43,3,11,55,11,35,1,63,35,49,19,45,9,57,51,1,
+     47,41,9,11,37,19,55,23,55,55,13,7,47,37,11,43,17,3,25,19,55,
+     59,37,33,43,1,5,21,5,63,49,61,21,51,15,19,43,47,17,9,53,45,
+     11,51,25,11,25,47,47,1,43,29,17,31,15,59,27,63,11,41,51,29,7,
+     27,63,31,43,3,29,39,3,59,59,1,53,63,23,63,47,51,23,61,39,47,
+     21,39,15,3,9,57,61,39,37,21,51,1,23,43,27,25,11,13,21,43,7,
+     11,33,55,1,37,35,27,61,39,5,19,61,61,57,59,21,59,61,57,25,55,
+     27,31,41,33,63,19,57,35,13,63,35,17,11,11,49,41,55,5,45,17,
+     35,5,31,31,37,17,45,51,1,39,49,55,19,41,13,5,51,5,49,1,21,13,
+     17,59,51,11,3,61,1,33,37,33,61,25,27,59,7,49,13,63,3,33,3,15,
+     9,13,35,39,11,59,59,1,57,11,5,57,13,31,13,11,55,45,9,55,55,
+     19,25,41,23,45,29,63,59,27,39,21,37,7,
+     61,49,35,39,9,29,7,25,23,57,5,19,15,33,49,37,25,17,45,29,15,
+     25,3,3,49,11,39,15,19,57,39,15,11,3,57,31,55,61,19,5,41,35,
+     59,61,39,41,53,53,63,31,9,59,13,35,55,41,49,5,41,25,27,43,5,
+     5,43,5,5,17,5,15,27,29,17,9,3,55,31,1,45,45,13,57,17,3,61,15,
+     49,15,47,9,37,45,9,51,61,21,33,11,21,63,63,47,57,61,49,9,59,
+     19,29,21,23,55,23,43,41,57,9,39,27,41,35,61,29,57,63,21,31,
+     59,35,49,3,49,47,49,33,21,19,21,35,11,17,37,23,59,13,37,35,
+     55,57,1,29,45,11,1,15,9,33,19,53,43,39,23,7,13,13,1,19,41,55,
+     1,13,15,59,55,15,3,57,37,31,17,1,3,21,29,25,55,9,37,33,53,41,
+     51,19,57,13,63,43,19,7,13,37,33,19,15,63,51,11,49,23,57,47,
+     51,15,53,41,1,15,37,61,11,35,29,33,23,55,11,59,19,61,61,45,
+     13,49,13,63,5,61,5,31,17,61,63,13,27,57,1,21,5,11,39,57,51,
+     53,39,25,41,39,37,23,31,25,33,17,57,29,27,23,47,41,29,19,47,
+     41,25,5,51,43,39,29,7,31,45,51,49,55,17,43,49,45,9,29,3,5,47,
+     9,15,19,
+     51,45,57,63,9,21,59,3,9,13,45,23,15,
+     31,21,15,51,35,9,11,61,23,53,29,51,45,31,29,5,35,29,53,35,17,
+     59,55,27,51,59,27,47,15,29,37,7,49,55,5,19,45,29,19,57,33,53,
+     45,21,9,3,35,29,43,31,39,3,45,1,41,29,5,59,41,33,35,27,19,13,
+     25,27,43,33,35,17,17,23,7,35,15,61,61,53,5,15,23,11,13,43,55,
+     47,25,43,15,57,45,1,49,63,57,15,31,31,7,53,27,15,47,23,7,29,
+     53,47,9,53,3,25,55,45,63,21,17,23,31,27,27,43,63,55,63,45,51,
+     15,27,5,37,43,11,27,5,27,59,21,7,39,27,63,35,47,55,17,17,17,
+     3,19,21,13,49,61,39,15},
+     /* [6][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       13,33,115,41,79,17,29,119,75,73,105,7,
+     59,65,21,3,113,61,89,45,107,21,71,79,19,71,61,41,57,121,87,
+     119,55,85,121,119,11,23,61,11,35,33,43,107,113,101,29,87,119,
+     97,29,17,89,5,127,89,119,117,103,105,41,83,25,41,55,69,117,
+     49,127,29,1,99,53,83,15,31,73,115,35,21,89,5,1,91,53,35,95,
+     83,19,85,55,51,101,33,41,55,45,95,61,27,37,89,75,57,61,15,
+     117,15,21,27,25,27,123,39,109,93,51,21,91,109,107,45,15,93,
+     127,3,53,81,79,107,79,87,35,109,73,35,83,107,1,51,7,59,33,
+     115,43,111,45,121,105,125,87,101,41,95,75,1,57,117,21,27,67,
+     29,53,117,63,1,77,89,115,49,127,15,79,81,29,65,103,33,73,79,
+     29,21,113,31,33,107,95,111,59,99,117,63,63,99,39,9,35,63,125,
+     99,45,93,33,93,9,105,75,51,115,11,37,17,41,21,43,73,19,93,7,
+     95,81,93,79,81,55,9,51,63,45,89,73,19,115,39,47,81,39,5,5,45,
+     53,65,49,17,105,13,107,5,5,19,73,59,43,83,97,115,27,1,69,103,
+     3,99,103,63,67,25,121,97,77,13,83,103,41,11,27,81,37,33,125,
+     71,41,41,59,41,87,123,
+     43,101,63,45,39,21,97,15,97,111,21,49,
+     13,17,79,91,65,105,75,1,45,67,83,107,125,87,15,81,95,105,65,
+     45,59,103,23,103,99,67,99,47,117,71,89,35,53,73,9,115,49,37,
+     1,35,9,45,81,19,127,17,17,105,89,49,101,7,37,33,11,95,95,17,
+     111,105,41,115,5,69,101,27,27,101,103,53,9,21,43,79,91,65,
+     117,87,125,55,45,63,85,83,97,45,83,87,113,93,95,5,17,77,77,
+     127,123,45,81,85,121,119,27,85,41,49,15,107,21,51,119,11,87,
+     101,115,63,63,37,121,109,7,43,69,19,77,49,71,59,35,7,13,55,
+     101,127,103,85,109,29,61,67,21,111,67,23,57,75,71,101,123,41,
+     107,101,107,125,27,47,119,41,19,127,33,31,109,7,91,91,39,125,
+     105,47,125,123,91,9,103,45,23,117,9,125,73,11,37,61,79,21,5,
+     47,117,67,53,85,33,81,121,47,61,51,127,29,65,45,41,95,57,73,
+     33,117,61,111,59,123,65,47,105,23,29,107,37,81,67,29,115,119,
+     75,73,99,103,7,57,45,61,95,49,101,101,35,47,119,39,67,31,103,
+     7,61,127,87,3,35,29,73,95,103,71,75,51,87,57,97,11,105,87,41,
+     73,109,69,35,121,39,111,1,77,
+     39,47,53,91,3,17,51,83,39,125,85,111,
+     21,69,85,29,55,11,117,1,47,17,65,63,47,117,17,115,51,25,33,
+     123,123,83,51,113,95,121,51,91,109,43,55,35,55,87,33,37,5,3,
+     45,21,105,127,35,17,35,37,97,97,21,77,123,17,89,53,105,75,25,
+     125,13,47,21,125,23,55,63,61,5,17,93,57,121,69,73,93,121,105,
+     75,91,67,95,75,9,69,97,99,93,11,53,19,73,5,33,79,107,65,69,
+     79,125,25,93,55,61,17,117,69,97,87,111,37,93,59,79,95,53,115,
+     53,85,85,65,59,23,75,21,67,27,99,79,27,3,95,27,69,19,75,47,
+     59,41,85,77,99,55,49,93,93,119,51,125,63,13,15,45,61,19,105,
+     115,17,83,7,7,11,61,37,63,89,95,119,113,67,123,91,33,37,99,
+     43,11,33,65,81,79,81,107,63,63,55,89,91,25,93,101,27,55,75,
+     121,79,43,125,73,27,109,35,21,71,113,89,59,95,41,45,113,119,
+     113,39,59,73,15,13,59,67,121,27,7,105,15,59,59,35,91,89,23,
+     125,97,53,41,91,111,29,31,3,103,61,71,35,7,119,29,45,49,111,
+     41,109,59,125,13,27,19,79,9,75,83,81,33,91,109,33,29,107,111,
+     101,107,109,65,59,43,37,
+     1,9,15,109,37,111,113,119,79,73,65,
+     71,93,17,101,87,97,43,23,75,109,41,49,53,31,97,105,109,119,
+     51,9,53,113,97,73,89,79,49,61,105,13,99,53,71,7,87,21,101,5,
+     71,31,123,121,121,73,79,115,13,39,101,19,37,51,83,97,55,81,
+     91,127,105,89,63,47,49,75,37,77,15,49,107,23,23,35,19,69,17,
+     59,63,73,29,125,61,65,95,101,81,57,69,83,37,11,37,95,1,73,27,
+     29,57,7,65,83,99,69,19,103,43,95,25,19,103,41,125,97,71,105,
+     83,83,61,39,9,45,117,63,31,5,117,67,125,41,117,43,77,97,15,
+     29,5,59,25,63,87,39,39,77,85,37,81,73,89,29,125,109,21,23,
+     119,105,43,93,97,15,125,29,51,69,37,45,31,75,109,119,53,5,
+     101,125,121,35,29,7,63,17,63,13,69,15,105,51,127,105,9,57,95,
+     59,109,35,49,23,33,107,55,33,57,79,73,69,59,107,55,11,63,95,
+     103,23,125,91,31,91,51,65,61,75,69,107,65,101,59,35,15},
+     /* [7][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       7,23,39,217,141,27,53,181,169,35,15,
+     207,45,247,185,117,41,81,223,151,81,189,61,95,185,23,73,113,
+     239,85,9,201,83,53,183,203,91,149,101,13,111,239,3,205,253,
+     247,121,189,169,179,197,175,217,249,195,95,63,19,7,5,75,217,
+     245,111,189,165,169,141,221,249,159,253,207,249,219,23,49,
+     127,237,5,25,177,37,103,65,167,81,87,119,45,79,143,57,79,187,
+     143,183,75,97,211,149,175,37,135,189,225,241,63,33,43,13,73,
+     213,57,239,183,117,21,29,115,43,205,223,15,3,159,51,101,127,
+     99,239,171,113,171,119,189,245,201,27,185,229,105,153,189,33,
+     35,137,77,97,17,181,55,197,201,155,37,197,137,223,25,179,91,
+     23,235,53,253,49,181,249,53,173,97,247,67,115,103,159,239,69,
+     173,217,95,221,247,97,91,123,223,213,129,181,87,239,85,89,
+     249,141,39,57,249,71,101,159,33,137,189,71,253,205,171,13,
+     249,109,131,199,189,179,31,99,113,41,173,23,189,197,3,135,9,
+     95,195,27,183,1,123,73,53,99,197,59,27,101,55,193,31,61,119,
+     11,7,255,233,53,157,193,97,83,65,81,239,167,69,71,109,
+     97,137,71,193,189,115,79,205,37,227,
+     53,33,91,229,245,105,77,229,161,103,93,13,161,229,223,69,15,
+     25,23,233,93,25,217,247,61,75,27,9,223,213,55,197,145,89,199,
+     41,201,5,149,35,119,183,53,11,13,3,179,229,43,55,187,233,47,
+     133,91,47,71,93,105,145,45,255,221,115,175,19,129,5,209,197,
+     57,177,115,187,119,77,211,111,33,113,23,87,137,41,7,83,43,
+     121,145,5,219,27,11,111,207,55,97,63,229,53,33,149,23,187,
+     153,91,193,183,59,211,93,139,59,179,163,209,77,39,111,79,229,
+     85,237,199,137,147,25,73,121,129,83,87,93,205,167,53,107,229,
+     213,95,219,109,175,13,209,97,61,147,19,13,123,73,35,141,81,
+     19,171,255,111,107,233,113,133,89,9,231,95,69,33,1,253,219,
+     253,247,129,11,251,221,153,35,103,239,7,27,235,181,5,207,53,
+     149,155,225,165,137,155,201,97,245,203,47,39,35,105,239,49,
+     15,253,7,237,213,55,87,199,27,175,49,41,229,85,3,149,179,129,
+     185,249,197,15,97,197,139,203,63,33,251,217,199,199,99,249,
+     33,229,177,13,209,147,97,31,125,177,137,
+     187,11,91,223,29,169,231,59,31,163,41,
+     57,87,247,25,127,101,207,187,73,61,105,27,91,171,243,33,3,1,
+     21,229,93,71,61,37,183,65,211,53,11,151,165,47,5,129,79,101,
+     147,169,181,19,95,77,139,197,219,97,239,183,143,9,13,209,23,
+     215,53,137,203,19,151,171,133,219,231,3,15,253,225,33,111,
+     183,213,169,119,111,15,201,123,121,225,113,113,225,161,165,1,
+     139,55,3,93,217,193,97,29,69,231,161,93,69,143,137,9,87,183,
+     113,183,73,215,137,89,251,163,41,227,145,57,81,57,11,135,145,
+     161,175,159,25,55,167,157,211,97,247,249,23,129,159,71,197,
+     127,141,219,5,233,131,217,101,131,33,157,173,69,207,239,81,
+     205,11,41,169,65,193,77,201,173,1,221,157,1,15,113,147,137,
+     205,225,73,45,49,149,113,253,99,17,119,105,117,129,243,75,
+     203,53,29,247,35,247,171,31,199,213,29,251,7,251,187,91,11,
+     149,13,205,37,249,137,139,9,7,113,183,205,187,39,3,79,155,
+     227,89,185,51,127,63,83,41,133,183,181,127,19,255,219,59,251,
+     3,187,57,217,115,217,229,181,185,149,83,115,11,
+     123,19,109,165,103,123,219,129,155,
+     207,177,9,49,181,231,33,233,67,155,41,9,95,123,65,117,249,85,
+     169,129,241,173,251,225,147,165,69,81,239,95,23,83,227,249,
+     143,171,193,9,21,57,73,97,57,29,239,151,159,191,47,51,1,223,
+     251,251,151,41,119,127,131,33,209,123,53,241,25,31,183,107,
+     25,115,39,11,213,239,219,109,185,35,133,123,185,27,55,245,61,
+     75,205,213,169,163,63,55,49,83,195,51,31,41,15,203,41,63,127,
+     161,5,143,7,199,251,95,75,101,15,43,237,197,117,167,155,21,
+     83,205,255,49,101,213,237,135,135,21,73,93,115,7,85,223,237,
+     79,89,5,57,239,67,65,201,155,71,85,195,89,181,119,135,147,
+     237,173,41,155,67,113,111,21,183,23,103,207,253,69,219,205,
+     195,43,197,229,139,177,129,69,97,201,163,189,11,99,91,253,
+     239,91,145,19,179,231,121,7,225,237,125,191,119,59,175,237,
+     131,79,43,45,205,199,251,153,207,37,179,113,255,107,217,61,7,
+     181,247,31,13,113,145,107,233,233,43,79,23,169,137,129,183,
+     53,91,55,103,223,87,177,157,79,213,139,
+     183,231,205,143,129,243,205,93,59,
+     15,89,9,11,47,133,227,75,9,91,19,171,163,79,7,103,5,119,155,
+     75,11,71,95,17,13,243,207,187},
+     /* [8][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       235,307,495,417,57,151,19,119,375,451,
+     55,449,501,53,185,317,17,21,487,13,347,393,15,391,307,189,
+     381,71,163,99,467,167,433,337,257,179,47,385,23,117,369,425,
+     207,433,301,147,333,85,221,423,49,3,43,229,227,201,383,281,
+     229,207,21,343,251,397,173,507,421,443,399,53,345,77,385,317,
+     155,187,269,501,19,169,235,415,61,247,183,5,257,401,451,95,
+     455,49,489,75,459,377,87,463,155,233,115,429,211,419,143,487,
+     195,209,461,193,157,193,363,181,271,445,381,231,135,327,403,
+     171,197,181,343,113,313,393,311,415,267,247,425,233,289,55,
+     39,247,327,141,5,189,183,27,337,341,327,87,429,357,265,251,
+     437,201,29,339,257,377,17,53,327,47,375,393,369,403,125,429,
+     257,157,217,85,267,117,337,447,219,501,41,41,193,509,131,207,
+     505,421,149,111,177,167,223,291,91,29,305,151,177,337,183,
+     361,435,307,507,77,181,507,315,145,423,71,103,493,271,469,
+     339,237,437,483,31,219,61,131,391,233,219,69,57,459,225,421,
+     7,461,111,451,277,185,193,125,251,199,73,71,7,409,417,149,
+     193,53,437,29,467,229,31,35,75,105,
+     503,75,317,401,367,131,365,441,433,93,377,405,465,259,283,
+     443,143,445,3,461,329,309,77,323,155,347,45,381,315,463,207,
+     321,157,109,479,313,345,167,439,307,235,473,79,101,245,19,
+     381,251,35,25,107,187,115,113,321,115,445,61,77,293,405,13,
+     53,17,171,299,41,79,3,485,331,13,257,59,201,497,81,451,199,
+     171,81,253,365,75,451,149,483,81,453,469,485,305,163,401,15,
+     91,3,129,35,239,355,211,387,101,299,67,375,405,357,267,363,
+     79,83,437,457,39,97,473,289,179,57,23,49,79,71,341,287,95,
+     229,271,475,49,241,261,495,353,381,13,291,37,251,105,399,81,
+     89,265,507,205,145,331,129,119,503,249,1,289,463,163,443,63,
+     123,361,261,49,429,137,355,175,507,59,277,391,25,185,381,197,
+     39,5,429,119,247,177,329,465,421,271,467,151,45,429,137,471,
+     11,17,409,347,199,463,177,11,51,361,95,497,163,351,127,395,
+     511,327,353,49,105,151,321,331,329,509,107,109,303,467,287,
+     161,45,385,289,363,331,265,407,37,433,315,343,63,51,185,71,
+     27,267,
+     503,239,293,245,281,297,75,461,371,
+     129,189,189,339,287,111,111,379,93,27,185,347,337,247,507,
+     161,231,43,499,73,327,263,331,249,493,37,25,115,3,167,197,
+     127,357,497,103,125,191,165,55,101,95,79,351,341,43,125,135,
+     173,289,373,133,421,241,281,213,177,363,151,227,145,363,239,
+     431,81,397,241,67,291,255,405,421,399,75,399,105,329,41,425,
+     7,283,375,475,427,277,209,411,3,137,195,289,509,121,55,147,
+     275,251,19,129,285,415,487,491,193,219,403,23,97,65,285,75,
+     21,373,261,339,239,495,415,333,107,435,297,213,149,463,199,
+     323,45,19,301,121,499,187,229,63,425,99,281,35,125,349,87,
+     101,59,195,511,355,73,263,243,101,165,141,11,389,219,187,449,
+     447,393,477,305,221,51,355,209,499,479,265,377,145,411,173,
+     11,433,483,135,385,341,89,209,391,33,395,319,451,119,341,227,
+     375,61,331,493,411,293,47,203,375,167,395,155,5,237,361,489,
+     127,21,345,101,371,233,431,109,119,277,125,263,73,135,123,83,
+     123,405,69,75,287,401,23,283,393,41,379,431,11,475,505,19,
+     365,265,271,
+     499,489,443,165,91,83,291,319,199,
+     107,245,389,143,137,89,125,281,381,215,131,299,249,375,455,
+     43,73,281,217,297,229,431,357,81,357,171,451,481,13,387,491,
+     489,439,385,487,177,393,33,71,375,443,129,407,395,127,65,333,
+     309,119,197,435,497,373,71,379,509,387,159,265,477,463,449,
+     47,353,249,335,505,89,141,55,235,187,87,363,93,363,101,67,
+     215,321,331,305,261,411,491,479,65,307,469,415,131,315,487,
+     83,455,19,113,163,503,99,499,251,239,81,167,391,255,317,363,
+     359,395,419,307,251,267,171,461,183,465,165,163,293,477,223,
+     403,389,97,335,357,297,19,469,501,249,85,213,311,265,379,297,
+     283,393,449,463,289,159,289,499,407,129,137,221,43,89,403,
+     271,75,83,445,453,389,149,143,423,499,317,445,157,137,453,
+     163,87,23,391,119,427,323,173,89,259,377,511,249,31,363,229,
+     353,329,493,427,57,205,389,91,83,13,219,439,45,35,371,441,17,
+     267,501,53,25,333,17,201,475,257,417,345,381,377,55,403,77,
+     389,347,363,211,413,419,5,167,219,201,285,425,11,77,269,489,
+     281,403,79,
+     425,125,81,331,437,271,397,299,475,
+     271,249,413,233,261,495,171,69,27,409,21,421,367,81,483,255,
+     15,219,365,497,181,75,431,99,325,407,229,281,63,83,493,5,113,
+     15,271,37,87,451,299,83,451,311,441,47,455,47,253,13,109,369,
+     347,11,409,275,63,441,15},
+     /* [9][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       519,307,931,1023,517,771,151,1023,
+     539,725,45,927,707,29,125,371,275,279,817,389,453,989,1015,
+     29,169,743,99,923,981,181,693,309,227,111,219,897,377,425,
+     609,227,19,221,143,581,147,919,127,725,793,289,411,835,921,
+     957,443,349,813,5,105,457,393,539,101,197,697,27,343,515,69,
+     485,383,855,693,133,87,743,747,475,87,469,763,721,345,479,
+     965,527,121,271,353,467,177,245,627,113,357,7,691,725,355,
+     889,635,737,429,545,925,357,873,187,351,677,999,921,477,233,
+     765,495,81,953,479,89,173,473,131,961,411,291,967,65,511,13,
+     805,945,369,827,295,163,835,259,207,331,29,315,999,133,967,
+     41,117,677,471,717,881,755,351,723,259,879,455,721,289,149,
+     199,805,987,851,423,597,129,11,733,549,153,285,451,559,377,
+     109,357,143,693,615,677,701,475,767,85,229,509,547,151,389,
+     711,785,657,319,509,99,1007,775,359,697,677,85,497,105,615,
+     891,71,449,835,609,377,693,665,627,215,911,503,729,131,19,
+     895,199,161,239,633,1013,537,255,23,149,679,1021,595,199,557,
+     659,251,829,727,439,495,647,223,
+     949,625,87,481,85,799,917,769,949,
+     739,115,499,945,547,225,1015,469,737,495,353,103,17,665,639,
+     525,75,447,185,43,729,577,863,735,317,99,17,477,893,537,519,
+     1017,375,297,325,999,353,343,729,135,489,859,267,141,831,141,
+     893,249,807,53,613,131,547,977,131,999,175,31,341,739,467,
+     675,241,645,247,391,583,183,973,433,367,131,467,571,309,385,
+     977,111,917,935,473,345,411,313,97,149,959,841,839,669,431,
+     51,41,301,247,1015,377,329,945,269,67,979,581,643,823,557,91,
+     405,117,801,509,347,893,303,227,783,555,867,99,703,111,797,
+     873,541,919,513,343,319,517,135,871,917,285,663,301,15,763,
+     89,323,757,317,807,309,1013,345,499,279,711,915,411,281,193,
+     739,365,315,375,809,469,487,621,857,975,537,939,585,129,625,
+     447,129,1017,133,83,3,415,661,53,115,903,49,79,55,385,261,
+     345,297,199,385,617,25,515,275,849,401,471,377,661,535,505,
+     939,465,225,929,219,955,659,441,117,527,427,515,287,191,33,
+     389,197,825,63,417,949,35,571,9,131,609,439,95,19,569,893,
+     451,397,971,801,
+     125,471,187,257,67,949,621,453,411,
+     621,955,309,783,893,597,377,753,145,637,941,593,317,555,375,
+     575,175,403,571,555,109,377,931,499,649,653,329,279,271,647,
+     721,665,429,957,803,767,425,477,995,105,495,575,687,385,227,
+     923,563,723,481,717,111,633,113,369,955,253,321,409,909,367,
+     33,967,453,863,449,539,781,911,113,7,219,725,1015,971,1021,
+     525,785,873,191,893,297,507,215,21,153,645,913,755,371,881,
+     113,903,225,49,587,201,927,429,599,513,97,319,331,833,325,
+     887,139,927,399,163,307,803,169,1019,869,537,907,479,335,697,
+     479,353,769,787,1023,855,493,883,521,735,297,1011,991,879,
+     855,591,415,917,375,453,553,189,841,339,211,601,57,765,745,
+     621,209,875,639,7,595,971,263,1009,201,23,77,621,33,535,963,
+     661,523,263,917,103,623,231,47,301,549,337,675,189,357,1005,
+     789,189,319,721,1005,525,675,539,191,813,917,51,167,415,579,
+     755,605,721,837,529,31,327,799,961,279,409,847,649,241,285,
+     545,407,161,591,73,313,811,17,663,269,261,37,783,127,917,231,
+     577,975,793,
+     921,343,751,139,221,79,817,393,545,
+     11,781,71,1,699,767,917,9,107,341,587,903,965,599,507,843,
+     739,579,397,397,325,775,565,925,75,55,979,931,93,957,857,753,
+     965,795,67,5,87,909,97,995,271,875,671,613,33,351,69,811,669,
+     729,401,647,241,435,447,721,271,745,53,775,99,343,451,427,
+     593,339,845,243,345,17,573,421,517,971,499,435,769,75,203,
+     793,985,343,955,735,523,659,703,303,421,951,405,631,825,735,
+     433,841,485,49,749,107,669,211,497,143,99,57,277,969,107,397,
+     563,551,447,381,187,57,405,731,769,923,955,915,737,595,341,
+     253,823,197,321,315,181,885,497,159,571,981,899,785,947,217,
+     217,135,753,623,565,717,903,581,955,621,361,869,87,943,907,
+     853,353,335,197,771,433,743,195,91,1023,63,301,647,205,485,
+     927,1003,987,359,577,147,141,1017,701,273,89,589,487,859,343,
+     91,847,341,173,287,1003,289,639,983,685,697,35,701,645,911,
+     501,705,873,763,745,657,559,699,315,347,429,197,165,955,859,
+     167,303,833,531,473,635,641,195,589,821,205,3,635,371,891,
+     249,123,
+     77,623,993,401,525,427,71,655,951,
+     357,851,899,535,493,323,1003,343,515,859,1017,5,423,315,1011,
+     703,41,777,163,95,831,79,975,235,633,723,297,589,317,679,981,
+     195,399,1003,121,501,155},
+     /* [10][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       7,2011,1001,49,825,415,1441,383,1581,
+     623,1621,1319,1387,619,839,217,75,1955,505,281,1629,1379,53,
+     1111,1399,301,209,49,155,1647,631,129,1569,335,67,1955,1611,
+     2021,1305,121,37,877,835,1457,669,1405,935,1735,665,551,789,
+     1543,1267,1027,1,1911,163,1929,67,1975,1681,1413,191,1711,
+     1307,401,725,1229,1403,1609,2035,917,921,1789,41,2003,187,67,
+     1635,717,1449,277,1903,1179,363,1211,1231,647,1261,1029,1485,
+     1309,1149,317,1335,171,243,271,1055,1601,1129,1653,205,1463,
+     1681,1621,197,951,573,1697,1265,1321,1805,1235,1853,1307,945,
+     1197,1411,833,273,1517,1747,1095,1345,869,57,1383,221,1713,
+     335,1751,1141,839,523,1861,1105,389,1177,1877,805,93,1591,
+     423,1835,99,1781,1515,1909,1011,303,385,1635,357,973,1781,
+     1707,1363,1053,649,1469,623,1429,1241,1151,1055,503,921,3,
+     349,1149,293,45,303,877,1565,1583,1001,663,1535,395,1141,
+     1481,1797,643,1507,465,2027,1695,367,937,719,545,1991,83,819,
+     239,1791,1461,1647,1501,1161,1629,139,1595,1921,1267,1415,
+     509,347,777,1083,363,269,1015,
+     1809,1105,1429,1471,2019,381,2025,
+     1223,827,1733,887,1321,803,1951,1297,1995,833,1107,1135,1181,
+     1251,983,1389,1565,273,137,71,735,1005,933,67,1471,551,457,
+     1667,1729,919,285,1629,1815,653,1919,1039,531,393,1411,359,
+     221,699,1485,471,1357,1715,595,1677,153,1903,1281,215,781,
+     543,293,1807,965,1695,443,1985,321,879,1227,1915,839,1945,
+     1993,1165,51,557,723,1491,817,1237,947,1215,1911,1225,1965,
+     1889,1503,1177,73,1767,303,177,1897,1401,321,921,217,1779,
+     327,1889,333,615,1665,1825,1639,237,1205,361,129,1655,983,
+     1089,1171,401,677,643,749,303,1407,1873,1579,1491,1393,1247,
+     789,763,49,5,1607,1891,735,1557,1909,1765,1777,1127,813,695,
+     97,731,1503,1751,333,769,865,693,377,1919,957,1359,1627,1039,
+     1783,1065,1665,1917,1947,991,1997,841,459,221,327,1595,1881,
+     1269,1007,129,1413,475,1105,791,1983,1359,503,691,659,691,
+     343,1375,1919,263,1373,603,1383,297,781,145,285,767,1739,
+     1715,715,317,1333,85,831,1615,81,1667,1467,1457,1453,1825,
+     109,387,1207,2039,213,1351,1329,1173,
+     57,1769,951,183,23,451,1155,1551,
+     2037,811,635,1671,1451,863,1499,1673,363,1029,1077,1525,277,
+     1023,655,665,1869,1255,965,277,1601,329,1603,1901,395,65,
+     1307,2029,21,1321,543,1569,1185,1905,1701,413,2041,1697,725,
+     1417,1847,411,211,915,1891,17,1877,1699,687,1089,1973,1809,
+     851,1495,1257,63,1323,1307,609,881,1543,177,617,1505,1747,
+     1537,925,183,77,1723,1877,1703,397,459,521,257,1177,389,1947,
+     1553,1583,1831,261,485,289,1281,1543,1591,1123,573,821,1065,
+     1933,1373,2005,905,207,173,1573,1597,573,1883,1795,1499,1743,
+     553,335,333,1645,791,871,1157,969,557,141,223,1129,1685,423,
+     1069,391,99,95,1847,531,1859,1833,1833,341,237,1997,1799,409,
+     431,1917,363,335,1039,1085,1657,1975,1527,1111,659,389,899,
+     595,1439,1861,1979,1569,1087,1009,165,1895,1481,1583,29,1193,
+     1673,1075,301,1081,1377,1747,1497,1103,1789,887,739,1577,313,
+     1367,1299,1801,1131,1837,73,1865,1065,843,635,55,1655,913,
+     1037,223,1871,1161,461,479,511,1721,1107,389,151,35,375,1099,
+     937,1185,1701,769,639,1633,
+     1609,379,1613,2031,685,289,975,671,
+     1599,1447,871,647,99,139,1427,959,89,117,841,891,1959,223,
+     1697,1145,499,1435,1809,1413,1445,1675,171,1073,1349,1545,
+     2039,1027,1563,859,215,1673,1919,1633,779,411,1845,1477,1489,
+     447,1545,351,1989,495,183,1639,1385,1805,1097,1249,1431,1571,
+     591,697,1509,709,31,1563,165,513,1425,1299,1081,145,1841,
+     1211,941,609,845,1169,1865,1593,347,293,1277,157,211,93,1679,
+     1799,527,41,473,563,187,1525,575,1579,857,703,1211,647,709,
+     981,285,697,163,981,153,1515,47,1553,599,225,1147,381,135,
+     821,1965,609,1033,983,503,1117,327,453,2005,1257,343,1649,
+     1199,599,1877,569,695,1587,1475,187,973,233,511,51,1083,665,
+     1321,531,1875,1939,859,1507,1979,1203,1965,737,921,1565,1943,
+     819,223,365,167,1705,413,1577,745,1573,655,1633,1003,91,1123,
+     477,1741,1663,35,715,37,1513,815,941,1379,263,1831,1735,1111,
+     1449,353,1941,1655,1349,877,285,1723,125,1753,985,723,175,
+     439,791,1051,1261,717,1555,1757,1777,577,1583,1957,873,331,
+     1163,313,1,1963,963,1905,821,
+     1677,185,709,545,1723,215,1885,
+     1249,583,1803,839,885,485,413,1767,425,129,1035,329,1263,
+     1881,1779,1565,359,367,453,707,1419,831,1889,887,1871,1869,
+     747,223,1547,1799,433,1441,553,2021,1303,1505,1735,1619,1065,
+     1161,2047,347,867,881,1447,329,781,1065,219,589,645,1257,
+     1833,749,1841,1733,1179,1191,1025,1639,1955,1423,1685,1711,
+     493,549,783,1653,397,895,233,759,1505,677,1449,1573,1297,
+     1821,1691,791,289,1187,867,1535,575,183},
+     /* [11][*] */
+     { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       3915,97,3047,937,2897,953,127,1201,
+     3819,193,2053,3061,3759,1553,2007,2493,603,3343,3751,1059,
+     783,1789,1589,283,1093,3919,2747,277,2605,2169,2905,721,4069,
+     233,261,1137,3993,3619,2881,1275,3865,1299,3757,1193,733,993,
+     1153,2945,3163,3179,437,271,3493,3971,1005,2615,2253,1131,
+     585,2775,2171,2383,2937,2447,1745,663,1515,3767,2709,1767,
+     3185,3017,2815,1829,87,3341,793,2627,2169,1875,3745,367,3783,
+     783,827,3253,2639,2955,3539,1579,2109,379,2939,3019,1999,
+     2253,2911,3733,481,1767,1055,4019,4085,105,1829,2097,2379,
+     1567,2713,737,3423,3941,2659,3961,1755,3613,1937,1559,2287,
+     2743,67,2859,325,2601,1149,3259,2403,3947,2011,175,3389,3915,
+     1315,2447,141,359,3609,3933,729,2051,1755,2149,2107,1741,
+     1051,3681,471,1055,845,257,1559,1061,2803,2219,1315,1369,
+     3211,4027,105,11,1077,2857,337,3553,3503,3917,2665,3823,3403,
+     3711,2085,1103,1641,701,4095,2883,1435,653,2363,1597,767,869,
+     1825,1117,1297,501,505,149,873,2673,551,1499,2793,3277,2143,
+     3663,533,3991,575,1877,1009,3929,473,3009,2595,3249,675,3593,
+     2453,1567,973,595,1335,1715,589,85,
+     2265,3069,461,1659,2627,1307,1731,1501,1699,3545,3803,2157,
+     453,2813,2047,2999,3841,2361,1079,573,69,1363,1597,3427,2899,
+     2771,1327,1117,1523,3521,2393,2537,1979,3179,683,2453,453,
+     1227,779,671,3483,2135,3139,3381,3945,57,1541,3405,3381,2371,
+     2879,1985,987,3017,3031,3839,1401,3749,2977,681,1175,1519,
+     3355,907,117,771,3741,3337,1743,1227,3335,2755,1909,3603,
+     2397,653,87,2025,2617,3257,287,3051,3809,897,2215,63,2043,
+     1757,3671,297,3131,1305,293,3865,3173,3397,2269,3673,717,
+     3041,3341,3595,3819,2871,3973,1129,513,871,1485,3977,2473,
+     1171,1143,3063,3547,2183,3993,133,2529,2699,233,2355,231,
+     3241,611,1309,3829,1839,1495,301,1169,1613,2673,243,3601,
+     3669,2813,2671,2679,3463,2477,1795,617,2317,1855,1057,1703,
+     1761,2515,801,1205,1311,473,3963,697,1221,251,381,3887,1761,
+     3093,3721,2079,4085,379,3601,3845,433,1781,29,1897,1599,2163,
+     75,3475,3957,1641,3911,2959,2833,1279,1099,403,799,2183,2699,
+     1711,2037,727,289,1785,1575,3633,2367,1261,3953,1735,171,
+     1959,
+     2867,859,2951,3211,15,1279,1323,599,
+     1651,3951,1011,315,3513,3351,1725,3793,2399,287,4017,3571,
+     1007,541,3115,429,1585,1285,755,1211,3047,915,3611,2697,2129,
+     3669,81,3939,2437,915,779,3567,3701,2479,3807,1893,3927,2619,
+     2543,3633,2007,3857,3837,487,1769,3759,3105,2727,3155,2479,
+     1341,1657,2767,2541,577,2105,799,17,2871,3637,953,65,69,2897,
+     3841,3559,4067,2335,3409,1087,425,2813,1705,1701,1237,821,
+     1375,3673,2693,3925,1541,1871,2285,847,4035,1101,2029,855,
+     2733,2503,121,2855,1069,3463,3505,1539,607,1349,575,2301,
+     2321,1101,333,291,2171,4085,2173,2541,1195,925,4039,1379,699,
+     1979,275,953,1755,1643,325,101,2263,3329,3673,3413,1977,2727,
+     2313,1419,887,609,2475,591,2613,2081,3805,3435,2409,111,3557,
+     3607,903,231,3059,473,2959,2925,3861,2043,3887,351,2865,369,
+     1377,2639,1261,3625,3279,2201,2949,3049,449,1297,897,1891,
+     411,2773,749,2753,1825,853,2775,3547,3923,3923,987,3723,2189,
+     3877,3577,297,2763,1845,3083,2951,483,2169,3985,245,3655,
+     3441,1023,235,835,3693,3585,327,1003,543,3059,2637,
+     2923,87,3617,1031,1043,903,2913,
+     2177,2641,3279,389,2009,525,4085,3299,987,2409,813,2683,373,
+     2695,3775,2375,1119,2791,223,325,587,1379,2877,2867,3793,655,
+     831,3425,1663,1681,2657,1865,3943,2977,1979,2271,3247,1267,
+     1747,811,159,429,2001,1195,3065,553,1499,3529,1081,2877,3077,
+     845,1793,2409,3995,2559,4081,1195,2955,1117,1409,785,287,
+     1521,1607,85,3055,3123,2533,2329,3477,799,3683,3715,337,3139,
+     3311,431,3511,2299,365,2941,3067,1331,1081,1097,2853,2299,
+     495,1745,749,3819,619,1059,3559,183,3743,723,949,3501,733,
+     2599,3983,3961,911,1899,985,2493,1795,653,157,433,2361,3093,
+     3119,3679,2367,1701,1445,1321,2397,1241,3305,3985,2349,4067,
+     3805,3073,2837,1567,3783,451,2441,1181,487,543,1201,3735,
+     2517,733,1535,2175,3613,3019},
+     /* [12][*] */
+     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     2319,653,1379,1675,1951,7075,2087,
+     7147,1427,893,171,2019,7235,5697,3615,1961,7517,6849,2893,
+     1883,2863,2173,4543,73,381,3893,6045,1643,7669,1027,1549,
+     3983,1985,6589,7497,2745,2375,7047,1117,1171,1975,5199,3915,
+     3695,8113,4303,3773,7705,6855,1675,2245,2817,1719,569,1021,
+     2077,5945,1833,2631,4851,6371,833,7987,331,1899,8093,6719,
+     6903,5903,5657,5007,2689,6637,2675,1645,1819,689,6709,7717,
+     6295,7013,7695,3705,7069,2621,3631,6571,6259,7261,3397,7645,
+     1115,4753,2047,7579,2271,5403,4911,7629,4225,1209,6955,6951,
+     1829,5579,5231,1783,4285,7425,599,5785,3275,5643,2263,657,
+     6769,6261,1251,3249,4447,4111,3991,1215,131,4397,3487,7585,
+     5565,7199,3573,7105,7409,1671,949,3889,5971,3333,225,3647,
+     5403,3409,7459,6879,5789,6567,5581,4919,1927,4407,8085,4691,
+     611,3005,591,753,589,171,5729,5891,1033,3049,6567,5257,8003,
+     1757,4489,4923,6379,5171,1757,689,3081,1389,4113,455,2761,
+     847,7575,5829,633,6629,1103,7635,803,6175,6587,2711,3879,67,
+     1179,4761,7281,1557,3379,2459,4273,4127,7147,35,
+     3549,395,3735,5787,4179,5889,5057,
+     7473,4713,2133,2897,1841,2125,1029,1695,6523,1143,5105,7133,
+     3351,2775,3971,4503,7589,5155,4305,1641,4717,2427,5617,1267,
+     399,5831,4305,4241,3395,3045,4899,1713,171,411,7099,5473,
+     5209,1195,1077,1309,2953,7343,4887,3229,6759,6721,6775,675,
+     4039,2493,7511,3269,4199,6625,7943,2013,4145,667,513,2303,
+     4591,7941,2741,987,8061,3161,5951,1431,831,5559,7405,1357,
+     4319,4235,5421,2559,4415,2439,823,1725,6219,4903,6699,5451,
+     349,7703,2927,7809,6179,1417,5987,3017,4983,3479,4525,4643,
+     4911,227,5475,2287,5581,6817,1937,1421,4415,7977,1789,3907,
+     6815,6789,6003,5609,4507,337,7427,7943,3075,6427,1019,7121,
+     4763,81,3587,2929,1795,8067,2415,1265,4025,5599,4771,3025,
+     2313,6129,7611,6881,5253,4413,7869,105,3173,1629,2537,1023,
+     4409,7209,4413,7107,7469,33,1955,2881,5167,6451,4211,179,
+     5573,7879,3387,7759,5455,7157,1891,5683,5689,6535,3109,6555,
+     6873,1249,4251,6437,49,2745,1201,7327,4179,6783,623,2779,
+     5963,2585,6927,5333,4033,285,7467,4443,4917,3,
+     4319,5517,3449,813,5499,2515,5771,
+     3357,2073,4395,4925,2643,7215,5817,1199,1597,1619,7535,4833,
+     609,4797,8171,6847,793,6757,8165,3371,2431,5235,4739,7703,
+     7223,6525,5891,5605,4433,3533,5267,5125,5037,225,6717,1121,
+     5741,2013,4327,4839,569,5227,7677,4315,2391,5551,859,3627,
+     6377,3903,4311,6527,7573,4905,7731,1909,1555,3279,1949,1887,
+     6675,5509,2033,5473,3539,5033,5935,6095,4761,1771,1271,1717,
+     4415,5083,6277,3147,7695,2461,4783,4539,5833,5583,651,1419,
+     2605,5511,3913,5795,2333,2329,4431,3725,6069,2699,7055,6879,
+     1017,3121,2547,4603,2385,6915,6103,5669,7833,2001,4287,6619,
+     955,2761,5711,6291,3415,3909,2841,5627,4939,7671,6059,6275,
+     6517,1931,4583,7301,1267,7509,1435,2169,6939,3515,2985,2787,
+     2123,1969,3307,353,4359,7059,5273,5873,6657,6765,6229,3179,
+     1583,6237,2155,371,273,7491,3309,6805,3015,6831,7819,713,
+     4747,3935,4109,1311,709,3089,7059,4247,2989,1509,4919,1841,
+     3045,3821,6929,4655,1333,6429,6649,2131,5265,1051,261,8057,
+     3379,2179,1993,5655,3063,6381,
+     3587,7417,1579,1541,2107,5085,2873,
+     6141,955,3537,2157,841,1999,1465,5171,5651,1535,7235,4349,
+     1263,1453,1005,6893,2919,1947,1635,3963,397,969,4569,655,
+     6737,2995,7235,7713,973,4821,2377,1673,1,6541}
+};
+
+#endif
diff --git a/util/sobolseq.c b/util/sobolseq.c
new file mode 100644 (file)
index 0000000..b3bee05
--- /dev/null
@@ -0,0 +1,299 @@
+/* Copyright (c) 2007 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+/* Generation of Sobol sequences in up to 1111 dimensions, based on the
+   algorithms described in:
+        P. Bratley and B. L. Fox, Algorithm 659, ACM Trans.
+       Math. Soft. 14 (1), 88-100 (1988),
+   as modified by:
+        S. Joe and F. Y. Kuo, ACM Trans. Math. Soft 29 (1), 49-57 (2003).
+
+   Note that the code below was written without even looking at the
+   Fortran code from the TOMS paper, which is only semi-free (being
+   under the restrictive ACM copyright terms).  Then I went to the
+   Fortran code and took out the table of primitive polynomials and
+   starting direction #'s ... since this is just a table of numbers
+   generated by a deterministic algorithm, it is not copyrightable.
+   (Obviously, the format of these tables then necessitated some
+   slight modifications to the code.)
+
+   For the test integral of Joe and Kuo (see the main() program
+   below), I get exactly the same results for integrals up to 1111
+   dimensions compared to the table of published numbers (to the 5
+   published significant digits).
+
+   This is not to say that the authors above should not be credited for
+   their clear description of the algorithm (and their tabulation of
+   the critical numbers).  Please cite them.  Just that I needed
+   a free/open-source implementation. */
+
+#include <stdlib.h>
+#include <math.h>
+
+#include "nlopt-util.h"
+
+#if defined(HAVE_STDINT_H)
+#  include <stdint.h>
+#endif
+
+#ifndef HAVE_UINT32_T
+#  if SIZEOF_UNSIGNED_LONG == 4
+      typedef unsigned long uint32_t;
+#  elif SIZEOF_UNSIGNED_INT == 4
+      typedef unsigned int uint32_t;
+#  else
+#    error No 32-bit unsigned integer type
+#  endif
+#endif
+
+typedef struct nlopt_soboldata_s {
+     unsigned sdim; /* dimension of sequence being generated */
+     uint32_t *mdata; /* array of length 32 * sdim */
+     uint32_t *m[32]; /* more convenient pointers to mdata, of direction #s */
+     uint32_t *x; /* previous x = x_n, array of length sdim */
+     unsigned *b; /* position of fixed point in x[i] is after bit b[i] */
+     uint32_t n; /* number of x's generated so far */
+} soboldata;
+
+/* Return position (0, 1, ...) of rightmost (least-significant) zero bit in n.
+ *
+ * This code uses a 32-bit version of algorithm to find the rightmost
+ * one bit in Knuth, _The Art of Computer Programming_, volume 4A
+ * (draft fascicle), section 7.1.3, "Bitwise tricks and
+ * techniques." 
+ *
+ * Assumes n has a zero bit, i.e. n < 2^32 - 1.
+ *
+ */
+static unsigned rightzero32(uint32_t n)
+{
+#if defined(__GNUC__) && \
+    ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ > 3)
+     return __builtin_ctz(~n); /* gcc builtin for version >= 3.4 */
+#else
+     const uint32_t a = 0x05f66a47; /* magic number, found by brute force */
+     static const unsigned decode[32] = {0,1,2,26,23,3,15,27,24,21,19,4,12,16,28,6,31,25,22,14,20,18,11,5,30,13,17,10,29,9,8,7};
+     n = ~n; /* change to rightmost-one problem */
+     n = a * (n & (-n)); /* store in n to make sure mult. is 32 bits */
+     return decode[n >> 27];
+#endif
+}
+
+/* generate the next term x_{n+1} in the Sobol sequence, as an array
+   x[sdim] of numbers in (0,1).  Returns 1 on success, 0 on failure
+   (if too many #'s generated) */
+static int sobol_gen(soboldata *sd, double *x)
+{
+     unsigned c, b, i, sdim;
+
+     if (sd->n == 4294967295U) return 0; /* n == 2^32 - 1 ... we would
+                                           need to switch to a 64-bit version
+                                           to generate more terms. */
+     c = rightzero32(sd->n++);
+     sdim = sd->sdim;
+     for (i = 0; i < sdim; ++i) {
+         b = sd->b[i];
+         if (b >= c) {
+              sd->x[i] ^= sd->m[c][i] << (b - c);
+              x[i] = ((double) (sd->x[i])) / (1U << (b+1));
+         }
+         else {
+              sd->x[i] = (sd->x[i] << (c - b)) ^ sd->m[c][i];
+              sd->b[i] = c;
+              x[i] = ((double) (sd->x[i])) / (1U << (c+1));
+         }
+     }
+     return 1;
+}
+
+#include "soboldata.h"
+
+static int sobol_init(soboldata *sd, unsigned sdim)
+{
+     unsigned i,j;
+     
+     if (!sdim || sdim > MAXDIM) return 0;
+
+     sd->mdata = (uint32_t *) malloc(sizeof(uint32_t) * (sdim * 32));
+     if (!sd->mdata) return 0;
+
+     for (j = 0; j < 32; ++j) {
+         sd->m[j] = sd->mdata + j * sdim;
+         sd->m[j][0] = 1; /* special-case Sobol sequence */
+     }
+     for (i = 1; i < sdim; ++i) {
+         uint32_t a = sobol_a[i-1];
+         unsigned d = 0, k;
+
+         while (a) {
+              ++d;
+              a >>= 1;
+         }
+         d--; /* d is now degree of poly */
+
+         /* set initial values of m from table */
+         for (j = 0; j < d; ++j)
+              sd->m[j][i] = sobol_minit[j][i-1];
+         
+         /* fill in remaining values using recurrence */
+         for (j = d; j < 32; ++j) {
+              a = sobol_a[i-1];
+              sd->m[j][i] = sd->m[j - d][i];
+              for (k = 0; k < d; ++k) {
+                   sd->m[j][i] ^= ((a & 1) * sd->m[j-d+k][i]) << (d-k);
+                   a >>= 1;
+              }
+         }
+     }
+
+     sd->x = (uint32_t *) malloc(sizeof(uint32_t) * sdim);
+     if (!sd->x) { free(sd->mdata); return 0; }
+
+     sd->b = (unsigned *) malloc(sizeof(unsigned) * sdim);
+     if (!sd->b) { free(sd->x); free(sd->mdata); return 0; }
+
+     for (i = 0; i < sdim; ++i) {
+         sd->x[i] = 0;
+         sd->b[i] = 0;
+     }
+
+     sd->n = 0;
+     sd->sdim = sdim;
+
+     return 1;
+}
+
+static void sobol_destroy(soboldata *sd)
+{
+     free(sd->mdata);
+     free(sd->x);
+     free(sd->b);
+}
+
+/************************************************************************/
+/* NLopt API to Sobol sequence creation, which hides soboldata structure
+   behind an opaque pointer */
+
+nlopt_sobol nlopt_sobol_create(unsigned sdim)
+{
+     nlopt_sobol s = (nlopt_sobol) malloc(sizeof(soboldata));
+     if (!s) return NULL;
+     if (!sobol_init(s, sdim)) { free(s); return NULL; }
+     return s;
+}
+
+extern void nlopt_sobol_destroy(nlopt_sobol s)
+{
+     if (s) {
+         sobol_destroy(s);
+         free(s);
+     }
+}
+
+/* next vector x[sdim] in Sobol sequence, with each x[i] in (0,1) */
+void nlopt_sobol_next01(nlopt_sobol s, double *x)
+{
+     if (!sobol_gen(s, x)) {
+         /* fall back on pseudo random numbers in the unlikely event
+            that we exceed 2^32-1 points */
+         unsigned i;
+         for (i = 0; i < s->sdim; ++i)
+              x[i] = nlopt_urand(0.0,1.0);
+     }
+}
+
+/* next vector in Sobol sequence, scaled to (lb[i], ub[i]) interval */
+void nlopt_sobol_next(nlopt_sobol s, double *x,
+                     const double *lb, const double *ub)
+{
+     unsigned i, sdim;
+     nlopt_sobol_next01(s, x);
+     for (sdim = s->sdim, i = 0; i < sdim; ++i)
+         x[i] = lb[i] + (ub[i] - lb[i]) * x[i];
+}
+
+/* if we know in advance how many points (n) we want to compute, then
+   adopt the suggestion of the Joe and Kuo paper, which in turn
+   is taken from Acworth et al (1998), of skipping a number of
+   points equal to the largest power of 2 smaller than n */
+void nlopt_sobol_skip(nlopt_sobol s, unsigned n, double *x)
+{
+     if (s) {
+         unsigned k = 1;
+         while (k*2 < n) k *= 2;
+         while (k-- > 0) sobol_gen(s, x);
+     }
+}
+
+/************************************************************************/
+
+/* compile with -DSOBOLSEQ_TEST for test program */
+#ifdef SOBOLSEQ_TEST
+#include <stdio.h>
+#include <time.h>
+
+/* test integrand from Joe and Kuo paper ... integrates to 1 */
+static double testfunc(unsigned n, const double *x)
+{
+     double f = 1;
+     unsigned j;
+     for (j = 1; j <= n; ++j) {
+         double cj = pow((double) j, 0.3333333333333333333);
+         f *= (fabs(4*x[j-1] - 2) + cj) / (1 + cj);
+     }
+     return f;
+}
+
+int main(int argc, char **argv)
+{
+     unsigned n, j, i, sdim;
+     static double x[MAXDIM];
+     double testint_sobol = 0, testint_rand = 0;
+     nlopt_sobol s;
+     if (argc < 3) { 
+         fprintf(stderr, "Usage: %s <sdim> <ngen>\n", argv[0]);
+         return 1;
+     }
+     nlopt_init_genrand(time(NULL));
+     sdim = atoi(argv[1]);
+     s = nlopt_sobol_create(sdim);
+     n = atoi(argv[2]);
+     nlopt_sobol_skip(s, n, x);
+     for (j = 1; j <= n; ++j) {
+         nlopt_sobol_next01(s, x);
+         testint_sobol += testfunc(sdim, x);
+         if (j < 100) {
+              printf("x[%d]: %g", j, x[0]);
+              for (i = 1; i < sdim; ++i) printf(", %g", x[i]);
+              printf("\n");
+         }
+         for (i = 0; i < sdim; ++i) x[i] = nlopt_urand(0.,1.);
+         testint_rand += testfunc(sdim, x);
+     }
+     nlopt_sobol_destroy(s);
+     printf("Test integral = %g using Sobol, %g using pseudorandom.\n",
+           testint_sobol / n, testint_rand / n);
+     printf("        error = %g using Sobol, %g using pseudorandom.\n",
+           testint_sobol / n - 1, testint_rand / n - 1);
+     return 0;
+}
+#endif
diff --git a/util/stop.c b/util/stop.c
new file mode 100644 (file)
index 0000000..9e29a75
--- /dev/null
@@ -0,0 +1,134 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include <math.h>
+#include "nlopt-util.h"
+
+/* utility routines to implement the various stopping criteria */
+
+static int relstop(double vold, double vnew, double reltol, double abstol)
+{
+     if (nlopt_isinf(vold)) return 0;
+     return(fabs(vnew - vold) < abstol 
+           || fabs(vnew - vold) < reltol * (fabs(vnew) + fabs(vold)) * 0.5
+           || (reltol > 0 && vnew == vold)); /* catch vnew == vold == 0 */
+}
+
+int nlopt_stop_ftol(const nlopt_stopping *s, double f, double oldf)
+{
+     return (relstop(oldf, f, s->ftol_rel, s->ftol_abs));
+}
+
+int nlopt_stop_f(const nlopt_stopping *s, double f, double oldf)
+{
+     return (f <= s->minf_max || nlopt_stop_ftol(s, f, oldf));
+}
+
+int nlopt_stop_x(const nlopt_stopping *s, const double *x, const double *oldx)
+{
+     unsigned i;
+     for (i = 0; i < s->n; ++i)
+         if (!relstop(oldx[i], x[i], s->xtol_rel, s->xtol_abs[i]))
+              return 0;
+     return 1;
+}
+
+int nlopt_stop_dx(const nlopt_stopping *s, const double *x, const double *dx)
+{
+     unsigned i;
+     for (i = 0; i < s->n; ++i)
+         if (!relstop(x[i] - dx[i], x[i], s->xtol_rel, s->xtol_abs[i]))
+              return 0;
+     return 1;
+}
+
+static double sc(double x, double smin, double smax)
+{
+     return smin + x * (smax - smin);
+}
+
+/* some of the algorithms rescale x to a unit hypercube, so we need to
+   scale back before we can compare to the tolerances */
+int nlopt_stop_xs(const nlopt_stopping *s,
+                 const double *xs, const double *oldxs,
+                 const double *scale_min, const double *scale_max)
+{
+     unsigned i;
+     for (i = 0; i < s->n; ++i)
+         if (relstop(sc(oldxs[i], scale_min[i], scale_max[i]), 
+                     sc(xs[i], scale_min[i], scale_max[i]),
+                     s->xtol_rel, s->xtol_abs[i]))
+              return 1;
+     return 0;
+}
+
+int nlopt_stop_evals(const nlopt_stopping *s)
+{
+     return (s->maxeval > 0 && s->nevals >= s->maxeval);
+}
+
+int nlopt_stop_time_(double start, double maxtime)
+{
+     return (maxtime > 0 && nlopt_seconds() - start >= maxtime);
+}
+
+int nlopt_stop_time(const nlopt_stopping *s)
+{
+     return nlopt_stop_time_(s->start, s->maxtime);
+}
+
+int nlopt_stop_evalstime(const nlopt_stopping *stop)
+{
+     return nlopt_stop_evals(stop) || nlopt_stop_time(stop);
+}
+
+int nlopt_stop_forced(const nlopt_stopping *stop)
+{
+     return stop->force_stop && *(stop->force_stop);
+}
+
+unsigned nlopt_count_constraints(unsigned p, const nlopt_constraint *c)
+{
+     unsigned i, count = 0;
+     for (i = 0; i < p; ++i)
+         count += c[i].m;
+     return count;
+}
+
+unsigned nlopt_max_constraint_dim(unsigned p, const nlopt_constraint *c)
+{
+     unsigned i, max_dim = 0;
+     for (i = 0; i < p; ++i)
+         if (c[i].m > max_dim)
+              max_dim = c[i].m;
+     return max_dim;
+}
+
+void nlopt_eval_constraint(double *result, double *grad,
+                          const nlopt_constraint *c,
+                          unsigned n, const double *x)
+{
+     if (c->f)
+         result[0] = c->f(n, x, grad, c->f_data);
+     else
+         c->mf(c->m, result, n, x, grad, c->f_data);
+}
diff --git a/util/timer.c b/util/timer.c
new file mode 100644 (file)
index 0000000..8019d98
--- /dev/null
@@ -0,0 +1,93 @@
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ */
+
+#include "nlopt-util.h"
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#if defined(_WIN32) || defined(__WIN32__)
+#  include <windows.h>    
+#endif
+
+/* return time in seconds since some arbitrary point in the past */
+double nlopt_seconds(void)
+{
+     static THREADLOCAL int start_inited = 0; /* whether start time has been initialized */
+#if defined(HAVE_GETTIMEOFDAY)
+     static THREADLOCAL struct timeval start;
+     struct timeval tv;
+     if (!start_inited) {
+         start_inited = 1;
+         gettimeofday(&start, NULL);
+     }
+     gettimeofday(&tv, NULL);
+     return (tv.tv_sec - start.tv_sec) + 1.e-6 * (tv.tv_usec - start.tv_usec);
+#elif defined(HAVE_TIME)
+     return time(NULL);
+#elif defined(_WIN32) || defined(__WIN32__)
+     static THREADLOCAL ULONGLONG start;
+     FILETIME ft;
+     if (!start_inited) {
+         start_inited = 1;
+         GetSystemTimeAsFileTime(&ft);
+         start = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
+     }
+     GetSystemTimeAsFileTime(&ft);
+     return 100e-9 * (((((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime) - start);
+#else
+     /* use clock() as a fallback... this is somewhat annoying
+       because clock() may wrap around with a fairly short period */
+     static THREADLOCAL clock_t start;
+     if (!start_inited) {
+         start_inited = 1;
+         start = clock();
+     }
+     return (clock() - start) * 1.0 / CLOCKS_PER_SEC;
+#endif
+}
+
+/* number based on time for use as random seed */
+unsigned long nlopt_time_seed(void)
+{
+#if defined(HAVE_GETTIMEOFDAY)
+     struct timeval tv;
+     gettimeofday(&tv, NULL);
+     return (tv.tv_sec ^ tv.tv_usec);
+#elif defined(HAVE_TIME)
+     return time(NULL);
+#elif defined(_WIN32) || defined(__WIN32__)
+     FILETIME ft;
+     GetSystemTimeAsFileTime(&ft);
+     return ft.dwHighDateTime ^ ft.dwLowDateTime;
+#else
+     return clock();
+#endif
+}