If you're trying to convert the code to C++, you can easily implement a (roughly) equivalent arange
function:
#include <vector>
template<typename T>
std::vector<T> arange(T start, T stop, T step = 1) {
std::vector<T> values;
for (T value = start; value < stop; value += step)
values.push_back(value);
return values;
}
You could then use it like this:
auto t = arange<double>(0, 3*fs);
auto L = t.length();
The **
is exponentiation. You could call the pow
function:
#include <cmath>
const double imax = pow(2., 16.);
But since you are dealing with constants anyway, you would be better off with:
const double imax = 65536.;
If you want to retain the expressive power of 2**16
and you don't want to incur the run-time cost of calling pow
(perhaps you want to be able to change the exponent without having to manually recalculate the constant), you can use a constexpr
function:
constexpr unsigned long power(unsigned long base, unsigned long exponent) {
return exponent == 0 ? 1 : base * pow(base, exponent - 1);
}
const unsigned long imax = power(2, 16);