Hi everyone. I'm writing a code which takes 4 files and do statistics stuff with the datas. I really would like to avoid this ugly copy-pasting, but I don't know exatly how I sould do it.
I was thinking about a struct with an extra data-member that store the amount of the other data-member, a pointer to the struct, then apply the funciton in a for loop and use the pointer to jump to the next data-member but I can't figure out how to do it.
If anyone has reference to leave here or tips to do this, I would really appreciate it.
One could have a struct to hold all the data points and their residuals. Then have a std::vector of that struct type. The struct could have static members (meaning there is only version of these values for all the objects of that struct type) for the totals, mean, standard deviations etc.
Not sure what you mean about pointers to get to the next value, just use a range based for loop to go through the whole vector.
The dada are the result of an Integral evaluated with Monte Carlo's techniques. Each file stores 10'000 numbers which are the result of the same integral evaluated with a different MC's technique (4 files --> 4 different methods).
Now, I want to store them in different conteiners because I want to highlight the differences between each MC technique used to evaluate the same integral, and see (with statistics and graphs) which MC method is the more accurate.
Ok, so you can have a struct which represents the data, but you won't be able to have static members for such things as the totals because you are using the same struct for 4 different sets of data.
So create the struct Data, then make a class which has a private std::vector<Data>. That class could have members which represent summary data such as totals or mean or Standard Deviation. Have functions which respectively read data, calculate, and show the results. Make objects out of this class, one for each data set.
This is just my take on how to do it, others might have better ideas :+)