Linear AlgebraThis page documents the core linear algebra tools included in dlib. In particular, the three most important objects in this part of the library are the matrix, vector, and rectangle. All the other tools on this page are functions for manipulating these three objects. A good example and introduction can be found in the matrix example program. Most of the linear algebra tools deal with dense matrices. However, there is also a limited amount of support for working with sparse matrices and vectors. In particular, the dlib tools represent sparse vectors using the containers in the C++ STL. For details, see the notes at the top of dlib/svm/sparse_vector_abstract.h. Finally, note that all the dense matrix tools can be obtained by #including <dlib/matrix.h> while the sparse vector tools can be obtained by #including <dlib/sparse_vector.h>. The geometry tools can be used by #including <dlib/geometry.h>. |
This object is also capable of using BLAS and LAPACK libraries such as ATLAS or the Intel MKL when available. To enable BLAS support all you have to do is #define DLIB_USE_BLAS and then make sure you link your application with your BLAS library. Similarly, to enable LAPACK support just #define DLIB_USE_LAPACK and link to your LAPACK library. Finally, the use of BLAS and LAPACK is transparent to the user, that is, the dlib matrix object uses BLAS and LAPACK internally to optimize various operations while still allowing the user to use a simple MATLAB like syntax.
Note that the cmake files that come with dlib know how to link a project with ATLAS or the Intel MKL if you are building on a linux system. The cmake files may also work in a few other cases as well but I haven't tested any others. But in any case, by no means are you required to use the dlib cmake files.
It is also worth noting that all the preconditions of every function related to the matrix object are checked by DLIB_ASSERT statements and thus can be enabled by #defining ENABLE_ASSERTS or DEBUG. Doing this will cause your program to run slower but should catch any usage errors.
If you want to work with general N-dimensional column vectors then you should the matrix object. In particular, you should usually use a matrix with this type: dlib::matrix<double,0,1>.