The Library
Help/Info
Current Release









Last Modified:
Jan 03, 2011

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
[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 :)

Specification: dlib/bigint/bigint_kernel_abstract.h
File to include: dlib/bigint.h

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]

centered_rect



There are various overloads of this function but the basic idea is that it returns a rectangle with a given width and height and centered about a given point.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

copy_graph_structure



This function takes a graph or directed_graph and copies its structure to another graph or directed_graph object. The only restriction is that you can't copy the structure of a graph into a directed_graph. The three other possible combinations are allowed however.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

crc32



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

Specification: dlib/crc32/crc32_kernel_abstract.h
File to include: dlib/crc32.h

Implementations:
crc32_kernel_1:
This implementation uses the polynomial 0xedb88320.
kernel_1a
is a typedef for crc32_kernel_1
[top]

create_join_tree



This function takes a graph object and creates a join tree for that graph. Or in other words, this function finds a tree decomposition of the given graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

create_moral_graph



This function takes a directed_graph and returns the moralized version of the graph in the form of a graph object.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

edge



This function takes a graph object and a pair of indices. It returns a reference to the edge object between the two nodes with the given indices.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

find_connected_nodes



This function takes a node from a graph or directed_graph object and a set of unsigned longs. It finds all the nodes in the given graph that are connected to the given node by an undirected path and returns them in the set (also note that the original query node is also returned in this set).

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

gate



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

Specification: dlib/quantum_computing/quantum_computing_abstract.h
File to include: dlib/quantum_computing.h
Code Examples: 1

[top]

get_rect



This is a simple template function that returns a rectangle representing the size of a 2D container (e.g. matrix or array2d).

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

graph_contains_directed_cycle



This function checks a directed_graph for directed cycles.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

graph_contains_length_one_cycle



This function takes a graph or directed_graph object and returns true if and only if the graph contains a node that has an edge that links back to itself.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

graph_contains_undirected_cycle



This function checks a directed_graph for undirected cycles.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

graph_is_connected



This function takes a graph or directed_graph object and determines if the graph is connected. That is, it returns true if and only if there is an undirected path between any two nodes in the given graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

grow_rect



This function takes a rectangle object, grows its borders by a given amount, and returns the result.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

hsort_array



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

Specification: dlib/sort.h
File to include: dlib/sort.h

[top]

isort_array



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

Specification: dlib/sort.h
File to include: dlib/sort.h

[top]

is_clique



This function takes a graph and a set of node index values and checks if the specified set of nodes is a clique in the graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

is_join_tree



This function takes two graph objects and checks if the second of the two graphs is a valid join tree (aka tree decomposition) of the first graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

is_maximal_clique



This function takes a graph and a set of node index values and checks if the specified set of nodes is a maximal clique in the graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

md5



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

Specification: dlib/md5/md5_kernel_abstract.h
File to include: dlib/md5.h

[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.

Specification: dlib/algs.h
File to include: dlib/algs.h

[top]

move_rect



This function takes a rectangle and moves it so that it's upper left corner occupies the given location.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

nearest_point



This function takes a rectangle and a point and returns the point in the given rectangle that is nearest to the given point.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

point



This object represents a point inside a Cartesian coordinate system.

Specification: dlib/geometry/vector_abstract.h
File to include: dlib/geometry.h

[top]

point_rotator



This is an object that rotates a 2D vector or point object about the origin.

Specification: dlib/geometry/vector_abstract.h
File to include: dlib/geometry.h

[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.

Specification: dlib/algs.h
File to include: dlib/algs.h

[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.

Specification: dlib/sort.h
File to include: dlib/sort.h

[top]

quantum_register



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

Specification: dlib/quantum_computing/quantum_computing_abstract.h
File to include: dlib/quantum_computing.h
Code Examples: 1

[top]

rand



This object represents a pseudorandom number generator.

Specification: dlib/rand/rand_kernel_abstract.h
File to include: dlib/rand.h

Implementations:
rand_kernel_1:
This implementation is done using the Mersenne Twister algorithm.
kernel_1a
is a typedef for rand_kernel_1

Extensions to rand

rand_float

This extension gives rand the ability to generate random floating point numbers.

Specification: dlib/rand/rand_float_abstract.h

Implementations:
rand_float_1:
The implementation is obvious. Click on the link if you want to see.
float_1a
is a typedef for rand_kernel_1a extended by rand_float_1
[top]

randomly_subsample



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

Specification: dlib/statistics/random_subset_selector_abstract.h
File to include: dlib/statistics.h

[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.

Specification: dlib/statistics/random_subset_selector_abstract.h
File to include: dlib/statistics.h

[top]

rectangle



This object represents a rectangular region inside a Cartesian coordinate system. It allows you to easily represent and manipulate rectangles.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

resize_rect



This function takes a rectangle and returns a new rectangle with the given size but with the same upper left corner as the original rectangle.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

resize_rect_height



This function takes a rectangle and returns a new rectangle with the given height but otherwise with the same edge points as the original rectangle.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

resize_rect_width



This function takes a rectangle and returns a new rectangle with the given width but otherwise with the same edge points as the original rectangle.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

rotate_point



This is a function that rotates a 2D vector or point object about a given point.

Specification: dlib/geometry/vector_abstract.h
File to include: dlib/geometry.h

[top]

running_covariance



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

Specification: dlib/statistics/statistics_abstract.h
File to include: dlib/statistics.h

[top]

running_scalar_covariance



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

Specification: dlib/statistics/statistics_abstract.h
File to include: dlib/statistics.h

[top]

running_stats



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

Specification: dlib/statistics/statistics_abstract.h
File to include: dlib/statistics.h
Code Examples: 1

[top]

set_difference



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

Specification: dlib/set_utils/set_utils_abstract.h
File to include: dlib/set_utils.h

[top]

set_intersection



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

Specification: dlib/set_utils/set_utils_abstract.h
File to include: dlib/set_utils.h

[top]

set_intersection_size



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

Specification: dlib/set_utils/set_utils_abstract.h
File to include: dlib/set_utils.h

[top]

set_union



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

Specification: dlib/set_utils/set_utils_abstract.h
File to include: dlib/set_utils.h

[top]

shrink_rect



This function takes a rectangle object, shrinks its borders by a given amount, and returns the result.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[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.

Specification: dlib/algs.h
File to include: dlib/algs.h

[top]

translate_rect



This function takes a rectangle and moves it by a given number of units along the x and y axis relative to where it was before the move.

Specification: dlib/geometry/rectangle_abstract.h
File to include: dlib/geometry.h

[top]

triangulate_graph_and_find_cliques



This function takes a graph and turns it into a chordal graph. It also returns a set that contains all the cliques present in the chordal graph.

Specification: dlib/graph_utils/graph_utils_abstract.h
File to include: dlib/graph_utils.h

[top]

vector



This object represents a two or three dimensional vector.

Specification: dlib/geometry/vector_abstract.h
File to include: dlib/geometry.h