init.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. #include <sstream>
  20. #include "../../module.hpp"
  21. #include "monoid.hpp"
  22. #include "braids.hpp"
  23. //*****************
  24. //* Global object *
  25. //*****************
  26. extern Gomu::Type* type_ArtinWordA;
  27. extern Gomu::Type* type_DualWordA;
  28. //****************
  29. //* MonoidFamily *
  30. //****************
  31. //! Display a MonoidFamily
  32. string mf_display(void* m);
  33. //! Delete a MonoidFamily
  34. void mf_delete(void* m);
  35. //! Return generators number fror rank n
  36. void* mf_generators_number(void* m,void* n);
  37. //***************
  38. //* MonoidTrait *
  39. //***************
  40. //! Return garside element of a given rank
  41. void* mt_garside_element(void* m,void* r);
  42. //! Test is a left divides b
  43. void* mt_is_left_divisible(void* m,void* a,void* b);
  44. //! Test is a left divides b and return extar informations
  45. void* mt_is_left_divisible_x(void* m,void* a,void* b);
  46. //! Test is a right divides b
  47. void* mt_is_right_divisible(void* m,void* a,void* b);
  48. //! Test is a right divides b and return extar informations
  49. void* mt_is_right_divisible_x(void* m,void* a,void* b);
  50. //! Return left complememnt
  51. void* mt_left_complement(void* m,void* a,void*b);
  52. //! Return left denominator
  53. void* mt_left_denominator(void* m);
  54. //! Return left gcd of a and b
  55. void* mt_left_gcd(void* m,void* a,void* b);
  56. //! Return left gcd with extra informations of a and b
  57. void* mt_left_gcd_x(void* m,void* a,void *b);
  58. //! Return left lcm of a and b
  59. void* mt_left_lcm(void* m,void* a,void* b);
  60. //! Return left lcm complement of a and b
  61. void* mt_left_lcm_complement(void* m,void* a,void* b);
  62. //! Return left numerator
  63. void* mt_left_numerator(void* m);
  64. //! Return the word under ranked Garside automorphism
  65. void* mt_phi(void* m,void* r,void* w);
  66. //! Return the word under power of ranked Garside automorphism
  67. void* mt_phi_power(void* m,void* r,void* w,void* p);
  68. //! Left reverse a word
  69. void* mt_left_reverse(void* m,void* w);
  70. //! Left reverse num*den^-1
  71. void* mt_left_reverse2(void* m,void* num,void* den);
  72. //! Return right complememnt
  73. void* mt_right_complement(void* m,void* a,void*b);
  74. //! Return right denominator
  75. void* mt_right_denominator(void* m);
  76. //! Return right gcd of a and b
  77. void* mt_right_gcd(void* m,void* a,void* b);
  78. //! Return right gcd with extra informations of a and b
  79. void* mt_right_gcd_x(void* m,void* a,void *b);
  80. //! Return right lcm of a and b
  81. void* mt_right_lcm(void* m,void* a,void* b);
  82. //! Return right lcm complement of a and b
  83. void* mt_right_lcm_complement(void* m,void* a,void* b);
  84. //! Right reverse a word
  85. void* mt_right_reverse(void* m,void* w);
  86. //! Right reverse den^-1*num
  87. void* mt_right_reverse2(void* m,void* den,void* num);
  88. //! Return right numerator
  89. void* mt_right_numerator(void* m);
  90. //********
  91. //* Word *
  92. //********
  93. //! Display a Word monoid
  94. string word_display(void* w);
  95. //! Delete a Word monoid
  96. void word_delete(void* w);
  97. //! Copy a word monoid
  98. void* word_copy(void* w);
  99. //! Compare to Word monoid
  100. int word_compare(void* w1,void* w2);
  101. //! Create a Word monoid from an array of integer
  102. void* word_from_array(void* arr);
  103. //! Return the length of a Word
  104. void* word_length(void*);
  105. //! Inverse a Word
  106. void* word_invserse(void*);
  107. //! Concatenate two words
  108. void* word_concatenate(void*,void*);
  109. //**************
  110. //* ArtinWordA *
  111. //**************
  112. //! Display a ArtinWordA
  113. string ArtinWordA_display(void* w);
  114. //*************
  115. //* DualWordA *
  116. //*************
  117. //! Display a DualWordA
  118. string DualWordA_display(void* w);
  119. //**********************
  120. //* Inline definitions *
  121. //**********************
  122. //--------------
  123. // MonoidFamily
  124. //--------------
  125. inline string
  126. mf_display(void* m){
  127. return ((MonoidFamily*)m)->display();
  128. }
  129. inline void
  130. mf_delete(void* m){
  131. delete (MonoidFamily*)m;
  132. }
  133. inline void*
  134. mf_generators_number(void* m,void* n){
  135. return Gomu::to_integer(((MonoidFamily*)m)->generators_number(Gomu::get_slong(n)));
  136. }
  137. //------
  138. // Word
  139. //------
  140. inline string
  141. word_display(void* w){
  142. return to_string(*((Word*)w));
  143. }
  144. inline void
  145. word_delete(void* w){
  146. delete (Word*)w;
  147. }
  148. inline void*
  149. word_copy(void* w){
  150. return (void*)new Word(*(Word*)w);
  151. }
  152. inline int
  153. word_compare(void* u,void* v){
  154. return cmp(*(Word*)u,*(Word*)v);
  155. }
  156. inline void*
  157. word_length(void* u){
  158. return Gomu::to_integer(((Word*)u)->size());
  159. }
  160. inline void*
  161. word_inverse(void* u){
  162. return new Word(((Word*)u)->inverse());
  163. }
  164. inline void*
  165. word_concatenate(void* u,void *v){
  166. return new Word(((Word*)u)->concatenate(*(Word*)v));
  167. }
  168. //------------
  169. // ArtinWordA
  170. //------------
  171. inline string
  172. ArtinWordA_display(void* w){
  173. return ((Word*)w)->display(ArtinA_disp);
  174. }
  175. //------------
  176. // DualWordA
  177. //------------
  178. inline string
  179. DualWordA_display(void* w){
  180. return ((Word*)w)->display(DualA_disp);
  181. }