clean out old experiments

This commit is contained in:
Florian Stecker 2022-06-13 11:25:40 +02:00
parent 69564f5750
commit 4cd76a8d81
5 changed files with 4 additions and 411 deletions

5
.gitignore vendored
View File

@ -1,6 +1,5 @@
*.o
enumerate
idealbounds
graph
D2n
dominant_weights
output/
old/

133
D2n.c
View File

@ -1,133 +0,0 @@
#include "thickenings.h"
#include "weyl.h"
#include "queue.h"
#include <strings.h>
#include <stdio.h>
#include <inttypes.h>
int main(int argc, const char *argv[])
{
if(argc < 2) {
fprintf(stderr, "Rank argument required.\n");
return 1;
}
int rank = atoi(argv[1]);
if(rank <= 0 || rank > 1000) {
fprintf(stderr, "Rank must be a small positive integer.\n");
return 1;
}
if(rank % 2) {
fprintf(stderr, "Rank must be even.\n"); // opposition involution not trivial otherwise
return 1;
}
doublequotient_t *dq = (doublequotient_t*)malloc(sizeof(doublequotient_t));
simple_type_t type;
type.series = 'D';
type.rank = rank;
dq->type.n = 1;
dq->type.factors = &type;
dq->left_invariance = (1<<rank) - 2;
dq->right_invariance = 0;
dq->group = 0;
dq->grouplists = 0;
dq->groupletters = 0;
dq->count = 1 << (rank - 1);
dq->cosets = (doublecoset_t*)malloc(dq->count*sizeof(doublecoset_t));
dq->lists = (doublecoset_list_t*)malloc(2*dq->count*rank*sizeof(doublecoset_list_t)); // conservative estimate
int nlists = 0;
int *bitmask = malloc((1<<(rank-1)) * sizeof(int));
int *bitmask_reverse = malloc((1<<rank) * sizeof(int));
int index = 0;
LOG("Prepare.\n");
for(int i = 0; i < dq->count; i++) {
dq->cosets[i].index = i;
dq->cosets[i].bruhat_lower = (doublecoset_list_t*)0;
dq->cosets[i].bruhat_higher = (doublecoset_list_t*)0;
dq->cosets[i].min = (weylgroup_element_t*)0;
dq->cosets[i].max = (weylgroup_element_t*)0;
}
LOG("Create bitmasks.\n");
for(uint64_t i = 0; i < (1 << rank); i++) {
if(__builtin_popcountll(i) % 2 == 1)
bitmask_reverse[i] = -1;
else {
bitmask[index] = i;
bitmask_reverse[i] = index++;
}
}
LOG("Generate bruhat order.\n");
for(int i = 0; i < dq->count; i++) {
for(int j = 0; j < rank - 1; j++) {
if(!(bitmask[i] & BIT(j)) && (bitmask[i] & BIT(j+1))) {
int lowerind = bitmask_reverse[bitmask[i] ^ (BIT(j) | BIT(j+1))];
dq->lists[nlists].next = dq->cosets[i].bruhat_lower;
dq->cosets[i].bruhat_lower = &dq->lists[nlists];
dq->cosets[i].bruhat_lower->to = &dq->cosets[lowerind];
nlists++;
}
}
if((bitmask[i] & BIT(0)) && (bitmask[i] & BIT(1))) {
int lowerind = bitmask_reverse[bitmask[i] & ~(BIT(0) | BIT(1))];
dq->lists[nlists].next = dq->cosets[i].bruhat_lower;
dq->cosets[i].bruhat_lower = &dq->lists[nlists];
dq->cosets[i].bruhat_lower->to = &dq->cosets[lowerind];
nlists++;
}
}
LOG("Revert bruhat order.\n");
for(int i = 0; i < dq->count; i++) {
for(doublecoset_list_t *cur = dq->cosets[i].bruhat_lower; cur; cur = cur->next) {
dq->lists[nlists].next = cur->to->bruhat_higher;
cur->to->bruhat_higher = &dq->lists[nlists];
cur->to->bruhat_higher->to = &dq->cosets[i];
nlists++;
}
}
LOG("Find opposites.\n");
for(int i = 0; i < dq->count; i++) {
int oppind = bitmask_reverse[~bitmask[i] & ((1<<rank) - 1)];
dq->cosets[i].opposite = &dq->cosets[oppind];
}
/*
printf("\n");
printf("digraph test123 {\n");
for(int i = 0; i < dq->count; i++) {
for(doublecoset_list_t *cur = dq->cosets[i].bruhat_lower; cur; cur = cur->next) {
printf("\"0x%02x\" -> \"0x%02x\";\n", bitmask[i], bitmask[cur->to->index]);
}
}
printf("}\n\n");
printf("Opposites:\n");
for(int i = 0; i < dq->count; i++)
printf("0x%02x <-> %d 0x%02x\n", bitmask[i], dq->cosets[i].opposite->index, bitmask[dq->cosets[i].opposite->index]);
printf("\n");
*/
long count = enumerate_balanced_thickenings(dq, 0, 0);
printf("Found %ld balanced ideals.\n", count);
free(bitmask);
free(bitmask_reverse);
free(dq->lists);
free(dq->cosets);
free(dq);
return 0;
}

