|
Blaze 3.9
|
Since Blaze is a header-only library, setting up the Blaze library on a particular system is a fairly easy two step process. In the following, this two step process is explained in detail, preceded only by a short summary of the requirements.
For maximum performance the Blaze library expects you to have a BLAS library installed (Intel MKL, ACML, Atlas, Goto, ...). If you don't have a BLAS library installed on your system, Blaze will still work and will not be reduced in functionality, but performance may be limited. Thus it is strongly recommended to install a BLAS library.
Additionally, for computing the determinant of a dense matrix, for the decomposition of dense matrices, for the dense matrix inversion, and for the computation of eigenvalues and singular values Blaze requires LAPACK. When either of these features is used it is necessary to link the LAPACK library to the final executable. If no LAPACK library is available the use of these features will result in a linker error.
Furthermore, it is possible to use Boost threads to run numeric operations in parallel. In this case the Boost library is required to be installed on your system. It is recommended to use the newest Boost library available, but Blaze requires at minimum the Boost version 1.54.0. If you don't have Boost installed on your system, you can download it for free from www.boost.org.
The first step is the installation of the Blaze header files. The most convenient way to do this is via CMake. Linux and macOS users can use the following two lines to copy the Blaze headers in the ./blaze subdirectory to the directory ${CMAKE_INSTALL_PREFIX}/include and the package configuration files to ${CMAKE_INSTALL_PREFIX}/share/blaze/cmake.
Windows users can do the same via the cmake-gui. Alternatively, it is possible to include Blaze by adding the following lines in any CMakeLists.txt file:
Alternatively Blaze provides the ./cmake/Blaze_Import CMake function to import the Blaze library into CMake based projects. This approach includes the configuration step (see Step 2: Configuration). To do so you need to import the function file like any other module/function into your CMake project:
After importing the function script you can import and use the Blaze library:
In this example, TARGET is the executable/library using Blaze and ARGUMENTS is the configuration you want for building Blaze. To configure Blaze using the import function you can set the input arguments like this example:
For more details about available configuration options please have a look at Configuration Files and the Blaze_Import.cmake function script.
An alternate way to install Blaze for Windows users is Microsoft's VC++ Packaging Tool (vcpkg). Blaze can be installed via the command line:
The tool automatically downloads the latest Blaze release and copies the header files to the common include directory. Please note that since Blaze is a header-only library the attempt to install any static or dynamic library will fail!
Since Blaze only consists of header files, the ./blaze subdirectory can be simply copied to a standard include directory (note that this requires root privileges):
Alternatively, on Unix-based machines (which includes Linux and Mac OS X) the CPLUS_INCLUDE_PATH environment variable can be set. The specified directory will be searched after any directories specified on the command line with the option -I and before the standard default directories (such as /usr/local/include and /usr/include). Assuming a user named 'Jon', the environment variable can be set as follows:
Last but not least, the ./blaze subdirectory can be explicitly specified on the command line. The following example demonstrates this by means of the GNU C++ compiler:
Windows doesn't have a standard include directory. Therefore the Blaze header files can be copied to any other directory or simply left in the default Blaze directory. However, the chosen include directory has to be explicitly specified as include path. In Visual Studio, this is done via the project property pages, configuration properties, C/C++, General settings. Here the additional include directories can be specified.
The second step is the configuration and customization of the Blaze library. Many aspects of Blaze can be adapted to specific requirements, environments and architectures. The most convenient way to configure Blaze is to modify the headers in the ./blaze/config/ subdirectory by means of CMake. Alternatively these header files can be customized manually. In both cases, however, the files are modified. If this is not an option it is possible to configure Blaze via the command line (see the tutorial section Configuration Files or the documentation in the configuration files).
Since the default settings are reasonable for most systems this step can also be skipped. However, in order to achieve maximum performance a customization of at least the following configuration files is required:
For an overview of other customization options and more details, please see the section Configuration Files.
The current major and minor version number of the Blaze library can be found in the <blaze/system/Version.h> header file. It is automatically included via the <blaze/Blaze.h> header file. The file contains the two following macros, which can for instance be used for conditional compilation:
Next: Getting Started