/**
 * @file
 * Useful numerical tools.
 */

#pragma once

#include <vector>
#include <cmath>

namespace darkprop {

template<typename Value>
std::vector<Value> geomspace(Value a, Value b, int n) {
    std::vector<Value> res(n);
    Value q = std::pow(b/a, 1./(n-1));
    for (int i = 0; i < n; ++i) {
        res[i] = a*std::pow(q, i);
    }
    return res;
}

template<typename Value>
std::vector<Value> linspace(Value a, Value b, int n, bool useend=true) {
    std::vector<Value> res(n);
    Value d = useend ? (b - a) / (n - 1) : (b - a) / n;
    for (int i = 0; i < n; ++i) {
        res[i] = a + i * d;
    }
    return res;
}

} // namespace darkprop
