Containers

Many of these containers were inspired by the RESOLVE/C++ course sequence at Ohio State. As such, most of the objects do not support copying in any form, only swapping is allowed. That is, when objects are added or removed from any of these containers they are swapped in and out, not copied.

This allows you to do things like have containers of containers of containers without encountering the overhead of the massive copying that would likely result if you did the same thing with the STL. It also means you can store objects that are not copyable inside these containers, which is not something you can do with the STL.

To use any of these containers all you need to do is #include the file indicated in the short section about the component you would like to use. Then pick which implementation you would like and typedef it to something nice. Here is an example of creating a typedef for a set of integers using the first kernel implementation.
typedef dlib::set<int>::kernel_1a set_of_ints;. Or as another example, if you wanted to make an expandable array of ints you might say
typedef dlib::array<int>::expand_1d_c array_of_ints;.

Note that it is assumed by these containers that swap() and operator< do not throw. They may not function correctly if this assumption is broken. Also note that the built in types (int, long, char, etc.) and std::string will not cause operator< or swap() to throw.

Note also that most of the containers inherit from the enumerable interface. Thus, all the member functions inherited from enumerable are defined in the enumerable class and their documentation is not repeated in each container's documentation. This includes the size() member function in each container.

Objects static_set array array2d binary_search_tree hash_map hash_set hash_table directed_graph graph map matrix math exp dlib/matrix/matrix_math_functions_abstract.h.html#exp log10 dlib/matrix/matrix_math_functions_abstract.h.html#log10 log dlib/matrix/matrix_math_functions_abstract.h.html#log sqrt dlib/matrix/matrix_math_functions_abstract.h.html#sqrt pow dlib/matrix/matrix_math_functions_abstract.h.html#pow squared dlib/matrix/matrix_math_functions_abstract.h.html#squared cubed dlib/matrix/matrix_math_functions_abstract.h.html#cubed sigmoid dlib/matrix/matrix_math_functions_abstract.h.html#sigmoid abs dlib/matrix/matrix_math_functions_abstract.h.html#abs reciprocal dlib/matrix/matrix_math_functions_abstract.h.html#reciprocal reciprocal_max dlib/matrix/matrix_math_functions_abstract.h.html#reciprocal_max normalize dlib/matrix/matrix_math_functions_abstract.h.html#normalize round dlib/matrix/matrix_math_functions_abstract.h.html#round ceil dlib/matrix/matrix_math_functions_abstract.h.html#ceil floor dlib/matrix/matrix_math_functions_abstract.h.html#floor round_zeros dlib/matrix/matrix_math_functions_abstract.h.html#round_zeros conj dlib/matrix/matrix_math_functions_abstract.h.html#conj norm dlib/matrix/matrix_math_functions_abstract.h.html#norm imag dlib/matrix/matrix_math_functions_abstract.h.html#imag real dlib/matrix/matrix_math_functions_abstract.h.html#real complex_matrix dlib/matrix/matrix_math_functions_abstract.h.html#complex_matrix sin dlib/matrix/matrix_math_functions_abstract.h.html#sin cos dlib/matrix/matrix_math_functions_abstract.h.html#cos tan dlib/matrix/matrix_math_functions_abstract.h.html#tan asin dlib/matrix/matrix_math_functions_abstract.h.html#asin acos dlib/matrix/matrix_math_functions_abstract.h.html#acos atan dlib/matrix/matrix_math_functions_abstract.h.html#atan sinh dlib/matrix/matrix_math_functions_abstract.h.html#sinh cosh dlib/matrix/matrix_math_functions_abstract.h.html#cosh tanh dlib/matrix/matrix_math_functions_abstract.h.html#tanh linear_algebra inv dlib/matrix/matrix_la_abstract.h.html#inv pinv dlib/matrix/matrix_la_abstract.h.html#pinv svd dlib/matrix/matrix_la_abstract.h.html#svd svd2 dlib/matrix/matrix_la_abstract.h.html#svd2 svd3 dlib/matrix/matrix_la_abstract.h.html#svd3 det dlib/matrix/matrix_la_abstract.h.html#det trace dlib/matrix/matrix_la_abstract.h.html#trace chol dlib/matrix/matrix_la_abstract.h.html#chol inv_lower_triangular dlib/matrix/matrix_la_abstract.h.html#inv_lower_triangular inv_upper_triangular dlib/matrix/matrix_la_abstract.h.html#inv_upper_triangular lu_decomposition dlib/matrix/matrix_la_abstract.h.html#lu_decomposition qr_decomposition dlib/matrix/matrix_la_abstract.h.html#qr_decomposition cholesky_decomposition dlib/matrix/matrix_la_abstract.h.html#cholesky_decomposition eigenvalue_decomposition dlib/matrix/matrix_la_abstract.h.html#eigenvalue_decomposition real_eigenvalues dlib/matrix/matrix_la_abstract.h.html#real_eigenvalues sub_expressions range dlib/matrix/matrix_subexp_abstract.h.html#range subm dlib/matrix/matrix_subexp_abstract.h.html#subm rowm dlib/matrix/matrix_subexp_abstract.h.html#rowm colm dlib/matrix/matrix_subexp_abstract.h.html#colm set_subm dlib/matrix/matrix_subexp_abstract.h.html#set_subm set_colm dlib/matrix/matrix_subexp_abstract.h.html#set_colm set_rowm dlib/matrix/matrix_subexp_abstract.h.html#set_rowm statistics sum dlib/matrix/matrix_utilities_abstract.h.html#sum sum_rows dlib/matrix/matrix_utilities_abstract.h.html#sum_rows sum_cols dlib/matrix/matrix_utilities_abstract.h.html#sum_cols prod dlib/matrix/matrix_utilities_abstract.h.html#prod mean dlib/matrix/matrix_utilities_abstract.h.html#mean max dlib/matrix/matrix_utilities_abstract.h.html#max min dlib/matrix/matrix_utilities_abstract.h.html#min find_min_and_max dlib/matrix/matrix_utilities_abstract.h.html#find_min_and_max index_of_min dlib/matrix/matrix_utilities_abstract.h.html#index_of_min index_of_max dlib/matrix/matrix_utilities_abstract.h.html#index_of_max variance dlib/matrix/matrix_utilities_abstract.h.html#variance covariance dlib/matrix/matrix_utilities_abstract.h.html#covariance randm dlib/matrix/matrix_utilities_abstract.h.html#randm utilities is_col_vector dlib/matrix/matrix_utilities_abstract.h.html#is_col_vector is_row_vector dlib/matrix/matrix_utilities_abstract.h.html#is_row_vector is_vector dlib/matrix/matrix_utilities_abstract.h.html#is_vector const_temp_matrix dlib/matrix/matrix_abstract.h.html#const_temp_matrix diag dlib/matrix/matrix_utilities_abstract.h.html#diag diagm dlib/matrix/matrix_utilities_abstract.h.html#diagm trans dlib/matrix/matrix_utilities_abstract.h.html#trans dot dlib/matrix/matrix_utilities_abstract.h.html#dot lowerm dlib/matrix/matrix_utilities_abstract.h.html#lowerm upperm dlib/matrix/matrix_utilities_abstract.h.html#upperm ones_matrix dlib/matrix/matrix_utilities_abstract.h.html#ones_matrix zeros_matrix dlib/matrix/matrix_utilities_abstract.h.html#zeros_matrix uniform_matrix dlib/matrix/matrix_utilities_abstract.h.html#uniform_matrix identity_matrix dlib/matrix/matrix_utilities_abstract.h.html#identity_matrix rotate dlib/matrix/matrix_utilities_abstract.h.html#rotate vector_to_matrix dlib/matrix/matrix_utilities_abstract.h.html#vector_to_matrix pointer_to_column_vector dlib/matrix/matrix_utilities_abstract.h.html#pointer_to_column_vector pointer_to_matrix dlib/matrix/matrix_utilities_abstract.h.html#pointer_to_matrix reshape_to_column_vector dlib/matrix/matrix_utilities_abstract.h.html#reshape_to_column_vector reshape dlib/matrix/matrix_utilities_abstract.h.html#reshape array_to_matrix dlib/matrix/matrix_utilities_abstract.h.html#array_to_matrix removerc dlib/matrix/matrix_utilities_abstract.h.html#removerc remove_row dlib/matrix/matrix_utilities_abstract.h.html#remove_row remove_col dlib/matrix/matrix_utilities_abstract.h.html#remove_col matrix_cast dlib/matrix/matrix_utilities_abstract.h.html#matrix_cast set_all_elements dlib/matrix/matrix_utilities_abstract.h.html#set_all_elements tmp dlib/matrix/matrix_utilities_abstract.h.html#tmp equal dlib/matrix/matrix_utilities_abstract.h.html#equal pointwise_multiply dlib/matrix/matrix_utilities_abstract.h.html#pointwise_multiply join_rows dlib/matrix/matrix_utilities_abstract.h.html#join_rows join_cols dlib/matrix/matrix_utilities_abstract.h.html#join_cols tensor_product dlib/matrix/matrix_utilities_abstract.h.html#tensor_product scale_columns dlib/matrix/matrix_utilities_abstract.h.html#scale_columns sort_columns dlib/matrix/matrix_utilities_abstract.h.html#sort_columns rsort_columns dlib/matrix/matrix_utilities_abstract.h.html#rsort_columns length dlib/matrix/matrix_utilities_abstract.h.html#length length_squared dlib/matrix/matrix_utilities_abstract.h.html#length_squared pixel_to_vector dlib/matrix/matrix_utilities_abstract.h.html#pixel_to_vector vector_to_pixel dlib/matrix/matrix_utilities_abstract.h.html#vector_to_pixel clamp dlib/matrix/matrix_utilities_abstract.h.html#clamp linspace dlib/matrix/matrix_utilities_abstract.h.html#linspace logspace dlib/matrix/matrix_utilities_abstract.h.html#logspace cartesian_product dlib/matrix/matrix_utilities_abstract.h.html#cartesian_product queue reference_counter type_safe_union sequence set stack std_vector_c static_map sliding_buffer tuple reference_wrapper smart pointers scoped_ptr shared_ptr shared_ptr_thread_safe weak_ptr
Interfaces map_pair enumerable remover remover dlib/interfaces/remover.h.html#remover asc_remover dlib/interfaces/remover.h.html#asc_remover pair_remover dlib/interfaces/remover.h.html#pair_remover asc_pair_remover dlib/interfaces/remover.h.html#asc_pair_remover
array dlib/array.h dlib/array/array_kernel_abstract.h This object is just like a C style array and the accessor functions operate in constant time. array_kernel_1 dlib/array/array_kernel_1.h This implementation is done using an array of pointers, each of which point to small sections of the array. This implementation allows the array to use only about as much memory as it needs at any given time. It does not use the memory_manager at all. kernel_1a is a typedef for array_kernel_1 array_kernel_2 dlib/array/array_kernel_2.h This implementation is done using a single array of max_size() elements. So this is just a simple layer on top of a C style array. It uses the memory_manager for all memory allocations. kernel_2a is a typedef for array_kernel_2 array_sort dlib/array/array_sort_abstract.h This extension gives an array the ability to sort its contents. array_sort_1 dlib/array/array_sort_1.h This is a version of the QuickSort algorithm. It swaps the entire array into a C style array, sorts it and then swaps it back into the array object. sort_1a is a typedef for array_kernel_1a extended by array_sort_1 sort_1b is a typedef for array_kernel_2a extended by array_sort_1 array_sort_2 dlib/array/array_sort_2.h This is a version of the QuickSort algorithm. sort_2a is a typedef for array_kernel_1a extended by array_sort_2 sort_2b is a typedef for array_kernel_2a extended by array_sort_2 array_expand dlib/array/array_expand_abstract.h This extension gives an array the ability to expand its size() beyond its max_size() without clearing out all its elements. It also adds a set of pop/push_back() functions similar to the ones in the std::vector object. array_expand_1 dlib/array/array_expand_1.h This is implemented by creating a new bigger array if max_size() isn't big enough, swapping everything into that new array, and then swapping that array with *this. expand_1a is a typedef for array_sort_1a extended by array_expand_1 expand_1b is a typedef for array_sort_1b extended by array_expand_1 expand_1c is a typedef for array_sort_2a extended by array_expand_1 expand_1d is a typedef for array_sort_2b extended by array_expand_1 sliding_buffer dlib/sliding_buffer.h dlib/sliding_buffer/sliding_buffer_kernel_abstract.h This object represents an array with the ability to rotate its contents left or right. sliding_buffer_kernel_1 dlib/sliding_buffer/sliding_buffer_kernel_1.h This object is implemented using a C style array in the obvious way. See the code for details. kernel_1a is a typedef for sliding_buffer_kernel_1 array2d dlib/array2d.h dlib/array2d/array2d_kernel_abstract.h This object represents a 2-Dimensional array of objects. image_ex.cpp.html array2d_kernel_1 dlib/array2d/array2d_kernel_1.h This is implemented in the obvious way. See the source for details. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for array2d_kernel_1 binary_search_tree dlib/binary_search_tree.h dlib/binary_search_tree/binary_search_tree_kernel_abstract.h This object represents a data dictionary that is built on top of some kind of binary search tree. binary_search_tree_kernel_1 dlib/binary_search_tree/binary_search_tree_kernel_1.h This implementation is done using an AVL binary search tree. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for binary_search_tree_kernel_1 binary_search_tree_kernel_2 dlib/binary_search_tree/binary_search_tree_kernel_2.h This implementation is done using a red-black binary search tree. It uses the memory_manager for all memory allocations. kernel_2a is a typedef for binary_search_tree_kernel_2 hash_map dlib/hash_map.h dlib/hash_map/hash_map_kernel_abstract.h This object represents a hashed mapping of items of type domain onto items of type range. hash_map_kernel_1 dlib/hash_map/hash_map_kernel_1.h This implementation is done using a hash_table object. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for hash_map_kernel_1 that uses hash_table_kernel_1a kernel_1b is a typedef for hash_map_kernel_1 that uses hash_table_kernel_2a kernel_1c is a typedef for hash_map_kernel_1 that uses hash_table_kernel_2b hash_set dlib/hash_set.h dlib/hash_set/hash_set_kernel_abstract.h This object represents a hashed unordered and unaddressed collection of unique items. hash_set_kernel_1 dlib/hash_set/hash_set_kernel_1.h This implementation is done using a hash_table object. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for hash_set_kernel_1 that uses hash_table_kernel_1a kernel_1b is a typedef for hash_set_kernel_1 that uses hash_table_kernel_2a kernel_1c is a typedef for hash_set_kernel_1 that uses hash_table_kernel_2b hash_table dlib/hash_table.h dlib/hash_table/hash_table_kernel_abstract.h This object represents a data dictionary that is built on top of some kind of hash table. hash_table_kernel_1 dlib/hash_table/hash_table_kernel_1.h This implementation is done using singly linked lists as hashing buckets. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for hash_table_kernel_1. hash_table_kernel_2 dlib/hash_table/hash_table_kernel_2.h This implementation is done using binary_search_tree objects as hashing buckets. It uses the memory_manager for all memory allocations. kernel_2a is a typedef for hash_table_kernel_2 that uses binary_search_tree_kernel_1 kernel_2b is a typedef for hash_table_kernel_2 that uses binary_search_tree_kernel_2 map dlib/map.h dlib/map/map_kernel_abstract.h This object represents a mapping of items of type domain onto items of type range. map_kernel_1 dlib/map/map_kernel_1.h This is implemented using the binary_search_tree component. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for map_kernel_1 that uses binary_search_tree_kernel_1 kernel_1b is a typedef for map_kernel_1 that uses binary_search_tree_kernel_2 enumerable dlib/interfaces/enumerable.h dlib/interfaces/enumerable.h This object is an abstract class which represents an interface for iterating over all the elements of a container. map_pair dlib/interfaces/map_pair.h dlib/interfaces/map_pair.h This object is an abstract class which represents an interface for accessing a pair from a container such as the map, hash_table, etc. remover dlib/interfaces/remover.h dlib/interfaces/remover.h This is a set of interfaces which gives the ability to remove all the items in a container without actually knowing what kind of container contains them. weak_ptr dlib/smart_pointers.h dlib/smart_pointers/weak_ptr_abstract.h

