Template Function minIndex#

Function Documentation#

template<typename T>
size_t minIndex(const std::vector<T> &vec)#

Find index of element with minimum absolute value in vector.

Scans vector and returns the index of element with smallest absolute value. Useful for identifying smallest energy gaps or weakest couplings.

Note

Linear O(n) search; if performance critical use std::min_element with custom comparator

Template Parameters:

T – Element type from vector (must support std::fabs)

Parameters:

vec – Input vector to search

Throws:

No – bounds checking - behavior undefined for empty vectors

Returns:

Index of element with minimum |value|