init.hpp 6.0 KB

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