Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • v1.9.0
  • v1.8.0
  • v1.7.0
  • v1.6.0
  • v1.5.0
  • v1.4.0
  • v1.3.1
  • v1.3.0
  • v1.2.2
  • v1.2.1
  • v1.2.0
  • v1.1.0
  • v1.0.1
  • v1.0.0
15 results

README.md

Blame
  • Tim Kaune's avatar
    Tim Kaune authored
    79e8ab73
    History

    Brent's univariate minimizer and zero finder

    This project provides a CMake framework, that automatically downloads and builds Brent's univariate minimizer and zero finder from Netlib (https://netlib.org/c/brent.shar).

    Prerequisites

    What you need:

    Linux (Ubuntu)

    Use your distribution's package manager to install the packages cmake and gcc.

    $ sudo apt-get install cmake gcc

    Mac OS X

    Homebrew

    $ brew install cmake gcc

    MacPorts

    $ sudo port -v install cmake ninja clang-<XX> gcc<YY>
    $ sudo port -v install gcc<YY>-libcxx +clang<XX>
    $ sudo port -v install openblas +native

    where you have to replace <XX> with the latest stable version of Clang and <YY> with the latest stable version of GCC (it's a dependency of OpenBLAS). You can discover all available versions of Clang and GCC like this:

    $ port search --name --line --regex '^clang-?\d*\.?\d*$'
    $ port search --name --line --regex '^gcc\d*$'

    Windows

    Install Cygwin and use the Cygwin package manager to install the packages cmake and gcc-g++.

    How to compile

    1. Clone the git repository or download the BrentMinimizer source code archive and unpack it to an arbitrary directory (e.g. brent-minimizer).
    2. Go to the brent-minimizer directory.
      1. Type cp ./CMakeUserPresets.template.json ./CMakeUserPresets.json.

      2. Next, type cmake --workflow --list-presets. A list of available build workflows will be shown to you. It is strongly recommended to use a shared variant. You should prefer shared libraries and dynamic linking over static linking.

      3. For configuring, building and installing the project, type cmake --workflow --preset user-shared-release-install. This will try to populate the ./build directory with a CMake configuration tree, execute the build and install the project. By default, the configured installation directory is ./install.

        But it will fail due to an unaccepted license. Study the license text and proceed to the next step.

      4. Open ./CMakeUserPresets.json in your favorite editor and set "Brent_TERMS_ACCEPTED": true in the first configure preset "user-config".

      5. Repeat step 2.3. Configuring, building and installing should be successful now.

    Now, the brent-minimizer code is compiled and you can use it in other projects. The installed brent-minimizer package is discoverable by CMake as BrentMinimizer. In the CMakeLists.txt of the other project, call:

    find_package(BrentMinimizer CONFIG REQUIRED)

    This makes the Netlib::BrentMinimizer CMake library target available to you.

    Then, to help CMake discover the BrentMinimizer package, call CMake for the other project like this:

    $ cmake -B ./build -DCMAKE_PREFIX_PATH=/path/to/BrentMinimizer/install/prefix

    If BrentMinimizer is installed in a proper system-wide location, the CMAKE_PREFIX_PATH shouldn't be necessary.