miniprojet/tests/examples/test-csv.cpp

28 lines
708 B
C++

#include <math.hpp>
#include <fstream>
#include <iostream>
#include <file.hpp>
#include <math.hpp>
int main(int argc, char** argv) {
math::complex c1 = {0.1, 0.2};
math::complex c2 = {0.3, 0.4};
math::complex c3 = {0.5, 0.6};
math::complex c4 = {0.7, 0.8};
math::csignal s1 = {c1, c2};
math::csignal s2 = {c3, c4};
std::pair<math::csignal, std::string> p1 = {s1, "label1"};
std::pair<math::csignal, std::string> p2 = {s2, "label2"};
math::dataset d = {p1, p2};
save_as_csv(d, "test.csv");
math::dataset d2 = load_csv("test.csv", s1.size());
for (auto p: d2) {
for (auto x: p.first) {
std::cout << x << " ";
}
std::cout << p.second << std::endl;
}
return 0;
}