The weak_ptr class template stores a weak reference to an object that is already managed by a shared_ptr. To access the object, a weak_ptr can be converted to a shared_ptr using the member function lock().

This is an implementation of the std::tr1::weak_ptr template from the document ISO/IEC PDTR 19768, Proposed Draft Technical Report on C++ Library Extensions. The only deviation from that document is that this shared_ptr is declared inside the dlib namespace rather than std::tr1.

type_safe_union dlib/type_safe_union.h dlib/type_safe_union/type_safe_union_kernel_abstract.h This object is a type safe analogue of the classic C union object. The type_safe_union, unlike a union, can contain non-POD types such as std::string.

It is also implemented without performing any heap memory allocations and instead it stores everything on the stack.

pipe_ex_2.cpp.html
shared_ptr_thread_safe dlib/smart_pointers_thread_safe.h dlib/smart_pointers/shared_ptr_thread_safe_abstract.h

This object represents a reference counted smart pointer just like shared_ptr except that it is threadsafe.

shared_ptr dlib/smart_pointers.h dlib/smart_pointers/shared_ptr_abstract.h

This object represents a reference counted smart pointer. Each shared_ptr contains a pointer to some object and when the last shared_ptr that points to the object is destructed or reset() then the object is guaranteed to be deleted.

This is an implementation of the std::tr1::shared_ptr template from the document ISO/IEC PDTR 19768, Proposed Draft Technical Report on C++ Library Extensions. The only deviation from that document is that this shared_ptr is declared inside the dlib namespace rather than std::tr1.