View File

@ -5,15 +5,8 @@ HEADERS=weyl.h thickenings.h queue.h bitvec.h
SPECIAL_OPTIONS=-O3 -flto -funroll-loops -Winline
OPTIONS=-m64 -march=native -std=gnu99 -D_GNU_SOURCE $(SPECIAL_OPTIONS)
NAME=enumerate-balanced-ideals
all: enumerate graph D2n dominant_weights
$(NAME).tar.bz2: $(NAME) $(HEADERS) enumerate.c weyl.c thickenings.c
tar cjhf $(NAME).tar.bz2 $(NAME)/enumerate.c $(NAME)/weyl.c $(NAME)/thickenings.c $(NAME)/weyl.h $(NAME)/thickenings.h $(NAME)/queue.h $(NAME)/bitvec.h $(NAME)/Makefile $(NAME)/graph.c
$(NAME):
ln -s . $(NAME)
all: enumerate graph
enumerate: enumerate.o weyl.o thickenings.o
gcc $(OPTIONS) -o enumerate enumerate.o thickenings.o weyl.o
@ -21,29 +14,17 @@ enumerate: enumerate.o weyl.o thickenings.o
graph: graph.o weyl.o
gcc $(OPTIONS) -o graph graph.o weyl.o
D2n: D2n.o weyl.o thickenings.o
gcc $(OPTIONS) -o D2n D2n.o weyl.o thickenings.o
dominant_weights: dominant_weights.o weyl.o thickenings.o
gcc $(OPTIONS) -o dominant_weights dominant_weights.o weyl.o thickenings.o -lcdd
enumerate.o: enumerate.c $(HEADERS)
gcc $(OPTIONS) -c enumerate.c
thickenings.o: thickenings.c $(HEADERS)
gcc $(OPTIONS) -c thickenings.c
D2n.o: D2n.c $(HEADERS)
gcc $(OPTIONS) -c D2n.c
weyl.o: weyl.c $(HEADERS)
gcc $(OPTIONS) -c weyl.c
graph.o: graph.c $(HEADERS)
gcc $(OPTIONS) -c graph.c
dominant_weights.o: dominant_weights.c $(HEADERS)
gcc $(OPTIONS) -c dominant_weights.c
clean:
rm -f enumerate graph D2n dominant_weights thickenings.o weyl.o enumerate.o graph.o D2n.o dominant_weights.o $(NAME) $(NAME).tar.bz2
rm -f enumerate graph thickenings.o weyl.o enumerate.o graph.o

View File

