braids.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. //! Set right complement for Artin monoid of type A
  45. int ArtinA_right_sc(const Generator& x,const Generator &y,Generator* comp);
  46. //! Ranked phi germ for Artin monoid of type A
  47. // \param r the rank
  48. // \param x the generator to map
  49. // \param p power to apply
  50. Generator ArtinA_rpg(size_t r,const Generator& x,int p);
  51. //-----------------
  52. // Dual of type A
  53. //-----------------
  54. //! Display function for generators of type A dual braids
  55. string DualA_disp(const Generator& x);
  56. //! Return the number of generators of type A dual braids of rank n
  57. size_t DualA_gnum(size_t n);
  58. //! Set left complement for dual monoid of type A
  59. int DualA_left_sc(const Generator& x,const Generator &y,Generator* comp);
  60. //! Set right complement for dual monoid of type A
  61. int DualA_right_sc(const Generator& x,const Generator &y,Generator* comp);
  62. //! Ranked phi germ for Artin monoid of type A
  63. // \param r the rank
  64. // \param x the generator to map
  65. // \param p power to apply
  66. Generator DualA_rpg(size_t r,const Generator& x,int p);
  67. //**********************
  68. //* Inline definitions *
  69. //**********************
  70. //---------------------
  71. // Auxiliary functions
  72. //---------------------
  73. inline string
  74. ArtinA_disp(const Generator& x){
  75. if(x==0) return "e";
  76. if(x>0) return "a"+to_string(x);
  77. return "A"+to_string(-x);
  78. }
  79. inline size_t
  80. ArtinA_gnum(size_t n){
  81. return n-1;
  82. }
  83. inline string
  84. DualA_disp(const Generator& x){
  85. if(x==0) return "e";
  86. if(x>0) return "a"+to_string(get_i(x))+to_string(get_j(x));
  87. return "A"+to_string(get_i(-x))+to_string(get_j(-x));
  88. }
  89. inline Generator
  90. generator(uint8_t i,uint8_t j){
  91. Generator res=j;
  92. res<<=8;
  93. return res+i;
  94. }
  95. inline uint8_t
  96. get_i(const Generator& x){
  97. uint8_t* t=(uint8_t*)&x;
  98. return t[0];
  99. }
  100. inline uint8_t
  101. get_j(const Generator& x){
  102. uint8_t* t=(uint8_t*)&x;
  103. return t[1];
  104. }
  105. #endif