tuple dlib/tuple.h dlib/tuple/tuple_abstract.h This is an implementation of a very simple templated container object. It contains between 0 and 31 objects where each object is listed explicitly in the tuple's template arguments.

Note that there is only one implementation of this object so there aren't any different kernels to choose from when you create instances of the tuple object. So for example, you could declare a tuple of 3 ints using the following statement: dlib::tuple<int,int,int> t;

reference_wrapper dlib/ref.h dlib/ref.h This is a simple object that just holds a reference to another object. It is useful because it can serve as a kind of "copyable reference". thread_function_ex.cpp.html scoped_ptr dlib/smart_pointers.h dlib/smart_pointers/scoped_ptr_abstract.h This is a implementation of the scoped_ptr class found in the Boost C++ library. It is a simple smart pointer class which guarantees that the pointer contained within it will always be deleted. The class does not permit copying and so does not do any kind of reference counting. Thus it is very simple and quite fast. graph dlib/graph.h dlib/graph/graph_kernel_abstract.h This object represents a graph which is a set of nodes with undirected edges connecting various nodes. graph_kernel_1 dlib/graph/graph_kernel_1.h This is implemented using std::vector to contain all the nodes and edges. kernel_1a is a typedef for graph_kernel_1 directed_graph dlib/directed_graph.h dlib/directed_graph/directed_graph_kernel_abstract.h This object represents a directed graph which is a set of nodes with directed edges connecting various nodes. directed_graph_kernel_1 dlib/directed_graph/directed_graph_kernel_1.h This is implemented using std::vector to contain all the nodes and edges. kernel_1a is a typedef for directed_graph_kernel_1 queue dlib/queue.h dlib/queue/queue_kernel_abstract.h This object represents a first in first out queue. queue_ex.cpp.html queue_kernel_1 dlib/queue/queue_kernel_1.h This is implemented in the obvious way using a singly linked list. It does not use the memory_manager at all. kernel_1a is a typedef for queue_kernel_1 queue_kernel_2 dlib/queue/queue_kernel_2.h This is implemented using a singly linked list and each node in the list contains block_size (a template parameter) elements. It uses the memory_manager for all memory allocations. kernel_2a is a typedef for queue_kernel_2 with a block_size of 20 kernel_2b is a typedef for queue_kernel_2 with a block_size of 100 queue_sort dlib/queue/queue_sort_abstract.h This extension gives a queue the ability to sort its contents. queue_sort_1 dlib/queue/queue_sort_1.h This is a version of the QuickSort algorithm. sort_1a is a typedef for queue_kernel_1a extended by queue_sort_1 sort_1b is a typedef for queue_kernel_2a extended by queue_sort_1 sort_1c is a typedef for queue_kernel_2b extended by queue_sort_1 reference_counter dlib/reference_counter.h dlib/reference_counter/reference_counter_kernel_abstract.h This object represents a container for an object and provides reference counting capabilities for the object it contains. reference_counter_kernel_1 dlib/reference_counter/reference_counter_kernel_1.h This implementation is done using pointers in the obvious way. kernel_1a is a typedef for reference_counter_kernel_1 sequence dlib/sequence.h dlib/sequence/sequence_kernel_abstract.h This object represents an ordered sequence of items, each item is associated with an integer value. The items are numbered from 0 to the number of items in the sequence minus 1. sequence_kernel_1 dlib/sequence/sequence_kernel_1.h This is implemented as an AVL binary search tree. Accessing(or adding or removing) an element always takes O(log n) time. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for sequence_kernel_1 sequence_kernel_2 dlib/sequence/sequence_kernel_2.h This implementation is done using a doubly linked list in the shape of a ring. It will remember the last element accessed(or added or removed) and give O(1) access time to the elements just left and right of it. Aside from that, accessing(or adding or removing) a random element will take O(n) and in the worst case it will take time proportional to the size of the sequence/2.

