61template <
typename T>
T sqr(
const T &
v) {
return v *
v; }
70 return static_cast<uint_t>(
71 std::distance(
vec.begin(), std::max_element(
vec.begin(),
vec.end())));
81 return static_cast<uint_t>(
82 std::distance(
vec.begin(), std::min_element(
vec.begin(),
vec.end())));
88template <
typename VectorType>
typename VectorType::value_type
max(
const VectorType &
vec)
90 return *std::max_element(
vec.begin(),
vec.end());
96template <
typename VectorType>
typename VectorType::value_type
min(
const VectorType &
vec)
98 return *std::min_element(
vec.begin(),
vec.end());
114 const auto amount =
static_cast<T>(index) / (
n - 1);
128 auto v = std::vector<T>{};
130 for (
auto i = 0
u;
i <
n; ++
i)
VectorType::value_type max(const VectorType &vec)
Returns the max element in the vector.
Definition math_utils.h:88
T sum_sqr(const DynVec< T > &vec)
Compute the sum of squares of the elements of the given vector.
Definition math_utils.h:44
uint_t arg_max(const VectorType &vec)
Returns the index of the element that has the maximum value in the array. Implementation taken from h...
Definition math_utils.h:68
uint_t arg_min(const VectorType &vec)
Returns the index of the element that has the minimum value in the array. Implementation taken from h...
Definition math_utils.h:79
VectorType::value_type min(const VectorType &vec)
Returns the minimum element in the vector.
Definition math_utils.h:96
T sqr(const T &v)
Definition math_utils.h:61
int_t sign(const T &expr)
Definition math_utils.h:22
std::vector< T > lin_space(T start, T stop, uint_t n)
Generate n evenly linearly spaced numbers between [start, stop]. Analogous to NumPy linspace.
Definition math_utils.h:125
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
int int_t
integer type
Definition bitrl_types.h:33
Eigen::RowVectorX< T > DynVec
Dynamically sized row vector.
Definition bitrl_types.h:74
std::size_t uint_t
uint_t
Definition bitrl_types.h:43