Function find_local_minima

Function Documentation

std::vector<std::pair<unsigned short int, float>> find_local_minima(const std::vector<float> &vec, bool include_global_minima)

Finds the local minima in a given vector of floats.

This function iterates through the input vector and identifies the local minima, which are elements that are smaller than their immediate neighbors. Optionally, it can also include the global minimum in the result.

Parameters:
  • vec – The input vector of floats to search for local minima.

  • include_global_minima – A boolean flag indicating whether to include the global minimum in the result.

Returns:

A vector of pairs, where each pair contains the index and value of a local minimum.