Skip to content

Instantly share code, notes, and snippets.

View lorenzoriano's full-sized avatar

Lorenzo Riano lorenzoriano

  • Industrial Next
  • San Francisco
View GitHub Profile
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))
@lorenzoriano
lorenzoriano / linspace.cpp
Last active December 12, 2022 02:28 — forked from jmbr/linspace.cpp
C++ Analogous of Python linspace, returns a std::vector
template <typename T>
std::vector<T> linspace(T a, T b, size_t N) {
T h = (b - a) / static_cast<T>(N-1);
std::vector<T> xs(N);
typename std::vector<T>::iterator x;
T val;
for (x = xs.begin(), val = a; x != xs.end(); ++x, val += h)
*x = val;
return xs;
}