It does not use the memory_manager at all.

kernel_2a is a typedef for sequence_kernel_2
sequence_sort dlib/sequence/sequence_sort_abstract.h This extension gives a sequence the ability to sort its contents. sequence_sort_1 dlib/sequence/sequence_sort_1.h This is a version of the QuickSort algorithm and it sorts sequences of less than 30 elements with a selection sort. This implementation is fastest when used with sequence_kernel_2 and fairly slow when used with sequence_kernel_1 sort_1a is a typedef for sequence_kernel_2a extended by sequence_sort_1 sequence_sort_2 dlib/sequence/sequence_sort_2.h This is a version of the QuickSort algorithm. This implementation of sort is the best to use with sequence_kernel_1 objects but gives extremely poor performance with sequence_kernel_2 objects. sort_2a is a typedef for sequence_kernel_1a extended by sequence_sort_2 sequence_compare dlib/sequence/sequence_compare_abstract.h This extension gives sequences the ability to compare themselves using operator< and operator==. Thus they can be used in the other container classes that require this ability. (maps, sets, etc.) sequence_compare_1 dlib/sequence/sequence_compare_1.h The implementation is obvious. Click on the sequence_compare_1 link if you want to see. compare_1a is a typedef for sequence_kernel_1a extended by sequence_compare_1 compare_1b is a typedef for sequence_kernel_2a extended by sequence_compare_1
set dlib/set.h dlib/set/set_kernel_abstract.h This object represents an unordered and unaddressed collection of unique items. set_kernel_1 dlib/set/set_kernel_1.h This is implemented using the binary_search_tree component. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for set_kernel_1 that uses binary_search_tree_kernel_1 kernel_1b is a typedef for set_kernel_1 that uses binary_search_tree_kernel_2 set_compare dlib/set/set_compare_abstract.h This extension gives sets the ability to compare themselves using operator< and operator==. Thus they can be used in the other container classes that require this ability. (maps, sets, etc.) set_compare_1 dlib/set/set_compare_1.h The implementation is obvious. Click on the set_compare_1 link if you want to see. compare_1a is a typedef for set_kernel_1a extended by set_compare_1 compare_1b is a typedef for set_kernel_1b extended by set_compare_1 stack dlib/stack.h dlib/stack/stack_kernel_abstract.h This object represents a last in first out stack. stack_kernel_1 dlib/stack/stack_kernel_1.h This implementation is done in the obvious way using a singly linked list. It uses the memory_manager for all memory allocations. kernel_1a is a typedef for stack_kernel_1 static_map dlib/static_map.h dlib/static_map/static_map_kernel_abstract.h This object represents a mapping of items of type domain onto items of type range. The difference between this object and the normal map object is that it does not support adding or removing individual objects from itself. This allows implementations to focus on using less memory and achieving faster searching. static_map_kernel_1 dlib/static_map/static_map_kernel_1.h This implementation is just a sorted array which can be searched using a binary search. kernel_1a is a typedef for static_map_kernel_1 static_set dlib/static_set.h dlib/static_set/static_set_kernel_abstract.h This object represents an unordered and unaddressed collection of items. The difference between this object and the normal set object is that it does not support adding or removing individual objects from itself. This allows implementations to focus on using less memory and achieving faster searching. static_set_kernel_1 dlib/static_set/static_set_kernel_1.h This implementation is just a sorted array which can be searched using a binary search. kernel_1a is a typedef for static_set_kernel_1 static_set_compare dlib/static_set/static_set_compare_abstract.h This extension gives static_sets the ability to compare themselves using operator< and operator==. Thus they can be used in the other container classes that require this ability. (maps, static_sets, etc.) static_set_compare_1 dlib/static_set/static_set_compare_1.h The implementation is obvious. Click on the static_set_compare_1 link if you want to see. compare_1a is a typedef for static_set_kernel_1a extended by static_set_compare_1 matrix dlib/matrix.h dlib/matrix/matrix_abstract.h This is a 2D matrix object that enables you to write code that deals with matrices using a simple syntax similar to what can be written in MATLAB. It is implemented using the expression templates technique which allows it to eliminate the temporary matrix objects that would normally be returned from expressions such as M = A+B+C+D; Normally each invocation of the + operator would construct and return a temporary matrix object but using this technique we can avoid creating all these temporary objects and receive a large speed boost.

