init.hpp 6.3 KB

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