|
| template<typename T , typename... Args> |
| T | product (T first, Args... rest) |
| | Variadic product - helper function.
|
| |
|
template<std::size_t N> |
| void | NDrange_impl (std::vector< std::array< std::size_t, N > > &result, std::array< std::size_t, N > ¤t, const std::array< std::size_t, N > &maxValues, std::size_t index) |
| |
| template<typename... Args> |
| auto | NDrange (std::size_t first, Args... rest) |
| | Variadic array of all possible indexes.
|
| |
| template<typename T , typename... Args> |
| T | max (T first, Args... rest) |
| | Returns maximum of any number of parameters (variadic function)
|
| |
| template<typename T , typename... Args> |
| T | min (T first, Args... rest) |
| | Returns minimum of any number of parameters (variadic function)
|
| |
| template<typename T , typename... Args> |
| T | max_abs (T first, Args... rest) |
| | Returns value with maximum absolute value of any number of parameters (variadic function)
|
| |
| template<typename T , typename... Args> |
| T | min_abs (T first, Args... rest) |
| | Returns value with minimum absolute value of any number of parameters (variadic function)
|
| |
| template<typename T , typename... Args> |
| T | max_difference (T first, Args... rest) |
| | Returns max{args..} - min{args...}, for any number of args (variadic)
|
| |
| template<int n, typename T > |
| constexpr auto | pow (T x) |
| | x^n for integer n (n compile-time template parameter), x any arithmetic type (T). Returns double for inverse powers, T otherwise
|
| |
| template<typename T > |
| constexpr T | pow (T x, int n) |
| | x^n for integer n (runtime n), x any floating point type (T).
|
| |
| template<typename T > |
| constexpr T | factorial (T x) |
| | Factorial x! - nb: does not check for overflow. Max x is 20 for uint64_t. Note: returns 1 for arguments <0.
|
| |
| template<typename T > |
| constexpr T | double_factorial (T x) |
| | Double factorial x!! - nb: does not check for overflow. Max x is 20 for uint64_t.
|
| |
| template<typename T > |
| constexpr int | sign (T value) |
| | Returns sign of value. Note: sign(0)==0.
|
| |
| template<typename T > |
| constexpr T | clip (T value, T max_abs) |
| | Clips value to between -max <= value <= max clip(x,max) : |x| > max, ret max; if |x|<-max, -max; else x.
|
| |
| template<typename T > |
| constexpr T | chop (T value, T min_abs) |
| | Sets values |v|<min to zero; if |v|>=min, returns v.
|
| |
| template<typename Function , typename Real > |
| std::pair< Real, Real > | derivative (Function y, Real x, Real delta_target=Real{1.0e-6}, Real dx=Real{0.01}, unsigned it_limit=250) |
| | Slow, but accurate, method of finding derivative of function (y) at a point (x). Returns derivative + error estimate.
|
| |
| template<typename Function , typename Real > |
| std::pair< Real, Real > | Newtons (Function f, Real x, Real delta_target=Real{1.0e-6}, Real dx=Real{0.01}, unsigned it_limit=250) |
| | Solve f(x) = 0 for x using Newtons method. Returns root + error estimate/.
|
| |
| template<typename Function , typename Real > |
| std::pair< Real, Real > | Newtons (Function f, Real x, std::pair< Real, Real > bounds, Real delta_target=Real{1.0e-6}, Real dx=Real{0.01}, unsigned it_limit=250) |
| | Solve f(x) = 0 for x using Newtons method. Returns root + error estimate. Enforced to be between bounds.
|
| |
|
std::string | omp_details () |
| |
|
std::string | random_string (std::size_t length) |
| |
| std::string | fstring (const std::string format,...) |
| | Returns a formatted std::string, with formatting printf-like commands. Note: maximum string lenth is 256 characters. If longer string required, use provided overload.
|
| |
| std::string | fstring (const std::size_t size, const std::string format,...) |
| | Overload: size is maximum string length (buffer size).
|
| |
| bool | wildcard_compare (std::string_view s1, std::string_view s2) |
| | Compares two strings, s1 and s2. s2 may contain ONE wildcard ('*') which will match anything.
|
| |
| char | tolower (char ch) |
| | return static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
|
| |
|
std::string | tolower (std::string t_string) |
| |
| bool | contains (std::string_view the_string, std::string_view sub_string) |
| | Checks if the_string (arg1) constaints sub_string (arg2)
|
| |
| bool | ci_contains (const std::string &the_string, const std::string &sub_string) |
| | Checks if the_string (arg1) constaints sub_string (arg2), case insensitive.
|
| |
| bool | contains (const std::string &the_string, const std::vector< std::string > &sub_strings) |
| | Checks if the_string (arg1) constaints any of the sub_strings (arg2)
|
| |
| bool | ci_contains (const std::string &the_string, const std::vector< std::string > &sub_strings) |
| | Checks if the_string (arg1) constaints any of the sub_strings (arg2), case insensitive.
|
| |
| bool | ci_compare (std::string_view s1, std::string_view s2) |
| | Case insensitive string compare. Essentially: LowerCase(s1)==LowerCase(s2)
|
| |
| bool | ci_wc_compare (std::string_view s1, std::string_view s2) |
| | Compares two strings, s1 and s2. s2 may contain ONE wildcard ('*') which will match anything. Case Insensitive version.
|
| |
| auto | Levenstein (std::string_view a, std::string_view b) |
| | A simple non-optimised implementation of the Levenshtein distance.
|
| |
| auto | ci_Levenstein (std::string_view a, std::string_view b) |
| | A simple non-optimised implementation of the Levenshtein distance (case insensitive)
|
| |
| auto | closest_match (std::string_view test_string, const std::vector< std::string > &list) |
| | Finds the closest match in list to test_string (return iterator)
|
| |
| auto | ci_closest_match (std::string_view test_string, const std::vector< std::string > &list) |
| | Finds the closest match (case insensitive) in list to test_string (return iterator)
|
| |
| bool | string_is_integer (std::string_view s) |
| | Checks if a string-like s is integer-like (including -)
|
| |
| std::vector< std::string > | split (const std::string &s, char delim=' ') |
| | Splits a string by delimeter into a vector.
|
| |
| std::string | concat (const std::vector< std::string > &v, const std::string &delim="") |
| | Takes vector of strings, concats into single string, with optional delimeter.
|
| |
| std::string | wrap (const std::string &input, std::size_t at=80, const std::string &prefix="") |
| | Wraps the string, 'input', at line 'at'. Optionally appends a prefix 'prefix' to each line. Does not split words (if can be avoided)
|
| |
| std::string | int_to_roman (int a) |
| | Converts integer, a, to Roman Numerals. Assumed that |a|<=4000.
|
| |
| template<typename T , typename... Args> |
| std::vector< T > | merge (std::vector< T > first, const std::vector< T > &second, const Args &...rest) |
| | Merges a number of vectors: {a,b,c},{d,e},{f} -> {a,b,c,d,e,f}.
|
| |
| template<typename T > |
| auto | compare (const std::vector< T > &first, const std::vector< T > &second) |
| | Directly compare two arithmetic vectors of the same type and length. Returns pair {delta, itr} where delta = |max|{first - second}, itr is iterator to position in first vector where the maximum delta occured. Note: Maximum is by magnitude, but delta is signed as (first-second)
|
| |
| template<typename T , typename U , typename Func > |
| auto | compare (const std::vector< T > &first, const std::vector< U > &second, Func &func) |
| | Compares two vectors of the same length, according to the rule given by func. Returns pair {delta, itr} where delta = max{|func(first,second)|}, itr is iterator to position in first vector where the maximum delta occured. Note: Maximum is by magnitude.
|
| |
| template<typename T > |
| auto | compare_eps (const std::vector< T > &first, const std::vector< T > &second) |
| | Compares values of two arithmetic vectors of the same type and length, relative to second value. Returns pair {eps, itr} where eps = |max|{(first - second)/second}, itr is iterator to position in first vector where the maximum eps occured. Note: Maximum is by magnitude, but eps is signed as (first-second)/second.
|
| |
| template<typename T , typename... Args> |
| void | add (std::vector< T > *first, const std::vector< T > &second, const Args &...rest) |
| | Adds any number of vectors, in place (modifies first vector). Must be of same type. May allocate; will resize first to be size of largest vector.
|
| |
| template<typename T , typename... Args> |
| std::vector< T > | add (std::vector< T > first, const std::vector< T > &second, const Args &...rest) |
| | Adds any number of vectors. Must be of same type. Size of returned vector will be size of largest vector; may allocate more than once if vectors are not all of same size.
|
| |
| template<typename T , typename... Args> |
| void | multiply (std::vector< T > *first, const std::vector< T > &second, const Args &...rest) |
| | Multiplies any number of (arithmetic) vectors, in place (modifies first vector). Must be of same type. May allocate; will resize first to be size of largest vector.
|
| |
| template<typename T , typename... Args> |
| std::vector< T > | multiply (std::vector< T > first, const std::vector< T > &second, const Args &...rest) |
| | Multiplies any number of vectors. Must be of same type. Size of returned vector will be size of largest vector; may allocate more than once if vectors are not all of same size.
|
| |
| template<typename F , typename T , typename... Args> |
| void | compose (const F &func, std::vector< T > *first, const std::vector< T > &second, const Args &...rest) |
| | Composes any number of vectors, in place (modifies first vector), using the provided function. Must be of same type. May allocate; will resize first to be size of largest vector. e.g., qip::compose(std::plus{}, &vo, v2, v3); same as qip::add(&vo, v2, v3)
|
| |
| template<typename F , typename T , typename... Args> |
| std::vector< T > | compose (const F &func, std::vector< T > first, const std::vector< T > &second, const Args &...rest) |
| | Composes any number of vectors. Must be of same type. Size of returned vector will be size of largest vector; may allocate more than once if vectors are not all of same size.
|
| |
| template<typename T > |
| void | scale (std::vector< T > *vec, T x) |
| | In-place scalar multiplication of std::vector - types must match.
|
| |
| template<typename T > |
| std::vector< T > | scale (std::vector< T > vec, T x) |
| | Scalar multiplication of std::vector - types must match.
|
| |
| template<typename T = double, typename N = std::size_t> |
| std::vector< T > | uniform_range (T first, T last, N number) |
| | Produces a uniformly*(see below) distributed range of values between [first,last] with number steps. number must be at least 2. first+last are guarenteed to be the first and last points in the range. For integral T, range will not be perfectly uniform, due to [first, ..., last] guarentee and rounding; also in this case same value may appear more than once if too-many steps are requested.
|
| |
| template<typename T = double, typename N = std::size_t> |
| std::vector< T > | logarithmic_range (T first, T last, N number) |
| | Produces a logarithmicly*(see below) distributed range of values between [first,last] with number steps. number must be at least 2. first+last are guarenteed to be the first and last points in the range. For integral T, range will not be perfectly logarithmic, due to [first, ..., last] guarentee and rounding; also in this case same value may appear more than once if too-many steps are requested.
|
| |
| template<typename T = double, typename N = std::size_t> |
| std::vector< T > | loglinear_range (T first, T last, T b, N number) |
| | Produces a Log-Linear distributed range of values between [first,last] with number steps. number must be at least 3. first+last are guarenteed to be the first and last points in the range. T must be floating point. Range is roughly logarithmic for values below 'b', and linear for values above b. Not tested for negative values.
|
| |
| template<typename T , typename... Args> |
| constexpr auto | multiply_at (std::size_t i, const T &first, const Args &...rest) |
| | first[i]*...rest[i] – used to allow inner_product
|
| |
| template<typename T , typename... Args> |
| constexpr auto | inner_product (const T &first, const Args &...rest) |
| | Variadic inner product (v1,v2,...vn) : sum_i v1[i]*v2[i]*...vn[i].
|
| |
|
template<typename T , typename... Args> |
| auto | inner_product_sub (std::size_t p0, std::size_t pinf, const T &first, const Args &...rest) |
| |
|
template<typename F , typename T > |
| T | apply_to (const F &func, T list) |
| |
| template<typename T , typename Func > |
| std::vector< T > | select_if (const std::vector< T > &in, Func condition) |
| | Creates a subset of a vector, whose element match condition. By copy. condition must have function signature: bool condition(T)
|
| |
| template<typename T , typename Func > |
| void | insert_into_if (const std::vector< T > &in, std::vector< T > *inout, Func condition) |
| | Inserts elements from in into inout, if condition is met.
|
| |
| template<typename T > |
| std::vector< T > | reverse (std::vector< T > in) |
| | Reverses a list.
|
| |
| template<typename T > |
| T | mean (std::vector< T > vec) |
| | Mean: \( \bar x = \sum_i x_i / N \).
|
| |
| template<typename T > |
| T | variance (std::vector< T > vec, std::size_t dof=0) |
| | Variance using two-pass method: \( \sum_i (x_i-xbar)^2 / (N-dof) \). dof is degrees of freedom; for sample variance dof = 1.
|
| |
| template<typename T > |
| T | sdev (std::vector< T > vec, std::size_t dof=0) |
| | Standard deviation: sqrt(variance)
|
| |
| template<typename T > |
| T | sem (std::vector< T > vec, std::size_t dof=0) |
| | Standard deviation: sqrt(variance)
|
| |
|
void | progbar (int i, int max, int length=50) |
| |
|
void | progbar50 (int i, int max) |
| |