Template shorthands, optimizers and constexpr data types. More...
Namespaces | |
Crtp | |
Curiously recurring template pattern classes. | |
Floating | |
Floating-point comparison helpers. | |
Functor | |
Functors for transformations. | |
Optimization | |
Functionality common to multiple optimizers. | |
Traits | |
Compile-time reflective trait objects. | |
Tuples | |
template metaprogramming metafunctions on tuple types | |
Data Structures | |
struct | Binding |
Type that will own rvalues, reference lvalues. More... | |
struct | BoundedNodeTrie |
Data structure to store chains of discrete choices with an finite range of choices at each position. More... | |
class | MinimalCache |
A minimal wrapper around a map class with cache semantics. More... | |
class | Cache |
class | Array |
struct | Bitmask |
class | Bitset |
Constexpr bitset class. More... | |
class | BTree |
A constexpr B-Tree. More... | |
class | DynamicArray |
class | DynamicMap |
A constexpr associative container with reasonably fast key-based lookup. More... | |
class | DynamicSet |
Tree-based set. More... | |
class | JSF |
General class enabling the construction of a pattern of PRNGs by Bob Jenkins. More... | |
struct | Generator |
Provides a seeded engine instance. More... | |
class | Optional |
An Option monadic type. More... | |
class | Optional< T & > |
struct | Pair |
Heterogeneous pair type. More... | |
class | UpperTriangularMatrix |
Strictly upper triangular matrix. More... | |
struct | Vector |
Constexpr three-dimensional vector math class. More... | |
class | Lbfgs |
LBFGS optimizer with optional boxing. More... | |
struct | NelderMead |
Nelder-Mead optimization. More... | |
struct | NewtonRaphson |
A very basic newton-raphson minimizer. More... | |
struct | SO3NelderMead |
Nelder-Mead optimization on SO(3) manifold. More... | |
struct | TrustRegionOptimizer |
Trust region Newton-Raphson minimizer with 2D subspace minimization. More... | |
struct | OrderedPair |
A class that imitates std::pair<T, U>, but whose template arguments are homogeneous and the stored values ordered (.first < .second). More... | |
struct | Permutation |
Container-abstracted permutation. More... | |
class | Poset |
Data structure for partially ordered sets with support for gradual ordering discovery. More... | |
class | StrongIndex |
Type helper for creating strong index types that are type-level distinct from their fundamental types. More... | |
struct | StrongIndexPermutation |
struct | TinyUnorderedSet |
An adapter class for std::vector that acts like an unordered set and stores its data in the underlying vector in an unordered fashion. More... | |
struct | TinySet |
An adapter class for std::vector that acts like an ordered set and stores its data in the underlying vector in order. More... | |
Typedefs | |
template<class ContainerType > | |
using | getValueType = typename Detail::getValueTypeImpl< ContainerType >::type |
Figures out the value type of a container via its iterators. | |
using | JSF32na = JSF< uint32_t, 27, 17, 0 > |
using | JSF32nb = JSF< uint32_t, 9, 16, 0 > |
using | JSF32nc = JSF< uint32_t, 9, 24, 0 > |
using | JSF32nd = JSF< uint32_t, 10, 16, 0 > |
using | JSF32ne = JSF< uint32_t, 10, 24, 0 > |
using | JSF32nf = JSF< uint32_t, 11, 16, 0 > |
using | JSF32ng = JSF< uint32_t, 11, 24, 0 > |
using | JSF32nh = JSF< uint32_t, 25, 8, 0 > |
using | JSF32ni = JSF< uint32_t, 25, 16, 0 > |
using | JSF32nj = JSF< uint32_t, 26, 8, 0 > |
using | JSF32nk = JSF< uint32_t, 26, 16, 0 > |
using | JSF32nl = JSF< uint32_t, 26, 17, 0 > |
using | JSF32nm = JSF< uint32_t, 27, 16, 0 > |
using | JSF32ra = JSF< uint32_t, 3, 14, 24 > |
using | JSF32rb = JSF< uint32_t, 3, 25, 15 > |
using | JSF32rc = JSF< uint32_t, 4, 15, 24 > |
using | JSF32rd = JSF< uint32_t, 6, 16, 28 > |
using | JSF32re = JSF< uint32_t, 7, 16, 27 > |
using | JSF32rf = JSF< uint32_t, 8, 14, 3 > |
using | JSF32rg = JSF< uint32_t, 11, 16, 23 > |
using | JSF32rh = JSF< uint32_t, 12, 16, 22 > |
using | JSF32ri = JSF< uint32_t, 12, 17, 23 > |
using | JSF32rj = JSF< uint32_t, 13, 16, 22 > |
using | JSF32rk = JSF< uint32_t, 15, 25, 3 > |
using | JSF32rl = JSF< uint32_t, 16, 9, 3 > |
using | JSF32rm = JSF< uint32_t, 17, 9, 3 > |
using | JSF32rn = JSF< uint32_t, 17, 27, 7 > |
using | JSF32ro = JSF< uint32_t, 19, 7, 3 > |
using | JSF32rp = JSF< uint32_t, 23, 15, 11 > |
using | JSF32rq = JSF< uint32_t, 23, 16, 11 > |
using | JSF32rr = JSF< uint32_t, 23, 17, 11 > |
using | JSF32rs = JSF< uint32_t, 24, 3, 16 > |
using | JSF32rt = JSF< uint32_t, 24, 4, 16 > |
using | JSF32ru = JSF< uint32_t, 25, 14, 3 > |
using | JSF32rv = JSF< uint32_t, 27, 16, 6 > |
using | JSF32rw = JSF< uint32_t, 27, 16, 7 > |
using | JSF32n = JSF32na |
using | JSF32r = JSF32rq |
using | JSF32 = JSF32n |
using | JSF64na = JSF< uint64_t, 39, 11, 0 > |
using | JSF64ra = JSF< uint64_t, 7, 13, 37 > |
using | JSF64n = JSF64na |
using | JSF64r = JSF64ra |
using | JSF64 = JSF64r |
Functions | |
template<class Container , typename T > | |
void | addToContainer (Container &container, const T &value) |
Adds an lvalue element to a container by calling the container's insert or push_back member functions, if one of either exists. | |
template<class Container , typename T > | |
void | addToContainer (Container &container, T &&value) |
Adds an rvalue to a container by calling the container's emplace or emplace_back member functions, if one of either exists. | |
template<class TargetContainer , class SourceContainer , class SizeModifierUnary = Functor::Identity> | |
void | reserveIfPossible (TargetContainer &target, const SourceContainer &source, SizeModifierUnary &&sourceModifierUnary=SizeModifierUnary{}) |
Rerves the space required in the target container if size can be determined from the source container. More... | |
template<typename T , typename... Tail> | |
constexpr auto | makeArray (T head, Tail...tail) -> Array< T, 1+sizeof...(Tail)> |
template<typename EnumType > | |
constexpr Bitmask< EnumType > | make_bitmask (EnumType a) |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t size, class UnaryFunction > | |
constexpr auto | map (const ArrayType< T, size > &array, UnaryFunction &&function) |
Maps all elements of any array-like container with a unary function. More... | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t size, class BinaryFunction > | |
constexpr T | reduce (const ArrayType< T, size > &array, T init, BinaryFunction &&reduction) |
Reduce an array-like container with a binary function. More... | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t size> | |
constexpr T | sum (const ArrayType< T, size > &array) |
Sum up all elements of an array-like class. More... | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t size> | |
PURITY_STRONG constexpr std::enable_if_t < std::is_arithmetic< T > ::value, ArrayType< T, size >> | iota () |
Iota for any array type. | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t begin, std::size_t end> | |
constexpr ArrayType< T,(end-begin)> | range () |
Range for any array type. | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t N1, std::size_t N2> | |
constexpr ArrayType< T, N1+N2 > | arrayConcatenate (const ArrayType< T, N1 > &a, const ArrayType< T, N2 > &b) |
Concatenation of two instances of an array-like class. | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t N, std::size_t... Ns> | |
constexpr auto | arrayConcatenate (const ArrayType< T, N > &startingArray, const ArrayType< T, Ns > &...remainingArrays) |
Variadic concatenation of multiple array-like class instances. | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t size> | |
constexpr bool | arraysEqual (const ArrayType< T, size > &a, const ArrayType< T, size > &b) |
Array-like container lexicographic equality comparaotr. More... | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t sizeA, std::size_t sizeB> | |
constexpr std::enable_if_t < (sizeA > sizeB), bool > | arraysLess (const ArrayType< T, sizeA > &a, const ArrayType< T, sizeB > &b) |
Lexicographical comparison for two instances of an array-like class. More... | |
template<typename T , class LessThanPredicate , class Iter > | |
constexpr Iter | lowerBound (Iter bound, Iter last, const T &item, LessThanPredicate predicate) |
Constexpr lower bound algorithm from STL. More... | |
template<class Container , typename T , class LessThanPredicate = std::less<>> | |
constexpr Container::const_iterator | binarySearch (const Container &container, const T &item, LessThanPredicate predicate=LessThanPredicate()) |
Binary search an order container. More... | |
template<class ContainerType , class LessThanComparator = std::less< getValueType<ContainerType> >> | |
constexpr bool | isPartiallyOrdered (const ContainerType &container, LessThanComparator comparator=LessThanComparator{}) |
Checks if a container is partially ordered. More... | |
template<class ContainerType , class LessThanComparator = std::less< getValueType<ContainerType> >> | |
constexpr bool | isTotallyOrdered (const ContainerType &container, LessThanComparator comparator=LessThanComparator{}) |
Checks if the container hold strictly increasing values. More... | |
template<template< typename, std::size_t > class ArrayType, typename T , std::size_t N, class BinaryFunction > | |
constexpr DynamicArray < DynamicArray< T, N >, N > | groupByEquality (const ArrayType< T, N > &data, BinaryFunction &&equalityComparator) |
template<typename T , std::size_t N> | |
DynamicArray< T, N > | merge (const DynamicArray< T, N > &a, const DynamicArray< T, N > &b) |
template<size_t nItems, typename T , template< typename, size_t > class ArrayType, class LessThanPredicate = std::less<T>, class EqualityPredicate = std::equal_to<T>> | |
constexpr DynamicSet< T, nItems, LessThanPredicate > | makeDynamicSet (const ArrayType< T, nItems > &array) |
Helper function to create a DynamicSet specifying only the maximum size. | |
template<typename T > | |
constexpr bool | testLogicalOperators (const T &a, const T &b) |
For any two types, check consistency of their logical operators. | |
template<typename T > | |
constexpr bool | testOperatorSmaller (const T &a, const T &b) |
Limited variant of testLogicalOperators. | |
template<class ContainerType > | |
constexpr Traits::getValueType < ContainerType > | sum (const ContainerType &container) |
Summation with zero-initialization. More... | |
template<class ContainerType > | |
constexpr std::enable_if_t < std::is_floating_point < Traits::getValueType < ContainerType > >::value, Traits::getValueType < ContainerType >> | average (const ContainerType &container) |
template<class ContainerType > | |
constexpr std::enable_if_t < !std::is_floating_point < Traits::getValueType < ContainerType > >::value, double > | average (const ContainerType &container) |
template<class ContainerType > | |
constexpr std::enable_if_t < std::is_floating_point < Traits::getValueType < ContainerType > >::value, Traits::getValueType < ContainerType >> | geometricMean (const ContainerType &container) |
Geometric average of all values in a container. More... | |
template<class ContainerType , typename FloatingType > | |
constexpr std::enable_if_t < std::is_floating_point < FloatingType >::value, FloatingType > | stddev (const ContainerType &container, const FloatingType averageValue) |
Calculate the standard deviation of a container with a known average. More... | |
template<class ContainerType > | |
constexpr auto | stddev (const ContainerType &container) |
template<class ContainerType > | |
constexpr auto | min (const ContainerType &container) |
Composable min_element function. Returns the smallest value of any container. More... | |
template<class ContainerType > | |
constexpr auto | max (const ContainerType &container) |
Composable max function. Returns the smallest value of any container. More... | |
template<typename T , size_t size> | |
std::array< T, size > | toSTL (const Array< T, size > &array) |
Converts an Array into a std::array. | |
template<typename T , size_t size> | |
std::vector< T > | toSTL (const DynamicArray< T, size > &dynamicArray) |
Converts a DynamicArray into a std::vector. | |
template<typename T , size_t size> | |
std::set< T > | toSTL (const DynamicSet< T, size > &dynamicSet) |
Converts a DynamicSet into a std::set. | |
template<template< typename, size_t > class ArrayType, typename ValueType , size_t size> | |
constexpr UpperTriangularMatrix < ValueType, size > | makeUpperTriangularMatrix (const ArrayType< ValueType, size > &data) |
Helper constructing function that deduces the required type signature. | |
PURITY_WEAK constexpr double | angle (const Vector &a, const Vector &b) |
Constexpr binary angle in radians calculation. More... | |
template<class Container , std::enable_if_t< Traits::hasSize< Container >::value, int > = 0> | |
auto | size (const Container &container) |
template<class UnaryFunction , typename T , template< typename, typename...> class Container, template< typename > class... Dependents> | |
auto | map_stl (const Container< T, Dependents< T >...> &container, UnaryFunction &&function) |
template<template< typename...> class Tuplelike, typename Unary , typename... Ts, std::enable_if_t<!Traits::isPairlike< Tuplelike< Ts...>>::value &&Traits::isTuplelike< Tuplelike< Ts...>>::value > * = nullptr> | |
constexpr auto | map (Tuplelike< Ts...> &&tup, Unary &&f) |
template<typename Pairlike , typename Unary , std::enable_if_t< Traits::isPairlike< Pairlike >::value &&!Traits::isTuplelike< Pairlike >::value > * = nullptr> | |
constexpr auto | map (Pairlike &&pair, Unary &&f) |
template<class Container , class UnaryFunction , std::enable_if_t<!Traits::isPairlike< Container >::value &&!Traits::isTuplelike< Container >::value > * = nullptr> | |
auto | map (Container &&container, UnaryFunction &&function) |
Maps all values of a container using a unary function. Returns a vector. More... | |
template<class Container , class Callable > | |
void | forEach (const Container &container, Callable &&callable) |
Apply a callable for all values of a container. | |
template<class Container , typename ComparisonFunction , typename MappingFunction > | |
Container::const_iterator | select (const Container &container, ComparisonFunction &&comparator, MappingFunction &&mapFunction) |
Select a value from a container. More... | |
template<class Container , typename T , class BinaryFunction > | |
T | accumulate (const Container &container, T init, BinaryFunction &&reductionFunction) |
Accumulate shorthand. More... | |
template<class Container , class UnaryPredicate = Functor::Identity> | |
bool | all_of (const Container &container, UnaryPredicate &&predicate=UnaryPredicate{}) |
all_of shorthand More... | |
template<class Container , class UnaryPredicate = Functor::Identity> | |
bool | any_of (const Container &container, UnaryPredicate &&predicate=UnaryPredicate{}) |
any_of shorthand More... | |
template<class Container > | |
void | sort (Container &container) |
Calls std::sort on a container. | |
template<class Container , typename Comparator > | |
void | sort (Container &container, Comparator &&comparator) |
Calls std::sort with a custom comparator on a container. | |
template<class Container > | |
void | reverse (Container &container) |
In-place reversal. | |
template<class Container , typename T > | |
void | remove (Container &container, const T &value) |
Applies erase-remove idiom in-place to container. | |
template<class Container , class UnaryFunction > | |
void | remove_if (Container &container, UnaryFunction &&predicate) |
Applies erase-remove idiom in-place to container with a predicate function. | |
template<class Container , class Predicate > | |
Container | copy_if (const Container &container, Predicate &&predicate) |
template<class Container > | |
Container | sorted (Container container) |
template<class Container , typename Comparator > | |
Container | sorted (Container container, Comparator &&comparator) |
template<class Container , typename T > | |
auto | find (const Container &container, const T &needle) |
std::find shorthand | |
template<class Container , typename UnaryPredicate > | |
auto | find_if (const Container &container, UnaryPredicate &&predicate) |
std::find_if shorthand | |
template<class Container , typename T > | |
std::size_t | index (const Container &container, const T &needle) |
template<class Container , typename UnaryPredicate > | |
std::size_t | index_if (const Container &container, UnaryPredicate &&predicate) |
template<typename T > | |
std::vector< T > | iota (unsigned upperBound) |
vector iota shorthand | |
template<class Container > | |
auto | makeContainsPredicate (const Container &container) |
Creates a predicate that uses std::find for the container's value type. | |
template<class Container , class UnaryFunction > | |
std::vector< std::vector < Traits::getValueType < Container > >> | groupByMapping (const Container &container, UnaryFunction &&function) |
template<class Container , class BinaryFunction > | |
std::vector< std::vector < Traits::getValueType < Container > >> | groupByEquality (const Container &container, BinaryFunction &&compareEqual) |
template<typename HT , typename TT , typename Function > | |
auto | invoke (Function &&function, const boost::tuples::cons< HT, TT > &tuple) |
Invokes a function with all values in a given boost tuple. | |
template<typename Fn , typename TupleType , std::enable_if_t< Detail::isTupleCallable< Fn, TupleType >::value, int > = 0> | |
auto | invoke (Fn &&function, const TupleType &tuple) |
If a callable can be called by unpacking a supplied tuple of arguments, the tuple is called. More... | |
template<typename Fn , typename... Args, std::enable_if_t< sizeof...(Args)!=1||!Detail::isTupleCallable< Fn, Args...>::value, int > = 0> | |
auto | invoke (Fn &&function, Args &&...args) |
template<typename Functor > | |
auto | make_tuple_callable (Functor &&functor) |
template<typename Derived > | |
bool | positiveDefinite (const Eigen::MatrixBase< Derived > &matrix) |
Determine whether a matrix is positive definite. More... | |
template<typename Derived > | |
bool | positiveSemidefinite (const Eigen::MatrixBase< Derived > &matrix) |
Determine whether a matrix is positive semidefinite. More... | |
template<class Container > | |
constexpr std::size_t | permutationIndex (const Container &container) |
Calculate the index of permutation of elements in a container. More... | |
template<typename Container > | |
constexpr void | inPlaceSwap (Container &data, const std::size_t a, const std::size_t b) |
Index-based in-place swapping of elements in an array-like container. More... | |
template<typename Container > | |
constexpr void | inPlaceReverse (Container &data, const std::size_t indexFrom, const std::size_t indexTo) |
Index-based in-place reversal of elements in an array-like container. More... | |
template<typename Container > | |
constexpr bool | inPlaceNextPermutation (Container &data, const std::size_t first, const std::size_t last) |
In-place next permutation. More... | |
template<typename Container > | |
constexpr bool | inPlaceNextPermutation (Container &data) |
template<typename Container > | |
constexpr bool | inPlacePreviousPermutation (Container &data, const std::size_t first, const std::size_t last) |
In-place previous permutation. More... | |
template<typename Container > | |
constexpr bool | inPlacePreviousPermutation (Container &data) |
template<class Container > | |
bool | next_permutation (Container &container) |
Calls std::next_permutation. | |
template<class Container > | |
bool | prev_permutation (Container &container) |
Calls std::prev_permutation. | |
template<class Container > | |
bool | nextCombinationPermutation (Container &toPermute, const Container &limits) |
For when you have to implement variable-depth for loops, each with different limits. More... | |
template<typename T , template< typename > class Comparator, template< typename >class Allocator> | |
std::set< T, Comparator< T > , Allocator< T > > | set_intersection (const std::set< T, Comparator< T >, Allocator< T >> &a, const std::set< T, Comparator< T >, Allocator< T >> &b) |
template<typename T , template< typename > class Comparator, template< typename >class Allocator> | |
std::set< T, Comparator< T > , Allocator< T > > | set_union (const std::set< T, Comparator< T >, Allocator< T >> &a, const std::set< T, Comparator< T >, Allocator< T >> &b) |
template<typename T , template< typename > class Comparator, template< typename >class Allocator> | |
std::set< T, Comparator< T > , Allocator< T > > | set_symmetric_difference (const std::set< T, Comparator< T >, Allocator< T >> &a, const std::set< T, Comparator< T >, Allocator< T >> &b) |
std::vector< std::string > | split (const std::string &s, char delimiter) |
template<class Container > | |
std::enable_if_t < !std::is_same < Traits::getValueType < Container >, std::string > ::value, std::string > | condense (const Container &container, const std::string &joiningChar=",") |
template<class Container > | |
std::enable_if_t< std::is_same < Traits::getValueType < Container >, std::string > ::value, std::string > | condense (const Container &container, const std::string &joiningChar=",") |
std::string | stringify (const std::string &x) |
template<typename T > | |
std::string | stringify (const boost::optional< T > &optional) |
template<typename T > | |
std::enable_if_t< std::is_enum < T >::value, std::string > | stringify (const T &enumType) |
template<typename T > | |
std::enable_if_t < std::is_arithmetic< T > ::value, std::string > | stringify (const T &a) |
template<typename T , typename U > | |
std::string | stringify (const std::pair< T, U > &pair) |
template<typename T > | |
std::string | stringify (const std::vector< T > &vec) |
template<typename T , std::size_t size> | |
std::string | stringify (const std::array< T, size > &arr) |
template<typename T > | |
std::string | stringify (const std::set< T > &set) |
template<typename T > | |
std::string | stringify (const std::unordered_set< T > &set) |
template<typename T > | |
std::string | stringify (const std::list< T > &list) |
template<typename T > | |
std::string | stringify (const std::forward_list< T > &list) |
template<typename T , typename U > | |
std::string | stringify (const std::map< T, U > &map) |
template<typename T , typename U > | |
std::string | stringify (const std::unordered_map< T, U > &map) |
template<typename... Ts> | |
std::string | stringify (const std::tuple< Ts...> &tuple) |
template<typename T > | |
std::enable_if_t < Detail::isMapType< T > ::value, std::string > | stringifyMap (const T &map) |
template<typename T > | |
std::string | stringifyContainer (const T &container) |
template<typename Container , class ElementStringifier > | |
std::string | stringifyContainer (const Container &container, ElementStringifier &&stringifier) |
template<typename TupleType , size_t... Inds> | |
std::string | stringifyTuple (const TupleType &tuple, std::index_sequence< Inds...>) |
template<typename Tag , typename T > | |
std::size_t | hash_value (const StrongIndex< Tag, T > &v) |
Hash support function for strong index types. More... | |
template<class UnorderedSetContainer > | |
UnorderedSetContainer | unorderedSetSymmetricDifference (const UnorderedSetContainer &a, const UnorderedSetContainer &b) |
template<class UnorderedSetContainer > | |
UnorderedSetContainer | unorderedSetDifference (const UnorderedSetContainer &a, const UnorderedSetContainer &b) |
template<class UnorderedSetContainer > | |
UnorderedSetContainer | unorderedSetIntersection (const UnorderedSetContainer &a, const UnorderedSetContainer &b) |
template<class UnorderedSetContainer > | |
UnorderedSetContainer | unorderedSetUnion (const UnorderedSetContainer &a, const UnorderedSetContainer &b) |
Template shorthands, optimizers and constexpr data types.
T Scine::Molassembler::Temple::accumulate | ( | const Container & | container, |
T | init, | ||
BinaryFunction && | reductionFunction | ||
) |
Accumulate shorthand.
Complexity \(\Theta(N)\)
bool Scine::Molassembler::Temple::all_of | ( | const Container & | container, |
UnaryPredicate && | predicate = UnaryPredicate {} |
||
) |
all_of shorthand
Complexity \(O(N)\)
PURITY_WEAK constexpr double Scine::Molassembler::Temple::angle | ( | const Vector & | a, |
const Vector & | b | ||
) |
Constexpr binary angle in radians calculation.
Complexity \(\Theta(1)\)
bool Scine::Molassembler::Temple::any_of | ( | const Container & | container, |
UnaryPredicate && | predicate = UnaryPredicate {} |
||
) |
any_of shorthand
Complexity \(O(N)\)
constexpr bool Scine::Molassembler::Temple::arraysEqual | ( | const ArrayType< T, size > & | a, |
const ArrayType< T, size > & | b | ||
) |
Array-like container lexicographic equality comparaotr.
Complexity \(O(N)\)
constexpr std::enable_if_t< (sizeA > sizeB), bool> Scine::Molassembler::Temple::arraysLess | ( | const ArrayType< T, sizeA > & | a, |
const ArrayType< T, sizeB > & | b | ||
) |
Lexicographical comparison for two instances of an array-like class.
Complexity \(O(N)\)
constexpr std::enable_if_t< std::is_floating_point<Traits::getValueType<ContainerType> >::value, Traits::getValueType<ContainerType>> Scine::Molassembler::Temple::average | ( | const ContainerType & | container | ) |
Composable average function. Returns the average (always as a double) of any basic data type. An assert checks whether the function receives an empty container.
Container must implement begin, end and size members, the contained type must have operator+ and be convertible to double.
Complexity \(\Theta(N)\)
constexpr std::enable_if_t< !std::is_floating_point<Traits::getValueType<ContainerType> >::value, double> Scine::Molassembler::Temple::average | ( | const ContainerType & | container | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
constexpr Container::const_iterator Scine::Molassembler::Temple::binarySearch | ( | const Container & | container, |
const T & | item, | ||
LessThanPredicate | predicate = LessThanPredicate() |
||
) |
Binary search an order container.
Binary searches within an ordered container. Returns an iterator to the sought element if found, otherwise returns the end iterator.
Complexity \(\Theta(N log N)\)
std::enable_if_t< !std::is_same< Traits::getValueType<Container>, std::string >::value, std::string> Scine::Molassembler::Temple::condense | ( | const Container & | container, |
const std::string & | joiningChar = "," |
||
) |
Condenses an iterable container into a comma-separated string of string representations of its contents. Requires container iterators to satisfy ForwardIterators and the contained type to be a valid template argument for std::to_string, which in essence means this works only for (a few) STL containers and (most) built-in datatypes.
constexpr std::enable_if_t< std::is_floating_point<Traits::getValueType<ContainerType> >::value, Traits::getValueType<ContainerType>> Scine::Molassembler::Temple::geometricMean | ( | const ContainerType & | container | ) |
Geometric average of all values in a container.
container | Complexity \(\Theta(N)\) |
std::vector< std::vector< Traits::getValueType<Container> >> Scine::Molassembler::Temple::groupByEquality | ( | const Container & | container, |
BinaryFunction && | compareEqual | ||
) |
Split a container's values by a binary comparison function. Returns a ragged 2D vector.
constexpr DynamicArray< DynamicArray<T, N>, N> Scine::Molassembler::Temple::groupByEquality | ( | const ArrayType< T, N > & | data, |
BinaryFunction && | equalityComparator | ||
) |
Groups data by equality.
std::vector< std::vector< Traits::getValueType<Container> >> Scine::Molassembler::Temple::groupByMapping | ( | const Container & | container, |
UnaryFunction && | function | ||
) |
Split a container's values by a mapping function whose return value elements are compared with. Matching mapped values are grouped and returned in a ragged 2D vector.
std::size_t Scine::Molassembler::Temple::hash_value | ( | const StrongIndex< Tag, T > & | v | ) |
Hash support function for strong index types.
Allows the use of strong index types in unordered STL containers like so:
constexpr bool Scine::Molassembler::Temple::inPlaceNextPermutation | ( | Container & | data, |
const std::size_t | first, | ||
const std::size_t | last | ||
) |
In-place next permutation.
In-place next permutation of elements in an array-like type. 1:1 index-based variant of std::next_permutation NOTE: works with std::array only in C++17 (missing constexpr markers)
Complexity \(O(N/2)\)
constexpr bool Scine::Molassembler::Temple::inPlaceNextPermutation | ( | Container & | data | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
constexpr bool Scine::Molassembler::Temple::inPlacePreviousPermutation | ( | Container & | data, |
const std::size_t | first, | ||
const std::size_t | last | ||
) |
In-place previous permutation.
In-place previous permutation of elements in an array-like type. 1:1 index-based variant of std::prev_permutation NOTE: works with std::array only in C++17
Complexity \(O(N/2)\)
constexpr bool Scine::Molassembler::Temple::inPlacePreviousPermutation | ( | Container & | data | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
constexpr void Scine::Molassembler::Temple::inPlaceReverse | ( | Container & | data, |
const std::size_t | indexFrom, | ||
const std::size_t | indexTo | ||
) |
Index-based in-place reversal of elements in an array-like container.
Complexity \(\Theta(N)\)
constexpr void Scine::Molassembler::Temple::inPlaceSwap | ( | Container & | data, |
const std::size_t | a, | ||
const std::size_t | b | ||
) |
Index-based in-place swapping of elements in an array-like container.
Complexity \(\Theta(1)\)
auto Scine::Molassembler::Temple::invoke | ( | Fn && | function, |
const TupleType & | tuple | ||
) |
If a callable can be called by unpacking a supplied tuple of arguments, the tuple is called.
constexpr bool Scine::Molassembler::Temple::isPartiallyOrdered | ( | const ContainerType & | container, |
LessThanComparator | comparator = LessThanComparator {} |
||
) |
Checks if a container is partially ordered.
Checks if a container holds strictly non-decreasing sequential values, i.e. its values are partially ordered.
Partially ordered: 1, 1, 2, 3 Totally ordered: 1, 2, 3 (no duplicates) Neither: 2, 1, 3
Complexity \(O(N)\)
constexpr bool Scine::Molassembler::Temple::isTotallyOrdered | ( | const ContainerType & | container, |
LessThanComparator | comparator = LessThanComparator {} |
||
) |
Checks if the container hold strictly increasing values.
Checks if a container holds strictly increasing values, i.e. its values are totally ordered.
Partially ordered: 1, 1, 2, 3 Totally ordered: 1, 2, 3 (no duplicates) Neither: 2, 1, 3
Complexity \(O(N)\)
constexpr Iter Scine::Molassembler::Temple::lowerBound | ( | Iter | bound, |
Iter | last, | ||
const T & | item, | ||
LessThanPredicate | predicate | ||
) |
Constexpr lower bound algorithm from STL.
Returns an index within the passed array-like container whose element at that index is not less than the passed vaue. Proceeds via binary search. 1:1 constexpr variant of std::lower_bound.
Complexity \(\Theta(N log N)\)
constexpr auto Scine::Molassembler::Temple::map | ( | const ArrayType< T, size > & | array, |
UnaryFunction && | function | ||
) |
Maps all elements of any array-like container with a unary function.
Complexity \(\Theta(N)\)
auto Scine::Molassembler::Temple::map | ( | Container && | container, |
UnaryFunction && | function | ||
) |
Maps all values of a container using a unary function. Returns a vector.
Complexity \(\Theta(N)\)
auto Scine::Molassembler::Temple::map_stl | ( | const Container< T, Dependents< T >...> & | container, |
UnaryFunction && | function | ||
) |
Maps the values in a container using a unary function.
Requires:
Besides custom containers that fulfill the required criteria, this function should be valid for the following STL containers:
Notably absent: array, map, multimap, unordered_multimap (some are covered by specializations below!)
Complexity \(\Theta(N)\)
constexpr auto Scine::Molassembler::Temple::max | ( | const ContainerType & | container | ) |
Composable max function. Returns the smallest value of any container.
Container must implement begin, end iterators. The iterators must be copy-assignable. The contained type must implement operator <.
Complexity \(\Theta(N)\)
constexpr auto Scine::Molassembler::Temple::min | ( | const ContainerType & | container | ) |
Composable min_element function. Returns the smallest value of any container.
Container must implement begin, end iterators. The iterators must be copy-assignable. The contained type must implement operator <.
Complexity \(\Theta(N)\)
bool Scine::Molassembler::Temple::nextCombinationPermutation | ( | Container & | toPermute, |
const Container & | limits | ||
) |
For when you have to implement variable-depth for loops, each with different limits.
Increments a container containing indices for each depth according to a const container containing the limits for each. Limits are exclusive!
E.g. for the limits 232, increments through the sequence 000 -> 001 -> 010 -> 011 -> 020 -> 021 -> 100 -> 101 -> 110 -> 111 -> 120 ...
Complexity \(\Theta(N)\)
constexpr std::size_t Scine::Molassembler::Temple::permutationIndex | ( | const Container & | container | ) |
Calculate the index of permutation of elements in a container.
The elements in the container must be comparable with a weak ordering.
Complexity \(\Theta(N^2)\)
bool Scine::Molassembler::Temple::positiveDefinite | ( | const Eigen::MatrixBase< Derived > & | matrix | ) |
Determine whether a matrix is positive definite.
matrix
must be hermitianbool Scine::Molassembler::Temple::positiveSemidefinite | ( | const Eigen::MatrixBase< Derived > & | matrix | ) |
Determine whether a matrix is positive semidefinite.
matrix
must be hermitianconstexpr T Scine::Molassembler::Temple::reduce | ( | const ArrayType< T, size > & | array, |
T | init, | ||
BinaryFunction && | reduction | ||
) |
Reduce an array-like container with a binary function.
Reduction of any array-like container with a binary function. This function is somewhat restricted, in that the type of the reduction must be identical to the value type of the array-like container. The binary function must have the signature T(const T& reduction, const T& element).
Complexity \(\Theta(N)\)
void Scine::Molassembler::Temple::reserveIfPossible | ( | TargetContainer & | target, |
const SourceContainer & | source, | ||
SizeModifierUnary && | sourceModifierUnary = SizeModifierUnary {} |
||
) |
Rerves the space required in the target container if size can be determined from the source container.
If the source container implements a size() const member and the target container implements a reserve() member, the target container reserves space according to the result of the source container size() call modified by the sourceModifierUnary.
TargetContainer | the Container type in which space should be reserved |
SourceContainer | The Container type whose size is used to calculate required size of the target |
SizeModifierUnary | A unary callable type that transforms the type returned by SourceContainer.size(), if applicable |
target | The container in which space should be reserved |
source | The container whose size should determined for reservation in the target |
sourceModifierUnary | A unary function that transforms the size determined from the source container. This is for if you expect to generate more or less elements in the target container. |
Container::const_iterator Scine::Molassembler::Temple::select | ( | const Container & | container, |
ComparisonFunction && | comparator, | ||
MappingFunction && | mapFunction | ||
) |
Select a value from a container.
Container | Container type |
ComparisonFunction | Comparison between members of the value |
MappingFunction | Map function from ValueType to ComparableType |
container | container with values |
comparator | Comparator instance |
mapFunction | Map function |
constexpr std::enable_if_t< std::is_floating_point<FloatingType>::value, FloatingType> Scine::Molassembler::Temple::stddev | ( | const ContainerType & | container, |
const FloatingType | averageValue | ||
) |
Calculate the standard deviation of a container with a known average.
Complexity \(\Theta(N)\)
constexpr auto Scine::Molassembler::Temple::stddev | ( | const ContainerType & | container | ) |
Calculates standard deviation without an existing average value
Container must implement begin, end and size members, the contained type must have operator+.
Complexity \(\Theta(2N)\)
constexpr Traits::getValueType<ContainerType> Scine::Molassembler::Temple::sum | ( | const ContainerType & | container | ) |
Summation with zero-initialization.
Composable sum function. Returns the type the container contains, assuming monadic behavior on operator + (value_type + value_type = value_type). Container must implement begin and end members.
Complexity \(\Theta(N)\)
constexpr T Scine::Molassembler::Temple::sum | ( | const ArrayType< T, size > & | array | ) |
Sum up all elements of an array-like class.
Summation of all elements of an array-like class. Requires operator + and zero-initialization of the contained type
Complexity \(\Theta(N)\)