-
Notifications
You must be signed in to change notification settings - Fork 5
/
klsupport.h
118 lines (98 loc) · 4.43 KB
/
klsupport.h
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
/*
This is klsupport.h
Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux
See file main.cpp for full copyright notice
*/
#ifndef KLSUPPORT_H /* guard against multiple inclusions */
#define KLSUPPORT_H
#include "globals.h"
#include "coxtypes.h"
#include "list.h"
#include "polynomials.h"
#include "schubert.h"
namespace klsupport {
using namespace coxeter;
using namespace coxtypes;
using namespace list;
using namespace polynomials;
using namespace schubert;
/******** type declarations **************************************************/
class KLSupport;
typedef unsigned short KLCoeff;
typedef short SKLCoeff;
typedef List<CoxNbr> ExtrRow;
/******** constants **********************************************************/
enum PolynomialType {KLPOL, UNEQ_KLPOL, INV_KLPOL, NUM_POLTYPES};
const KLCoeff KLCOEFF_MAX = USHRT_MAX-1; /* top value is reserved */
const KLCoeff undef_klcoeff = KLCOEFF_MAX + 1;
const KLCoeff KLCOEFF_MIN = 0;
const SKLCoeff SKLCOEFF_MIN = SHRT_MIN+1;
const SKLCoeff SKLCOEFF_MAX = -SKLCOEFF_MIN;
const SKLCoeff undef_sklcoeff = SKLCOEFF_MIN-1;
/******** function declarations **********************************************/
KLCoeff& safeAdd(KLCoeff& a, const KLCoeff& b);
SKLCoeff& safeAdd(SKLCoeff& a, const SKLCoeff& b);
KLCoeff& safeMultiply(KLCoeff& a, const KLCoeff& b);
SKLCoeff& safeMultiply(SKLCoeff& a, const SKLCoeff& b);
KLCoeff& safeSubtract(KLCoeff& a, const KLCoeff& b);
/******** type definitions ***************************************************/
class KLSupport {
private:
SchubertContext* d_schubert;
List<ExtrRow*> d_extrList;
List<CoxNbr> d_inverse;
List<Generator> d_last;
BitMap d_involution;
public:
List<ExtrRow*>& extrList() {return d_extrList;} // this should go
/* constructors and destructors */
void* operator new(size_t size) {return arena().alloc(size);}
void operator delete(void* ptr)
{return arena().free(ptr,sizeof(KLSupport));}
KLSupport(SchubertContext* p);
~KLSupport();
/* accessors */
const ExtrRow& extrList(const CoxNbr& y) const; /* inlined */
CoxNbr inverse(const CoxNbr& x) const; /* inlined */
CoxNbr inverseMin(const CoxNbr& x) const;
const BitMap& involution() const; /* inlined */
bool isExtrAllocated(const CoxNbr& x) const; /* inlined */
bool isInvolution(const CoxNbr& x) const; /* inlined */
Generator last(const CoxNbr& x) const; /* inlined */
Length length(const CoxNbr& x) const; /* inlined */
Rank rank() const; /* inlined */
const SchubertContext& schubert() const; /* inlined */
CoxNbr size() const; /* inlined */
void sortIRow(const CoxNbr& y, Permutation& a) const; /* inlined */
void standardPath(List<Generator>& g, const CoxNbr& x) const;
/* manipulators */
void allocExtrRow(const CoxNbr& y);
void allocRowComputation(const CoxNbr& y);
void applyInverse(const CoxNbr& y);
void applyIPermutation(const CoxNbr& y, const Permutation& a); /* inlined */
CoxNbr extendContext(const CoxWord& g);
void permute(const Permutation& a);
void revertSize(const Ulong& n);
SchubertContext& schubert(); /* inlined */
};
/******** inlined definitions ************************************************/
inline const ExtrRow& KLSupport::extrList(const CoxNbr& y) const
{return *d_extrList[y];}
inline CoxNbr KLSupport::inverse(const CoxNbr& x) const {return d_inverse[x];}
inline const BitMap& KLSupport::involution() const {return d_involution;}
inline bool KLSupport::isExtrAllocated(const CoxNbr& x) const
{return d_extrList[x] != 0;}
inline bool KLSupport::isInvolution(const CoxNbr& x) const
{return d_involution.getBit(x);}
inline Generator KLSupport::last(const CoxNbr& x) const {return d_last[x];}
inline Length KLSupport::length(const CoxNbr& x) const
{return d_schubert->length(x);}
inline Rank KLSupport::rank() const {return d_schubert->rank();}
inline CoxNbr KLSupport::size() const {return schubert().size();}
inline SchubertContext& KLSupport::schubert() {return *d_schubert;}
inline void KLSupport::applyIPermutation(const CoxNbr& y, const Permutation& a)
{rightRangePermute(*d_extrList[y],a);}
inline const SchubertContext& KLSupport::schubert() const
{return *d_schubert;}
}
#endif