#include #include #include #include #include #include #include #include "data.h" /* * Arbitrary data set */ //Constructor Data::Data(){ std::vector> T; std::string name = "Data_0"; data_set = T; name_set = name; } Data::Data(const Data& other): data_set(other.data_set), name_set(other.name_set){} Data::Data(std::string name): name_set(name){ std::vector> T; data_set = T; } Data::Data(std::vector> T, std::string name): data_set(T), name_set(name){} //Random generator int partition(std::vector> &a,int start,int end){ double pivot = a[end][0]; int P_index = start; std::vector tmp; for(int i=start;i> &a,int start,int end){ if(start> T; double x=0,y=0; for(int i=0;i> T; double t1=0,t2=0,x=0,y=0; for(int i=0;i pol = {}; FILE * param = fopen((name_set+".param.temp").c_str(), "w"); for(int i=0;i> T = {}; for(int i=0;i V){ data_set.push_back(V); } void Data::setData(std::vector> T){ data_set = T; } void Data::fromFile(std::string filepath){ std::vector> T; std::fstream data(filepath, std::ios::in); double a=0.,b=0.; while(data >> a >> b) T.push_back({a,b}); data.close(); data_set = T; } std::vector> Data::getData() const { return data_set; } void Data::setName(std::string name){ name_set = name; } std::string Data::getName() const { return name_set; } //Display methods void Data::displayData(){ std::vector commandsForGnuplot = {"set title \""+name_set+"\"","set key bmargin","plot '"+name_set+".temp' w lp lc -1 title '"+name_set+"'"}; FILE * temp = fopen((name_set+".temp").c_str(), "w"); FILE * gnuplotPipe = popen ("gnuplot -persistent", "w"); for (int i=0; i < data_set.size(); i++){ fprintf(temp, "%lf %lf \n", data_set[i][0], data_set[i][1]); } for (std::string command : commandsForGnuplot){ fprintf(gnuplotPipe,"%s \n", command.c_str()); } } void Data::exportData(){ FILE * fich = fopen((name_set+".data").c_str(), "w"); for (int i=0; i < data_set.size(); i++){ fprintf(fich, "%lf %lf \n", data_set[i][0], data_set[i][1]); } } //Get more informations int Data::getCard() const { return data_set.size(); } void Data::print() const { for(int i=0;i