@ -1,180 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <setoper.h>
#include <cdd.h>
#include "weyl.h"
#include "thickenings.h"
doublequotient_t *dq;
double *vector;
char buf[1000], buf2[1000];
typedef struct {
dd_MatrixPtr M;
dd_LPSolutionPtr lps;
} info_t;
static char* alphabetize(weylgroup_element_t *e, char *str)
{
if(e->wordlength == 0)
sprintf(str, "1");
else {
for(int j = 0; j < e->wordlength; j++)
str[j] = e->word[j] + 'a';
str[e->wordlength] = 0;
}
return str;
}
static char* print_vector(double *v, int rank, char *buf)
{
int written = 0;
for(int i = 0; i < rank; i++) {
written += sprintf(buf+written, "%.4f", v[i]);
if(i != rank -1) {
sprintf(buf+written, ", ");
written += 2;
}
}
return buf;
}
static char* print_vector_ptr(dd_Arow v, int rank, char *buf)
{
int written = 0;
for(int i = 0; i < rank; i++) {
written += sprintf(buf+written, "%.4f", v[i][0]);
if(i != rank -1) {
sprintf(buf+written, ", ");
written += 2;
}
}
return buf;
}
static void balanced_thickening_callback(const bitvec_t *pos, int size, const enumeration_info_t *ei)
{
int bit, funcbit, sign;
dd_rowset ImL, Lbasis;
dd_ErrorType err = dd_NoError;
info_t *info = (info_t*)ei->callback_data;
int rank = weyl_rank(dq->type);
for(int i = 0; i < size; i++) {
bit = i < size/2 ? bv_get_bit(pos, i) : !bv_get_bit(pos, size - 1 - i);
sign = bit ? 1 : -1;
info->M->matrix[i][0][0] = 0.0;
for(int j = 0; j < rank; j++)
info->M->matrix[i][j+1][0] = sign*vector[rank*i+j];
// printf("0 %.2f %.2f %.2f %d %d\n", sign*vector[3*i], sign*vector[3*i+1], sign*vector[3*i+2], bit, funcbit);
}
for(int i = 0; i < rank; i++) {
info->M->matrix[i+size][0][0] = 0.0;
for(int j = 0; j < rank; j++) {
if(i == j)
info->M->matrix[i+size][j+1][0] = 1.0;
else
info->M->matrix[i+size][j+1][0] = 0.0;
}
}
// dd_WriteMatrix(stdout, info->M);
dd_FindRelativeInterior(info->M, &ImL, &Lbasis, &(info->lps), &err);
if(set_card(Lbasis) != 0)
printf("codim = %ld\n", set_card(Lbasis));
else
printf("weight = (%s)\n", print_vector_ptr(info->lps->sol, rank + 1, buf));
dd_FreeLPSolution(info->lps);
// printf("\n");
}
static int apply_reflection(double *in, double *out, int rank, int reflection)
{
memcpy(out, in, rank*sizeof(double));
/*
out[reflection] *= -1;
if(reflection != 0)
out[reflection-1] += in[reflection];
if(reflection != rank-1)
out[reflection+1] += in[reflection];
*/
out[reflection] *= -1;
if(reflection != 0)
out[reflection] += in[reflection-1];
if(reflection != rank-1)
out[reflection] += in[reflection+1];
}
int main(int argc, char *argv[])
{
semisimple_type_t type;
simple_type_t simple;
info_t info;
type.n = 1;
type.factors = &simple;
simple.series = 'A';
simple.rank = 3;
dq = weyl_generate_bruhat(type, 0, 0);
int order = weyl_order(type);
int rank = weyl_rank(type);
weylgroup_element_t *group = dq->group;
vector = malloc(weyl_order(type)*weyl_rank(type)*sizeof(double));
for(int i = 0; i < rank; i++)
vector[i] = 0.0;
for(int i = 0; 2*i < rank; i++) {
for(int j = i; j < rank - i; j++) {
vector[j] += rank - 2*i;
}
}
/*
vector[0] = 4.1;
vector[1] = 6.1;
vector[2] = 5.9;
vector[3] = 3.9;
*/
printf("regular element: (%s)\n", print_vector(vector, rank, buf));
for(int i = 0; i < order; i++) {
printf("%s (%s)\n", alphabetize(&group[i], buf), print_vector(vector + rank*i, rank, buf2));
for(int j = 0; j < rank; j++)
if(group[i].left[j]->wordlength > group[i].wordlength)
apply_reflection(&vector[rank*i], &vector[rank*group[i].left[j]->index], rank, j);
}
printf("\n");
dd_set_global_constants();
info.M = dd_CreateMatrix(order+rank, rank+1);
info.M->representation = dd_Inequality;
info.M->numbtype = dd_Real;
info.M->objective = dd_LPmax;
enumerate_balanced_thickenings(dq, balanced_thickening_callback, &info);
dd_FreeMatrix(info.M);
weyl_destroy_bruhat(dq);
free(vector);
return 0;
}

View File

@ -1,74 +0,0 @@
#include "weyl.h"
#include "queue.h"
#include <limits.h>
#include <string.h>
#include <stdio.h>
static char* alphabetize(weylgroup_element_t *e, char *str)
{
if(e->wordlength == 0)
sprintf(str, "1");
else {
for(int j = 0; j < e->wordlength; j++)
str[j] = e->word[j] + 'a';
str[e->wordlength] = 0;
}
return str;
}
int main(int argc, char *argv[])
{
semisimple_type_t type;
simple_type_t simple;
char buf[100];
simple.series = 'A';
simple.rank = atoi(argv[1]);
type.n = 1;
type.factors = &simple;
int order = weyl_order(type);
doublequotient_t *dq = weyl_generate_bruhat(type, 0, 0);
queue_t q;
int cur;
int *viewed = (int*)malloc(order*sizeof(int));
int found;
int minimum = INT_MAX;
for(int i = 0; i < order; i++) {
found = 0;
memset(viewed, 0, order*sizeof(int));
queue_init(&q);
queue_put(&q, dq->cosets[i].opposite->index);
while((cur = queue_get(&q)) != -1) {
if(cur == i) { // found what we were looking for
// printf("foo: %d %d\n", i, dq->cosets[i].min->wordlength);
found = 1;
break;
}
for(doublecoset_list_t *current = dq->cosets[cur].bruhat_lower; current; current = current->next) {
if(!viewed[current->to->index]) {
viewed[current->to->index] = 1;
queue_put(&q, current->to->index);
}
}
}
if(!found) {
printf("%s %d not found\n", alphabetize(dq->cosets[i].min, buf), dq->cosets[i].min->wordlength);
if(dq->cosets[i].min->wordlength < minimum)
minimum = dq->cosets[i].min->wordlength;
// break;
} else {
printf("%s %d found\n", alphabetize(dq->cosets[i].min, buf), dq->cosets[i].min->wordlength);
}
}
printf("Minimum l(w) such that w0w can be in a balanced ideal: %d\n", minimum);
free(viewed);
return 0;
}