Using newmat11 with OPT++2.1

18 April 2006

Opt++ is a C++ library for maximising or minimising functions developed by Juan C. Meza
(Lawrence Berkeley National Laboratory) Patricia D. Hough and Pamela J. Williams (Sandia National Laboratories). Download it from http://csmr.ca.sandia.gov/projects/opt++/. It runs on a variety of Unix systems including Linux.

It makes extensive use my newmat09 matrix library. Newmat09 is now very old and one should update.

This note is about compiling Opt++ with when using newmat11.

My tests have all been under Red Hat Linux workstation running Gnu G++ version 3.2.3, Fedora 3 running Gnu G++ version 3.4.2, Cygwin under Windows XP running Gnu G++ version 3.3.3.

Here is what you need to do:

You need the version of newmat11 dated April, 2006 or later. Download from my download directory.

Find the newmat09 subdirectory of the OPT++2.1 directory. Delete the *.C files (but leave newmat1.C or some dummy file named newmat1.C) and copy the *.h and *.cpp newmat11 files and Makefile.in to this directory. It's fine to copy all the newmat11 files.

These are the .cpp files that you need:

  • bandmat.cpp
  • myexcept.cpp
  • newmat1.cpp
  • newmat2.cpp
  • cholesky.cpp
  • evalue.cpp
  • newmat3.cpp
  • newmat4.cpp
  • newmat5.cpp
  • newmat6.cpp
  • fft.cpp
  • hholder.cpp
  • newmat7.cpp
  • newmat8.cpp
  • newmat9.cpp
  • newmatex.cpp
  • jacobi.cpp
  • sort.cpp
  • newmatrm.cpp
  • submat.cpp
  • newmatnl.cpp
  • solution.cpp
  • svd.cpp
  • newfft.cpp
  • nm_misc.cpp

and these are the .h files:

  • controlw.h
  • include.h
  • myexcept.h
  • newmat.h
  • newmatap.h
  • newmatio.h
  • newmatnl.h
  • newmatrc.h
  • newmatrm.h
  • solution.h
     

There will be a file boolean.h left over from newmat09. I don't use this anymore but leave it on the directory to keep the make files happy.

Edit include.h to activate (i.e. remove // from the beginning) the line

   #define OPT_COMPATIBLE               // for use with opt++

With newer compilers you may also need to activate the line (with Gnu G++ you automatically get the correct version)

   #define _STANDARD_                   // using standard library

Go to the subdirectory src/Utils.

Edit file cblas.C. Comment out the function ColumnVector::Dot.

Edit file mcholesky.C. Insert

#define WANT_MATH

before the line  #include "include.h".

Go to the subdirectory include and edit file globals.h. Delete the max and min #defines and insert

inline double min(double a, double b) { return a < b ? a : b; }
inline double max(double a, double b) { return a > b ? a : b; }

Also insert

#define WANT_MATH

before the line  #include "include.h".

Then follow the instructions in the OPT++2.1 file INSTALL.


Warning: the linked makefile system in Opt++ does not correctly detect changes in the newmat09 directory. If you change any .h file in the newmat09 directory run

make clobber

to make sure all files affected by your change are recompiled.


 

Other systems:

I have compiled a subset of the code with MS Visual C++ 6.0. Contact me if you need details.