Utilities

utils

Functions

void file_error(const std::string &input)

File not found error.

Parameters:

input – filename or path

std::unique_ptr<int32_t[]> lbl2num(const std::vector<std::string> &lbl)

Convert label from string to integers.

Parameters:

lbl – vector of labels in string format

Returns:

std::unique_ptr<int[]> array of labels as integers

std::vector<std::string> split(const std::string &txt, const std::string &del)

Split string to tokens.

Parameters:
  • txt – input string

  • del – delimiter as string

Returns:

std::vector<std::string> vector of token

Variables

constexpr int error_file = 1

error as no file found

namespace std

STL namespace.

Functions

template<typename T>
std::unique_ptr<T> make_unique(std::size_t size)

Wrap for the older version of gcc anc clang.

Template Parameters:

T – type of the pointer array

Parameters:

size – lenght of unique_ptr array

Returns:

pointer array as unique_ptr (e.g. std :: unique_ptr < float[] > in modern c++)

sort

Functions

template<typename type, typename lambda>
void mergeargsort_serial(int32_t *index, type *arr, const int32_t &start, const int32_t &end, lambda order)

Mergesort of the indexes serial.

This function is the serial version of the sorting using indexes. The original array is unchanged at the end of the function but the indexes for its reordering are evaluated and stored into the indexes variable. See numpy.argsort in Python as analogy.

Template Parameters:
  • type – Input array type

  • lambda – Function for the comparison evaluation

Parameters:
  • index – Array of indexes (it must have the same size of arr)

  • arr – Array of values to reorder

  • start – Starting point for the reordering (commonly set to 0)

  • end – End point for the reordering (commonly set to array_size)

  • order – Lambda function for the comparison evaluation

template<typename type, typename lambda>
void mergeargsort_parallel_omp(int32_t *index, type *arr, const int32_t &start, const int32_t &end, const int32_t &threads, lambda order)

Mergesort of the indexes with OMP multithreading support.

This function is the parallel version of the sorting using indexes. The original array is unchanged at the end of the function but the indexes for its reordering are evaluated and stored into the indexes variable. See numpy.argsort in Python as analogy.

Template Parameters:
  • type – Input array type

  • lambda – Function for the comparison evaluation

Parameters:
  • index – Array of indexes (it must have the same size of arr)

  • arr – Array of values to reorder

  • start – Starting point for the reordering (commonly set to 0, but it is used for the parallelization master-slave)

  • end – End point for the reordering (commonly set to array_size)

  • threads – Number of threads to use in the evaluation

  • order – Lambda function for the comparison evaluation