dentist.util.math

Some additional mathematical functions.

Members

Functions

N
ElementType!Range N(Range values, Num totalSize)

Calculate the Nxx (e.g. N50) of values.

absdiff
Num absdiff(in Num a, in Num b)

Returns the absolute difference between two numbers.

add
G.Edge add(ref G graph, G.Edge edge)

Add an edge to this graph and handle existing edges with handleConflict. The handler must have this signature Edge handleConflict(Edge, Edge).

bulkAdd
void bulkAdd(ref G graph, R edges)

Add a set of edges to this graph and merge mutli-edges using merge.

ceil
Integer ceil(in Integer x, in Integer base)

Round x upward according to base, ie. returns the next integer larger or equal to x which is divisible by base.

ceildiv
Integer ceildiv(in Integer a, in Integer b)

Returns the result of ceil(a / b) but uses integer arithmetic only.

findAllCliques
auto findAllCliques(in size_t[][] adjacencyList)

Find all maximal cliques in a graph represented by adjacencyList. The implementation is based on version 1 of the Bron-Kerbosch algorithm [1].

floor
Integer floor(in Integer x, in Integer base)

Round x downward according to base, ie. returns the next integer smaller or equal to x which is divisible by base.

longestIncreasingSubsequence
auto longestIncreasingSubsequence(Range sequence)

Calculate a longest increasing subsequence of sequence. This subsequence is not necessarily contiguous, or unique. Given a sequence of n elements the algorithm uses O(n log n) evaluation of pred.

mean
ElementType!Range mean(Range values)

Calculate the mean of range.

median
ElementType!Range median(Range values)

Calculate the median of range.

Structs

Graph
struct Graph(Node, Weight = void, Flag!"isDirected" isDirected = No.isDirected, EdgePayload = void)

This structure represents a graph with optional edge payloads. The graph is represented as a list of edges which is particularly suited for sparse graphs. While the set of nodes is fixed the set of edges is mutable.

NaturalNumberSet
struct NaturalNumberSet

Meta

License

Subject to the terms of the MIT license, as written in the included LICENSE file.

Authors

Arne Ludwig <arne.ludwig@posteo.de>