-
Notifications
You must be signed in to change notification settings - Fork 5
/
schubert.cpp
1906 lines (1455 loc) · 47 KB
/
schubert.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This is schubert.cpp
Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux
See file main.cpp for full copyright notice
*/
#include "schubert.h"
#include "error.h"
namespace schubert {
using namespace error;
};
/****************************************************************************
This file contains the definition of the general functions pertaining
to Schubert contexts, and the definition of the StandardSchubertContext
class. Other implementations of Schubert contexts will be found in
other files.
A Schubert context contains a description of a finite decreasing subset Q
of the group (initially the singleton {e}), and should be capable of
providing data and services related to the Bruhat ordering and to the
(partially defined) action of the generators on the Q. The elements of Q
are assumed to be enumerated by the integers in the range [0,size()[,
in an ordering compatible with the Bruhat ordering.
Specifically, the following functions are required :
- managing the context :
- append(g,x) : appends to the CoxWord g a reduced expression of the
element #x in Q;
- contextNumber(g) : returns the number x in [0,size()[ corresponding
to the CoxWord g, or undef_coxnbr if there is no such x;
- descent sets :
- descent(x) : returns the two-sided descent set of x, flagged in a
LFlags;
- ldescent(x), rdescent(x) : same for left (right) descent sets;
- firstDescent(x), firstLDescent(); firstRDescent(x) : returns the
first set bit in the corresponding descent sets;
- downset(s) : a bitmap of the set of x s.t. xs < x;
- isDescent(x,s) : tells if s is a descent for x;
- maximize(x,f), minimize(x,f) : extremalizes x w.r.t. the action of the
generators flagged by f;
- Bruhat ordering :
- extendSubSet(q,s) : given q holding a decreasing subset of Q, and
s s.t. q.s is contained in Q, puts q.s in q;
- extractClosure(q,x) : puts in q the interval [e,x];
- hasse(x) : returns the coatom list of x;
- inOrder(x,y) : tells if x <= y;
- action of generators :
- shift(x,s) : returns the shift xs (left shift by s-rank() if s > rank());
- lshift(x,s), rshift(x,s) : left or right shifts;
- length :
- length(x) : returns the length of element #x;
- maxlength() : largest length of element in context;
- parity(x) : a bitmap of the set of z s.t. length(z) = length(x) mod 2;
- sizes :
- rank() : returns the rank of the underlying group;
- setSize(n) : this should really be a private function; it can be used
safely only in order to _reduce_ the size of the context (typically,
when the Schubert extension succeeded but the kl extension failed,
and we wish to revert;)
- size() : returns the current size of the context;
The StandardSchubertContext class contains lengths, shifts, coatoms and
downsets as tables, so the above functions are really simply table accesses.
The context extension and interval extraction is done as described in my
paper "Computing Kazhdan-Lusztig polynomials for arbitrary Coxeter groups",
Experiment. Math. 11 (2002), no. 3, pp. 371-381.
****************************************************************************/
namespace {
using namespace schubert;
using namespace bits;
const char* undef_str = "undefined";
void resetOne(SubSet& q);
};
/****************************************************************************
Chapter I -- The StandardSchubertContext class.
This section defines the functions in the SchubertContext class :
- constructors and destructors :
- StandardSchubertContext(G);
- ~StandardSchubertContext
- accessors :
- append(g,x) : appends the normal form of x to g;
- closure(x) : returns a bitmap of the interval [e,x];
- contextNumber(g) : returns the number of g in the context;
- descent(x), ldescent(x), rdescent(x) : descent sets; (inlined)
- downset(s) : bitmap of {x, xs < x}; (inlined)
- firstDescent(x), firstLDescent(x), firstRDescent(x) : smallest
generator taking x down; (inlined)
- hasse(x) : the list of coatoms of x; (inlined)
- inOrder(x,y) : tells if x <= y;
- length (x) : the length of x; (inlined)
- maximize(x,f) : maximizes x w.r.t. the action of the generators in f;
- maxlength() : maximal length in context; (inlined)
- minimize(x,f) : minimizes x w.r.t. the action of the generators in f;
- normalForm(g,x,order) : returns the normal form of x for order;
- parity(x) : bitmap of {z, l(z)=l(x) mod 2}; (inlined)
- rank() : the rank of the group; (inlined)
- shift(x,s), lshift(x,s), rshift(x,s) : shifts x by s; (inlined)
- size() : the size of the context; (inlined)
- twoDescent(y) : returns the "super-descent" set of y;
- modifiers :
- extendContext(g) : extends the context to accomodate g;
- extendSubSet(s) : extends the subset to accomodate multiplication by s;
- permute(q) : applies the permutation q to the context;
- revertSize(n) : reverts to a previous size;
- setSize(n) : resets the size;
- subset() : gives access to the subset; (inlined)
****************************************************************************/
namespace schubert {
/******** constructors ******************************************************/
StandardSchubertContext::StandardSchubertContext(const CoxGraph& G)
:d_graph(G), d_rank(G.rank()), d_maxlength(0), d_size(1), d_length(1),
d_hasse(1), d_descent(1), d_shift(1), d_star(1), d_subset(1)
/*
Constructor for the SchubertContext class. The data are initialized for
the one-element context {e} : size is one, and for the single element
0, length is 0, descent sets are empty, coatom set is empty, shifts
are all undefined.
*/
{
d_length.setSizeValue(1);
d_hasse.setSizeValue(1);
d_descent.setSizeValue(1);
d_shift.setSizeValue(1);
d_star.setSizeValue(1);
d_shift[0] = new(arena()) CoxNbr[2*rank()];
for (Ulong j = 0; j < 2*static_cast<Ulong>(d_rank); ++j)
d_shift[0][j] = undef_coxnbr;
d_star[0] = new(arena()) CoxNbr[2*nStarOps()];
for (StarOp j = 0; j < 2*nStarOps(); ++j)
d_star[0][j] = undef_coxnbr;
d_downset = new(arena()) BitMap[2*d_rank];
for (Ulong j = 0; j < 2*static_cast<Ulong>(d_rank); ++j)
new(d_downset+j) BitMap(1);
d_parity = new(arena()) BitMap[2];
new(d_parity) BitMap(1);
new(d_parity+1) BitMap(1);
d_parity[0].setBit(0);
}
StandardSchubertContext::~StandardSchubertContext()
/*
Destructing a SchubertContext turns out to be a little bit tricky,
because of the way memory has been allocated for the various structures,
in the successive extensions. In particular, in d_shift and d_star,
only *some* pointers have been allocated by new.
This problem will be much easier to handle once the memory allocations
go through a private arena; it will then be enough to simply free the
arena. For now, we introduce a monitoring through a stack of
ContextExtensions.
Apart from this, the only thing that has to be deleted directly is
downset.
*/
{
/* reverse history */
while (d_history.size()) {
delete *d_history.pop();
}
for (Ulong j = 0; j < 2*static_cast<Ulong>(d_rank); ++j) {
d_downset[j].~BitMap();
}
d_parity[0].~BitMap();
d_parity[1].~BitMap();
arena().free(d_star[0],2*nStarOps()*sizeof(CoxNbr));
arena().free(d_shift[0],2*rank()*sizeof(CoxNbr));
}
/******** accessors ********************************************************/
CoxWord& StandardSchubertContext::append(CoxWord& g, const CoxNbr& d_x) const
/*
This function appends to g the ShortLex normal form of x. The normal form is
easily obtained using the left descent sets.
NOTE : it is the progarmmer's responsibilty when using this function, to
guarantee that the result is reduced. Otherwise, use "prod".
*/
{
CoxNbr x = d_x;
while (x) {
Generator s = firstBit(ldescent(x));
g.append(s+1);
x = lshift(x,s);
}
return g;
}
CoxNbr StandardSchubertContext::contextNumber(const CoxWord& g) const
/*
This functions returns the number corresponding to g in the current
context; returns undef_coxnbr if g is not in the context.
*/
{
CoxNbr x = 0;
for (Ulong j = 0; j < g.length(); ++j) {
Generator s = g[j]-1;
x = rshift(x,s);
if (x == undef_coxnbr)
break;
}
return x;
}
void StandardSchubertContext::extractClosure(BitMap& b, const CoxNbr& x) const
/*
This function puts in b the subset [e,x] of p. It is assumed that b
is capable of holding a subset of p.
Forwards the error MEMORY_WARNING if CATCH_MEMORY_OVERFLOW is set.
*/
{
SubSet q(d_size);
resetOne(q);
for (CoxNbr x1 = x; x1;) {
Generator s = firstLDescent(x1);
extendSubSet(q,s);
x1 = d_shift[x1][s+d_rank];
}
b = q.bitMap();
return;
}
bool StandardSchubertContext::inOrder(CoxNbr x, CoxNbr y) const
/*
Checks if x <= y in the Bruhat ordering, using the well-known recursive
algorithm : if y = 0, then x must be 0; otherwise, take s s.t. ys < y;
then if xs < x, x <= y iff xs < ys; if xs > x, x <= y iff x <= ys.
NOTE : this function is not intended for heavy use!
*/
{
if (x == 0)
return true;
if (x == y)
return true;
if (x > y)
return false;
Generator s = firstDescent(y);
CoxNbr xs = d_shift[x][s];
CoxNbr ys = d_shift[y][s];
if (xs < x)
return inOrder(xs,ys);
else /* xs > x */
return inOrder(x,ys);
}
CoxNbr StandardSchubertContext::maximize(const CoxNbr& x, const LFlags& f)
const
/*
This function maximizes x w.r.t. the flags in f. The return value is
undef_coxnbr if the extremalization takes us outside the context. It
is assumed that f is a valid set of flags, i.e., contained in S \coprod S.
*/
{
CoxNbr x1 = x;
LFlags g = f & ~d_descent[x1];
while (g)
{
Generator s = firstBit(g);
x1 = d_shift[x1][s];
if (x1 == undef_coxnbr)
break;
g = f & ~d_descent[x1];
}
return x1;
}
CoxNbr StandardSchubertContext::minimize(const CoxNbr& x, const LFlags& f)
const
/*
This function minimizes x w.r.t. the flags in f. Here the return value
is always defined. It is assumed that f is a valid set of flags, i.e.,
contained in S \coprod S.
*/
{
CoxNbr x1 = x;
LFlags g = f & d_descent[x1];
while (g)
{
Generator s = firstBit(g);
x1 = d_shift[x1][s];
g = f & d_descent[x1];
}
return x1;
}
CoxWord& StandardSchubertContext::normalForm(CoxWord& g, const CoxNbr& d_x,
const Permutation& order) const
/*
This function returns the normal form of x for the given ordering of the
generators. The order parameter is typically d_out in interface; so
order[j] is the external number of the internal generator #j.
NOTE : this function is more expensive than append; its main intention
is for use in i/o functions.
*/
{
g.reset();
CoxNbr x = d_x;
while (x) {
Generator s = minDescent(ldescent(x),order);
g.append(s+1);
x = lshift(x,s);
}
return g;
}
LFlags StandardSchubertContext::twoDescent(const CoxNbr& x) const
/*
Returns the "super-descent" set of x; this is the union of the descent
set of x, and of the descent sets of the xs, where s runs through the
descent set of x.
*/
{
LFlags f = descent(x);
for (LFlags f1 = f; f1; f1 &= f1-1) {
Generator s = firstBit(f1);
CoxNbr xs = shift(x,s);
f |= descent(xs);
}
return f;
}
/******** modifiers ********************************************************/
CoxNbr StandardSchubertContext::extendContext(const CoxWord& g)
/*
This function extends the context to the smallest one containing the
exixting one and the given g, i.e., the new context is the union of
the old context and [e,g]. Apart from some previously undefined shifts
becoming defined, this doesn't induce _any_ modification in the data
for the old context; the numbers of the new elements come in at the top.
Sets the error ... in case of failure.
The outline of the function is as follows. First, we determine the
largest subword h of g which is alreaady in the context, and construct
the interval [e,h] as a subset of the context. Then, for each remaining
generator in g, we add the elements in [e,hs] not already in the
context, and we update everything.
*/
{
CoxNbr y = 0;
SubSet& q = d_subset;
resetOne(q);
Ulong j = 0;
CATCH_MEMORY_OVERFLOW = true;
for (; j < g.length(); ++j) {
Generator s = g[j]-1;
if (rshift(y,s) == undef_coxnbr)
break;
extendSubSet(q,s);
if (ERRNO)
goto error_handling;
y = rshift(y,s);
}
for (; j < g.length(); ++j) {
Generator s = g[j]-1;
fullExtension(q,s);
if (ERRNO)
goto error_handling;
if (j >= d_maxlength)
d_maxlength = j+1;
y = rshift(y,s);
}
CATCH_MEMORY_OVERFLOW = false;
return y;
error_handling:
Error(ERRNO);
ERRNO = EXTENSION_FAIL;
return(undef_coxnbr);
}
void StandardSchubertContext::extendSubSet(SubSet& q, const Generator& s) const
/*
Given a subset q of p holding a decreasing subset, and a geneator s s.t.
q.s. is contained in the context, in the context, this function puts in q
the set q.s ( here s can be either a right or a left shift.)
Forwards the error MEMORY_WARNING if CATCH_MEMORY_OVERFLOW is set.
*/
{
Ulong a = q.size();
for (Ulong j = 0; j < a; ++j) { /* run through q */
CoxNbr x = (CoxNbr)q[j];
CoxNbr xs = d_shift[x][s];
if (xs < x)
continue;
if (q.isMember(xs))
continue;
/* if we get here a new element is found */
q.add(xs);
if (ERRNO)
return;
}
return;
}
void StandardSchubertContext::permute(const Permutation& a)
/*
This function applies the permutation a to the context. We have explained
in kl.cpp how this should be done. The objects to be permuted are the
following :
- d_length : a table with range in the context;
- d_hasse : each row is a list with values in the context; the table itself
has range in the context; in addition the permuted rows should be sorted;
- d_descent : a table with range in the context;
- d_shift : a table with range in the context; each row has values in the
context, or undef_coxnbr;
- d_downset : a table of bitmaps ranging over the context;
- d_parity : a pair of bitmaps ranging over the context;
*/
{
static BitMap b(0);
static CoatomList hasse_buf; /* quick fix; can go when all lists are
pointer lists */
/* permute values */
for (CoxNbr x = 0; x < d_size; ++x) {
CoatomList& c = d_hasse[x];
for (Ulong j = 0; j < c.size(); ++j)
c[j] = a[c[j]];
c.sort();
}
for (CoxNbr x = 0; x < d_size; ++x) {
for (Generator s = 0; s < 2*d_rank; ++s) {
if (d_shift[x][s] != undef_coxnbr)
d_shift[x][s] = a[d_shift[x][s]];
}
}
/* permute the ranges */
b.setSize(a.size());
b.reset();
for (CoxNbr x = 0; x < this->size(); ++x) {
if (b.getBit(x))
continue;
if (a[x] == x) {
b.setBit(x);
continue;
}
for (CoxNbr y = a[x]; y != x; y = a[y]) {
/* back up values for y */
Length length_buf = d_length[y];
hasse_buf.shallowCopy(d_hasse[y]);
LFlags descent_buf = d_descent[y];
CoxNbr* shift_buf = d_shift[y];
/* put values for x in y */
d_length[y] = d_length[x];
d_hasse[y].shallowCopy(d_hasse[x]);
d_descent[y] = d_descent[x];
d_shift[y] = d_shift[x];
/* store backup values in x */
d_length[x] = length_buf;
d_hasse[x].shallowCopy(hasse_buf);
d_descent[x] = descent_buf;
d_shift[x] = shift_buf;
/* modify downsets */
for (Generator s = 0; s < 2*this->rank(); ++s) {
bool t = d_downset[s].getBit(y);
d_downset[s].setBit(y,d_downset[s].getBit(x));
d_downset[s].setBit(x,t);
}
/* modify parity bitmaps */
bool t = d_parity[0].getBit(y);
d_parity[0].setBit(y,d_parity[0].getBit(x));
d_parity[0].setBit(x,t);
t = d_parity[1].getBit(y);
d_parity[1].setBit(y,d_parity[1].getBit(x));
d_parity[1].setBit(x,t);
/* set bit*/
b.setBit(y);
}
b.setBit(x);
}
}
void StandardSchubertContext::revertSize(const Ulong& n)
/*
This function reverts the size of the context to some previous value. It
is very important that n is indeed a previous value of the context size
(i.e. that it can be found through the extension history), and that no
permutation has taken place between that previous size and the current size.
This function is intended to be used immediately after the extension of
the rest of the context failed, so that everything returns to where it
was before. Because of the way things are allocated, we are actually able
to return most of the allocated memory (only the allocations for the
basic lists will remain as they were.)
*/
{
Ulong m = size();
while (m > n) {
ContextExtension* h = *d_history.pop();
m -= h->size();
delete h;
}
return;
}
void StandardSchubertContext::setSize(const Ulong& n)
/*
Resizes the various data structures to accomodate a context of size n.
This means that the Lists d_length, d_hasse, d_descent and d_shift
are resized to size n, and that memory is allocated for the new shift
tables; we cannot do this for coatom lists, since they are variable in
size.
It is assumed that n is greater than the current size.
Sets the error MEMORY_WARNING in case of overflow, if CATCH_MEMORY_OVERFLOW
had been set.
*/
{
Ulong prev_size = size();
CATCH_MEMORY_OVERFLOW = true;
ContextExtension* e = new ContextExtension(*this,n-size());
if (ERRNO) /* extension failed */
goto revert;
d_history.push(e);
CATCH_MEMORY_OVERFLOW = false;
return;
revert:
CATCH_MEMORY_OVERFLOW = false;
revertSize(prev_size);
return;
}
/******** input/output ****************************************************/
String& StandardSchubertContext::append(String& str, const CoxNbr& x)
const
{
if (x == undef_coxnbr)
io::append(str,undef_str);
else
coxtypes::append(str,x);
return str;
}
String& StandardSchubertContext::append(String& str, const CoxNbr& x,
const Interface& I) const
{
if (x == undef_coxnbr)
return io::append(str,undef_str);
else {
CoxWord g(0);
normalForm(g,x,I.order());
return I.append(str,g);
}
}
void StandardSchubertContext::print(FILE* file, const CoxNbr& x) const
{
if (x == undef_coxnbr)
fprintf(file,"%s",undef_str);
else
fprintf(file,"%lu",static_cast<Ulong>(x));
return;
}
void StandardSchubertContext::print(FILE* file, const CoxNbr& x,
const Interface& I) const
{
if (x == undef_coxnbr)
fprintf(file,"%s",undef_str);
else {
CoxWord g(0);
normalForm(g,x,I.order());
I.print(file,g);
}
return;
}
/******** private member functions ******************************************
The following functions are defined as private member functions. The
main reason for this is that this gives access to the representation,
so that we can inline the access (to the shift table for instance) that
would otherwise go to a virtual function call.
- fillCoatoms(first,s) : fills in the coatom lists of new elements of
the extension by s;
- fillDihedralShifts(x,s) : fills in the shifts in the case where
x is dihedral;
- fillShifts(first,s) : fills in the shift tables of new elements of
the extension by s;
- fillStar(first) : fills in the star tables of new elements;
- fullExtension(q,s) : fills in the extension obtained by adding
the elements xs, x in q;
*****************************************************************************/
void StandardSchubertContext::fillCoatoms(const Ulong& first,
const Generator& s)
/*
This auxiliary fills the coatom lists of the new elements in p.
It is assumed that p has been resized to the correct size, that
first is the first new element, that lengths and shifts by s have
been filled in.
*/
{
static List<CoxNbr> c(1);
for (CoxNbr x = first; x < d_size; ++x) {
/* put coatom list in c */
CoxNbr xs = d_shift[x][s];
c.setSize(0);
c.append(xs);
CoatomList& cs = d_hasse[xs];
for (Ulong j = 0; j < cs.size(); ++j) {
CoxNbr z = cs[j];
CoxNbr zs = d_shift[z][s];
if (zs > z) /* z moves up */
insert(c,zs);
}
/* copy to d_hasse[x] */
d_hasse[x].assign(c);
}
return;
}
void StandardSchubertContext::fillDihedralShifts(const CoxNbr& x,
const Generator& s)
/*
This function fills in the shifts for x in the dihedral case. It is
assumed that the shift by s is already filled in, and that length(x)
is > 1. We have denoted on the right the action of s, on the left
the action on the side different from s. This works even if in fact
the action of s is on the left.
*/
{
CoxNbr xs = d_shift[x][s];
/* find the other generator involved, on the same side as s */
Generator s1, t, t1;
CoxEntry m;
if (s < d_rank) { /* action is on the right */
t = firstRDescent(xs);
s1 = s + d_rank;
t1 = t + d_rank;
m = d_graph.M(s,t);
}
else { /* action is on the left */
s1 = s - d_rank;
t1 = firstLDescent(xs);
t = t1 + d_rank;
m = d_graph.M(s1,t1);
}
const CoatomList& c = d_hasse[x];
CoxNbr z; /* the other coatom of x */
if (c[0] == xs)
z = c[1];
else
z = c[0];
if (d_length[x] == m) { /* descents for s,t on both sides */
d_descent[x] |= lmask[t] | lmask[s1] | lmask[t1];
d_downset[t].setBit(x);
d_downset[s1].setBit(x);
d_downset[t1].setBit(x);
d_shift[x][t] = z;
d_shift[z][t] = x;
if (m % 2) { /* xs = tx; xt = sx */
d_shift[x][s1] = z;
d_shift[z][s1] = x;
d_shift[x][t1] = xs;
d_shift[xs][t1] = x;
}
else { /* xs = sx; xt = tx */
d_shift[x][s1] = xs;
d_shift[xs][s1] = x;
d_shift[x][t1] = z;
d_shift[z][t1] = x;
}
}
else { /* descent on one side only */
if (d_length[x] % 2) { /* xs and sx */
d_shift[x][s1] = z;
d_shift[z][s1] = x;
d_descent[x] |= lmask[s1];
d_downset[s1].setBit(x);
}
else { /* xs and tx */
d_shift[x][t1] = z;
d_shift[z][t1] = x;
d_descent[x] |= lmask[t1];
d_downset[t1].setBit(x);
}
}
return;
}
void StandardSchubertContext::fillShifts(const CoxNbr& first,
const Generator& s)
/*
This function fills in the shift tables of the new elements in p. It is
assumed that first is the first new element, that the coatom tables,
lengths and shifts by s have already been filled in. We use the algorithm
deduced form Dyer's theorem, alluded to in the introduction.
*/
{
CoxNbr x = first;
/* check if something happens in length one; if there is a new element
of length one, it is unique and equal to s */
if (d_length[x] == 1) { /* x = s */
Generator t;
if (s < d_rank) /* s acts on the right */
t = s + d_rank;
else /* s acts on the left */
t = s - d_rank;
d_shift[0][t] = x;
d_shift[x][t] = 0;
d_descent[x] |= lmask[t];
d_downset[t].setBit(x);
++x;
}
for (; x < d_size; ++x) {
const CoatomList& c = d_hasse[x];
if (c.size() == 2) { /* dihedral case */
fillDihedralShifts(x,s);
continue;
}
for (Generator t = 0; t < 2*d_rank; ++t) { /* examine shift by t */
if (t == s)
continue;
bool firstplus = true;
CoxNbr z = undef_coxnbr;
for (Ulong j = 0; j < c.size(); ++j) {
if (!(lmask[t] & d_descent[c[j]])) { /* coatom has ascent */
if (firstplus) { /* it's the first time */
firstplus = false;
z = c[j]; // z is the coatom that goes up
}
else {
goto nextt;
}
}
}
/* if we reach this point there was exactly one ascent */
d_shift[x][t] = z;
d_shift[z][t] = x;
d_descent[x] |= lmask[t];
d_downset[t].setBit(x);
nextt:
continue;
}
}
return;
}
void StandardSchubertContext::fillStar(const CoxNbr& first)
/*
This function fills in the star operations for the new elements. Each
star operation is a partially defined involution. The tables have
already been initially set to undef_coxnbr; we fill in the operation in
pairs, using the element that goes down.
Recall that a star operation is associated to each edge {s,t} in the
Coxeter graph such that m(s,t) < infty. The domain of the left star operation
is the set of elements for which ldescent() intersects {s,t} in one element
exactly (in other words, the elements that are neither minimal nor maximal
in the left coset under the dihedral subgroup generated by s and t.)
NOTE : a value undef_coxnbr means that either the element is not in the
domain of the star operation, or that the star operation takes us out
of context; hence an undefined value may become defined after extension;
but this will always happen for elements paired up with a new element,
so we only have to go through the new ones.
*/
{
const List<LFlags>& ops = d_graph.starOps();
for (CoxNbr x = first; x < d_size; ++x) {
LFlags fx = rdescent(x);
for (StarOp j = 0; j < nStarOps(); ++j) {
/* determine if x is in right domain */
LFlags f = fx & ops[j];
if ((f == 0) || (f == ops[j]))
continue;
CoxNbr x_min = minimize(x,ops[j]);
Length d = d_length[x] - d_length[x_min];
Generator s = firstBit(f); /* the _only_ bit in f, actually */
Generator t = firstBit(ops[j] & ~f);
CoxEntry m = d_graph.M(s,t);
if (2*d < m) /* star is either undef_coxnbr or increasing */
continue;
/* if we get here we fill in a pair in d_star */
if (2*d == m)
d_star[x][j] = x;
else {
CoxNbr x1 = x;
while ((d_length[x1] - d_length[x_min]) > (m - d)) {
LFlags f1 = rdescent(x1) & ops[j];
Generator s1 = firstBit(f1);
x1 = d_shift[x1][s1];
}
d_star[x][j] = x1;
d_star[x1][j] = x;
}
}
fx = ldescent(x);
for (StarOp j = 0; j < nStarOps(); ++j) {
/* determine if x is in left domain */
LFlags f = fx & ops[j];
if ((f == 0) || (f == ops[j]))
continue;
LFlags lops = ops[j] << d_rank;
CoxNbr x_min = minimize(x,lops);
Length d = d_length[x] - d_length[x_min];
Generator s = firstBit(f); /* the _only_ bit in f, actually */
Generator t = firstBit(ops[j] & ~f);
CoxEntry m = d_graph.M(s,t);
if (2*d < m) /* star is either undef_coxnbr or increasing */
continue;
/* if we get here we fill in a pair in d_star */
if (2*d == m)
d_star[x][j+nStarOps()] = x;
else {
CoxNbr x1 = x;
while ((d_length[x1] - d_length[x_min]) > (m - d)) {
LFlags f1 = ldescent(x1) & ops[j];
Generator s1 = firstBit(f1);