results.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef RESULTS_HPP
  2. #define RESULTS_HPP
  3. #include <iostream>
  4. #include "semigroup.hpp"
  5. using namespace std;
  6. class Results{
  7. public:
  8. size_t ng[g_max+1];
  9. bool has_counter_example;
  10. Semigroup S_counter_example;
  11. void clear();
  12. void add(const Results& res);
  13. void to_file(string filename) const;
  14. void from_file(string filename);
  15. };
  16. inline
  17. void Results::clear(){
  18. has_counter_example=false;
  19. for(size_t g=0;g<=g_max;++g){
  20. ng[g]=0;
  21. }
  22. }
  23. inline
  24. void Results::add(const Results& res){
  25. if((not has_counter_example) and res.has_counter_example){
  26. S_counter_example=res.S_counter_example;
  27. has_counter_example=true;
  28. }
  29. for(size_t g=0;g<=g_max;++g){
  30. ng[g]+=res.ng[g];
  31. }
  32. }
  33. inline
  34. void Results::to_file(string filename) const{
  35. fstream file;
  36. file.open((filename).c_str(),ios::out|ios::binary|ios::trunc);
  37. file.write((char*)ng,sizeof(size_t)*(g_max+1));
  38. file.close();
  39. }
  40. inline
  41. void Results::from_file(string filename){
  42. fstream file;
  43. file.open((filename).c_str(),ios::in|ios::binary);
  44. file.read((char*)ng,sizeof(size_t)*(g_max+1));
  45. file.close();
  46. }
  47. #endif