braids.hpp 3.0 KB

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