This object is also capable of using BLAS libraries such as ATLAS or the Intel MKL when available. To enable this feature all you have to do is #define DLIB_USE_BLAS and then make sure you link your application with your BLAS library. Additionally, the use of BLAS is transparent to the user, that is, the dlib matrix object uses BLAS internally to optimize all the various forms of matrix multiplication 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.

Finally, you don't need to #include anything to get the matrix extensions listed below. They are included by the dlib/matrix.h file for you.

matrix_ex.cpp.html matrix_expressions_ex.cpp.html matrix_utilities dlib/matrix/matrix_utilities_abstract.h This extension contains miscellaneous utility functions for manipulating matrix objects. matrix_la dlib/matrix/matrix_la_abstract.h This extension contains linear algebra functions to calculate QR, LU, Cholesky, eigenvalue, and singular value decompositions. It also contains a few other miscellaneous functions that solve systems of equations or calculate values derived from the above decompositions. matrix_math_functions dlib/matrix/matrix_math_functions_abstract.h This extension contains mathematical functions that operate on each element of a matrix independently. matrix_sub_expressions dlib/matrix/matrix_subexp_abstract.h This extension contains a number of functions for dealing with sub-matrices.
std_vector_c dlib/stl_checked.h dlib/stl_checked/std_vector_c_abstract.h This object is a simple wrapper around the std::vector object. It provides an identical interface but also checks the preconditions of each member function. That is, if you violate a requires clause the dlib::fatal_error exception is thrown.