The Library
Help/Info
Current Release
Sourceforge









Get dlib C++ Library at SourceForge.net. Fast, secure and Free Open Source software downloads

Last Modified:
Aug 23, 2013

Algorithms



This page documents library components that are all basically just implementations of mathematical functions or algorithms that don't fit in any of the other pages of the dlib documentation. So this includes things like checksums, cryptographic hashes, sorting, etc.


Tools
Statistics
Hashing
Filtering
[top]

bigint



This object represents an arbitrary precision unsigned integer. It's pretty simple. It's interface is just like a normal int, you don't have to tell it how much memory to use or anything unusual. It just goes :)

#include <dlib/bigint.h>
Detailed Documentation

Implementations:
bigint_kernel_1:
This implementation is done using an array of unsigned shorts. It is also reference counted. For further details see the above link. Also note that kernel_2 should be faster in almost every case so you should really just use that version of the bigint object.
kernel_1a
is a typedef for bigint_kernel_1
kernel_1a_c
is a typedef for kernel_1a that checks its preconditions.
bigint_kernel_2:
This implementation is basically the same as kernel_1 except it uses the Fast Fourier Transform to perform multiplications much faster.
kernel_2a
is a typedef for bigint_kernel_2
kernel_2a_c
is a typedef for kernel_2a that checks its preconditions.
[top]

correlation



This is a function for computing the correlation between matching elements of two std::vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

count_bits



This function counts the number of bits in an unsigned integer which are set to 1.

#include <dlib/hash.h>
Detailed Documentation

[top]

covariance



This is a function for computing the covariance between matching elements of two std::vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

crc32



This object represents the CRC-32 algorithm for calculating checksums.

#include <dlib/crc32.h>
Detailed Documentation

[top]

create_max_margin_projection_hash



Creates a random projection based locality sensitive hashing function. This is accomplished using a variation on the random hyperplane generation technique from the paper:
Random Maximum Margin Hashing by Alexis Joly and Olivier Buisson
In particular, we use a linear support vector machine to generate planes. We train it on randomly selected and randomly labeled points from the data to be hashed.

#include <dlib/lsh.h>
Detailed Documentation

[top]

create_random_projection_hash



Creates a random projection based locality sensitive hashing function. The projection matrix is generated by sampling its elements from a Gaussian random number generator.

#include <dlib/lsh.h>
Detailed Documentation

[top]

disjoint_subsets



This object represents a set of integers which is partitioned into a number of disjoint subsets. It supports the two fundamental operations of finding which subset a particular integer belongs to as well as merging subsets.

#include <dlib/disjoint_subsets.h>
Detailed Documentation

[top]

gate



This object represents a quantum gate that operates on a quantum_register.

#include <dlib/quantum_computing.h>
Detailed Documentation
C++ Example Programs: quantum_computing_ex.cpp

[top]

gaussian_random_hash



This function uses hashing to generate Gaussian distributed random values with mean 0 and variance 1.

#include <dlib/hash.h>
Detailed Documentation

[top]

hamming_distance



This function returns the hamming distance between two unsigned integers. That is, it returns the number of bits which differer in the two integers.

#include <dlib/hash.h>
Detailed Documentation

[top]

hash



This is a set of convenience functions for invoking murmur_hash3 on std::strings, std::vectors, std::maps, or dlib::matrix objects.

As an aside, the hash() for matrix objects is defined here. It has the same interface as all the others.



#include <dlib/hash.h>
Detailed Documentation

[top]

hash_samples



This is a simple function for hashing a bunch of vectors using a locality sensitive hashing object such as hash_similar_angles_128. It is also capable of running in parallel on a multi-core CPU.

#include <dlib/graph_utils_threaded.h>
Detailed Documentation

[top]

hash_similar_angles_128



This object is a tool for computing locality sensitive hashes that give vectors with small angles between each other similar hash values. In particular, this object creates 128 random planes which pass though the origin and uses them to create a 128bit hash.

#include <dlib/lsh.h>
Detailed Documentation

[top]

hash_similar_angles_256



This object is a tool for computing locality sensitive hashes that give vectors with small angles between each other similar hash values. In particular, this object creates 256 random planes which pass though the origin and uses them to create a 256bit hash.

#include <dlib/lsh.h>
Detailed Documentation

[top]

hash_similar_angles_512



This object is a tool for computing locality sensitive hashes that give vectors with small angles between each other similar hash values. In particular, this object creates 512 random planes which pass though the origin and uses them to create a 512bit hash.

#include <dlib/lsh.h>
Detailed Documentation

[top]

hash_similar_angles_64



This object is a tool for computing locality sensitive hashes that give vectors with small angles between each other similar hash values. In particular, this object creates 64 random planes which pass though the origin and uses them to create a 64bit hash.

#include <dlib/lsh.h>
Detailed Documentation

[top]

hsort_array



hsort_array is an implementation of the heapsort algorithm. It will sort anything that has an array like operator[] interface.

#include <dlib/sort.h>
Detailed Documentation

[top]

integrate_function_adapt_simp



Computes an approximation of the integral of a real valued function using the adaptive Simpson method outlined in
Gander, W. and W. Gautshi, "Adaptive Quadrature -- Revisited" BIT, Vol. 40, (2000), pp.84-101


#include <dlib/numerical_integration.h>
Detailed Documentation
C++ Example Programs: integrate_function_adapt_simp_ex.cpp

