1. Michael Forbes
  2. broyden


broyden /

Filename Size Date modified Message
makefiles [888c39225055]
98 B
198 B
189 B
2.3 KB
4.9 KB
292 B
1.5 KB

Broyden Solvers

Broyden Solvers

This project contains solvers based on the extended Broyden method written in C++ using the armadillo linear algebra library. The library can be used from the C++ header files in a C++ application, or as a statically linked library libbroyden.a which provides a C interface (declared in src/interface.c and defined in src/interface.cpp).

In addition, we provide an automatically generated SWIG interface to the C++ classes so that these can be used from python through the mmf_broyden package.


To use the C/C++ libraries you will need to install my patched version of armadillo (I have critically modified the qr routine to work in a memory-limited context). You can get this using mercurial:

hg qclone https://bitbucket.org/mforbes/armadillo_patch_queue armadillo
  • Notes:

    • You will have to enable the Mercurial Queues Extension by including the following in your ~/.hgrc file:

      mq =
    • If you have LAPACK and BLAS libraries on your system, then armadillo can be used as a header-only library. To configure this automatically, you will need CMake which is used to locate your LAPACK and BLAS installations. You can bypass this step and obviate the need for CMake by manually editing the file include/armadillo_bits/config.hpp in the source distribution to define the appropriate macros. After this is done, just make sure that the include directory is included in your CPATH or in CPPFLAGS.

Once armadillo is installed, get the source for this project:

hg clone https://bitbucket.org/mforbes/broyden broyden
  • Note:

    • This mercurial repository will pull in the following projects as subrepositories:
      • https://bitbucket.org/mforbes/makefiles -> makefiles: Provides a common collection of GNU makefiles for building the project. This allows almost everything to be built automatically, including automatically generating prerequisites.
      • https://bitbucket.org/mforbes/cpp_utils -> external/mmfbb.cpp_utils: Some C++ logging utilities.
      • https://bitbucket.org/mforbes/swig_cpp_python -> external/mmfbb.swig_cpp_python provides the armadillo typemaps required to automatically generate the python interface. The only important files are external/mmfbb.swig_cpp_python/swig/arma.i and external/mmfbb.swig_cpp_python/swig/numpy.i which must be linked or copied to swig/arma.i and swig/numpy.i. (This should be done automatically upon checkout.)

You should now be able to make the library libbroyden.a by simply running:

  • Note:

    • This is presently broken: I need to complete rules for making libraries. As a work around, you can manually build the library bu running:

      ar rv _build/libbroyden.a _build/obj/interface.o

      The make command may fail to build some tests, but should build the interface.o file.

The python package is called mmf_broyden and can be built with:

make python

This will generate the SWIG wrappers in _build/_generated and build the python module (by running python setup.py build in build/lib*/mmf_broyden. You can install it for use with other python packages by running the usual:

python setup.py install

after which point you should be able to import it as import mmf_broyden. Note that the C++ classes are wrapped in mmf_broyden.swig.broyden. Note: by default, the python distutils usually compiles with -DNDEBUG which will disable all asserts and debugging logs. You might want to manually compile without this for debugging purposes (I don't know a good way of doing this with simple modifications of setup.py.)

Finally, you can make the documentation by running:

make doc

This will require Doxygen, Sphinx and several other packages. See https://bitbucket.org/mforbes/pymmf for details. I try to keep a fairly up-to-date version of the documentation at https://mforbes.bitbucket.org/broyden/index.html.