2016-07-26 08:09:34 +00:00
# include <string.h>
# include <stdio.h>
# include "coxeter.h"
# include "queue.h"
# include "thickenings.h"
int main ( int argc , const char * argv [ ] )
{
semisimple_type_t type ;
2016-11-11 16:07:45 +00:00
unsigned long right_invariance , left_invariance ;
int rank , order , hyperplanes , cosets ;
2016-11-14 10:54:52 +00:00
int fixpoints ;
2016-07-26 08:09:34 +00:00
node_t * graph ;
char string_buffer1 [ 1000 ] ;
const char * alphabet = " abcdefghijklmnopqrstuvwxyz " ;
2016-11-11 16:07:45 +00:00
// read arguments
2016-07-26 08:09:34 +00:00
ERROR ( argc < 2 , " Too few arguments! \n " ) ;
2016-11-11 16:07:45 +00:00
type . n = 0 ;
2016-07-26 08:09:34 +00:00
for ( int i = 0 ; i < argc - 1 ; i + + ) {
2016-11-11 16:07:45 +00:00
if ( argv [ i + 1 ] [ 0 ] < ' A ' | | argv [ i + 1 ] [ 0 ] > ' I ' )
break ;
type . n + + ;
}
type . factors = ( simple_type_t * ) malloc ( type . n * sizeof ( simple_type_t ) ) ;
for ( int i = 0 ; i < type . n ; i + + ) {
2016-07-26 08:09:34 +00:00
type . factors [ i ] . series = argv [ i + 1 ] [ 0 ] ;
type . factors [ i ] . rank = argv [ i + 1 ] [ 1 ] - ' 0 ' ;
ERROR ( argv [ i + 1 ] [ 0 ] < ' A ' | | argv [ i + 1 ] [ 0 ] > ' I ' | | argv [ i + 1 ] [ 1 ] < ' 1 ' | | argv [ i + 1 ] [ 1 ] > ' 9 ' , " Arguments must be Xn with X out of A-I and n out of 0-9 \n " ) ;
}
2016-11-11 16:07:45 +00:00
left_invariance = right_invariance = 0 ;
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
if ( argc - type . n > = 3 ) {
if ( strcmp ( argv [ type . n + 1 ] , " - " ) ! = 0 )
for ( int i = 0 ; i < strlen ( argv [ type . n + 1 ] ) ; i + + )
left_invariance | = ( 1 < < ( argv [ type . n + 1 ] [ i ] - ' a ' ) ) ;
if ( strcmp ( argv [ type . n + 2 ] , " - " ) ! = 0 )
for ( int i = 0 ; i < strlen ( argv [ type . n + 2 ] ) ; i + + )
right_invariance | = ( 1 < < ( argv [ type . n + 2 ] [ i ] - ' a ' ) ) ;
2016-07-26 08:09:34 +00:00
}
2016-11-11 16:07:45 +00:00
ERROR ( strlen ( alphabet ) < rank , " The alphabet has too few letters \n " ) ;
2016-07-26 08:09:34 +00:00
// generate graph
2016-11-11 16:07:45 +00:00
graph = graph_alloc ( type ) ;
cosets = prepare_simplified_graph ( type , left_invariance , right_invariance , graph ) ;
ERROR ( cosets < 0 , " The left invariance is not preserved by the opposition involution: %d %d! \n " , left_invariance , opposition_involution ( type , left_invariance ) ) ;
2016-07-26 08:09:34 +00:00
// print stuff
2016-11-11 16:07:45 +00:00
rank = coxeter_rank ( type ) ; // number of simple roots
order = coxeter_order ( type ) ; // number of Weyl group elements
hyperplanes = coxeter_hyperplanes ( type ) ; // number of positive roots
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
fprintf ( stderr , " Rank: %d \t Order: %d \t Positive Roots: %d \t Cosets: %d \n " , rank , order , hyperplanes , cosets ) ;
2016-07-26 08:09:34 +00:00
fprintf ( stderr , " \n " ) ;
2016-11-11 16:07:45 +00:00
fprintf ( stderr , " Shortest coset representatives: \n " ) ;
for ( int i = 0 , wl = 0 ; i < cosets ; i + + ) {
2016-07-26 08:09:34 +00:00
if ( i = = 0 ) {
fprintf ( stderr , " 1 " ) ;
} else if ( graph [ i ] . wordlength > wl ) {
fprintf ( stderr , " \n %s " , alphabetize ( graph [ i ] . word , graph [ i ] . wordlength , alphabet , string_buffer1 ) ) ;
wl = graph [ i ] . wordlength ;
} else
fprintf ( stderr , " %s " , alphabetize ( graph [ i ] . word , graph [ i ] . wordlength , alphabet , string_buffer1 ) ) ;
}
fprintf ( stderr , " \n \n " ) ;
2016-11-14 10:54:52 +00:00
fixpoints = 0 ;
for ( int i = 0 ; i < cosets ; i + + )
if ( graph [ i ] . opposite = = i ) {
if ( fixpoints = = 0 )
fprintf ( stderr , " No thickenings since the longest element fixes the following cosets: %s " , alphabetize ( graph [ i ] . word , graph [ i ] . wordlength , alphabet , string_buffer1 ) ) ;
else
fprintf ( stderr , " %s " , alphabetize ( graph [ i ] . word , graph [ i ] . wordlength , alphabet , string_buffer1 ) ) ;
fixpoints + + ;
}
if ( fixpoints > 0 ) {
fprintf ( stderr , " \n \n " ) ;
} else {
// enumerate balanced thickenings
fwrite ( & type . n , sizeof ( int ) , 1 , stdout ) ;
fwrite ( type . factors , sizeof ( simple_type_t ) , type . n , stdout ) ;
fwrite ( & left_invariance , sizeof ( unsigned long ) , type . n , stdout ) ;
fwrite ( & right_invariance , sizeof ( unsigned long ) , type . n , stdout ) ;
long count = enumerate_balanced_thickenings ( type , graph , cosets , alphabet , stdout ) ;
fprintf ( stderr , " Found %ld balanced thickenings \n \n " , count ) ;
}
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
graph_free ( type , graph ) ;
2016-07-26 08:09:34 +00:00
free ( type . factors ) ;
return 0 ;
}