[top]

isort_array



isort_array is an implementation of the insertion sort algorithm. It will sort anything that has an array like operator[] interface.

#include <dlib/sort.h>
Detailed Documentation

[top]

kalman_filter



This object implements the Kalman filter, which is a tool for recursively estimating the state of a process given measurements related to that process. To use this tool you will have to be familiar with the workings of the Kalman filter. An excellent introduction can be found in the paper:
An Introduction to the Kalman Filter by Greg Welch and Gary Bishop


#include <dlib/filtering.h>
Detailed Documentation

[top]

md5



This is an implementation of The MD5 Message-Digest Algorithm as described in rfc1321.

#include <dlib/md5.h>
Detailed Documentation

[top]

mean_sign_agreement



This is a function for computing the probability that matching elements of two std::vectors have the same sign.

#include <dlib/statistics.h>
Detailed Documentation

[top]

mean_squared_error



This is a function for computing the mean squared error between matching elements of two std::vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

median



This function takes three parameters and finds the median of the three. The median is swapped into the first parameter and the first parameter ends up in one of the other two, unless the first parameter was the median to begin with of course.

#include <dlib/algs.h>
Detailed Documentation

[top]

murmur_hash3



This function takes a block of memory and returns a 32bit hash. The hashing algorithm used is Austin Appleby's excellent MurmurHash3.

#include <dlib/hash.h>
Detailed Documentation

[top]

murmur_hash3_128bit



This function takes a block of memory and returns a 128bit hash. The hashing algorithm used is Austin Appleby's excellent MurmurHash3.

#include <dlib/hash.h>
Detailed Documentation

[top]

numeric_constants



This is just a header file containing definitions of common numeric constants such as pi and e.

#include <dlib/numeric_constants.h>
Detailed Documentation

[top]

projection_hash



This is a tool for hashing elements of a vector space into the integers. It is intended to represent locality sensitive hashing functions such as the popular random projection hashing method.

#include <dlib/lsh.h>
Detailed Documentation

[top]

put_in_range



This is a simple function that takes a range and a value and returns the given value if it is within the range. If it isn't in the range then it returns the end of range value that is closest.

#include <dlib/algs.h>
Detailed Documentation

[top]

qsort_array



qsort_array is an implementation of the QuickSort algorithm. It will sort anything that has an array like operator[] interface. If the quick sort becomes unstable then it switches to a heap sort. This way sorting is guaranteed to take at most N*log(N) time.

#include <dlib/sort.h>
Detailed Documentation

[top]

quantum_register



This object represents a set of quantum bits. It can be used with the quantum gate object to simulate quantum algorithms.

#include <dlib/quantum_computing.h>
Detailed Documentation
C++ Example Programs: quantum_computing_ex.cpp

[top]

rand



This object represents a pseudorandom number generator.

#include <dlib/rand.h>
Detailed Documentation

[top]

randomly_subsample



This is a set of convenience functions for creating random subsets of data.

#include <dlib/statistics.h>
Detailed Documentation

[top]

random_subset_selector



This object is a tool to help you select a random subset of a large body of data. In particular, it is useful when the body of data is too large to fit into memory.

#include <dlib/statistics.h>
Detailed Documentation

[top]

rls_filter



This object is a tool for doing time series prediction using linear recursive least squares. In particular, this object takes a sequence of points from the user and, at each step, attempts to predict the value of the next point.

#include <dlib/filtering.h>
Detailed Documentation

[top]

running_covariance



This object is a simple tool for computing the mean and covariance of a sequence of vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

running_cross_covariance



This object is a simple tool for computing the mean and cross-covariance matrices of a sequence of pairs of vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

running_scalar_covariance



This object is a simple tool for computing the covariance of a sequence of scalar values.

#include <dlib/statistics.h>
Detailed Documentation

[top]

running_stats



This object represents something that can compute the running mean, variance, skewness, and kurtosis statistics of a stream of real numbers.

#include <dlib/statistics.h>
Detailed Documentation
C++ Example Programs: running_stats_ex.cpp, kcentroid_ex.cpp

[top]

r_squared



This is a function for computing the R squared coefficient between matching elements of two std::vectors.

#include <dlib/statistics.h>
Detailed Documentation

[top]

set_difference



This function takes two set objects and gives you their difference.

#include <dlib/set_utils.h>
Detailed Documentation

[top]

set_intersection



This function takes two set objects and gives you their intersection.

#include <dlib/set_utils.h>
Detailed Documentation

[top]

set_intersection_size



This function takes two set objects and tells you how many items they have in common.

#include <dlib/set_utils.h>
Detailed Documentation

[top]

set_union



This function takes two set objects and gives you their union.

#include <dlib/set_utils.h>
Detailed Documentation

[top]

split_array



This function is used to efficiently split array like objects into two parts. It uses the global swap() function instead of copying to move elements around, so it works on arrays of non-copyable types.

#include <dlib/array.h>
Detailed Documentation

[top]

square_root



square_root is a function which takes an unsigned long and returns the square root of it or if the root is not an integer then it is rounded up to the next integer.

#include <dlib/algs.h>
Detailed Documentation

[top]

uniform_random_hash



This function uses hashing to generate uniform random values in the range [0,1).

#include <dlib/hash.h>
Detailed Documentation