-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcells.cpp
1391 lines (1043 loc) · 30.2 KB
/
cells.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 cells.cpp
Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux
See file main.cpp for full copyright notice
*/
#include "cells.h"
#include "stack.h"
namespace cells {
using namespace klsupport;
using namespace stack;
};
/****************************************************************************
This module contains code for the computation of Kazhdan-Lustig cells for
the group (say in the finite case; in the infinite case the best we can
hope for is to get pieces of cells.)
The main tool for this seems to be the systematic use of *-operations;
this is particularly effective in the simply laced cases, but very useful
also in the other ones. These operations are recalled and implemented
in the Schubert module.
Let us recall the results that we use here, all contained in the original
Inventiones paper of Kazhdan and Lusztig. Each left cell is stable under
left *-operations (insofar as they are defined); in other terms for each
x such that *x (w.r.t. some simple edge {s,t}) is defined, *x is left-
equivalent to x. So left cells are unions of left star-orbits (in type A,
it is even so that the left cells are the left star-orbits.) Furthermore,
the domain of every right star-operation is a union of right equi-descent
classes, and therefore a union of left cells; and the operation takes left
cells to left cells isomorphically as W-graphs. In particular also, each
two-sided cell is a union of two-sided star orbits.
So our first goal should be to try to get at the functions defining the
partitions in left, right and two-sided cells, computing as few
mu-coefficients as possible; then we will want to determine the full
W-graph structure on the cells, classify them up to isomorphism, and
have functions such as "get the (left, right, 2-sided) cell of an element."
More sophisticated data for cells (distinguished involutions, a-functions
...) will have to wait a little bit more.
****************************************************************************/
namespace {
using namespace cells;
typedef List<CoxNbr> CoxList;
};
/****************************************************************************
Chapter I -- Partitions
This section contains functions that define partitions of (subsets of)
the context, useful for cell-computations. The following functions are
defined :
- lCells(pi,p), rCells(pi,kl), lrCells(pi,kl) : partition of the context
into left (right, two-sided) kazhdan-lusztig cells;
- lDescentPartition(pi,p), rDescentPartititon(pi,p) : partition of p
according to left (right) descent sets;
- lStringEquiv(pi,p), rStringEquiv(pi,p) : partition of p according
to weak Bruhat equivalences;
- lGeneralizedTau(pi,p), rGeneralizedTau(pi,p) : left (right) descent
partition, stabilized under star operations;
****************************************************************************/
namespace cells {
void lCells(Partition& pi, kl::KLContext& kl)
/*
This function puts in pi the partition of p into left cells --- in the case
of an incomplete context, they will be the cells defined by the links in
the graph.
The idea will be to minimize k-l computations. We proceed as follows. First,
we determine the generalized-tau partition of the context. Then, we look
at the star-orbits among the tau-classes, and decompose one representative
of each into cells; we propagate the cells using star-operations.
*/
{
static SubSet q(0);
static SubSet a(0);
static WGraph X(0);
static Partition qcells(0);
static List<Ulong> cell_count(0);
static List<Ulong> qcell_count(0);
static OrientedGraph P(0);
static Fifo<Ulong> orbit;
const SchubertContext& p = kl.schubert();
q.setBitMapSize(p.size());
a.setBitMapSize(p.size());
a.reset();
cell_count.setSize(0);
rGeneralizedTau(pi,p);
for (CoxNbr x = 0; x < p.size(); ++x) {
/* a holds the elements already processed */
if (a.isMember(x))
continue;
/* put the next generalized-tau class in q */
q.reset();
pi.writeClass(q.bitMap(),pi(x));
q.readBitMap();
/* put cell-partition of q in qcells */
X.reset();
lWGraph(X,q,kl);
X.graph().cells(qcells,&P);
/* the fifo-list orbit is used to traverse the *-orbit of the first
element of the current generalized-tau class */
orbit.push(a.size());
qcell_count.setSize(0);
/* get class counts and mark off cells in q */
for (PartitionIterator i(qcells); i; ++i) {
const Set& c = i();
qcell_count.append(c.size());
cell_count.append(c.size());
for (Ulong j = 0; j < c.size(); ++j)
a.add(q[c[j]]);
}
/* propagate cells with star-operations; the idea is that star operations
act on the level of generalized-tau classes, so each element in a given
generalized-tau class accepts the same language. */
while (orbit.size()) {
Ulong c = orbit.pop();
CoxNbr z = a[c];
for (StarOp j = 0; j < p.nStarOps(); ++j) {
CoxNbr zj = p.star(z,j);
if (zj == undef_coxnbr)
continue;
if (a.isMember(zj))
continue;
/* mark off orbit */
orbit.push(a.size());
for (Ulong i = 0; i < q.size(); ++i) {
CoxNbr y = a[c+i];
CoxNbr yj = p.star(y,j);
a.add(yj);
}
for (Ulong i = 0; i < qcell_count.size(); ++i) {
cell_count.append(qcell_count[i]);
}
}
}
}
/* write down the partition */
Ulong c = 0;
for (Ulong j = 0; j < cell_count.size(); ++j) {
for (Ulong i = 0; i < cell_count[j]; ++i) {
pi[a[c+i]] = j;
}
c += cell_count[j];
}
pi.setClassCount(cell_count.size());
return;
}
void rCells(Partition& pi, kl::KLContext& kl)
/*
Same as lCells, but does the partition into right cells.
*/
{
static SubSet q(0);
static SubSet a(0);
static WGraph X(0);
static Partition qcells(0);
static List<Ulong> cell_count(0);
static List<Ulong> qcell_count(0);
static OrientedGraph P(0);
static Fifo<Ulong> orbit;
static Permutation v(0);
const SchubertContext& p = kl.schubert();
q.setBitMapSize(p.size());
a.setBitMapSize(p.size());
a.reset();
cell_count.setSize(0);
lGeneralizedTau(pi,p);
for (CoxNbr x = 0; x < p.size(); ++x) {
if (a.isMember(x))
continue;
/* get the next generalized-tau class */
q.reset();
pi.writeClass(q.bitMap(),pi(x));
q.readBitMap();
/* find cells in class */
X.reset();
rWGraph(X,q,kl);
X.graph().cells(qcells,&P);
/* the fifo-list orbit is used to traverse the *-orbit of the first
element of the current generalized-tau class */
orbit.push(a.size());
qcell_count.setSize(0);
/* get class counts and mark off cells in q */
for (PartitionIterator i(qcells); i; ++i) {
const Set& c = i();
qcell_count.append(c.size());
cell_count.append(c.size());
for (Ulong j = 0; j < c.size(); ++j)
a.add(q[c[j]]);
}
/* propagate cells with star-operations */
while (orbit.size()) {
Ulong c = orbit.pop();
CoxNbr z = a[c];
for (StarOp j = p.nStarOps(); j < 2*p.nStarOps(); ++j) {
CoxNbr zj = p.star(z,j);
if (zj == undef_coxnbr)
continue;
if (a.isMember(zj))
continue;
/* mark off orbit */
orbit.push(a.size());
for (Ulong i = 0; i < q.size(); ++i) {
CoxNbr y = a[c+i];
CoxNbr yj = p.star(y,j);
a.add(yj);
}
for (Ulong i = 0; i < qcell_count.size(); ++i) {
cell_count.append(qcell_count[i]);
}
}
}
}
/* write down the partition */
Ulong c = 0;
for (Ulong j = 0; j < cell_count.size(); ++j) {
for (Ulong i = 0; i < cell_count[j]; ++i) {
pi[a[c+i]] = j;
}
c += cell_count[j];
}
pi.setClassCount(cell_count.size());
return;
}
void lrCells(Partition& pi, kl::KLContext& kl)
/*
This function computes the two-sided cells in the context. There are
certainly better ways to do this, but I'm afraid I don't know enough
to do it other than by filling in all the mu's ...
*/
{
kl.fillMu();
WGraph X(0);
lrWGraph(X,kl);
X.graph().cells(pi);
return;
}
void lDescentPartition(Partition& pi, const SchubertContext& p)
/*
This function writes in pi the partition of p according to the left
descent sets.
*/
{
static List<LFlags> d(0); /* holds the appearing descent sets */
pi.setSize(p.size());
d.setSize(0);
for (CoxNbr x = 0; x < p.size(); ++x)
insert(d,p.ldescent(x));
for (CoxNbr x = 0; x < p.size(); ++x)
pi[x] = find(d,p.ldescent(x));
pi.setClassCount(d.size());
return;
}
void lStringEquiv(Partition& pi, const SchubertContext& p)
/*
This function writes in pi the partition of p according to the (left)
weak Bruhat links which are equivalences for the W-graph. In other words,
x is equivalent to sx if sx > x and the left descent set of x is not
contained in the left descent set of sx; this means that there is a t,
not commuting with s, in the left descent set of x s.t. x and sx are
in the same left chain for {s,t}.
*/
{
static BitMap b(0);
static Fifo<CoxNbr> orbit;
b.setSize(p.size());
b.reset();
pi.setSize(p.size());
Ulong count = 0;
for (CoxNbr x = 0; x < p.size(); ++x) {
if (b.getBit(x))
continue;
b.setBit(x);
pi[x] = count;
orbit.push(x);
while (orbit.size()) {
CoxNbr z = orbit.pop();
for (Generator s = 0; s < p.rank(); ++s) {
CoxNbr sz = p.lshift(z,s);
if (b.getBit(sz))
continue;
LFlags fz = p.ldescent(z);
LFlags fsz = p.ldescent(sz);
LFlags f = fz & fsz;
if ((f == fz) || (f == fsz)) /* inclusion */
continue;
b.setBit(sz);
pi[sz] = count;
orbit.push(sz);
}
}
count++;
}
pi.setClassCount(count);
return;
}
void lStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p)
/*
Does the partition of the subset q into left string classes. It is assumed
that q is stable under the equivalence relation.
*/
{
static BitMap b(0);
static Fifo<CoxNbr> orbit;
b.setSize(p.size());
b.reset();
pi.setSize(q.size());
Ulong count = 0;
for (Ulong j = 0; j < q.size(); ++j) {
const CoxNbr x = q[j];
if (b.getBit(x))
continue;
b.setBit(x);
pi[j] = count;
orbit.push(x);
while (orbit.size()) {
CoxNbr z = orbit.pop();
for (Generator s = 0; s < p.rank(); ++s) {
CoxNbr sz = p.lshift(z,s);
if (b.getBit(sz))
continue;
LFlags fz = p.ldescent(z);
LFlags fsz = p.ldescent(sz);
LFlags f = fz & fsz;
if ((f == fz) || (f == fsz)) /* inclusion */
continue;
if (!q.isMember(sz)) { // q is not stable! this shouldn't happen
ERRNO = ERROR_WARNING;
return;
}
b.setBit(sz);
orbit.push(sz);
}
}
count++;
}
pi.setClassCount(count);
return;
}
void rDescentPartition(Partition& pi, const SchubertContext& p)
/*
This function writes in pi the partition of p according to the right
descent sets.
*/
{
static List<LFlags> d(0); /* holds the appearing descent sets */
pi.setSize(p.size());
d.setSize(0);
for (CoxNbr x = 0; x < p.size(); ++x)
insert(d,p.rdescent(x));
for (CoxNbr x = 0; x < p.size(); ++x)
pi[x] = find(d,p.rdescent(x));
pi.setClassCount(d.size());
return;
}
void rStringEquiv(Partition& pi, const SchubertContext& p)
/*
Same as lStringEquiv, but on the other side.
*/
{
static BitMap b(0);
static Fifo<CoxNbr> orbit;
b.setSize(p.size());
b.reset();
pi.setSize(p.size());
Ulong count = 0;
for (CoxNbr x = 0; x < p.size(); ++x) {
if (b.getBit(x))
continue;
b.setBit(x);
pi[x] = count;
orbit.push(x);
while (orbit.size()) {
CoxNbr z = orbit.pop();
for (Generator s = 0; s < p.rank(); ++s) {
CoxNbr zs = p.rshift(z,s);
if (b.getBit(zs))
continue;
LFlags fz = p.rdescent(z);
LFlags fzs = p.rdescent(zs);
LFlags f = fz & fzs;
if ((f == fz) || (f == fzs)) /* inclusion */
continue;
b.setBit(zs);
pi[zs] = count;
orbit.push(zs);
}
}
count++;
}
pi.setClassCount(count);
return;
}
void rStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p)
/*
Same as lStringEquiv, but on the other side.
*/
{
static BitMap b(0);
static Fifo<CoxNbr> orbit;
b.setSize(p.size());
b.reset();
pi.setSize(q.size());
Ulong count = 0;
for (Ulong j = 0; j < q.size(); ++j) {
const CoxNbr x = q[j];
if (b.getBit(x))
continue;
b.setBit(x);
pi[j] = count;
orbit.push(x);
while (orbit.size()) {
CoxNbr z = orbit.pop();
for (Generator s = 0; s < p.rank(); ++s) {
CoxNbr zs = p.rshift(z,s);
if (b.getBit(zs))
continue;
LFlags fz = p.rdescent(z);
LFlags fzs = p.rdescent(zs);
LFlags f = fz & fzs;
if ((f == fz) || (f == fzs)) /* inclusion */
continue;
if (!q.isMember(zs)) { // q is not stable! this shouldn't happen
ERRNO = ERROR_WARNING;
return;
}
b.setBit(zs);
orbit.push(zs);
}
}
count++;
}
pi.setClassCount(count);
return;
}
void lGeneralizedTau(Partition& pi, const SchubertContext& p)
/*
Like rGeneralizedTau, but on the left.
*/
{
static Permutation v(0);
static List<Ulong> b(0);
static List<Ulong> cc(0);
static List<Ulong> a(0);
/* initialize pi with partition into right descent sets */
Ulong prev;
lDescentPartition(pi,p);
v.setSize(pi.size());
do {
prev = pi.classCount();
/* refine */
for (Ulong r = p.nStarOps(); r < 2*p.nStarOps(); ++r) {
pi.sortI(v); /* sort partition */
Ulong count = pi.classCount();
cc.setSize(count);
cc.setZero();
for (Ulong j = 0; j < pi.size(); ++j)
cc[pi[j]]++;
Ulong i = 0;
for (Ulong c = 0; c < pi.classCount(); ++c) {
CoxNbr x = v[i]; /* first element in class */
if (p.star(x,r) == undef_coxnbr)
goto next_class;
/* find possibilities for v[.]*r */
b.setSize(0);
for (Ulong j = 0; j < cc[c]; ++j) {
Ulong cr = pi[p.star(v[i+j],r)];
insert(b,cr);
}
if (b.size() > 1) { /* there is a refinement */
a.setSize(cc[c]);
for (Ulong j = 0; j < a.size(); ++j)
a[j] = find(b,pi[p.star(v[i+j],r)]);
for (Ulong j = 0; j < cc[c]; ++j) {
if (a[j] > 0)
pi[v[i+j]] = count+a[j]-1;
}
count += b.size()-1;
}
next_class:
i += cc[c];
continue;
}
pi.setClassCount(count);
}
} while (prev < pi.classCount());
return;
}
void rGeneralizedTau(Partition& pi, const SchubertContext& p)
/*
This is the most delicate of the partition functions. It is the maximal
refinement of the right descent partition under right star operations.
In other words, two elements x and y are in the same class for this
partition, if for each right star-word a (i.e. a sequence of right
star-operations), x*a and y*a have the same right descent set.
The algorithm is very much like the minimization algorithm for a finite
state automaton.
NOTE : this could probably be simplified with a PartitionIterator; be
wary though of modifications in pi during the loop.
*/
{
static Permutation v(0);
static List<Ulong> b(0);
static List<Ulong> cc(0);
static List<Ulong> a(0);
/* initialize pi with partition into right descent sets */
Ulong prev;
rDescentPartition(pi,p);
v.setSize(pi.size());
do {
prev = pi.classCount();
/* refine */
for (Ulong r = 0; r < p.nStarOps(); ++r) {
pi.sortI(v); /* sort partition */
Ulong count = pi.classCount();
cc.setSize(count);
cc.setZero();
for (Ulong j = 0; j < pi.size(); ++j)
cc[pi[j]]++;
Ulong i = 0;
for (Ulong c = 0; c < pi.classCount(); ++c) {
CoxNbr x = v[i]; /* first element in class */
if (p.star(x,r) == undef_coxnbr)
goto next_class;
/* find possibilities for v[.]*r */
b.setSize(0);
for (Ulong j = 0; j < cc[c]; ++j) {
Ulong cr = pi[p.star(v[i+j],r)];
insert(b,cr);
}
if (b.size() > 1) { /* there is a refinement */
a.setSize(cc[c]);
for (Ulong j = 0; j < a.size(); ++j)
a[j] = find(b,pi[p.star(v[i+j],r)]);
for (Ulong j = 0; j < cc[c]; ++j) {
if (a[j] > 0)
pi[v[i+j]] = count+a[j]-1;
}
count += b.size()-1;
}
next_class:
i += cc[c];
continue;
}
pi.setClassCount(count);
}
} while (prev < pi.classCount());
return;
}
};
/*****************************************************************************
Chapter II -- W-graph construction
This section defines functions for the construction of W-graphs :
- lGraph(X,kl) : the graph part only, no descent sets;
- lrGraph(X,kl) : the graph part only, no descent sets;
- rGraph(X,kl) : the graph part only, no descent sets;
- lWGraph(X,kl) : constructs a W-graph directly from the k-l data;
- lWGraph(X,q,kl) : the same, restricted to a subset;
- rWGraph(X,kl) : constructs a W-graph directly from the k-l data;
- rWGraph(X,q,kl) : the same, restricted to a subset;
*****************************************************************************/
namespace cells {
void lGraph(OrientedGraph& X, kl::KLContext& kl)
{
const SchubertContext& p = kl.schubert();
X.setSize(kl.size());
X.reset();
for (CoxNbr y = 0; y < kl.size(); ++y) {
const kl::MuRow& mu = kl.muList(y);
for (Ulong j = 0; j < mu.size(); ++j) {
if (mu[j].mu != 0) {
CoxNbr x = mu[j].x;
if (p.ldescent(x) != p.ldescent(y)) /* make an edge from x to y */
X.edge(x).append(y);
}
}
}
for (CoxNbr y = 0; y < kl.size(); ++y) {
const CoatomList& c = p.hasse(y);
for (Ulong j = 0; j < c.size(); ++j) {
if ((p.ldescent(c[j])&p.ldescent(y)) != p.ldescent(c[j]))
X.edge(c[j]).append(y);
if ((p.ldescent(c[j])&p.ldescent(y)) != p.ldescent(y))
X.edge(y).append(c[j]);
}
}
return;
}
void lrGraph(OrientedGraph& X, kl::KLContext& kl)
{
const SchubertContext& p = kl.schubert();
X.setSize(kl.size());
X.reset();
for (CoxNbr y = 0; y < kl.size(); ++y) {
const kl::MuRow& mu = kl.muList(y);
for (Ulong j = 0; j < mu.size(); ++j) {
if (mu[j].mu != 0) {
CoxNbr x = mu[j].x;
if (p.descent(x) != p.descent(y)) /* make an edge from x to y */
X.edge(x).append(y);
}
}
}
for (CoxNbr y = 0; y < kl.size(); ++y) {
const CoatomList& c = p.hasse(y);
for (Ulong j = 0; j < c.size(); ++j) {
if ((p.descent(c[j])&p.descent(y)) != p.descent(c[j]))
X.edge(c[j]).append(y);
if ((p.descent(c[j])&p.descent(y)) != p.descent(y))
X.edge(y).append(c[j]);
}
}
return;
}
void rGraph(OrientedGraph& X, kl::KLContext& kl)
{
const SchubertContext& p = kl.schubert();
X.setSize(kl.size());
X.reset();
for (CoxNbr y = 0; y < kl.size(); ++y) {
const kl::MuRow& mu = kl.muList(y);
for (Ulong j = 0; j < mu.size(); ++j) {
if (mu[j].mu != 0) {
CoxNbr x = mu[j].x;
if (p.rdescent(x) != p.rdescent(y)) /* make an edge from x to y */
X.edge(x).append(y);
}
}
}
for (CoxNbr y = 0; y < kl.size(); ++y) {
const CoatomList& c = p.hasse(y);
for (Ulong j = 0; j < c.size(); ++j) {
if ((p.rdescent(c[j])&p.rdescent(y)) != p.rdescent(c[j]))
X.edge(c[j]).append(y);
if ((p.rdescent(c[j])&p.rdescent(y)) != p.rdescent(y))
X.edge(y).append(c[j]);
}
}
return;
}
void lWGraph(WGraph& X, kl::KLContext& kl)
/*
This function constructs a W-graph directly from the k-l data. In other
words, we construct a graph with vertex set the elements of p; for each
x < y s.t. mu(x,y) != 0, and L(x) != L(y), we set an edge from x to y
if L(y) \subset L(x), from y to x if L(x) \subset L(y); the coefficient
of this edge will be mu(x,y) in both cases.
Also, to each vertex is associated the descent set L(x).
Assumes that the mu-table has been filled.
NOTE : this should be changed when there will no longer be a mu-table
in the current sense.
*/
{
X.setSize(kl.size());
const SchubertContext& p = kl.schubert();
OrientedGraph& Y = X.graph();
// fill in Y
lGraph(Y,kl);
// fill in coefficients
for (CoxNbr y = 0; y < kl.size(); ++y) {
CoeffList& c = X.coeffList(y);
const EdgeList& e = X.edge(y);
c.setSize(e.size());
Length ly = p.length(y);
for (Ulong j = 0; j < c.size(); ++j) {
CoxNbr x = e[j];
Length lx = p.length(x);
if ((lx < ly) || (lx-ly) == 1)
c[j] = 1;
else
c[j] = kl.mu(y,x);
}
}
// fill in descent sets
for (CoxNbr y = 0; y < kl.size(); ++y)
X.descent(y) = p.ldescent(y);
return;
}
void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl)
/*
This function constructs the left W-graph for the subset q. It is
assumed that q is a union of left cells (typically, q might be a right
descent class, or one of the classes provided by GeneralizedTau).
The difference with the full lWGraph, is that we do _not_ assume that
the mu-coefficients have already been computed; we compute them as
needed.
It is assumed that q is sorted in increasing order.
*/
{
static List<Ulong> qr(0);
X.setSize(q.size());
const SchubertContext& p = kl.schubert();
OrientedGraph& Y = X.graph();
BitMap b(p.size());
Y.reset();
for (Ulong j = 0; j < q.size(); ++j) {
CoxNbr y = q[j];
Length ly = p.length(y);
// set descent set
X.descent(j) = p.ldescent(y);
p.extractClosure(b,y);
b &= q.bitMap();
qr.setSize(0);
// qr holds the relative positions within q of the elements <= y
for (Ulong i = 0; i < q.size(); ++i) {
if (b.getBit(q[i]))
qr.append(i);
}
for (Ulong i = 0; i < qr.size(); ++i) {
CoxNbr x = q[qr[i]];
Length lx = p.length(x);
if ((ly-lx)%2 == 0)
continue;
if ((ly-lx) == 1) { /* found a hasse edge */
if ((p.ldescent(x)&p.ldescent(y)) != p.ldescent(x)) {
Y.edge(qr[i]).append(j);
X.coeffList(qr[i]).append(1);
}
if ((p.ldescent(x)&p.ldescent(y)) != p.ldescent(y)) {
Y.edge(j).append(qr[i]);
X.coeffList(j).append(1);
}
continue;
}
KLCoeff mu = kl.mu(x,y);
if (mu != 0) {
if (p.ldescent(x) != p.ldescent(y)) {
Y.edge(qr[i]).append(j);
X.coeffList(qr[i]).append(mu);
}
}
}
}
return;
}
void lrWGraph(WGraph& X, kl::KLContext& kl)
/*
Like lWGraph, but for two-sided W-graphs.
*/
{
X.setSize(kl.size());
const SchubertContext& p = kl.schubert();
OrientedGraph& Y = X.graph();
// fill in Y
lrGraph(Y,kl);
// fill in coefficients
for (CoxNbr y = 0; y < kl.size(); ++y) {
CoeffList& c = X.coeffList(y);
const EdgeList& e = X.edge(y);
c.setSize(e.size());
Length ly = p.length(y);
for (Ulong j = 0; j < c.size(); ++j) {
CoxNbr x = e[j];
Length lx = p.length(x);
if ((lx < ly) || (lx-ly) == 1)
c[j] = 1;
else