22namespace jsa::cicuetea {
47#if SIZE_MAX > 0xFFFFFFFFu
66inline size_t constrain(
size_t idx,
size_t size) {
return idx % size; }
77inline double square(
double x) {
return x * x; }
86inline Eigen::ArrayXd
regspace(Eigen::Index num)
88 return Eigen::ArrayXd::LinSpaced(num, 0, num - 1);
104inline Eigen::ArrayXd
regspace(Eigen::Index low, Eigen::Index high)
106 return Eigen::ArrayXd::LinSpaced(high - low + 1, low, high);
124inline Eigen::ArrayXd
logspace(
double start,
double end, Eigen::Index num)
126 return Eigen::ArrayXd::LinSpaced(num, std::log(start), std::log(end)).exp();
double square(double x)
Computes the square of a given number.
Definition MathUtils.h:77
Eigen::ArrayXd regspace(Eigen::Index num)
Generates a linearly spaced array of values from 0 to num-1.
Definition MathUtils.h:86
size_t constrain(size_t idx, size_t size)
Constrains an index to fit within the bounds of a given size by wrapping it around.
Definition MathUtils.h:66
Eigen::ArrayXd logspace(double start, double end, Eigen::Index num)
Generates a logarithmically spaced array.
Definition MathUtils.h:124
constexpr size_t nextPow2(size_t x)
Computes the next power of 2 greater than or equal to the given number.
Definition MathUtils.h:38