braids.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. * This file is part of Gomu.
  3. *
  4. * Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
  5. *
  6. * Gomu is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Gomu is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Gomu. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef BRAIDS_HPP
  20. #define BRAIDS_HPP
  21. #include "monoid.hpp"
  22. //******************
  23. //* Global objects *
  24. //******************
  25. extern MonoidFamily ArtinA_mf;
  26. extern MonoidFamily DualA_mf;
  27. //***********************************
  28. //* Auxiliary functions declaration *
  29. //***********************************
  30. //! Initilise all braids structure
  31. void braids_init();
  32. Generator generator(uint8_t i,uint8_t j);
  33. uint8_t get_i(const Generator& x);
  34. uint8_t get_j(const Generator& y);
  35. //-----------------
  36. // Artin of type A
  37. //-----------------
  38. //! Display function for generators of type A braids
  39. string ArtinA_disp(const Generator& x);
  40. //! Return the number of generators of type A braid of rank n
  41. size_t ArtinA_gnum(size_t n);
  42. //! Set left complement for Artin monoid of type A
  43. int ArtinA_left_sc(const Generator& x,const Generator &y,Generator* comp);
  44. //! Return the rank of an Artin generator of type A
  45. size_t ArtinA_rank(const Generator& x);
  46. //! Set right complement for Artin monoid of type A
  47. int ArtinA_right_sc(const Generator& x,const Generator &y,Generator* comp);
  48. //! Ranked phi germ for Artin monoid of type A
  49. // \param r the rank
  50. // \param x the generator to map
  51. // \param p power to apply
  52. Generator ArtinA_rpg(size_t r,const Generator& x,int p);
  53. //! Ranked Garside word factory
  54. Word ArtinA_rgwf(size_t r);
  55. //-----------------
  56. // Dual of type A
  57. //-----------------
  58. //! Display function for generators of type A dual braids
  59. string DualA_disp(const Generator& x);
  60. //! Return the number of generators of type A dual braids of rank n
  61. size_t DualA_gnum(size_t n);
  62. //! Set left complement for dual monoid of type A
  63. int DualA_left_sc(const Generator& x,const Generator &y,Generator* comp);
  64. //! Return the rank of an dual generator of type A
  65. size_t DualA_rank(const Generator& x);
  66. //! Set right complement for dual monoid of type A
  67. int DualA_right_sc(const Generator& x,const Generator &y,Generator* comp);
  68. //! Ranked phi germ for Artin monoid of type A
  69. // \param r the rank
  70. // \param x the generator to map
  71. // \param p power to apply
  72. Generator DualA_rpg(size_t r,const Generator& x,int p);
  73. //! Ranked Garside word factory
  74. Word DualA_rgwf(size_t r);
  75. //**********************
  76. //* Inline definitions *
  77. //**********************
  78. //---------------------
  79. // Auxiliary functions
  80. //---------------------
  81. inline string
  82. ArtinA_disp(const Generator& x){
  83. if(x==0) return "e";
  84. if(x>0) return "a"+to_string(x);
  85. return "A"+to_string(-x);
  86. }
  87. inline size_t
  88. ArtinA_gnum(size_t n){
  89. return n-1;
  90. }
  91. inline size_t
  92. ArtinA_rank(const Generator& x){
  93. return abs(x);
  94. }
  95. inline string
  96. DualA_disp(const Generator& x){
  97. if(x==0) return "e";
  98. if(x>0) return "a"+to_string(get_i(x))+to_string(get_j(x));
  99. return "A"+to_string(get_i(-x))+to_string(get_j(-x));
  100. }
  101. inline size_t
  102. DualA_rank(const Generator& x){
  103. return get_j(abs(x))-1;
  104. }
  105. inline Generator
  106. generator(uint8_t i,uint8_t j){
  107. Generator res=j;
  108. res<<=8;
  109. return res+i;
  110. }
  111. inline uint8_t
  112. get_i(const Generator& x){
  113. uint8_t* t=(uint8_t*)&x;
  114. return t[0];
  115. }
  116. inline uint8_t
  117. get_j(const Generator& x){
  118. uint8_t* t=(uint8_t*)&x;
  119. return t[1];
  120. }
  121. #endif