8 #ifndef ROHDESCHWARZ_TO_VECTOR_HPP
9 #define ROHDESCHWARZ_TO_VECTOR_HPP
26 template <
class out_type,
class in_type =
unsigned char>
27 std::vector<out_type>
to_vector(in_type* data, std::size_t data_size)
30 using out_type_p = out_type*;
34 const std::size_t size =
sizeof(in_type) * data_size /
sizeof(out_type);
37 const out_type_p begin = out_type_p(data);
38 const out_type_p end = begin + size;
39 return std::vector<out_type>(begin, end);
50 template <
class in_type =
unsigned char>
54 std::vector<double> values = to_vector<double>(data, data_size);
57 std::vector<std::complex<double>> output;
58 output.reserve(values.size() / 2);
61 for (
int i = 0; i + 1 < values.size(); i += 2)
63 const double real = values[i];
64 const double imag = values[i + 1];
65 output.emplace_back(real, imag);
std::vector< std::complex< double > > to_vector_complex_double(in_type *data, std::size_t data_size)
Converts a vector of a primitive type to a vector of complex<double>
std::vector< out_type > to_vector(in_type *data, std::size_t data_size)
Converts a vector of a primitive type to a vector of a different primitive type.