Mercurial > hg > octave-nkf
changeset 5235:5f0ad69b5c8c
[project @ 2005-03-22 19:48:16 by jwe]
author | jwe |
---|---|
date | Tue, 22 Mar 2005 19:48:46 +0000 |
parents | a791b8b777e4 |
children | 6879f10db3a4 |
files | ChangeLog Makeconf.in configure.in src/ChangeLog src/DLD-FUNCTIONS/__glpk__.cc src/Makefile.in src/oct-conf.h.in src/toplev.cc |
diffstat | 8 files changed, 92 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-03-22 John W. Eaton <jwe@octave.org> + * Makeconf.in (GLPK_LIBS): Substitute value. + (do-subst-config-vals): Add to list of substitutions. + + * configure.in: Check for glpk. + * emacs/octave-mod.el (octave-abbrev-table): Omit fifth and sixth arguments from define-abbrev for compatibility with some older versions of Emacs.
--- a/Makeconf.in +++ b/Makeconf.in @@ -186,6 +186,7 @@ BLAS_LIBS = @BLAS_LIBS@ FFTW_LIBS = @FFTW_LIBS@ +GLPK_LIBS = @GLPK_LIBS@ LIBS = @LIBS@ # The arguments passed to configure. @@ -428,6 +429,7 @@ -e "s;%OCTAVE_CONF_FFTW_LIBS%;\"${FFTW_LIBS}\";" \ -e "s;%OCTAVE_CONF_FLIBS%;\"${FLIBS}\";" \ -e "s;%OCTAVE_CONF_FPICFLAG%;\"${FPICFLAG}\";" \ + -e "s;%OCTAVE_CONF_GLPK_LIBS%;\"${GLPK_LIBS}\";" \ -e "s;%OCTAVE_CONF_INCFLAGS%;\"${INCFLAGS}\";" \ -e "s;%OCTAVE_CONF_LD_CXX%;\"${LD_CXX}\";" \ -e "s;%OCTAVE_CONF_LDFLAGS%;\"${LDFLAGS}\";" \
--- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.468 $) +AC_REVISION($Revision: 1.469 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -430,6 +430,30 @@ AC_DEFINE(HAVE_FFTW3, 1, [Define if the FFTW3 library is used.]) fi +# Checks for GLPK header and library. + +AC_ARG_WITH(glpk, + [ --without-glpk don't use GLPK], + with_glpk=$withval, with_glpk=yes) + +glpk_lib= +if test "$with_glpk" = yes; then + glpk_lib="glpk" +elif test "$with_glpk" != no; then + glpk_lib="$with_glpk" +fi + +GLPK_LIBS= +if test -n "$glpk_lib"; then + AC_CHECK_LIB($glpk_lib, glp_lpx_simplex, [ + AC_CHECK_HEADERS(glpk.h, [ + GLPK_LIBS="-l$glpk_lib" + AC_DEFINE(HAVE_GLPK, 1, [Define if GLPK is available.])])]) +fi +AC_SUBST(GLPK_LIBS) + +# Checks for MPI header and library. + WITH_MPI=true AC_ARG_WITH(mpi, [ --without-mpi don't use MPI], @@ -1528,6 +1552,7 @@ Fortran libraries: $FLIBS BLAS libraries: $BLAS_LIBS FFTW libraries: $FFTW_LIBS + GLPK libraries: $GLPK_LIBS UMFPACK libraries: $UMFPACK_LIBS HDF5 libraries: $HDF5_LIBS MPI libraries: $MPI_LIBS
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,9 +1,17 @@ 2005-03-22 John W. Eaton <jwe@octave.org> - + + * Makefile.in: Add special rule for __glpk__.oct. + + * toplev.cc (octave_config_info): Add GLPK_LIBS to the list. + * oct-conf.h.in (OCTAVE_CONF_GLPK_LIBS): Substitute here. + * DLD-FUNCTIONS/__glpk__.cc (F__glpk__, glpk): Adapt to Octave coding style. (glpk): Move decls closer to first use. (F__glpk__): Eliminate unnecessary loop seting inf values. + Ensure that isMIP is initialized. + Declare sense, nz, and isMIP volatile to avoid GCC warnings that + these variables might be might be clobbered by `longjmp' or `vfork' * DLD-FUNCTIONS/__glpk__.cc: New file.
--- a/src/DLD-FUNCTIONS/__glpk__.cc +++ b/src/DLD-FUNCTIONS/__glpk__.cc @@ -30,7 +30,12 @@ #include "defun-dld.h" #include "error.h" +#include "gripes.h" +#include "oct-map.h" #include "oct-obj.h" +#include "pager.h" + +#if defined (HAVE_GLPK) extern "C" { #include <glpk.h> @@ -113,14 +118,14 @@ int -glpk_fault_hook (void *info, char *msg) +glpk_fault_hook (void * /* info */, char *msg) { OCTERR << "*** SEVERE CRITICAL ERROR *** from GLPK !\n\n"<<msg<<" %s\n"; longjmp (mark, -1); } int -glpk_print_hook (void *info, char *msg) +glpk_print_hook (void * /* info */, char *msg) { OCTERR << msg << "\n"; return 1; @@ -267,7 +272,7 @@ error = lpx_integer (lp); } else - error=lpx_simplex(lp); + error = lpx_simplex(lp); } break; @@ -354,13 +359,17 @@ return error; } -DEFUN_DLD (__glpk__, args, nlhs, +#endif + +DEFUN_DLD (__glpk__, args, , "__glpk__: internal interface for the GLPK library.\n\ You should be using using glpk instead") { // The list of values to return. See the declaration in oct-obj.h octave_value_list retval; +#if defined (HAVE_GLPK) + int nrhs = args.length (); if (nrhs < 1) @@ -370,9 +379,9 @@ } //-- 1st Input. Sense of optimization. - int sense; + volatile int sense; double SENSE = args(0).scalar_value (); - if (SENSE> = 0) + if (SENSE >= 0) sense = 1; else sense = -1; @@ -393,7 +402,7 @@ Array<int> cn (mrowsA*mrowsc+1); ColumnVector a (mrowsA*mrowsc+1, 0.0); - int nz = 0; + volatile int nz = 0; for (int i = 0; i < mrowsA; i++) { for (int j = 0; j < mrowsc; j++) @@ -490,7 +499,7 @@ charMatrix VTYPE (args(7).char_matrix_value ()); Array<int> vartype (mrowsc); - int isMIP; + volatile int isMIP = 0; for (int i = 0; i < mrowsc ; i++) { if (VTYPE(i,0) == 'I') @@ -499,9 +508,7 @@ vartype(i) = LPX_IV; } else - { - vartype(i) = LPX_CV; - } + vartype(i) = LPX_CV; } //-- 9th Input. A structure containing the control parameters. @@ -729,17 +736,16 @@ ColumnVector mem (1); int jmpret = setjmp (mark); + if (jmpret == 0) - { - int error = glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (), - cn.fortran_vec (), a.fortran_vec (), b, ctype, - freeLB.fortran_vec (), lb, freeUB.fortran_vec (), - ub, vartype.fortran_vec (), isMIP, lpsolver, - save_pb, xmin.fortran_vec (), fmin.fortran_vec (), - status.fortran_vec (), lambda.fortran_vec (), - redcosts.fortran_vec (), time.fortran_vec (), - mem.fortran_vec ()); - } + glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (), + cn.fortran_vec (), a.fortran_vec (), b, ctype, + freeLB.fortran_vec (), lb, freeUB.fortran_vec (), + ub, vartype.fortran_vec (), isMIP, lpsolver, + save_pb, xmin.fortran_vec (), fmin.fortran_vec (), + status.fortran_vec (), lambda.fortran_vec (), + redcosts.fortran_vec (), time.fortran_vec (), + mem.fortran_vec ()); Octave_map extra; @@ -753,5 +759,11 @@ retval(1) = octave_value(fmin); retval(0) = octave_value(xmin); +#else + + gripe_not_supported ("glpk"); + +#endif + return retval; }
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -537,6 +537,18 @@ $< | $(SED) 's,lookup\[,gperf_lookup[,' > $@-t @$(top_srcdir)/move-if-change $@-t $@ +# How to make a .oct file from a .o file: + +ifeq ($(ENABLE_DYNAMIC_LINKING), true) + ifdef CXXPICFLAG + __glpk__.oct : pic/__glpk__.o octave$(EXEEXT) + $(DL_LD) $(DL_LDFLAGS) -o $@ $< $(OCT_LINK_DEPS) $(GLPK_LIBS) + else + __glpk__.oct : __glpk__.o octave$(EXEEXT) + $(DL_LD) $(DL_LDFLAGS) -o $@ $< $(OCT_LINK_DEPS) $(GLPK_LIBS) + endif +endif + check: all .PHONY: check
--- a/src/oct-conf.h.in +++ b/src/oct-conf.h.in @@ -148,6 +148,10 @@ #define OCTAVE_CONF_FPICFLAG %OCTAVE_CONF_FPICFLAG% #endif +#ifndef OCTAVE_CONF_GLPK_LIBS +#define OCTAVE_CONF_GLPK_LIBS %OCTAVE_CONF_GLPK_LIBS% +#endif + #ifndef OCTAVE_CONF_INCFLAGS #define OCTAVE_CONF_INCFLAGS %OCTAVE_CONF_INCFLAGS% #endif