fbgsense 0.1
Generic FBG spectrum analysis tool
linspace.h
1#pragma once
2// https://gist.github.com/lorenzoriano/5414671
3
4#include <vector>
5
9template <typename T>
10std::vector<double> linspace(T start, T end, int num)
11{
12 std::vector<double> linspaced;
13
14 if (0 != num)
15 {
16 if (1 == num)
17 {
18 linspaced.push_back(start);
19 }
20 else
21 {
22 double len = num - 1;
23 double delta = (end - start) / len;
24
25 for (size_t i = 0; i < len; ++i)
26 {
27 linspaced.push_back(start + (delta * i));
28 }
29
30 // ensure that start and end are exactly the same as the input
31 linspaced.push_back(end);
32 }
33 }
34
35 return linspaced;
36}