dalicious.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].

findCyclicSubgraphs
auto findCyclicSubgraphs(G graph, G.IncidentEdgesCache incidentEdgesCache = G.IncidentEdgesCache.init)

Find a cycle base of an undirected graph using the Paton's algorithm.

findMaximallyConnectedComponents
auto findMaximallyConnectedComponents(in size_t numNodes)

Find all maximal connected components of a graph-like structure. The predicate isConnected will be evaluated O(n^^2) times in the worst-case and Ω(n) in the best case. In expectation it will be evaluated θ(n*log(n)).

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.

mean
double mean(Values values, Weights weights)

Calculate the weighted mean of values.

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>