init.hpp 6.4 KB

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