semigroup.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include <iostream>
  2. #include <cstring>
  3. #include "semigroup.hpp"
  4. void init_full_N(Semigroup &m){
  5. epi8 block ={1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8};
  6. for(auto i=0; i<NBLOCKS; i++){
  7. m.blocks[i] = block;
  8. block = block + 8;
  9. }
  10. m.genus = 0;
  11. m.conductor = 1;
  12. m.min = 1;
  13. m.left=1;
  14. m.left_primitive=0;
  15. m.e=1;
  16. m.wilf=0;
  17. }
  18. void init(Semigroup& S,char c,char g,char m,char* d){
  19. S.conductor=c;
  20. S.genus=g;
  21. S.min=m;
  22. memcpy((void*)S.decs,(void*)d,(3*MAX_GENUS+1));
  23. S.left=0;
  24. S.left_primitive=0;
  25. S.e=0;
  26. for(ind_t i=0;i<S.conductor;++i){
  27. if(d[i]>0){
  28. ++S.left;
  29. if(d[i]==1){
  30. ++S.e;
  31. ++S.left_primitive;
  32. }
  33. }
  34. }
  35. for(ind_t i=S.conductor;i<S.conductor+S.min;++i){
  36. if(d[i]==1){
  37. ++S.e;
  38. }
  39. }
  40. S.wilf=S.left*S.e-S.conductor;
  41. }
  42. void init_ordinary(Semigroup &O,int m){
  43. O.decs[0]=1;
  44. for(auto i=1;i<2*m;++i){
  45. O.decs[i]=i/m;
  46. }
  47. for(auto i=0;i<SIZE-2*m;++i){
  48. O.decs[2*m+i]=2+i/2;
  49. }
  50. O.genus = m-1;
  51. O.conductor = m;
  52. O.min = m;
  53. O.left=1;
  54. O.left_primitive=0;
  55. O.e=m;
  56. O.wilf=0;
  57. }
  58. void print_Semigroup(const Semigroup &m)
  59. {
  60. unsigned int i;
  61. std::cout<<"min = "<<m.min<<", cond = "<<m.conductor<<", genus = "<<m.genus<<", decs = ";
  62. for (i=0; i<SIZE; i++) std::cout<<((int) m.decs[i])<<' ';
  63. std::cout<<std::endl;
  64. }
  65. void print_Semigroup_gen(const Semigroup &m)
  66. {
  67. unsigned int i;
  68. std::cout<<"m = "<<m.min<<", c = "<<m.conductor<<", g = "<<m.genus<<" w = "<<m.wilf<<" ";
  69. std::cout<<"< ";
  70. for (i=1; i<SIZE; i++){
  71. if(m.decs[i]==1){
  72. std::cout<<i<<' ';
  73. }
  74. }
  75. std::cout<<'>'<<std::endl;
  76. }
  77. #include <cmath>
  78. void output(const Semigroup& m,fstream& f){
  79. int q=ceil(float(m.conductor)/float(m.min));
  80. int rho=q*m.min-m.conductor;
  81. f<<"c = "<<m.conductor<<", g = "<<m.genus<<", r = "<<rho<<", w = "<<m.wilf<<" : ["<<m.min;
  82. for (auto i=m.min+1; i<SIZE; i++){
  83. if(m.decs[i]==1){
  84. f<<','<<i;
  85. }
  86. }
  87. f<<']'<<endl;
  88. }
  89. void record(const Semigroup& S,fstream& f){
  90. char c,g,m;
  91. c=S.conductor;
  92. g=S.genus;
  93. m=S.min;
  94. f.write(&c,1);
  95. f.write(&g,1);
  96. f.write(&m,1);
  97. f.write((char*)(&S.decs),3*MAX_GENUS+1);
  98. }
  99. void print_epi8(epi8 bl)
  100. {
  101. unsigned int i;
  102. for (i=0; i<16; i++) std::cout<<((uint8_t*)&bl)[i]<<' ';
  103. std::cout<<std::endl;
  104. }