123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- #include "braids.hpp"
- #include "init.hpp"
- MonoidFamily ArtinA_mf("Artin A-type",ArtinA_disp,ArtinA_gnum,ArtinA_rank);
- MonoidFamily DualA_mf("Dual A-type",DualA_disp,DualA_gnum,DualA_rank);
- void braids_init(){
- ArtinA_mf.data=(void*)type_ArtinWordA;
- ArtinA_mf.set_left_complement(&ArtinA_left_sc);
- ArtinA_mf.set_right_complement(&ArtinA_right_sc);
- ArtinA_mf.set_ranked_phi_germ(&ArtinA_rpg);
- ArtinA_mf.set_ranked_garside_word_factory(&ArtinA_rgwf);
-
- DualA_mf.data=(void*)type_DualWordA;
- DualA_mf.set_left_complement(&DualA_left_sc);
- DualA_mf.set_right_complement(&DualA_right_sc);
- DualA_mf.set_ranked_phi_germ(&DualA_rpg);
- DualA_mf.set_ranked_garside_word_factory(&DualA_rgwf);
- }
- int ArtinA_left_sc(const Generator& x,const Generator& y,Generator* comp){
-
- if(x==y) return 0;
- if(abs(x-y)==1){
- comp[0]=x;
- comp[1]=y;
- return 2;
- }
- else{
- comp[0]=y;
- return 1;
- }
- }
- int ArtinA_right_sc(const Generator& x,const Generator& y,Generator* comp){
-
- if(x==y) return 0;
- if(abs(x-y)==1){
- comp[0]=y;
- comp[1]=x;
- return 2;
- }
- else{
- comp[0]=y;
- return 1;
- }
- }
- Generator ArtinA_rpg(size_t r,const Generator& x,int p){
- int power=abs(p)%2;
- if(power==0) return x;
- if(x>0) return r-x;
- return -(r+x);
- }
- Word ArtinA_rgwf(size_t r){
- Word res(r*(r+1)/2);
- size_t ind=0;
- for(size_t n=r;n>0;--n){
- for(size_t i=1;i<=n;++i){
- res[ind++]=i;
- }
- }
- return res;
- }
- inline size_t
- DualA_gnum(size_t n){
- size_t res=0;
- for(size_t i=1;i<n;++i){
- res+=i;
- }
- return res;
- }
- int DualA_left_sc(const Generator& x,const Generator& y,Generator* comp){
-
- if(x==y) return 0;
- uint p=get_i(x);
- uint q=get_j(x);
- uint r=get_i(y);
- uint s=get_j(y);
-
- if(p==r){
- comp[0]=(q<s)?y:generator(s,q);
- return 1;
- }
-
- if(q==s){
- comp[0]=(p<r)?y:generator(r,p);
- return 1;
- }
-
- if(p==s){
- comp[0]=y;
- return 1;
- }
-
- if(q==r){
- comp[0]=generator(p,s);
- return 1;
- }
-
- if(p<r and r<q and q<s){
- comp[0]=generator(r,q);
- comp[1]=generator(p,s);
- return 2;
- }
-
- if(r<p and p<s and s<q){
- comp[0]=generator(s,q);
- comp[1]=generator(r,p);
- return 2;
- }
-
- comp[0]=y;
- return 1;
- }
- int DualA_right_sc(const Generator& x,const Generator& y,Generator* comp){
-
- if(x==y) return 0;
- uint p=get_i(x);
- uint q=get_j(x);
- uint r=get_i(y);
- uint s=get_j(y);
-
- if(p==r){
- comp[0]=(q<s)?generator(q,s):y;
- return 1;
- }
-
- if(q==s){
- comp[0]=(p<r)?generator(p,r):y;
- return 1;
- }
-
- if(p==s){
- comp[0]=generator(r,q);
- return 1;
- }
-
- if(q==r){
- comp[0]=y;
- return 1;
- }
-
- if(p<r and r<q and q<s){
- comp[0]=generator(q,s);
- comp[1]=generator(p,r);
- return 2;
- }
-
- if(r<p and p<s and s<q){
- comp[0]=generator(p,s);
- comp[1]=generator(r,q);
- return 2;
- }
-
- comp[0]=y;
- return 1;
- }
- Generator DualA_rpg(size_t r,const Generator& x,int p){
- int n=r+1;
- int power=p%n;
- if(power<0) power+=n;
- int sign,absx;
- if(x>0){
- sign=1;
- absx=x;
- }
- else{
- sign=-1;
- absx=-x;
- }
- int i=(get_i(absx)-1+power)%n+1;
- int j=(get_j(absx)-1+power)%n+1;
- if(i>j) swap(i,j);
- return sign*generator(i,j);
- }
- Word DualA_rgwf(size_t r){
- Word res(r);
- for(size_t i=0;i<r;++i){
- res[i]=generator(i+1,i+2);
- }
- return res;
- }
|