init.hpp 5.0 KB

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