From a132c731926911c4918dc4a13f75533623198fe9 Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Wed, 27 Dec 2023 18:57:13 -0800 Subject: [PATCH 1/6] stuff --- wgraph.cpp | 717 ++++++++++++++++++++++++++++------------------------- 1 file changed, 373 insertions(+), 344 deletions(-) diff --git a/wgraph.cpp b/wgraph.cpp index a3f4a0f..176d134 100644 --- a/wgraph.cpp +++ b/wgraph.cpp @@ -1,6 +1,6 @@ /* This is wgraph.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -31,12 +31,13 @@ ****************************************************************************/ -namespace { +namespace +{ using namespace wgraph; using namespace stack; - void getClass(const OrientedGraph& X, const Vertex& y, BitMap& b, - Partition& pi, OrientedGraph* P = 0); + void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, + Partition &pi, OrientedGraph *P = 0); }; @@ -44,7 +45,7 @@ namespace { Chapter I -- The WGraph class - Recall that a W-graph is an oriented graph, together with the datum of a + Recall that a W-graph is an oriented graph, together with the datum of a subset of the generating set S for each vertex, and a coefficient mu(x,y) for each edge, so that certain formulae (abstracted from the formulae that give the action of the standard generators of the Hecke algebra on @@ -84,103 +85,107 @@ namespace { ****************************************************************************/ -namespace wgraph { +namespace wgraph +{ -WGraph::WGraph(const Ulong& n):d_coeff(n),d_descent(n) + WGraph::WGraph(const Ulong &n) : d_coeff(n), d_descent(n) -/* - Constructor for the WGraph class. -*/ + /* + Constructor for the WGraph class. + */ -{ - d_graph = new OrientedGraph(n); -} + { + d_graph = new OrientedGraph(n); + } -WGraph::~WGraph() + WGraph::~WGraph() -/* - The only non-automatic part is the deletion of d_graph. -*/ + /* + The only non-automatic part is the deletion of d_graph. + */ -{ - delete d_graph; -} + { + delete d_graph; + } -void WGraph::reset() + void WGraph::reset() -/* - This function resets the structure to an empty graph of the same size. -*/ + /* + This function resets the structure to an empty graph of the same size. + */ -{ - d_graph->reset(); - d_coeff.setZero(); - d_descent.setZero(); + { + d_graph->reset(); + d_coeff.setZero(); + d_descent.setZero(); - return; -} + return; + } -void WGraph::setSize(const Ulong& n) + void WGraph::setSize(const Ulong &n) -/* - Sets the sizes of the data structures so that the graph can accomodate - n vertices. -*/ + /* + Sets the sizes of the data structures so that the graph can accomodate + n vertices. + */ -{ - d_graph->setSize(n); - d_coeff.setSize(n); - d_descent.setSize(n); + { + d_graph->setSize(n); + d_coeff.setSize(n); + d_descent.setSize(n); - return; -} + return; + } -void WGraph::print(FILE* file, const Interface& I) const + void WGraph::print(FILE *file, const Interface &I) const -/* - Prints the graph on a file in ascii format. -*/ + /* + Prints the graph on a file in ascii format. + */ -{ - const OrientedGraph& Y = *d_graph; + { + const OrientedGraph &Y = *d_graph; - int d = digits(size()-1,10); + int d = digits(size() - 1, 10); - /* count number of edges */ + /* count number of edges */ - Ulong count = 0; + Ulong count = 0; - for (Vertex x = 0; x < size(); ++x) { - const EdgeList& e = Y.edge(x); - count += e.size(); - } + for (Vertex x = 0; x < size(); ++x) + { + const EdgeList &e = Y.edge(x); + count += e.size(); + } - // find alignement - - String str(0); - LFlags f = leqmask[I.rank()-1]; - interface::append(str,f,I); - Ulong descent_maxwidth = str.length(); - - fprintf(file,"%lu vertices, %lu edges\n\n",size(),count); - - for (Vertex x = 0; x < size(); ++x) { - fprintf(file,"%*lu : ",d,x); - io::reset(str); - interface::append(str,descent(x),I); - pad(str,descent_maxwidth ); - io::print(file,str); - fprintf(file," "); - const EdgeList e = Y.edge(x); - const CoeffList c = coeffList(x); - for (Ulong j = 0; j < e.size(); ++j) { - fprintf(file,"%lu(%lu)",e[j],static_cast(c[j])); - if (j+1 < e.size()) /* there is more to come */ - fprintf(file,","); + // find alignement + + String str(0); + LFlags f = leqmask[I.rank() - 1]; + interface::append(str, f, I); + Ulong descent_maxwidth = str.length(); + + fprintf(file, "%lu vertices, %lu edges\n\n", size(), count); + + for (Vertex x = 0; x < size(); ++x) + { + fprintf(file, "%*lu : ", d, x); + io::reset(str); + interface::append(str, descent(x), I); + pad(str, descent_maxwidth); + io::print(file, str); + fprintf(file, " "); + const EdgeList e = Y.edge(x); + const CoeffList c = coeffList(x); + for (Ulong j = 0; j < e.size(); ++j) + { + fprintf(file, "%lu(%lu)", e[j], static_cast(c[j])); + if (j + 1 < e.size()) /* there is more to come */ + fprintf(file, ","); + } + fprintf(file, "\n"); } - fprintf(file,"\n"); } -} }; @@ -209,9 +214,9 @@ void WGraph::print(FILE* file, const Interface& I) const - normalPermuation(a) : gives the permutation to a normalized form; - print() : prints out the graph; - - modifiers : + - modifiers : - - edge(x) : returns a non-copnstant reference to the list of edges + - edge(x) : returns a non-copnstant reference to the list of edges originating from x (inlined); - permute(a) : permutes the graph according to a; - reset() : resets the structure; @@ -220,266 +225,283 @@ void WGraph::print(FILE* file, const Interface& I) const ****************************************************************************/ -namespace wgraph { - -OrientedGraph::~OrientedGraph() - -/* - Destruction is automatic. -*/ +namespace wgraph +{ -{} + OrientedGraph::~OrientedGraph() -void OrientedGraph::cells(Partition& pi, OrientedGraph* P) const + /* + Destruction is automatic. + */ -/* - Define a preorder relation on the vertices by setting x <= y iff there is an - oriented path from x to y. This function puts in pi the partition function - corresponding to the equivalence classes of this preorder. We use the - Tarjan algorithm, explained in one of the Knuth books, but which I learned - from Bill Casselman. - - The vertices for which the partition function is already defined will - be said to be dealt with. These are marked off in an auxiliary bitmap. - The algorithm goes as follows. Start with the first vertex that has not - been dealt with, say x0. We will have to deal (potentially) with the set - of all vertices visible from x0 (i.e >= x0). There will be a stack of - vertices, corresponding to a path originating from x0, such that at each - point in time, each vertex y >= x0 which is not dealt with will be - equivalent to an element of the stack; the least such (in the stack - ordering) will be called y_min, so that for instance x0_min = 0. We - record these values in an additional table, initialized to some value - undefined. - - Now let x be at the top of the stack. Look at the edges originating from - x. Ignore the ones that go to vertices which are dealt with. If there - are no edges left, x is minimal and is a class by itself; we can take - it off, mark it as dealt with, and continue. Otherwise, run through the - edges one by one. Let the edge be x->y. If y_min is defined, this means - that y has already been examined, and is not dealt with. But each such - element is equivalent to an element in the active stack, so y_min should - be one of the elements in the active stack, hence x is visible from y_min: - in other words, x and y are equivalent, and we set x_min = y_min if - y_min < x_min. Otherwise, y is seen for the first time; then we just put - it on the stack. When we are done with the edges of x, we have now the - value of x_min which is the inf over the edges originating from x of - the y_min. If this value is equal to the stack-position of x, we see that x - is minimal in its class, and we get a new class by taking all the successors - of x not already dealt with. We then move to the parent of x and continue - the process there. -*/ + { + } -{ - static Permutation a(0); - static BitMap b(0); - static List v(1); - static List elist(1); - static List ecount(1); - static List min(0); - - pi.setSize(size()); - pi.setClassCount(0); - - b.setSize(size()); - b.reset(); - min.setSize(size()); - min.setZero(); - - for (Vertex x = 0; x < size(); ++x) - min[x] = size(); - - for (Vertex x = 0; x < size(); ++x) { - - if (b.getBit(x)) /* x is dealt with */ - continue; - - v[0] = x; - v.setSize(1); - elist[0] = &edge(x); - elist.setSize(1); - ecount[0] = 0; - ecount.setSize(1); - min[x] = 0; - Ulong t = 1; - - while(t) { - Vertex y = v[t-1]; - Vertex z; - const EdgeList& e = *elist[t-1]; - for (; ecount[t-1] < e.size(); ++ecount[t-1]) { - z = e[ecount[t-1]]; - if (b.getBit(z)) - continue; - if (min[z] == size()) /* z is new */ - goto add_path; - if (min[y] > min[z]) - min[y] = min[z]; + void OrientedGraph::cells(Partition &pi, OrientedGraph *P) const + + /* + Define a preorder relation on the vertices by setting x <= y iff there is an + oriented path from x to y. This function puts in pi the partition function + corresponding to the equivalence classes of this preorder. We use the + Tarjan algorithm, explained in one of the Knuth books, but which I learned + from Bill Casselman. + + The vertices for which the partition function is already defined will + be said to be dealt with. These are marked off in an auxiliary bitmap. + The algorithm goes as follows. Start with the first vertex that has not + been dealt with, say x0. We will have to deal (potentially) with the set + of all vertices visible from x0 (i.e >= x0). There will be a stack of + vertices, corresponding to a path originating from x0, such that at each + point in time, each vertex y >= x0 which is not dealt with will be + equivalent to an element of the stack; the least such (in the stack + ordering) will be called y_min, so that for instance x0_min = 0. We + record these values in an additional table, initialized to some value + undefined. + + Now let x be at the top of the stack. Look at the edges originating from + x. Ignore the ones that go to vertices which are dealt with. If there + are no edges left, x is minimal and is a class by itself; we can take + it off, mark it as dealt with, and continue. Otherwise, run through the + edges one by one. Let the edge be x->y. If y_min is defined, this means + that y has already been examined, and is not dealt with. But each such + element is equivalent to an element in the active stack, so y_min should + be one of the elements in the active stack, hence x is visible from y_min: + in other words, x and y are equivalent, and we set x_min = y_min if + y_min < x_min. Otherwise, y is seen for the first time; then we just put + it on the stack. When we are done with the edges of x, we have now the + value of x_min which is the inf over the edges originating from x of + the y_min. If this value is equal to the stack-position of x, we see that x + is minimal in its class, and we get a new class by taking all the successors + of x not already dealt with. We then move to the parent of x and continue + the process there. + */ + + { + static Permutation a(0); + static BitMap b(0); + static List v(1); + static List elist(1); + static List ecount(1); + static List min(0); + + pi.setSize(size()); + pi.setClassCount(0); + + b.setSize(size()); + b.reset(); + min.setSize(size()); + min.setZero(); + + for (Vertex x = 0; x < size(); ++x) + min[x] = size(); + + for (Vertex x = 0; x < size(); ++x) + { + + if (b.getBit(x)) /* x is dealt with */ + continue; + + v[0] = x; + v.setSize(1); + elist[0] = &edge(x); + elist.setSize(1); + ecount[0] = 0; + ecount.setSize(1); + min[x] = 0; + Ulong t = 1; + + while (t) + { + Vertex y = v[t - 1]; + Vertex z; + const EdgeList &e = *elist[t - 1]; + for (; ecount[t - 1] < e.size(); ++ecount[t - 1]) + { + z = e[ecount[t - 1]]; + if (b.getBit(z)) + continue; + if (min[z] == size()) /* z is new */ + goto add_path; + if (min[y] > min[z]) + min[y] = min[z]; + } + /* at this point we have exhausted the edges of y */ + if (min[y] == t - 1) + { /* take off class */ + getClass(*this, y, b, pi, P); + } + else if (min[y] < min[v[t - 2]]) /* if t=1, previous case holds */ + min[v[t - 2]] = min[y]; + t--; + continue; + add_path: + v.setSize(t + 1); + elist.setSize(t + 1); + ecount.setSize(t + 1); + v[t] = z; + elist[t] = &edge(z); + ecount[t] = 0; + min[z] = t; + t++; } - /* at this point we have exhausted the edges of y */ - if (min[y] == t-1) { /* take off class */ - getClass(*this,y,b,pi,P); - } - else if (min[y] < min[v[t-2]]) /* if t=1, previous case holds */ - min[v[t-2]] = min[y]; - t--; - continue; - add_path: - v.setSize(t+1); - elist.setSize(t+1); - ecount.setSize(t+1); - v[t] = z; - elist[t] = &edge(z); - ecount[t] = 0; - min[z] = t; - t++; } + return; } - return; -} - -void OrientedGraph::levelPartition(Partition& pi) const - -/* - Assuming the graph has no oriented cycles, this function writes in pi the - partition of the vertices according to their level, where sinks have level - 0, then sinks in the remaining poset have level one, etc. - - NOTE : the implementation is simple-minded : we traverse the graph as many - times as there are levels. -*/ - -{ - static BitMap b(0); - static BitMap b1(0); - - b.setSize(size()); - b.reset(); - b1.setSize(size()); - b1.reset(); - pi.setSize(size()); - Ulong count = 0; - Ulong current_level = 0; - - while (count < size()) { - for (SetElt x = 0; x < size(); ++x) { - if (b.getBit(x)) - continue; - const EdgeList e = d_edge[x]; - for (Ulong j = 0; j < e.size(); ++j) { - if (!b.getBit(e[j])) /* next x */ - goto nextx; + void OrientedGraph::levelPartition(Partition &pi) const + + /* + Assuming the graph has no oriented cycles, this function writes in pi the + partition of the vertices according to their level, where sinks have level + 0, then sinks in the remaining poset have level one, etc. + + NOTE : the implementation is simple-minded : we traverse the graph as many + times as there are levels. + */ + + { + static BitMap b(0); + static BitMap b1(0); + + b.setSize(size()); + b.reset(); + b1.setSize(size()); + b1.reset(); + pi.setSize(size()); + Ulong count = 0; + Ulong current_level = 0; + + while (count < size()) + { + for (SetElt x = 0; x < size(); ++x) + { + if (b.getBit(x)) + continue; + const EdgeList e = d_edge[x]; + for (Ulong j = 0; j < e.size(); ++j) + { + if (!b.getBit(e[j])) /* next x */ + goto nextx; + } + /* i we get here, x is the next element in the permutation */ + pi[x] = current_level; + b1.setBit(x); + ++count; + nextx: + continue; } - /* i we get here, x is the next element in the permutation */ - pi[x] = current_level; - b1.setBit(x); - ++count; - nextx: - continue; + b.assign(b1); + current_level++; } - b.assign(b1); - current_level++; - } - pi.setClassCount(current_level); - return; -} + pi.setClassCount(current_level); + return; + } -void OrientedGraph::permute(const Permutation& a) + void OrientedGraph::permute(const Permutation &a) -/* - This function permutes the graph according to the permutation a, according - to the usual rule : the edges of a(x) should be the image under a of the - edge set of x. + /* + This function permutes the graph according to the permutation a, according + to the usual rule : the edges of a(x) should be the image under a of the + edge set of x. - As usual, permuting values is easy : it is enough to apply a to the - elements in the various edgelists. Permuting ranges is trickier, because - it involves a^-1. + As usual, permuting values is easy : it is enough to apply a to the + elements in the various edgelists. Permuting ranges is trickier, because + it involves a^-1. - It is assumed of course that a holds a permutation of size size(). -*/ + It is assumed of course that a holds a permutation of size size(). + */ -{ - static BitMap b(0); - static EdgeList e_buf(0); + { + static BitMap b(0); + static EdgeList e_buf(0); - /* permute values */ + /* permute values */ - for (SetElt x = 0; x < size(); ++x) { - EdgeList& e = d_edge[x]; - for (Ulong j = 0; j < e.size(); ++j) { - e[j] = a[e[j]]; + for (SetElt x = 0; x < size(); ++x) + { + EdgeList &e = d_edge[x]; + for (Ulong j = 0; j < e.size(); ++j) + { + e[j] = a[e[j]]; + } } - } - /* permute ranges */ + /* permute ranges */ - b.setSize(size()); - b.reset(); + b.setSize(size()); + b.reset(); - for (SetElt x = 0; x < size(); ++x) { - if (b.getBit(x)) - continue; - if (a[x] == x) { /* fixed point */ + for (SetElt x = 0; x < size(); ++x) + { + if (b.getBit(x)) + continue; + if (a[x] == x) + { /* fixed point */ + b.setBit(x); + continue; + } + for (SetElt y = a[x]; y != x; y = a[y]) + { + /* back up values for y */ + e_buf.shallowCopy(d_edge[y]); + /* put values for x in y */ + d_edge[y].shallowCopy(d_edge[x]); + /* store backup values in x */ + d_edge[x].shallowCopy(e_buf); + /* set bit */ + b.setBit(y); + } b.setBit(x); - continue; - } - for (SetElt y = a[x]; y != x; y = a[y]) { - /* back up values for y */ - e_buf.shallowCopy(d_edge[y]); - /* put values for x in y */ - d_edge[y].shallowCopy(d_edge[x]); - /* store backup values in x */ - d_edge[x].shallowCopy(e_buf); - /* set bit */ - b.setBit(y); } - b.setBit(x); } -} -void OrientedGraph::print(FILE* file) const + void OrientedGraph::print(FILE *file) const -/* - Does a printout of the graph on the file. -*/ + /* + Does a printout of the graph on the file. + */ -{ - fprintf(file,"size : %lu\n\n",size()); + { + fprintf(file, "size : %lu\n\n", size()); - int d = digits(size(),10); + int d = digits(size(), 10); - for (Vertex x = 0; x < size(); ++x) { - const EdgeList& e = edge(x); - fprintf(file,"%*lu : ",d,x); - for (Ulong j = 0; j < e.size(); ++j) { - fprintf(file,"%*lu",d,e[j]); - if (j < e.size()-1) { /* there is more to come */ - fprintf(file,","); + for (Vertex x = 0; x < size(); ++x) + { + const EdgeList &e = edge(x); + fprintf(file, "%*lu : ", d, x); + for (Ulong j = 0; j < e.size(); ++j) + { + fprintf(file, "%*lu", d, e[j]); + if (j < e.size() - 1) + { /* there is more to come */ + fprintf(file, ","); + } } + fprintf(file, "\n"); } - fprintf(file,"\n"); - } - fprintf(file,"\n"); + fprintf(file, "\n"); - return; -} + return; + } -void OrientedGraph::reset() + void OrientedGraph::reset() -/* - Resets the structure to hold a edge-less graph of the same size. -*/ + /* + Resets the structure to hold a edge-less graph of the same size. + */ -{ - for (Ulong j = 0; j < size(); ++j) { - d_edge[j].setSize(0); - } + { + for (Ulong j = 0; j < size(); ++j) + { + d_edge[j].setSize(0); + } - return; -} + return; + } }; @@ -494,53 +516,60 @@ void OrientedGraph::reset() ****************************************************************************/ -namespace { - -void getClass(const OrientedGraph& X, const Vertex& y, BitMap& b, - Partition& pi, OrientedGraph* P) - -/* - After the element y has been identified as minimal among the elements not - already marked in b, this function marks off the equivalence class of y; - these are just the elements visible from y and not already marked in b. - The class is also written as a new class in pi. -*/ - +namespace { - static Fifo c; - - Ulong a = pi.classCount(); - c.push(y); - b.setBit(y); - pi[y] = a; - if (P) - P->setSize(a+1); - - while (c.size()) { - Vertex x = c.pop(); - const EdgeList& e = X.edge(x); - for (Ulong j = 0; j < e.size(); ++j) { - Vertex z = e[j]; - if (b.getBit(z)) { - if (P && (pi[z] < a)) { /* add a new edge to P */ - EdgeList& f = P->edge(a); - if (find(f,pi[z]) == not_found) { /* edge is new */ - insert(f,pi[z]); - } - } - continue; - } - else { - c.push(z); - b.setBit(z); - pi[z] = a; + + void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, + Partition &pi, OrientedGraph *P) + + /* + After the element y has been identified as minimal among the elements not + already marked in b, this function marks off the equivalence class of y; + these are just the elements visible from y and not already marked in b. + The class is also written as a new class in pi. + */ + + { + static Fifo c; + + Ulong a = pi.classCount(); + c.push(y); + b.setBit(y); + pi[y] = a; + if (P) + P->setSize(a + 1); + + while (c.size()) + { + Vertex x = c.pop(); + const EdgeList &e = X.edge(x); + for (Ulong j = 0; j < e.size(); ++j) + { + Vertex z = e[j]; + if (b.getBit(z)) + { + if (P && (pi[z] < a)) + { /* add a new edge to P */ + EdgeList &f = P->edge(a); + if (find(f, pi[z]) == not_found) + { /* edge is new */ + insert(f, pi[z]); + } + } + continue; + } + else + { + c.push(z); + b.setBit(z); + pi[z] = a; + } } } - } - pi.setClassCount(a+1); + pi.setClassCount(a + 1); - return; -} + return; + } }; From a49a20892f067b705ee42916290a9876e1da7358 Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Thu, 28 Dec 2023 11:03:38 -0800 Subject: [PATCH 2/6] gitignore --- .gitignore | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..259148f --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app From cf33c04ed3244b04da4972f2e8be08584254b99f Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Thu, 28 Dec 2023 11:05:37 -0800 Subject: [PATCH 3/6] updated to c++20 --- makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 747361c..d648ccf 100644 --- a/makefile +++ b/makefile @@ -7,9 +7,11 @@ dependencies := $(patsubst %.cpp,%.d,$(wildcard *.cpp)) globals = globals.h -pflags = -c $(includedirs) -pg -O -oflags = -c $(includedirs) -O -Wall -gflags = -c $(includedirs) -g +flags = -std=c++20 + +pflags = -c $(includedirs) -pg -O $(flags) +oflags = -c $(includedirs) -O -Wall $(flags) +gflags = -c $(includedirs) -g $(flags) cflags = $(gflags) # the default setting From 78095abbe27da4b6a9ba4416a02c49901a8208ba Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Thu, 28 Dec 2023 11:09:02 -0800 Subject: [PATCH 4/6] format --- .clang-format | 1 + affine.cpp | 62 +- affine.h | 125 +-- automata.cpp | 22 +- automata.h | 83 +- bits.cpp | 251 +++--- bits.h | 495 ++++++------ cells.cpp | 715 +++++++++-------- cells.h | 64 +- commands.cpp | 1561 ++++++++++++++++++------------------ commands.h | 111 +-- constants.cpp | 44 +- constants.h | 24 +- coxgroup.cpp | 235 +++--- coxgroup.h | 554 +++++++------ coxtypes.cpp | 75 +- coxtypes.h | 147 ++-- dictionary.h | 68 +- dictionary.hpp | 167 ++-- directories.h | 12 +- dotval.h | 36 +- error.cpp | 955 +++++++++++------------ error.h | 128 +-- fcoxgroup.cpp | 569 +++++++------- fcoxgroup.h | 321 ++++---- files.cpp | 1011 +++++++++--------------- files.h | 365 ++++----- files.hpp | 769 +++++++++--------- general.cpp | 34 +- general.h | 125 +-- globals.h | 4 +- graph.cpp | 1857 +++++++++++++++++++++---------------------- graph.h | 113 +-- hecke.h | 143 ++-- hecke.hpp | 214 +++-- help.cpp | 241 +++--- help.h | 212 ++--- interactive.cpp | 898 +++++++++++---------- interactive.h | 73 +- interface.cpp | 1088 +++++++++++++------------- interface.h | 439 ++++++----- invkl.cpp | 706 +++++++++-------- invkl.h | 250 +++--- io.cpp | 198 +++-- io.h | 129 +-- iterator.h | 36 +- kl.cpp | 1995 +++++++++++++++++++++++------------------------ kl.h | 320 ++++---- klsupport.cpp | 169 ++-- klsupport.h | 157 ++-- list.h | 184 ++--- list.hpp | 205 ++--- main.cpp | 20 +- makefile | 3 + memory.cpp | 116 ++- memory.h | 56 +- minroots.cpp | 1452 +++++++++++++++++----------------- minroots.h | 138 ++-- polynomials.h | 422 +++++----- polynomials.hpp | 430 +++++----- posets.cpp | 49 +- posets.h | 46 +- schubert.cpp | 742 +++++++++--------- schubert.h | 542 +++++++------ search.h | 75 +- search.hpp | 55 +- special.cpp | 29 +- special.h | 8 +- stack.h | 80 +- stack.hpp | 46 +- transducer.cpp | 308 ++++---- transducer.h | 193 ++--- type.cpp | 29 +- type.h | 51 +- typeA.cpp | 135 ++-- typeA.h | 310 ++++---- uneqkl.cpp | 757 +++++++++--------- uneqkl.h | 256 +++--- vector.h | 167 ++-- vector.hpp | 28 +- version.h | 10 +- wgraph.cpp | 711 ++++++++--------- wgraph.h | 152 ++-- 83 files changed, 12947 insertions(+), 13229 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..1ef6b4f --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +SortIncludes: Never \ No newline at end of file diff --git a/affine.cpp b/affine.cpp index c53737d..16df5f9 100644 --- a/affine.cpp +++ b/affine.cpp @@ -26,9 +26,9 @@ /* local variables */ namespace affine { - using namespace error; - using namespace graph; - using namespace minroots; +using namespace error; +using namespace graph; +using namespace minroots; /**************************************************************************** @@ -50,37 +50,30 @@ namespace affine { ****************************************************************************/ -AffineCoxGroup::AffineCoxGroup(const Type& x, const Rank& l):CoxGroup(x,l) -{} +AffineCoxGroup::AffineCoxGroup(const Type &x, const Rank &l) : CoxGroup(x, l) {} /** Virtual destructor for the AffineCoxGroup class. Currently, nothing has to be done. */ -AffineCoxGroup::~AffineCoxGroup() -{} +AffineCoxGroup::~AffineCoxGroup() {} -AffineBigRankCoxGroup::AffineBigRankCoxGroup(const Type& x, const Rank& l) - : AffineCoxGroup(x,l) -{} +AffineBigRankCoxGroup::AffineBigRankCoxGroup(const Type &x, const Rank &l) + : AffineCoxGroup(x, l) {} /** Virtual destructor for the AffineBigRankCoxGroup class. Currently, nothing has to be done. */ -AffineBigRankCoxGroup::~AffineBigRankCoxGroup() -{} +AffineBigRankCoxGroup::~AffineBigRankCoxGroup() {} -GeneralABRCoxGroup::GeneralABRCoxGroup(const Type& x, const Rank& l) - :AffineBigRankCoxGroup(x,l) -{} +GeneralABRCoxGroup::GeneralABRCoxGroup(const Type &x, const Rank &l) + : AffineBigRankCoxGroup(x, l) {} -GeneralABRCoxGroup::~GeneralABRCoxGroup() -{} +GeneralABRCoxGroup::~GeneralABRCoxGroup() {} -AffineMedRankCoxGroup::AffineMedRankCoxGroup(const Type& x, const Rank& l) - :AffineCoxGroup(x,l) -{ +AffineMedRankCoxGroup::AffineMedRankCoxGroup(const Type &x, const Rank &l) + : AffineCoxGroup(x, l) { mintable().fill(graph()); /* an error is set here in case of failure */ } @@ -89,40 +82,33 @@ AffineMedRankCoxGroup::AffineMedRankCoxGroup(const Type& x, const Rank& l) Virtual destructor for the AffineMedRankCoxGroup class. The destruction of the mintable should be the job of the CoxGroup destructor. */ -AffineMedRankCoxGroup::~AffineMedRankCoxGroup() -{} +AffineMedRankCoxGroup::~AffineMedRankCoxGroup() {} -GeneralAMRCoxGroup::GeneralAMRCoxGroup(const Type& x, const Rank& l) - :AffineMedRankCoxGroup(x,l) -{} +GeneralAMRCoxGroup::GeneralAMRCoxGroup(const Type &x, const Rank &l) + : AffineMedRankCoxGroup(x, l) {} /** Virtual destructor for the GeneralAMRCoxGroup class. Currently, nothing has to be done. */ -GeneralAMRCoxGroup::~GeneralAMRCoxGroup() -{} +GeneralAMRCoxGroup::~GeneralAMRCoxGroup() {} -AffineSmallRankCoxGroup::AffineSmallRankCoxGroup(const Type& x, const Rank& l) - :AffineMedRankCoxGroup(x,l) -{} +AffineSmallRankCoxGroup::AffineSmallRankCoxGroup(const Type &x, const Rank &l) + : AffineMedRankCoxGroup(x, l) {} /** Virtual destructor for the AffineSmallRankCoxGroup class. Currently, nothing has to be done. */ -AffineSmallRankCoxGroup::~AffineSmallRankCoxGroup() -{} +AffineSmallRankCoxGroup::~AffineSmallRankCoxGroup() {} -GeneralASRCoxGroup::GeneralASRCoxGroup(const Type& x, const Rank& l) - :AffineSmallRankCoxGroup(x,l) -{} +GeneralASRCoxGroup::GeneralASRCoxGroup(const Type &x, const Rank &l) + : AffineSmallRankCoxGroup(x, l) {} /** Virtual destructor for the GeneralASRCoxGroup class. Currently, nothing has to be done. */ -GeneralASRCoxGroup::~GeneralASRCoxGroup() -{} +GeneralASRCoxGroup::~GeneralASRCoxGroup() {} -} +} // namespace affine diff --git a/affine.h b/affine.h index 95ef24f..43fc3e9 100644 --- a/affine.h +++ b/affine.h @@ -5,96 +5,103 @@ See file main.cpp for full copyright notice */ -#ifndef AFFINE_H /* guarantee single inclusion */ +#ifndef AFFINE_H /* guarantee single inclusion */ #define AFFINE_H #include "globals.h" #include "coxgroup.h" namespace affine { - using namespace coxeter; +using namespace coxeter; //******** type declarations ************************************************* - class AffineCoxGroup; - class AffineBigRankCoxGroup; - class GeneralABRCoxGroup; - class AffineMedRankCoxGroup; - class GeneralAMRCoxGroup; - class AffineSmallRankCoxGroup; - class GeneralASRCoxGroup; +class AffineCoxGroup; +class AffineBigRankCoxGroup; +class GeneralABRCoxGroup; +class AffineMedRankCoxGroup; +class GeneralAMRCoxGroup; +class AffineSmallRankCoxGroup; +class GeneralASRCoxGroup; //******** type definitions ************************************************** class AffineCoxGroup : public CoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(AffineCoxGroup));} - - AffineCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(AffineCoxGroup)); + } + + AffineCoxGroup(const Type &x, const Rank &l); virtual ~AffineCoxGroup(); -/* accessors */ - CoxSize order() const; /* inlined */ + /* accessors */ + CoxSize order() const; /* inlined */ }; class AffineBigRankCoxGroup : public AffineCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(AffineBigRankCoxGroup));} - AffineBigRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(AffineBigRankCoxGroup)); + } + AffineBigRankCoxGroup(const Type &x, const Rank &l); virtual ~AffineBigRankCoxGroup(); }; -class GeneralABRCoxGroup:public AffineBigRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralABRCoxGroup));} - GeneralABRCoxGroup(const Type& x, const Rank& l); +class GeneralABRCoxGroup : public AffineBigRankCoxGroup { +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralABRCoxGroup)); + } + GeneralABRCoxGroup(const Type &x, const Rank &l); ~GeneralABRCoxGroup(); }; class AffineMedRankCoxGroup : public AffineCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(AffineMedRankCoxGroup));} - AffineMedRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(AffineMedRankCoxGroup)); + } + AffineMedRankCoxGroup(const Type &x, const Rank &l); virtual ~AffineMedRankCoxGroup(); }; -class GeneralAMRCoxGroup:public AffineMedRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralAMRCoxGroup));} - GeneralAMRCoxGroup(const Type& x, const Rank& l); +class GeneralAMRCoxGroup : public AffineMedRankCoxGroup { +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralAMRCoxGroup)); + } + GeneralAMRCoxGroup(const Type &x, const Rank &l); ~GeneralAMRCoxGroup(); }; class AffineSmallRankCoxGroup : public AffineMedRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(AffineSmallRankCoxGroup));} - AffineSmallRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(AffineSmallRankCoxGroup)); + } + AffineSmallRankCoxGroup(const Type &x, const Rank &l); virtual ~AffineSmallRankCoxGroup(); }; -class GeneralASRCoxGroup:public AffineSmallRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralASRCoxGroup));} - GeneralASRCoxGroup(const Type& x, const Rank& l); +class GeneralASRCoxGroup : public AffineSmallRankCoxGroup { +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralASRCoxGroup)); + } + GeneralASRCoxGroup(const Type &x, const Rank &l); ~GeneralASRCoxGroup(); }; @@ -103,7 +110,7 @@ class GeneralASRCoxGroup:public AffineSmallRankCoxGroup { /** Return the order of this Coxeter group, which is infinite. */ -inline CoxSize AffineCoxGroup::order() const {return infinite_coxsize;} -} +inline CoxSize AffineCoxGroup::order() const { return infinite_coxsize; } +} // namespace affine #endif diff --git a/automata.cpp b/automata.cpp index 655c2f2..683742a 100644 --- a/automata.cpp +++ b/automata.cpp @@ -1,6 +1,6 @@ /* This is automata.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -10,7 +10,7 @@ #include "memory.h" namespace automata { - using namespace memory; +using namespace memory; }; /**************************************************************************** @@ -44,28 +44,28 @@ namespace automata { namespace automata { ExplicitAutomaton::ExplicitAutomaton(Ulong n, Ulong m) - :d_accept(n),d_rank(m),d_size(n) + : d_accept(n), d_rank(m), d_size(n) { - d_table = (State **)arena().alloc(d_size*sizeof(Ulong *)); - d_table[0] = (State *)arena().alloc(d_size*d_rank*sizeof(Ulong)); + d_table = (State **)arena().alloc(d_size * sizeof(Ulong *)); + d_table[0] = (State *)arena().alloc(d_size * d_rank * sizeof(Ulong)); for (Ulong j = 1; j < d_size; ++j) - d_table[j] = d_table[j-1] + d_rank; + d_table[j] = d_table[j - 1] + d_rank; } ExplicitAutomaton::~ExplicitAutomaton() /* The memory allocated directly by ExplicitAutomaton is the one for - the table, and for the pointers to the rows. Recall that the number of - states is recorded in d_size, the number of letters in the alphabet in + the table, and for the pointers to the rows. Recall that the number of + states is recorded in d_size, the number of letters in the alphabet in d_rank. Hence we have the size of our allocation. */ { - arena().free(d_table[0],d_size*d_rank*sizeof(Ulong)); - arena().free(d_table,d_size*sizeof(Ulong *)); + arena().free(d_table[0], d_size * d_rank * sizeof(Ulong)); + arena().free(d_table, d_size * sizeof(Ulong *)); } -}; +}; // namespace automata diff --git a/automata.h b/automata.h index b4a67c7..c12773f 100644 --- a/automata.h +++ b/automata.h @@ -5,27 +5,27 @@ See file main.cpp for full copyright notice */ -#ifndef AUTOMATA_H /* guard against multiple inclusions */ +#ifndef AUTOMATA_H /* guard against multiple inclusions */ #define AUTOMATA_H #include "globals.h" #include "bits.h" namespace automata { - using namespace coxeter; +using namespace coxeter; /******** type declarations **************************************************/ - class Automaton; - class ExplicitAutomaton; - typedef unsigned Letter; - typedef unsigned State; +class Automaton; +class ExplicitAutomaton; +typedef unsigned Letter; +typedef unsigned State; /******** type definitions ***************************************************/ class Automaton { - public: -/* accessors */ +public: + /* accessors */ virtual State act(State x, Letter a) const = 0; virtual State initialState() const = 0; virtual bool isAccept(State x) const = 0; @@ -34,50 +34,55 @@ class Automaton { virtual Ulong size() const = 0; }; -class ExplicitAutomaton:public Automaton { - private: +class ExplicitAutomaton : public Automaton { +private: State **d_table; bits::BitMap d_accept; State d_failure; State d_initial; Ulong d_rank; Ulong d_size; - public: -/* constructors and destructors */ + +public: + /* constructors and destructors */ ExplicitAutomaton(Ulong n, Ulong m); virtual ~ExplicitAutomaton(); -/* manipulators */ - void setAccept(State x); /* inlined */ - void setFailure(State x); /* inlined */ - void setInitial(State x); /* inlined */ - void setTable(State x, Letter a, State xa); /* inlined */ -/* accessors */ - State act(State x, Letter a) const; /* inlined */ - State initialState() const; /* inlined */ - bool isAccept(State x) const; /* inlined */ - bool isFailure(State x) const; /* inlined */ - Ulong rank() const; /* inlined */ - Ulong size() const; /* inlined */ + /* manipulators */ + void setAccept(State x); /* inlined */ + void setFailure(State x); /* inlined */ + void setInitial(State x); /* inlined */ + void setTable(State x, Letter a, State xa); /* inlined */ + /* accessors */ + State act(State x, Letter a) const; /* inlined */ + State initialState() const; /* inlined */ + bool isAccept(State x) const; /* inlined */ + bool isFailure(State x) const; /* inlined */ + Ulong rank() const; /* inlined */ + Ulong size() const; /* inlined */ }; /******** inline implementations ******************************************/ - inline void ExplicitAutomaton::setAccept(State x) {d_accept.setBit(x);} - inline void ExplicitAutomaton::setFailure(State x) {d_failure = x;} - inline void ExplicitAutomaton::setInitial(State x) {d_initial = x;} - inline void ExplicitAutomaton::setTable(State x, Letter a, State xa) - {d_table[x][a] = xa;} - - inline State ExplicitAutomaton::act(State x, Letter a) const - {return d_table[x][a];} - inline State ExplicitAutomaton::initialState() const {return d_initial;} - inline bool ExplicitAutomaton::isAccept(State x) const - {return d_accept.getBit(x);} - inline bool ExplicitAutomaton::isFailure(State x) const - {return x == d_failure;} - inline Ulong ExplicitAutomaton::rank() const {return d_rank;} - inline Ulong ExplicitAutomaton::size() const {return d_size;} +inline void ExplicitAutomaton::setAccept(State x) { d_accept.setBit(x); } +inline void ExplicitAutomaton::setFailure(State x) { d_failure = x; } +inline void ExplicitAutomaton::setInitial(State x) { d_initial = x; } +inline void ExplicitAutomaton::setTable(State x, Letter a, State xa) { + d_table[x][a] = xa; +} +inline State ExplicitAutomaton::act(State x, Letter a) const { + return d_table[x][a]; } +inline State ExplicitAutomaton::initialState() const { return d_initial; } +inline bool ExplicitAutomaton::isAccept(State x) const { + return d_accept.getBit(x); +} +inline bool ExplicitAutomaton::isFailure(State x) const { + return x == d_failure; +} +inline Ulong ExplicitAutomaton::rank() const { return d_rank; } +inline Ulong ExplicitAutomaton::size() const { return d_size; } + +} // namespace automata #endif diff --git a/bits.cpp b/bits.cpp index 082aef4..7b485cd 100644 --- a/bits.cpp +++ b/bits.cpp @@ -1,6 +1,6 @@ /* This is bits.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -55,11 +55,13 @@ namespace bits { -Permutation::Permutation():List() +Permutation::Permutation() + : List() {} -Permutation::Permutation(const Ulong& n):List(n) +Permutation::Permutation(const Ulong &n) + : List(n) {} @@ -67,7 +69,7 @@ Permutation::~Permutation() {} -Permutation& Permutation::identity(const Ulong& n) +Permutation &Permutation::identity(const Ulong &n) /* Sets the permutation to the identity permutation of [0,n[. @@ -83,7 +85,7 @@ Permutation& Permutation::identity(const Ulong& n) return *this; } -Permutation& Permutation::inverse() +Permutation &Permutation::inverse() /* Inverts the current permutation : new(old(x)) = x. This is a little @@ -96,7 +98,7 @@ Permutation& Permutation::inverse() static Permutation i(0); i.setSize(size()); - Permutation& t = *this; + Permutation &t = *this; for (SetElt x = 0; x < size(); ++x) i[t[x]] = x; @@ -106,7 +108,7 @@ Permutation& Permutation::inverse() return t; } -Permutation& Permutation::rightCompose(const Permutation& a) +Permutation &Permutation::rightCompose(const Permutation &a) /* Increments the current permutation by composition on the right with a : @@ -117,7 +119,7 @@ Permutation& Permutation::rightCompose(const Permutation& a) static Permutation c(0); c.setSize(size()); - Permutation& t = *this; + Permutation &t = *this; for (SetElt x = 0; x < size(); ++x) c[x] = t[a[x]]; @@ -127,7 +129,7 @@ Permutation& Permutation::rightCompose(const Permutation& a) return t; } -Permutation& Permutation::compose(const Permutation& a) +Permutation &Permutation::compose(const Permutation &a) /* Increments the current permutation by composition on the left with a : @@ -141,7 +143,7 @@ Permutation& Permutation::compose(const Permutation& a) return *this; } -}; +}; // namespace bits /***************************************************************************** @@ -171,7 +173,7 @@ Permutation& Permutation::compose(const Permutation& a) - setSize(n) : resizes the bitmap to size n; - operations : - + - operator~ () : changes into opposite bitmap; - operator&= (map) : intersects with map; - operator|= (map) : does union with map; @@ -183,8 +185,8 @@ namespace bits { /********** constructors and destructors *************************************/ -BitMap::BitMap(const Ulong& n) - :d_map(n/BITS(LFlags)+(bool)(n%BITS(LFlags))), d_size(n) +BitMap::BitMap(const Ulong &n) + : d_map(n / BITS(LFlags) + (bool)(n % BITS(LFlags))), d_size(n) /* Constructor for the BitMap class; constructs a bitmap capable of @@ -192,7 +194,7 @@ BitMap::BitMap(const Ulong& n) */ { - d_map.setSize(n/BITS(LFlags)+(bool)(n%BITS(LFlags))); + d_map.setSize(n / BITS(LFlags) + (bool)(n % BITS(LFlags))); } BitMap::~BitMap() @@ -236,15 +238,14 @@ Ulong BitMap::firstBit() const if (d_map[j]) { /* first bit found */ f = d_map[j]; return f; - } - else + } else first += BITS(LFlags); } return first + bits::firstBit(f); } -bool BitMap::isEmpty(const Ulong& m) const +bool BitMap::isEmpty(const Ulong &m) const /* This function checks whether the intersection of the bitmap with the @@ -252,19 +253,19 @@ bool BitMap::isEmpty(const Ulong& m) const */ { - Ulong lsize = d_size/BITS(LFlags)+(bool)(d_size%BITS(LFlags)); + Ulong lsize = d_size / BITS(LFlags) + (bool)(d_size % BITS(LFlags)); /* look at word containing m */ - Ulong ml = m/BITS(LFlags); - Ulong mr = m%BITS(LFlags); - Ulong mc = BITS(LFlags)-1 - mr; + Ulong ml = m / BITS(LFlags); + Ulong mr = m % BITS(LFlags); + Ulong mc = BITS(LFlags) - 1 - mr; LFlags f = leqmask[mc] << mr; - if (d_map[ml]&f) - return(false); + if (d_map[ml] & f) + return (false); - for (Ulong j = ml+1; j < lsize; ++j) { + for (Ulong j = ml + 1; j < lsize; ++j) { if (d_map[j]) return false; } @@ -283,13 +284,13 @@ Ulong BitMap::lastBit() const if (d_size == 0) return 0; - Ulong base = (d_size-1)/BITS(LFlags)+1; + Ulong base = (d_size - 1) / BITS(LFlags) + 1; - while(base) { + while (base) { base--; LFlags f = d_map[base]; if (f) - return (base*BITS(LFlags)+constants::lastBit(f)); + return (base * BITS(LFlags) + constants::lastBit(f)); } /* if we reach this point, the bitmap is empty */ @@ -299,7 +300,7 @@ Ulong BitMap::lastBit() const /********** modifiers ********************************************************/ -BitMap& BitMap::assign(const BitMap& map) +BitMap &BitMap::assign(const BitMap &map) /* Copies the content of map into the current map. @@ -312,8 +313,7 @@ BitMap& BitMap::assign(const BitMap& map) return *this; } - -void BitMap::permute(Permutation& q) +void BitMap::permute(Permutation &q) /* This function applies the permutation q to the bitmap b. Here b is @@ -333,8 +333,8 @@ void BitMap::permute(Permutation& q) continue; for (Ulong j = q[i]; j != i; j = q[j]) { bool t = getBit(j); - setBit(j,getBit(i)); - setBit(i,t); + setBit(j, getBit(i)); + setBit(i, t); b.setBit(j); } b.setBit(i); @@ -343,8 +343,7 @@ void BitMap::permute(Permutation& q) return; } - -void BitMap::setSize(const Ulong& n) +void BitMap::setSize(const Ulong &n) /* Resizes the bitmap to hold n bits. If the size grows, it is guaranteed @@ -352,14 +351,14 @@ void BitMap::setSize(const Ulong& n) */ { - d_map.setSize(n/BITS(LFlags) + (bool)(n%BITS(LFlags))); + d_map.setSize(n / BITS(LFlags) + (bool)(n % BITS(LFlags))); - if (n > size()) { /* set new bits to zero */ - Ulong f = size()/BITS(LFlags); /* word holding first new bit */ - Ulong fb = size()%BITS(LFlags); /* bit address of first new bit in f */ - LFlags old = ((1L << fb) - 1L); /* flags old bits */ + if (n > size()) { /* set new bits to zero */ + Ulong f = size() / BITS(LFlags); /* word holding first new bit */ + Ulong fb = size() % BITS(LFlags); /* bit address of first new bit in f */ + LFlags old = ((1L << fb) - 1L); /* flags old bits */ d_map[f] &= old; - d_map.setZero(f+1,d_map.size()-f-1); + d_map.setZero(f + 1, d_map.size() - f - 1); } d_size = n; @@ -367,7 +366,7 @@ void BitMap::setSize(const Ulong& n) /********** operators ********************************************************/ -void BitMap::operator~ () +void BitMap::operator~() /* Transforms the bitmap into its complement. One has to be careful not to @@ -378,12 +377,12 @@ void BitMap::operator~ () for (Ulong j = 0; j < d_map.size(); ++j) d_map[j] = ~d_map[j]; - d_map[d_map.size()-1] &= lastchunk(); + d_map[d_map.size() - 1] &= lastchunk(); return; } -void BitMap::operator&= (const BitMap& map) +void BitMap::operator&=(const BitMap &map) /* Does the bitwise intersection with map. It is assumed that map has at @@ -396,7 +395,7 @@ void BitMap::operator&= (const BitMap& map) return; } -void BitMap::operator|= (const BitMap& map) +void BitMap::operator|=(const BitMap &map) /* Does the bitwise union with map. It is assumed that map has at @@ -409,7 +408,7 @@ void BitMap::operator|= (const BitMap& map) return; } -void BitMap::andnot(const BitMap& map) +void BitMap::andnot(const BitMap &map) /* Does the bitwise intersection with ~map. It is assumed that map has at @@ -422,7 +421,7 @@ void BitMap::andnot(const BitMap& map) return; } -}; +}; // namespace bits /**************************************************************************** @@ -446,7 +445,7 @@ void BitMap::andnot(const BitMap& map) The following functions are defined : - - Iterator(const BitMap&, bool) : constructs begin() if true, end() if + - Iterator(const BitMap&, bool) : constructs begin() if true, end() if false; - operator* () : returns the position of the current bit; - operator++ () : moves to the next set bit, or past-the-end; @@ -464,8 +463,8 @@ BitMap::Iterator::Iterator() {} -BitMap::Iterator::Iterator(const BitMap& b) - :d_b(&b) +BitMap::Iterator::Iterator(const BitMap &b) + : d_b(&b) /* Constructs begin(). @@ -475,7 +474,7 @@ BitMap::Iterator::Iterator(const BitMap& b) d_chunk = d_b->d_map.ptr(); d_bitAddress = 0; - for (d_bitAddress = 0; d_bitAddress < d_b->size(); + for (d_bitAddress = 0; d_bitAddress < d_b->size(); d_bitAddress += BITS(LFlags)) { if (*d_chunk) { d_bitAddress += bits::firstBit(*d_chunk); @@ -495,10 +494,10 @@ BitMap::Iterator::~Iterator() {} -BitMap::Iterator& BitMap::Iterator::operator++ () +BitMap::Iterator &BitMap::Iterator::operator++() /* - Increment operator (prefix notation). Valid if the iterator is + Increment operator (prefix notation). Valid if the iterator is dereferenceable. Result is dereferenceable or past-the-end. */ @@ -507,16 +506,15 @@ BitMap::Iterator& BitMap::Iterator::operator++ () f >>= 1; if (f) { - d_bitAddress += bits::firstBit(f)+1; - } - else { /* go to next chunk */ + d_bitAddress += bits::firstBit(f) + 1; + } else { /* go to next chunk */ d_bitAddress &= baseBits; ++d_chunk; - for (d_bitAddress += BITS(LFlags) ; d_bitAddress < d_b->size(); - d_bitAddress += BITS(LFlags)) { + for (d_bitAddress += BITS(LFlags); d_bitAddress < d_b->size(); + d_bitAddress += BITS(LFlags)) { if (*d_chunk) { - d_bitAddress += bits::firstBit(*d_chunk); - break; + d_bitAddress += bits::firstBit(*d_chunk); + break; } ++d_chunk; } @@ -527,7 +525,7 @@ BitMap::Iterator& BitMap::Iterator::operator++ () return *this; } -BitMap::Iterator& BitMap::Iterator::operator-- () +BitMap::Iterator &BitMap::Iterator::operator--() /* Decrement operator (prefix notation). Valid if the iterator is past-the-end, @@ -538,25 +536,24 @@ BitMap::Iterator& BitMap::Iterator::operator-- () LFlags f = 0; if (bitPos()) { - f = *d_chunk & leqmask[bitPos()-1]; + f = *d_chunk & leqmask[bitPos() - 1]; } if (f) { d_bitAddress &= baseBits; d_bitAddress += bits::lastBit(f); - } - else { /* go to previous chunk */ + } else { /* go to previous chunk */ d_bitAddress &= baseBits; while (d_bitAddress) { d_bitAddress -= BITS(LFlags); --d_chunk; if (*d_chunk) { - d_bitAddress += bits::lastBit(*d_chunk); - break; + d_bitAddress += bits::lastBit(*d_chunk); + break; } } } - + return *this; } @@ -567,8 +564,8 @@ BitMap::Iterator BitMap::begin() const */ { - static Iterator i; - new(&i) Iterator(*this); + static Iterator i; + new (&i) Iterator(*this); return i; } @@ -579,14 +576,14 @@ BitMap::Iterator BitMap::end() const i.d_b = this; i.d_bitAddress = d_size; - i.d_chunk = d_map.ptr()+d_map.size(); + i.d_chunk = d_map.ptr() + d_map.size(); if (i.bitPos()) i.d_chunk--; return i; } -}; +}; // namespace bits /**************************************************************************** @@ -634,7 +631,8 @@ Partition::Partition() {} -Partition::Partition(const Ulong &n):d_list(n),d_classCount(0) +Partition::Partition(const Ulong &n) + : d_list(n), d_classCount(0) { d_list.setSize(n); @@ -650,7 +648,7 @@ Partition::~Partition() /******* accessors **********************************************************/ -void Partition::sort(Permutation& a) const +void Partition::sort(Permutation &a) const /* Puts in a the permutation vector for which the classes are contiguous, @@ -678,10 +676,10 @@ void Partition::sort(Permutation& a) const /* put class offsets in count */ - count.setData(count.ptr(),1,count.size()-1); + count.setData(count.ptr(), 1, count.size() - 1); for (Ulong j = 2; j < count.size(); ++j) - count[j] += count[j-1]; + count[j] += count[j - 1]; count[0] = 0; @@ -696,7 +694,7 @@ void Partition::sort(Permutation& a) const } } -void Partition::sortI(Permutation& a) const +void Partition::sortI(Permutation &a) const /* Like sort, but returns the inverse permutation directly. This is in fact @@ -723,10 +721,10 @@ void Partition::sortI(Permutation& a) const /* put class offsets in count */ - count.setData(count.ptr(),1,count.size()-1); + count.setData(count.ptr(), 1, count.size() - 1); for (Ulong j = 2; j < count.size(); ++j) - count[j] += count[j-1]; + count[j] += count[j - 1]; count[0] = 0; @@ -741,7 +739,7 @@ void Partition::sortI(Permutation& a) const } } -void Partition::writeClass(BitMap& b, const Ulong& n) const +void Partition::writeClass(BitMap &b, const Ulong &n) const /* This function sets the bitmap to the bitmap of class #n. It is assumed @@ -796,7 +794,7 @@ void Partition::normalize() return; } -void Partition::normalize(Permutation& a) +void Partition::normalize(Permutation &a) /* Same as normalize(), but records the permutation in a. @@ -828,7 +826,7 @@ void Partition::normalize(Permutation& a) return; } -void Partition::permute(const Permutation& a) +void Partition::permute(const Permutation &a) /* Permutes the partition according to a (i.e., apply a to the domain of @@ -840,7 +838,7 @@ void Partition::permute(const Permutation& a) b.setSize(size()); b.reset(); - + for (SetElt x = 0; x < size(); ++x) { if (b.getBit(x)) continue; @@ -856,7 +854,7 @@ void Partition::permute(const Permutation& a) return; } -void Partition::permuteRange(const Permutation& a) +void Partition::permuteRange(const Permutation &a) /* Applies the permutation a to the range of the partition function. @@ -880,7 +878,7 @@ void Partition::setClassCount() for (Ulong j = 0; j < size(); ++j) { if (d_list[j] >= count) - count = d_list[j]+1; + count = d_list[j] + 1; } d_classCount = count; @@ -890,7 +888,7 @@ void Partition::setClassCount() /******** input/output ******************************************************/ -void Partition::printClassSizes(FILE* file) const +void Partition::printClassSizes(FILE *file) const /* This function prints out the sizes of the classes in the partition. @@ -907,17 +905,17 @@ void Partition::printClassSizes(FILE* file) const } for (Ulong j = 0; j < d_classCount; ++j) { - fprintf(file,"%lu",count[j]); - if (j < d_classCount-1) - fprintf(file,","); + fprintf(file, "%lu", count[j]); + if (j < d_classCount - 1) + fprintf(file, ","); } - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -}; +}; // namespace bits /**************************************************************************** @@ -933,11 +931,11 @@ void Partition::printClassSizes(FILE* file) const namespace bits { -PartitionIterator::PartitionIterator(const Partition& pi) - :d_pi(pi),d_a(pi.size()),d_class(0),d_base(0),d_valid(true) +PartitionIterator::PartitionIterator(const Partition &pi) + : d_pi(pi), d_a(pi.size()), d_class(0), d_base(0), d_valid(true) /* - + */ { @@ -949,18 +947,17 @@ PartitionIterator::PartitionIterator(const Partition& pi) { d_a.setSize(pi.size()); pi.sortI(d_a); - + /* load first class */ - + Ulong j = 0; - + for (; (j < d_a.size()) && (d_pi(d_a[j]) == d_pi(d_a[d_base])); ++j) { d_class.append(d_a[j]); } } - done: - ; +done:; } PartitionIterator::~PartitionIterator() @@ -971,7 +968,7 @@ PartitionIterator::~PartitionIterator() {} -void PartitionIterator::operator++ () +void PartitionIterator::operator++() { d_base += d_class.size(); @@ -989,7 +986,7 @@ void PartitionIterator::operator++ () } } -}; +}; // namespace bits /**************************************************************************** @@ -1026,7 +1023,6 @@ void PartitionIterator::operator++ () *****************************************************************************/ - namespace bits { SubSet::~SubSet() @@ -1037,7 +1033,7 @@ SubSet::~SubSet() {} -void SubSet::add(const Ulong& n) +void SubSet::add(const Ulong &n) /* Adds a new element to the subset. It is assumed that n is a legal value @@ -1091,7 +1087,7 @@ void SubSet::reset() return; } -}; +}; // namespace bits /***************************************************************************** @@ -1103,23 +1099,21 @@ void SubSet::reset() *****************************************************************************/ +unsigned bits::bitCount(const LFlags &d_f) -unsigned bits::bitCount(const LFlags& d_f) - /* Returns the number of set bits in f. */ - + { unsigned count = 0; - for (LFlags f = d_f; f; f &= f-1) - count++; /* see K&R */ - + for (LFlags f = d_f; f; f &= f - 1) + count++; /* see K&R */ + return count; } - /***************************************************************************** Chapter VIII -- Copying memory. @@ -1131,11 +1125,10 @@ unsigned bits::bitCount(const LFlags& d_f) *****************************************************************************/ - void bits::memSet(void *dest, void *source, Ulong size, Ulong count) /* - Copies into dest count repetitions of the pattern made up by the first size + Copies into dest count repetitions of the pattern made up by the first size bits in source. */ @@ -1145,22 +1138,20 @@ void bits::memSet(void *dest, void *source, Ulong size, Ulong count) if (count == 0) return; - memmove(dest,source,size); + memmove(dest, source, size); source = dest; dest = (void *)((char *)dest + size); - for (c = 1; c <= count/2; c *= 2) - { - memmove(dest,source,c*size); - dest = (void *)((char *)dest + c*size); - } + for (c = 1; c <= count / 2; c *= 2) { + memmove(dest, source, c * size); + dest = (void *)((char *)dest + c * size); + } - memmove(dest,source,(count-c)*size); + memmove(dest, source, (count - c) * size); return; } - /***************************************************************************** Chapter IX -- Input/Output. @@ -1175,7 +1166,7 @@ void bits::memSet(void *dest, void *source, Ulong size, Ulong count) namespace bits { -String& append(String& l, const BitMap& map) +String &append(String &l, const BitMap &map) /* Appends the map to the string. Uses a representation in terms of zeroes @@ -1185,15 +1176,15 @@ String& append(String& l, const BitMap& map) { for (Ulong j = 0; j < map.size(); ++j) { if (map.getBit(j)) /* bit is set */ - append(l,"1"); + append(l, "1"); else - append(l,"0"); + append(l, "0"); } return l; } -void print(FILE* file, const BitMap& map) +void print(FILE *file, const BitMap &map) /* Prints the map to the file. Uses append. @@ -1203,13 +1194,13 @@ void print(FILE* file, const BitMap& map) static String buf(0); reset(buf); - append(buf,map); - print(file,buf); + append(buf, map); + print(file, buf); return; } -}; +}; // namespace bits /***************************************************************************** @@ -1223,7 +1214,7 @@ void print(FILE* file, const BitMap& map) namespace bits { -bool isRefinement(const Partition& pi1, const Partition& pi2) +bool isRefinement(const Partition &pi1, const Partition &pi2) /* Tells whether pi1 is a refinement of pi2. Both are assumed to be partitions @@ -1233,14 +1224,14 @@ bool isRefinement(const Partition& pi1, const Partition& pi2) { for (PartitionIterator i(pi1); i; ++i) { - const Set& l = i(); + const Set &l = i(); Ulong a = pi2(l[0]); for (Ulong j = 1; j < l.size(); ++j) if (pi2(l[j]) != a) - return false; + return false; } return true; } -}; +}; // namespace bits diff --git a/bits.h b/bits.h index 5203622..cdb3b89 100644 --- a/bits.h +++ b/bits.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef BITS_H /* guarantee single inclusion */ +#ifndef BITS_H /* guarantee single inclusion */ #define BITS_H #include @@ -17,280 +17,311 @@ #include "constants.h" namespace bits { - using namespace coxeter; - using namespace list; - using namespace io; - using namespace constants; +using namespace coxeter; +using namespace list; +using namespace io; +using namespace constants; /******** type declarations *************************************************/ - class BitMap; - class Partition; - class PartitionIterator; - class Permutation; - class SubSet; - typedef unsigned char Flags; - typedef Ulong LFlags; - typedef Ulong SetElt; - typedef List Set; +class BitMap; +class Partition; +class PartitionIterator; +class Permutation; +class SubSet; +typedef unsigned char Flags; +typedef Ulong LFlags; +typedef Ulong SetElt; +typedef List Set; /******** function declarations *********************************************/ - String& append(String& l, const BitMap& map); - unsigned bitCount(const LFlags& f); - bool isRefinement(const Partition& pi1, const Partition& pi2); - void memSet(void *dest, void *source, Ulong size, Ulong count); - void print(FILE* file, const BitMap& map); - template void rightRangePermute(List& r, const Permutation& a); - template void sortI(const List& r, Permutation& a); - template void sortI(const List& r, C& inOrder, - Permutation& a); - template void sortI_f(const List& r, F& f, - Permutation& a); +String &append(String &l, const BitMap &map); +unsigned bitCount(const LFlags &f); +bool isRefinement(const Partition &pi1, const Partition &pi2); +void memSet(void *dest, void *source, Ulong size, Ulong count); +void print(FILE *file, const BitMap &map); +template void rightRangePermute(List &r, const Permutation &a); +template void sortI(const List &r, Permutation &a); +template +void sortI(const List &r, C &inOrder, Permutation &a); +template +void sortI_f(const List &r, F &f, Permutation &a); /******** type definitions **************************************************/ -class Permutation:public Set { - public: -/* constructors and destructors */ +class Permutation : public Set { +public: + /* constructors and destructors */ Permutation(); - Permutation(const Ulong& n); + Permutation(const Ulong &n); ~Permutation(); -/* manipulators */ - Permutation& identity(const Ulong& n); - Permutation& inverse(); - Permutation& compose(const Permutation& a); - Permutation& rightCompose(const Permutation& a); + /* manipulators */ + Permutation &identity(const Ulong &n); + Permutation &inverse(); + Permutation &compose(const Permutation &a); + Permutation &rightCompose(const Permutation &a); }; class BitMap { - private: +private: List d_map; Ulong d_size; - public: -/* constructors and destructors */ - BitMap() {}; - BitMap(const Ulong& n); - BitMap(const BitMap& map): d_map(map.d_map), d_size(map.d_size) {}; - ~BitMap(); /* standard destructor */ -/* modifiers */ - BitMap& operator=(const BitMap& map); /* inlined */ - BitMap& assign(const BitMap& map); - void clearBit(const Ulong& n); /* inlined */ - void permute(Permutation& q); - void reset(); /* inlined */ - void setBit(const Ulong& n); /* inlined */ - void setBit(const Ulong& n, const bool& t); /* inlined */ - void setSize(const Ulong& n); -/* operations */ - void operator~ (); - void operator&= (const BitMap& map); - void operator|= (const BitMap& map); - void andnot(const BitMap& map); -/* accessors */ + +public: + /* constructors and destructors */ + BitMap(){}; + BitMap(const Ulong &n); + BitMap(const BitMap &map) : d_map(map.d_map), d_size(map.d_size){}; + ~BitMap(); /* standard destructor */ + /* modifiers */ + BitMap &operator=(const BitMap &map); /* inlined */ + BitMap &assign(const BitMap &map); + void clearBit(const Ulong &n); /* inlined */ + void permute(Permutation &q); + void reset(); /* inlined */ + void setBit(const Ulong &n); /* inlined */ + void setBit(const Ulong &n, const bool &t); /* inlined */ + void setSize(const Ulong &n); + /* operations */ + void operator~(); + void operator&=(const BitMap &map); + void operator|=(const BitMap &map); + void andnot(const BitMap &map); + /* accessors */ Ulong bitCount() const; - LFlags chunk(const Ulong& m) const; /* inlined */ + LFlags chunk(const Ulong &m) const; /* inlined */ Ulong firstBit() const; - bool isEmpty(const Ulong& m) const; + bool isEmpty(const Ulong &m) const; Ulong lastBit() const; - LFlags lastchunk() const; /* inlined */ - bool getBit(const Ulong& n) const; /* inlined */ - Ulong size() const; /* inlined */ -/* iterator */ + LFlags lastchunk() const; /* inlined */ + bool getBit(const Ulong &n) const; /* inlined */ + Ulong size() const; /* inlined */ + /* iterator */ class Iterator; class ReverseIterator; friend class Iterator; Iterator begin() const; Iterator end() const; - ReverseIterator rbegin() const; /* inlined */ - ReverseIterator rend() const; /* inlined */ + ReverseIterator rbegin() const; /* inlined */ + ReverseIterator rend() const; /* inlined */ }; class BitMap::Iterator { /* is really a constant iterator */ - private: - static const LFlags posBits = BITS(LFlags) - 1; /* BITS(LFlags) should be a - power of two */ +private: + static const LFlags posBits = BITS(LFlags) - 1; /* BITS(LFlags) should be a + power of two */ static const LFlags baseBits = ~posBits; - const BitMap* d_b; - const LFlags* d_chunk; + const BitMap *d_b; + const LFlags *d_chunk; Ulong d_bitAddress; - public: + +public: Iterator(); - Iterator(const BitMap& b); + Iterator(const BitMap &b); ~Iterator(); - Ulong bitPos() const; /* inlined */ - Ulong operator* () const; /* inlined */ - Iterator& operator++ (); - Iterator& operator-- (); - bool operator== (const Iterator& i) const; /* inlined */ - bool operator!= (const Iterator& i) const; /* inlined */ + Ulong bitPos() const; /* inlined */ + Ulong operator*() const; /* inlined */ + Iterator &operator++(); + Iterator &operator--(); + bool operator==(const Iterator &i) const; /* inlined */ + bool operator!=(const Iterator &i) const; /* inlined */ /* friend declaration */ friend Iterator BitMap::end() const; }; class BitMap::ReverseIterator { - private: +private: Iterator d_i; - public: - ReverseIterator() {}; - explicit ReverseIterator(const Iterator& i):d_i(i) {}; - ~ReverseIterator() {}; - Ulong operator* () const; /* inlined */ - ReverseIterator& operator++ (); /* inlined */ - ReverseIterator& operator-- (); /* inlined */ - bool operator== (const ReverseIterator& i) const; /* inlined */ - bool operator!= (const ReverseIterator& i) const; /* inlined */ + +public: + ReverseIterator(){}; + explicit ReverseIterator(const Iterator &i) : d_i(i){}; + ~ReverseIterator(){}; + Ulong operator*() const; /* inlined */ + ReverseIterator &operator++(); /* inlined */ + ReverseIterator &operator--(); /* inlined */ + bool operator==(const ReverseIterator &i) const; /* inlined */ + bool operator!=(const ReverseIterator &i) const; /* inlined */ }; class Partition { - private: +private: List d_list; Ulong d_classCount; - public: -/* class definitions */ + +public: + /* class definitions */ typedef Ulong valueType; -/* constructors and destructors */ + /* constructors and destructors */ Partition(); Partition(const Ulong &n); - Partition(const Partition& a, const BitMap& b); - template Partition(const List& r, F& f); - template Partition(const I& first, const I& last, F& f); + Partition(const Partition &a, const BitMap &b); + template Partition(const List &r, F &f); + template Partition(const I &first, const I &last, F &f); ~Partition(); -/* accessors */ - const Ulong& operator() (const Ulong& j) const; /* inlined */ - Ulong classCount() const; /* inlined */ - Ulong size() const; /* inlined */ - void sort(Permutation& a) const; - void sortI(Permutation& a) const; - void writeClass(BitMap& b, const Ulong& n) const; -/* modifiers */ - Ulong& operator[] (const Ulong& j); /* inlined */ + /* accessors */ + const Ulong &operator()(const Ulong &j) const; /* inlined */ + Ulong classCount() const; /* inlined */ + Ulong size() const; /* inlined */ + void sort(Permutation &a) const; + void sortI(Permutation &a) const; + void writeClass(BitMap &b, const Ulong &n) const; + /* modifiers */ + Ulong &operator[](const Ulong &j); /* inlined */ void normalize(); - void normalize(Permutation& a); - void permute(const Permutation& a); - void permuteRange(const Permutation& a); + void normalize(Permutation &a); + void permute(const Permutation &a); + void permuteRange(const Permutation &a); void setClassCount(); - void setClassCount(const Ulong& count); /* inlined */ - void setSize(const Ulong &n); /* inlined */ -/* input/output */ - void printClassSizes(FILE* file) const; + void setClassCount(const Ulong &count); /* inlined */ + void setSize(const Ulong &n); /* inlined */ + /* input/output */ + void printClassSizes(FILE *file) const; }; class PartitionIterator { - const Partition& d_pi; + const Partition &d_pi; Permutation d_a; Set d_class; Ulong d_base; bool d_valid; - public: -/* constructors and destructors */ - PartitionIterator(const Partition& pi); + +public: + /* constructors and destructors */ + PartitionIterator(const Partition &pi); ~PartitionIterator(); -/* iterator operations */ - operator bool() const; /* inlined */ + /* iterator operations */ + operator bool() const; /* inlined */ void operator++(); - const Set& operator()() const; /* inlined */ + const Set &operator()() const; /* inlined */ }; class SubSet { - private: +private: BitMap d_bitmap; List d_list; - public: -/* constructors and destructors */ - SubSet() {}; - SubSet(const Ulong& n):d_bitmap(n), d_list(0) {}; - SubSet(const SubSet& q):d_bitmap(q.d_bitmap), d_list(q.d_list) {}; - ~SubSet(); /* standard destructor */ -/* accessors */ - const Ulong& operator[] (const Ulong& j) const; /* inlined */ - const BitMap& bitMap() const; /* inlined */ - Ulong find(const SetElt& x) const; /* inlined */ - bool isMember(const Ulong& n) const; /* inlined */ - Ulong size() const; /* inlined */ -/* modifiers */ - Ulong& operator[] (const Ulong& j); /* inlined */ - void add(const Ulong& n); - SubSet& assign(const SubSet& q); /* inlined */ - BitMap& bitMap(); /* inlined */ + +public: + /* constructors and destructors */ + SubSet(){}; + SubSet(const Ulong &n) : d_bitmap(n), d_list(0){}; + SubSet(const SubSet &q) : d_bitmap(q.d_bitmap), d_list(q.d_list){}; + ~SubSet(); /* standard destructor */ + /* accessors */ + const Ulong &operator[](const Ulong &j) const; /* inlined */ + const BitMap &bitMap() const; /* inlined */ + Ulong find(const SetElt &x) const; /* inlined */ + bool isMember(const Ulong &n) const; /* inlined */ + Ulong size() const; /* inlined */ + /* modifiers */ + Ulong &operator[](const Ulong &j); /* inlined */ + void add(const Ulong &n); + SubSet &assign(const SubSet &q); /* inlined */ + BitMap &bitMap(); /* inlined */ void readBitMap(); void reset(); - void setBitMapSize(const Ulong& n); /* inlined */ - void setListSize(const Ulong& n); /* inlined */ - void sortList(); /* inlined */ + void setBitMapSize(const Ulong &n); /* inlined */ + void setListSize(const Ulong &n); /* inlined */ + void sortList(); /* inlined */ }; /**** Inline implementations **********************************************/ - inline BitMap& BitMap::operator= (const BitMap& map) {return assign(map);} - inline void BitMap::clearBit(const Ulong& n) - {d_map[n/BITS(LFlags)] &= ~(lmask[n%BITS(LFlags)]);} - inline LFlags BitMap::chunk(const Ulong& m) const {return d_map[m];} - inline bool BitMap::getBit(const Ulong& n) const - {return d_map[n/BITS(LFlags)] & lmask[n%BITS(LFlags)];} - inline LFlags BitMap::lastchunk() const - {return leqmask[(size()-1)%BITS(LFlags)];} - inline void BitMap::reset() {d_map.setZero();} - inline void BitMap::setBit(const Ulong& n) - {d_map[n/BITS(LFlags)] |= lmask[n%BITS(LFlags)];} - inline void BitMap::setBit(const Ulong& n, const bool& t) - {if (t) setBit(n); else clearBit(n);} - inline Ulong BitMap::size() const {return d_size;} - inline BitMap::ReverseIterator BitMap::rbegin() const - {return ReverseIterator(end());} - inline BitMap::ReverseIterator BitMap::rend() const - {return ReverseIterator(begin());} - - inline Ulong BitMap::Iterator::bitPos() const - {return d_bitAddress&posBits;} - inline Ulong BitMap::Iterator::operator* () const - {return d_bitAddress;} - inline bool BitMap::Iterator::operator== (const BitMap::Iterator& i) const - {return d_bitAddress == i.d_bitAddress;} - inline bool BitMap::Iterator::operator!= (const BitMap::Iterator& i) const - {return d_bitAddress != i.d_bitAddress;} - - inline Ulong BitMap::ReverseIterator::operator* () const - {Iterator tmp(d_i); --tmp; return *tmp;} - inline BitMap::ReverseIterator& BitMap::ReverseIterator::operator++ () - {--d_i; return *this;} - inline BitMap::ReverseIterator& BitMap::ReverseIterator::operator-- () - {++d_i; return *this;} - inline bool BitMap::ReverseIterator::operator== (const ReverseIterator& i) - const {return d_i == i.d_i;} - inline bool BitMap::ReverseIterator::operator!= (const ReverseIterator& i) - const {return d_i != i.d_i;} - - inline const Ulong& Partition::operator() (const Ulong &j) const - {return d_list[j];} - inline Ulong& Partition::operator[] (const Ulong &j) - {return d_list[j];} - inline Ulong Partition::classCount() const {return d_classCount;} - inline void Partition::setClassCount(const Ulong& count) - {d_classCount = count;} - inline void Partition::setSize(const Ulong& n) {d_list.setSize(n);} - inline Ulong Partition::size() const {return d_list.size();} - - inline PartitionIterator::operator bool() const - {return d_valid;} - inline const Set& PartitionIterator::operator()() const - {return d_class;} - - inline Ulong& SubSet::operator[] (const Ulong& j) {return d_list[j];} - inline const Ulong& SubSet::operator[] (const Ulong& j) const - {return d_list[j];} - inline SubSet& SubSet::assign(const SubSet& q) - {new(this) SubSet(q); return *this;} - inline const BitMap& SubSet::bitMap() const {return d_bitmap;} - inline BitMap& SubSet::bitMap() {return d_bitmap;} - inline Ulong SubSet::find(const SetElt& x) const - {return list::find(d_list,x);} - inline bool SubSet::isMember(const Ulong& n) const - {return d_bitmap.getBit(n);} - inline void SubSet::setBitMapSize(const Ulong& n) {d_bitmap.setSize(n);} - inline void SubSet::setListSize(const Ulong& n) {d_list.setSize(n);} - inline Ulong SubSet::size() const {return d_list.size();} - inline void SubSet::sortList() {return d_list.sort();} +inline BitMap &BitMap::operator=(const BitMap &map) { return assign(map); } +inline void BitMap::clearBit(const Ulong &n) { + d_map[n / BITS(LFlags)] &= ~(lmask[n % BITS(LFlags)]); +} +inline LFlags BitMap::chunk(const Ulong &m) const { return d_map[m]; } +inline bool BitMap::getBit(const Ulong &n) const { + return d_map[n / BITS(LFlags)] & lmask[n % BITS(LFlags)]; +} +inline LFlags BitMap::lastchunk() const { + return leqmask[(size() - 1) % BITS(LFlags)]; +} +inline void BitMap::reset() { d_map.setZero(); } +inline void BitMap::setBit(const Ulong &n) { + d_map[n / BITS(LFlags)] |= lmask[n % BITS(LFlags)]; +} +inline void BitMap::setBit(const Ulong &n, const bool &t) { + if (t) + setBit(n); + else + clearBit(n); +} +inline Ulong BitMap::size() const { return d_size; } +inline BitMap::ReverseIterator BitMap::rbegin() const { + return ReverseIterator(end()); +} +inline BitMap::ReverseIterator BitMap::rend() const { + return ReverseIterator(begin()); +} + +inline Ulong BitMap::Iterator::bitPos() const { return d_bitAddress & posBits; } +inline Ulong BitMap::Iterator::operator*() const { return d_bitAddress; } +inline bool BitMap::Iterator::operator==(const BitMap::Iterator &i) const { + return d_bitAddress == i.d_bitAddress; +} +inline bool BitMap::Iterator::operator!=(const BitMap::Iterator &i) const { + return d_bitAddress != i.d_bitAddress; +} + +inline Ulong BitMap::ReverseIterator::operator*() const { + Iterator tmp(d_i); + --tmp; + return *tmp; +} +inline BitMap::ReverseIterator &BitMap::ReverseIterator::operator++() { + --d_i; + return *this; +} +inline BitMap::ReverseIterator &BitMap::ReverseIterator::operator--() { + ++d_i; + return *this; +} +inline bool +BitMap::ReverseIterator::operator==(const ReverseIterator &i) const { + return d_i == i.d_i; +} +inline bool +BitMap::ReverseIterator::operator!=(const ReverseIterator &i) const { + return d_i != i.d_i; +} + +inline const Ulong &Partition::operator()(const Ulong &j) const { + return d_list[j]; +} +inline Ulong &Partition::operator[](const Ulong &j) { return d_list[j]; } +inline Ulong Partition::classCount() const { return d_classCount; } +inline void Partition::setClassCount(const Ulong &count) { + d_classCount = count; +} +inline void Partition::setSize(const Ulong &n) { d_list.setSize(n); } +inline Ulong Partition::size() const { return d_list.size(); } + +inline PartitionIterator::operator bool() const { return d_valid; } +inline const Set &PartitionIterator::operator()() const { return d_class; } + +inline Ulong &SubSet::operator[](const Ulong &j) { return d_list[j]; } +inline const Ulong &SubSet::operator[](const Ulong &j) const { + return d_list[j]; +} +inline SubSet &SubSet::assign(const SubSet &q) { + new (this) SubSet(q); + return *this; +} +inline const BitMap &SubSet::bitMap() const { return d_bitmap; } +inline BitMap &SubSet::bitMap() { return d_bitmap; } +inline Ulong SubSet::find(const SetElt &x) const { + return list::find(d_list, x); +} +inline bool SubSet::isMember(const Ulong &n) const { + return d_bitmap.getBit(n); +} +inline void SubSet::setBitMapSize(const Ulong &n) { d_bitmap.setSize(n); } +inline void SubSet::setListSize(const Ulong &n) { d_list.setSize(n); } +inline Ulong SubSet::size() const { return d_list.size(); } +inline void SubSet::sortList() { return d_list.sort(); } /******** template definitions ***********************************************/ @@ -300,19 +331,19 @@ class SubSet { assumed that operator<= is defined for the value type of f (so that the function insert may be applied.) */ -template Partition::Partition(const List& r, F& f) : d_list(0) -{ +template +Partition::Partition(const List &r, F &f) : d_list(0) { List c(0); for (Ulong j = 0; j < r.size(); ++j) { - insert(c,f(r[j])); + insert(c, f(r[j])); } d_list.setSize(r.size()); d_classCount = c.size(); for (Ulong j = 0; j < r.size(); ++j) { - d_list[j] = find(c,f(r[j])); + d_list[j] = find(c, f(r[j])); } } @@ -325,14 +356,13 @@ template Partition::Partition(const List& r, F& f) : d_lis are attributed in the order of the values of f on the range. */ template -Partition::Partition(const I& first, const I& last, F& f) : d_list(0) -{ +Partition::Partition(const I &first, const I &last, F &f) : d_list(0) { List c(0); Ulong count = 0; for (I i = first; i != last; ++i) { - insert(c,f(*i)); + insert(c, f(*i)); count++; } @@ -342,10 +372,9 @@ Partition::Partition(const I& first, const I& last, F& f) : d_list(0) count = 0; for (I i = first; i != last; ++i) { - d_list[count] = find(c,f(*i)); + d_list[count] = find(c, f(*i)); count++; } - } /** @@ -356,9 +385,7 @@ Partition::Partition(const I& first, const I& last, F& f) : d_list(0) We cannot write this directly however, or we would overwrite. So we do something similar as with ordinary range permutations. */ -template -void rightRangePermute(List& r, const Permutation& a) -{ +template void rightRangePermute(List &r, const Permutation &a) { BitMap b(r.size()); for (Ulong j = 0; j < a.size(); ++j) { @@ -393,16 +420,14 @@ void rightRangePermute(List& r, const Permutation& a) Doesn't actually modify r; it only writes down in a the permutation s.t. new[j] = old[a[j]]. */ -template -void sortI(const List& r, Permutation& a) -{ +template void sortI(const List &r, Permutation &a) { a.identity(r.size()); /* set the starting value of h */ Ulong h = 1; - for (; h < r.size()/3; h = 3*h+1) + for (; h < r.size() / 3; h = 3 * h + 1) ; /* do the sort */ @@ -411,8 +436,8 @@ void sortI(const List& r, Permutation& a) for (Ulong j = h; j < r.size(); ++j) { Ulong buf = a[j]; Ulong i = j; - for (; (i >= h) && (r[a[i-h]] > r[buf]); i -= h) - a[i] = a[i-h]; + for (; (i >= h) && (r[a[i - h]] > r[buf]); i -= h) + a[i] = a[i - h]; a[i] = buf; } } @@ -430,15 +455,14 @@ void sortI(const List& r, Permutation& a) s.t. new[j] = old[a[j]]. */ template -void sortI(const List& r, C& inOrder, Permutation& a) -{ +void sortI(const List &r, C &inOrder, Permutation &a) { a.identity(r.size()); /* set the starting value of h */ Ulong h = 1; - for (; h < r.size()/3; h = 3*h+1) + for (; h < r.size() / 3; h = 3 * h + 1) ; /* do the sort */ @@ -447,8 +471,8 @@ void sortI(const List& r, C& inOrder, Permutation& a) for (Ulong j = h; j < r.size(); ++j) { Ulong buf = a[j]; Ulong i = j; - for (; (i >= h) && !inOrder(r[a[i-h]],r[buf]); i -= h) - a[i] = a[i-h]; + for (; (i >= h) && !inOrder(r[a[i - h]], r[buf]); i -= h) + a[i] = a[i - h]; a[i] = buf; } } @@ -464,15 +488,14 @@ void sortI(const List& r, C& inOrder, Permutation& a) s.t. new[j] = old[a[j]]. */ template -void sortI_f(const List& r, F& f, Permutation& a) -{ +void sortI_f(const List &r, F &f, Permutation &a) { a.identity(r.size()); /* set the starting value of h */ Ulong h = 1; - for (; h < r.size()/3; h = 3*h+1) + for (; h < r.size() / 3; h = 3 * h + 1) ; /* do the sort */ @@ -481,8 +504,8 @@ void sortI_f(const List& r, F& f, Permutation& a) for (Ulong j = h; j < r.size(); ++j) { Ulong buf = a[j]; Ulong i = j; - for (; (i >= h) && (f(r[a[i-h]]) > f(r[buf])); i -= h) - a[i] = a[i-h]; + for (; (i >= h) && (f(r[a[i - h]]) > f(r[buf])); i -= h) + a[i] = a[i - h]; a[i] = buf; } } @@ -490,6 +513,6 @@ void sortI_f(const List& r, F& f, Permutation& a) return; } -} +} // namespace bits #endif diff --git a/cells.cpp b/cells.cpp index ca2e0b4..1a2a123 100644 --- a/cells.cpp +++ b/cells.cpp @@ -1,6 +1,6 @@ /* This is cells.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -10,9 +10,9 @@ #include "stack.h" namespace cells { - using namespace klsupport; - using namespace stack; -}; +using namespace klsupport; +using namespace stack; +}; // namespace cells /**************************************************************************** @@ -37,21 +37,21 @@ namespace cells { 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 + 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 + More sophisticated data for cells (distinguished involutions, a-functions ...) will have to wait a little bit more. ****************************************************************************/ namespace { - using namespace cells; +using namespace cells; - typedef List CoxList; -}; +typedef List CoxList; +}; // namespace /**************************************************************************** @@ -67,14 +67,14 @@ namespace { 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 + - lGeneralizedTau(pi,p), rGeneralizedTau(pi,p) : left (right) descent partition, stabilized under star operations; ****************************************************************************/ namespace cells { -void lCells(Partition& pi, kl::KLContext& kl) +void lCells(Partition &pi, kl::KLContext &kl) /* This function puts in pi the partition of p into left cells --- in the case @@ -97,32 +97,32 @@ void lCells(Partition& pi, kl::KLContext& kl) static OrientedGraph P(0); static Fifo orbit; - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); q.setBitMapSize(p.size()); a.setBitMapSize(p.size()); a.reset(); cell_count.setSize(0); - rGeneralizedTau(pi,p); + 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)); + 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); + 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 */ @@ -133,11 +133,11 @@ void lCells(Partition& pi, kl::KLContext& kl) /* get class counts and mark off cells in q */ for (PartitionIterator i(qcells); i; ++i) { - const Set& c = 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]]); + a.add(q[c[j]]); } /* propagate cells with star-operations; the idea is that star operations @@ -151,27 +151,26 @@ void lCells(Partition& pi, kl::KLContext& kl) for (StarOp j = 0; j < p.nStarOps(); ++j) { - CoxNbr zj = p.star(z,j); + CoxNbr zj = p.star(z, j); - if (zj == undef_coxnbr) - continue; - if (a.isMember(zj)) - continue; + if (zj == undef_coxnbr) + continue; + if (a.isMember(zj)) + continue; - /* mark off orbit */ + /* mark off orbit */ - orbit.push(a.size()); + 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]); - } + 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]); + } } } } @@ -182,7 +181,7 @@ void lCells(Partition& pi, kl::KLContext& kl) for (Ulong j = 0; j < cell_count.size(); ++j) { for (Ulong i = 0; i < cell_count[j]; ++i) { - pi[a[c+i]] = j; + pi[a[c + i]] = j; } c += cell_count[j]; } @@ -192,7 +191,7 @@ void lCells(Partition& pi, kl::KLContext& kl) return; } -void rCells(Partition& pi, kl::KLContext& kl) +void rCells(Partition &pi, kl::KLContext &kl) /* Same as lCells, but does the partition into right cells. @@ -209,30 +208,30 @@ void rCells(Partition& pi, kl::KLContext& kl) static Fifo orbit; static Permutation v(0); - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); q.setBitMapSize(p.size()); a.setBitMapSize(p.size()); a.reset(); cell_count.setSize(0); - lGeneralizedTau(pi,p); + 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)); + pi.writeClass(q.bitMap(), pi(x)); q.readBitMap(); /* find cells in class */ X.reset(); - rWGraph(X,q,kl); - X.graph().cells(qcells,&P); + 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 */ @@ -243,11 +242,11 @@ void rCells(Partition& pi, kl::KLContext& kl) /* get class counts and mark off cells in q */ for (PartitionIterator i(qcells); i; ++i) { - const Set& c = 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]]); + a.add(q[c[j]]); } /* propagate cells with star-operations */ @@ -257,29 +256,28 @@ void rCells(Partition& pi, kl::KLContext& kl) Ulong c = orbit.pop(); CoxNbr z = a[c]; - for (StarOp j = p.nStarOps(); j < 2*p.nStarOps(); ++j) { + for (StarOp j = p.nStarOps(); j < 2 * p.nStarOps(); ++j) { - CoxNbr zj = p.star(z,j); + CoxNbr zj = p.star(z, j); - if (zj == undef_coxnbr) - continue; - if (a.isMember(zj)) - continue; + if (zj == undef_coxnbr) + continue; + if (a.isMember(zj)) + continue; - /* mark off orbit */ + /* mark off orbit */ - orbit.push(a.size()); + 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]); - } + 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]); + } } } } @@ -290,7 +288,7 @@ void rCells(Partition& pi, kl::KLContext& kl) for (Ulong j = 0; j < cell_count.size(); ++j) { for (Ulong i = 0; i < cell_count[j]; ++i) { - pi[a[c+i]] = j; + pi[a[c + i]] = j; } c += cell_count[j]; } @@ -300,7 +298,7 @@ void rCells(Partition& pi, kl::KLContext& kl) return; } -void lrCells(Partition& pi, kl::KLContext& kl) +void lrCells(Partition &pi, kl::KLContext &kl) /* This function computes the two-sided cells in the context. There are @@ -312,13 +310,13 @@ void lrCells(Partition& pi, kl::KLContext& kl) kl.fillMu(); WGraph X(0); - lrWGraph(X,kl); + lrWGraph(X, kl); X.graph().cells(pi); return; } -void lDescentPartition(Partition& pi, const SchubertContext& p) +void lDescentPartition(Partition &pi, const SchubertContext &p) /* This function writes in pi the partition of p according to the left @@ -332,17 +330,17 @@ void lDescentPartition(Partition& pi, const SchubertContext& p) d.setSize(0); for (CoxNbr x = 0; x < p.size(); ++x) - insert(d,p.ldescent(x)); + insert(d, p.ldescent(x)); for (CoxNbr x = 0; x < p.size(); ++x) - pi[x] = find(d,p.ldescent(x)); + pi[x] = find(d, p.ldescent(x)); pi.setClassCount(d.size()); return; } -void lStringEquiv(Partition& pi, const SchubertContext& p) +void lStringEquiv(Partition &pi, const SchubertContext &p) /* This function writes in pi the partition of p according to the (left) @@ -372,17 +370,17 @@ void lStringEquiv(Partition& pi, const SchubertContext& p) 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); + 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++; @@ -393,10 +391,10 @@ void lStringEquiv(Partition& pi, const SchubertContext& p) return; } -void lStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) +void lStringEquiv(Partition &pi, const SubSet &q, const SchubertContext &p) /* - Does the partition of the subset q into left string classes. It is assumed + Does the partition of the subset q into left string classes. It is assumed that q is stable under the equivalence relation. */ @@ -420,20 +418,20 @@ void lStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) 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); + 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++; @@ -444,7 +442,7 @@ void lStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) return; } -void rDescentPartition(Partition& pi, const SchubertContext& p) +void rDescentPartition(Partition &pi, const SchubertContext &p) /* This function writes in pi the partition of p according to the right @@ -458,17 +456,17 @@ void rDescentPartition(Partition& pi, const SchubertContext& p) d.setSize(0); for (CoxNbr x = 0; x < p.size(); ++x) - insert(d,p.rdescent(x)); + insert(d, p.rdescent(x)); for (CoxNbr x = 0; x < p.size(); ++x) - pi[x] = find(d,p.rdescent(x)); + pi[x] = find(d, p.rdescent(x)); pi.setClassCount(d.size()); return; } -void rStringEquiv(Partition& pi, const SchubertContext& p) +void rStringEquiv(Partition &pi, const SchubertContext &p) /* Same as lStringEquiv, but on the other side. @@ -493,17 +491,17 @@ void rStringEquiv(Partition& pi, const SchubertContext& p) 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); + 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++; @@ -514,7 +512,7 @@ void rStringEquiv(Partition& pi, const SchubertContext& p) return; } -void rStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) +void rStringEquiv(Partition &pi, const SubSet &q, const SchubertContext &p) /* Same as lStringEquiv, but on the other side. @@ -540,20 +538,20 @@ void rStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) 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); + 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++; @@ -564,7 +562,7 @@ void rStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p) return; } -void lGeneralizedTau(Partition& pi, const SchubertContext& p) +void lGeneralizedTau(Partition &pi, const SchubertContext &p) /* Like rGeneralizedTau, but on the left. @@ -579,7 +577,7 @@ void lGeneralizedTau(Partition& pi, const SchubertContext& p) /* initialize pi with partition into right descent sets */ Ulong prev; - lDescentPartition(pi,p); + lDescentPartition(pi, p); v.setSize(pi.size()); do { @@ -587,66 +585,65 @@ void lGeneralizedTau(Partition& pi, const SchubertContext& p) /* refine */ - for (Ulong r = p.nStarOps(); r < 2*p.nStarOps(); ++r) { + for (Ulong r = p.nStarOps(); r < 2 * p.nStarOps(); ++r) { - pi.sortI(v); /* sort partition */ + 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]]++; + cc[pi[j]]++; Ulong i = 0; for (Ulong c = 0; c < pi.classCount(); ++c) { - CoxNbr x = v[i]; /* first element in class */ + CoxNbr x = v[i]; /* first element in class */ - if (p.star(x,r) == undef_coxnbr) - goto next_class; + if (p.star(x, r) == undef_coxnbr) + goto next_class; - /* find possibilities for v[.]*r */ + /* find possibilities for v[.]*r */ - b.setSize(0); + b.setSize(0); - for (Ulong j = 0; j < cc[c]; ++j) { - Ulong cr = pi[p.star(v[i+j],r)]; - insert(b,cr); - } + 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; - } + 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; + i += cc[c]; + continue; } pi.setClassCount(count); - } - + } while (prev < pi.classCount()); return; } -void rGeneralizedTau(Partition& pi, const SchubertContext& p) +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 + 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 @@ -665,7 +662,7 @@ void rGeneralizedTau(Partition& pi, const SchubertContext& p) /* initialize pi with partition into right descent sets */ Ulong prev; - rDescentPartition(pi,p); + rDescentPartition(pi, p); v.setSize(pi.size()); do { @@ -675,58 +672,57 @@ void rGeneralizedTau(Partition& pi, const SchubertContext& p) for (Ulong r = 0; r < p.nStarOps(); ++r) { - pi.sortI(v); /* sort partition */ + 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]]++; + cc[pi[j]]++; Ulong i = 0; for (Ulong c = 0; c < pi.classCount(); ++c) { - CoxNbr x = v[i]; /* first element in class */ + CoxNbr x = v[i]; /* first element in class */ - if (p.star(x,r) == undef_coxnbr) - goto next_class; + if (p.star(x, r) == undef_coxnbr) + goto next_class; - /* find possibilities for v[.]*r */ + /* find possibilities for v[.]*r */ - b.setSize(0); + b.setSize(0); - for (Ulong j = 0; j < cc[c]; ++j) { - Ulong cr = pi[p.star(v[i+j],r)]; - insert(b,cr); - } + 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; - } + 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; + i += cc[c]; + continue; } pi.setClassCount(count); - } - + } while (prev < pi.classCount()); return; } -}; +}; // namespace cells /***************************************************************************** @@ -746,103 +742,103 @@ void rGeneralizedTau(Partition& pi, const SchubertContext& p) namespace cells { -void lGraph(OrientedGraph& X, kl::KLContext& kl) +void lGraph(OrientedGraph &X, kl::KLContext &kl) -{ - const SchubertContext& p = kl.schubert(); +{ + 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); + 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); + 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); + 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]); + 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) +void lrGraph(OrientedGraph &X, kl::KLContext &kl) { - const SchubertContext& p = kl.schubert(); + 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); + 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); + 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); + 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]); + 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) +void rGraph(OrientedGraph &X, kl::KLContext &kl) { - const SchubertContext& p = kl.schubert(); + 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); + 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); + 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); + 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]); + 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) +void lWGraph(WGraph &X, kl::KLContext &kl) /* This function constructs a W-graph directly from the k-l data. In other @@ -861,27 +857,27 @@ void lWGraph(WGraph& X, kl::KLContext& kl) { X.setSize(kl.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); // fill in Y - lGraph(Y,kl); + 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); + 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; + if ((lx < ly) || (lx - ly) == 1) + c[j] = 1; else - c[j] = kl.mu(y,x); + c[j] = kl.mu(y, x); } } @@ -893,7 +889,7 @@ void lWGraph(WGraph& X, kl::KLContext& kl) return; } -void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) +void lWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl) /* This function constructs the left W-graph for the subset q. It is @@ -907,12 +903,12 @@ void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) It is assumed that q is sorted in increasing order. */ -{ +{ static List qr(0); X.setSize(q.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); BitMap b(p.size()); Y.reset(); @@ -926,7 +922,7 @@ void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) X.descent(j) = p.ldescent(y); - p.extractClosure(b,y); + p.extractClosure(b, y); b &= q.bitMap(); qr.setSize(0); @@ -934,7 +930,7 @@ void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) for (Ulong i = 0; i < q.size(); ++i) { if (b.getBit(q[i])) - qr.append(i); + qr.append(i); } for (Ulong i = 0; i < qr.size(); ++i) { @@ -942,27 +938,27 @@ void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) 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; + 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); + 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); - } + if (p.ldescent(x) != p.ldescent(y)) { + Y.edge(qr[i]).append(j); + X.coeffList(qr[i]).append(mu); + } } } } @@ -970,7 +966,7 @@ void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) return; } -void lrWGraph(WGraph& X, kl::KLContext& kl) +void lrWGraph(WGraph &X, kl::KLContext &kl) /* Like lWGraph, but for two-sided W-graphs. @@ -978,27 +974,27 @@ void lrWGraph(WGraph& X, kl::KLContext& kl) { X.setSize(kl.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); // fill in Y - lrGraph(Y,kl); + 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); + 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; + if ((lx < ly) || (lx - ly) == 1) + c[j] = 1; else - c[j] = kl.mu(y,x); + c[j] = kl.mu(y, x); } } @@ -1010,7 +1006,7 @@ void lrWGraph(WGraph& X, kl::KLContext& kl) return; } -void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) +void lrWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl) /* This function constructs the left W-graph for the subset q. It is @@ -1024,12 +1020,12 @@ void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) It is assumed that q is sorted in increasing order. */ -{ +{ static List qr(0); X.setSize(q.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); BitMap b(p.size()); Y.reset(); @@ -1043,7 +1039,7 @@ void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) X.descent(j) = p.descent(y); - p.extractClosure(b,y); + p.extractClosure(b, y); b &= q.bitMap(); qr.setSize(0); @@ -1051,7 +1047,7 @@ void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) for (Ulong i = 0; i < q.size(); ++i) { if (b.getBit(q[i])) - qr.append(i); + qr.append(i); } for (Ulong i = 0; i < qr.size(); ++i) { @@ -1059,27 +1055,27 @@ void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) 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.descent(x)&p.descent(y)) != p.descent(x)) { - Y.edge(qr[i]).append(j); - X.coeffList(qr[i]).append(1); - } - if ((p.descent(x)&p.descent(y)) != p.descent(y)) { - Y.edge(j).append(qr[i]); - X.coeffList(j).append(1); - } - continue; + if ((ly - lx) % 2 == 0) + continue; + if ((ly - lx) == 1) { /* found a hasse edge */ + if ((p.descent(x) & p.descent(y)) != p.descent(x)) { + Y.edge(qr[i]).append(j); + X.coeffList(qr[i]).append(1); + } + if ((p.descent(x) & p.descent(y)) != p.descent(y)) { + Y.edge(j).append(qr[i]); + X.coeffList(j).append(1); + } + continue; } - KLCoeff mu = kl.mu(x,y); + KLCoeff mu = kl.mu(x, y); if (mu != 0) { - if (p.descent(x) != p.descent(y)) { - Y.edge(qr[i]).append(j); - X.coeffList(qr[i]).append(mu); - } + if (p.descent(x) != p.descent(y)) { + Y.edge(qr[i]).append(j); + X.coeffList(qr[i]).append(mu); + } } } } @@ -1087,7 +1083,7 @@ void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) return; } -void rWGraph(WGraph& X, kl::KLContext& kl) +void rWGraph(WGraph &X, kl::KLContext &kl) /* Like lWGraph, but for right W-graphs. @@ -1095,27 +1091,27 @@ void rWGraph(WGraph& X, kl::KLContext& kl) { X.setSize(kl.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); // fill in Y - rGraph(Y,kl); + rGraph(Y, kl); // fill in coefficients for (CoxNbr y = 0; y < kl.size(); ++y) { - CoeffList& c = X.coeffList(y); - const EdgeList& e = X.edge(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; + if ((lx < ly) || (lx - ly) == 1) + c[j] = 1; else - c[j] = kl.mu(y,x); + c[j] = kl.mu(y, x); } } @@ -1127,18 +1123,18 @@ void rWGraph(WGraph& X, kl::KLContext& kl) return; } -void rWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) +void rWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl) /* Like lWGraph, but for right W-graphs. */ -{ +{ static List qr(0); X.setSize(q.size()); - const SchubertContext& p = kl.schubert(); - OrientedGraph& Y = X.graph(); + const SchubertContext &p = kl.schubert(); + OrientedGraph &Y = X.graph(); BitMap b(p.size()); Y.reset(); @@ -1150,13 +1146,13 @@ void rWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) X.descent(j) = p.rdescent(y); - p.extractClosure(b,y); + p.extractClosure(b, y); b &= q.bitMap(); qr.setSize(0); for (Ulong i = 0; i < q.size(); ++i) { if (b.getBit(q[i])) - qr.append(i); + qr.append(i); } for (Ulong i = 0; i < qr.size(); ++i) { @@ -1164,36 +1160,35 @@ void rWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) 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.rdescent(x)&p.rdescent(y)) != p.rdescent(x)) { - Y.edge(qr[i]).append(j); - X.coeffList(qr[i]).append(1); - } - if ((p.rdescent(x)&p.rdescent(y)) != p.rdescent(y)) { - Y.edge(j).append(qr[i]); - X.coeffList(j).append(1); - } - continue; + if ((ly - lx) % 2 == 0) + continue; + if ((ly - lx) == 1) { /* found a hasse edge */ + if ((p.rdescent(x) & p.rdescent(y)) != p.rdescent(x)) { + Y.edge(qr[i]).append(j); + X.coeffList(qr[i]).append(1); + } + if ((p.rdescent(x) & p.rdescent(y)) != p.rdescent(y)) { + Y.edge(j).append(qr[i]); + X.coeffList(j).append(1); + } + continue; } - KLCoeff mu = kl.mu(x,y); + KLCoeff mu = kl.mu(x, y); if (mu != 0) { - if (p.rdescent(x) != p.rdescent(y)) { - Y.edge(qr[i]).append(j); - X.coeffList(qr[i]).append(mu); - } + if (p.rdescent(x) != p.rdescent(y)) { + Y.edge(qr[i]).append(j); + X.coeffList(qr[i]).append(mu); + } } - } } return; } -}; +}; // namespace cells /***************************************************************************** @@ -1211,22 +1206,22 @@ void rWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl) namespace cells { -void lGraph(OrientedGraph& X, uneqkl::KLContext& kl) +void lGraph(OrientedGraph &X, uneqkl::KLContext &kl) /* - Puts in X the graph corresponding to the left edges in the context. It + Puts in X the graph corresponding to the left edges in the context. It assumes that the (right) mu-table has been filled. */ -{ - const SchubertContext& p = kl.schubert(); +{ + const SchubertContext &p = kl.schubert(); X.setSize(kl.size()); - LFlags S = leqmask[kl.rank()-1]; + LFlags S = leqmask[kl.rank() - 1]; /* reset X */ for (CoxNbr y = 0; y < X.size(); ++y) { - EdgeList& e = X.edge(y); + EdgeList &e = X.edge(y); e.setSize(0); } @@ -1234,31 +1229,31 @@ void lGraph(OrientedGraph& X, uneqkl::KLContext& kl) for (CoxNbr y = 0; y < X.size(); ++y) { CoxNbr yi = kl.inverse(y); - for (LFlags f = ~p.rdescent(y) & S; f; f &= (f-1)) { + for (LFlags f = ~p.rdescent(y) & S; f; f &= (f - 1)) { Generator s = firstBit(f); - const uneqkl::MuRow& muRow = kl.muList(s,y); + const uneqkl::MuRow &muRow = kl.muList(s, y); for (Ulong j = 0; j < muRow.size(); ++j) { - Vertex x = kl.inverse(muRow[j].x); - EdgeList& e = X.edge(x); - e.append(yi); + Vertex x = kl.inverse(muRow[j].x); + EdgeList &e = X.edge(x); + e.append(yi); } - Vertex sy = kl.inverse(p.shift(y,s)); - EdgeList& e = X.edge(sy); + Vertex sy = kl.inverse(p.shift(y, s)); + EdgeList &e = X.edge(sy); e.append(yi); } - } + } /* sort edgelists */ for (CoxNbr y = 0; y < X.size(); ++y) { - EdgeList& e = X.edge(y); + EdgeList &e = X.edge(y); e.sort(); } return; } -void lrGraph(OrientedGraph& X, uneqkl::KLContext& kl) +void lrGraph(OrientedGraph &X, uneqkl::KLContext &kl) /* Puts in X the graph corresponding to the edges in the context. It assumes @@ -1267,36 +1262,36 @@ void lrGraph(OrientedGraph& X, uneqkl::KLContext& kl) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); X.setSize(kl.size()); - LFlags S = leqmask[kl.rank()-1]; + LFlags S = leqmask[kl.rank() - 1]; /* write down right edges */ - rGraph(X,kl); + rGraph(X, kl); /* add left edges */ for (CoxNbr y = 0; y < X.size(); ++y) { Vertex yi = kl.inverse(y); - for (LFlags f = ~p.rdescent(y) & S; f; f &= (f-1)) { + for (LFlags f = ~p.rdescent(y) & S; f; f &= (f - 1)) { Generator s = firstBit(f); - const uneqkl::MuRow& muRow = kl.muList(s,y); + const uneqkl::MuRow &muRow = kl.muList(s, y); for (Ulong j = 0; j < muRow.size(); ++j) { - Vertex x = kl.inverse(muRow[j].x); - EdgeList& e = X.edge(x); - insert(e,yi); + Vertex x = kl.inverse(muRow[j].x); + EdgeList &e = X.edge(x); + insert(e, yi); } - Vertex sy = kl.inverse(p.shift(y,s)); - EdgeList& e = X.edge(sy); - insert(e,yi); + Vertex sy = kl.inverse(p.shift(y, s)); + EdgeList &e = X.edge(sy); + insert(e, yi); } - } + } return; } -void rGraph(OrientedGraph& X, uneqkl::KLContext& kl) +void rGraph(OrientedGraph &X, uneqkl::KLContext &kl) /* Puts in X the graph corresponding to the edges in the context. It assumes @@ -1304,29 +1299,29 @@ void rGraph(OrientedGraph& X, uneqkl::KLContext& kl) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); X.setSize(kl.size()); - LFlags S = leqmask[kl.rank()-1]; + LFlags S = leqmask[kl.rank() - 1]; /* reset X */ for (CoxNbr y = 0; y < X.size(); ++y) { - EdgeList& e = X.edge(y); + EdgeList &e = X.edge(y); e.setSize(0); } /* make edges */ for (CoxNbr y = 0; y < X.size(); ++y) { - for (LFlags f = ~p.rdescent(y) & S; f; f &= (f-1)) { + for (LFlags f = ~p.rdescent(y) & S; f; f &= (f - 1)) { Generator s = firstBit(f); - const uneqkl::MuRow& muRow = kl.muList(s,y); + const uneqkl::MuRow &muRow = kl.muList(s, y); for (Ulong j = 0; j < muRow.size(); ++j) { - EdgeList& e = X.edge(muRow[j].x); - e.append(y); + EdgeList &e = X.edge(muRow[j].x); + e.append(y); } - CoxNbr ys = p.shift(y,s); - EdgeList& e = X.edge(ys); + CoxNbr ys = p.shift(y, s); + EdgeList &e = X.edge(ys); e.append(y); } } @@ -1334,14 +1329,14 @@ void rGraph(OrientedGraph& X, uneqkl::KLContext& kl) /* sort lists */ for (CoxNbr y = 0; y < X.size(); ++y) { - EdgeList& e = X.edge(y); + EdgeList &e = X.edge(y); e.sort(); } return; } -}; +}; // namespace cells /***************************************************************************** Chapter IV -- Utilities @@ -1354,7 +1349,7 @@ void rGraph(OrientedGraph& X, uneqkl::KLContext& kl) namespace cells { -CoxNbr checkClasses (const Partition& pi, const SchubertContext& p) +CoxNbr checkClasses(const Partition &pi, const SchubertContext &p) /* This function checks if the classes of a refined partition are stable @@ -1378,9 +1373,9 @@ CoxNbr checkClasses (const Partition& pi, const SchubertContext& p) for (; pi(v[i]) == j; ++i) { q.add(v[i]); } - lStringEquiv(pi_q,q,p); + lStringEquiv(pi_q, q, p); if (ERRNO) { - printf("error in class #%lu\n",j); + printf("error in class #%lu\n", j); return q[0]; } } @@ -1388,4 +1383,4 @@ CoxNbr checkClasses (const Partition& pi, const SchubertContext& p) return 0; } -}; +}; // namespace cells diff --git a/cells.h b/cells.h index 586b56b..0a48811 100644 --- a/cells.h +++ b/cells.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CELLS_H /* guard against multiple inclusions */ +#ifndef CELLS_H /* guard against multiple inclusions */ #define CELLS_H #include "globals.h" @@ -15,39 +15,39 @@ #include "wgraph.h" namespace cells { - using namespace coxeter; - using namespace bits; - using namespace wgraph; +using namespace coxeter; +using namespace bits; +using namespace wgraph; /******** function declarations **********************************************/ - CoxNbr checkClasses(const Partition& pi, const SchubertContext& p); - void lCells(Partition& pi, kl::KLContext& kl); - void rCells(Partition& pi, kl::KLContext& kl); - void lrCells(Partition& pi, kl::KLContext& kl); - void lDescentPartition(Partition& pi, const SchubertContext& p); - void rDescentPartition(Partition& pi, const SchubertContext& p); - void lStringEquiv(Partition& pi, const SchubertContext& p); - void lStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p); - void rStringEquiv(Partition& pi, const SchubertContext& p); - void rStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p); - void lrStringEquiv(Partition& pi, const SchubertContext& p); - void lrStringEquiv(Partition& pi, const SubSet& q, const SchubertContext& p); - void lGeneralizedTau(Partition& pi, const SchubertContext& p); - void rGeneralizedTau(Partition& pi, const SchubertContext& p); - void lGraph(OrientedGraph& X, kl::KLContext& kl); - void lrGraph(OrientedGraph& X, kl::KLContext& kl); - void rGraph(OrientedGraph& X, kl::KLContext& kl); - void lGraph(OrientedGraph& X, uneqkl::KLContext& kl); - void lrGraph(OrientedGraph& X, uneqkl::KLContext& kl); - void rGraph(OrientedGraph& X, uneqkl::KLContext& kl); - void lWGraph(WGraph& X, kl::KLContext& kl); - void lWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl); - void rWGraph(WGraph& X, kl::KLContext& kl); - void rWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl); - void lrWGraph(WGraph& X, kl::KLContext& kl); - void lrWGraph(WGraph& X, const SubSet& q, kl::KLContext& kl); - void printCellPartition(FILE* file, const kl::KLContext& kl); -} +CoxNbr checkClasses(const Partition &pi, const SchubertContext &p); +void lCells(Partition &pi, kl::KLContext &kl); +void rCells(Partition &pi, kl::KLContext &kl); +void lrCells(Partition &pi, kl::KLContext &kl); +void lDescentPartition(Partition &pi, const SchubertContext &p); +void rDescentPartition(Partition &pi, const SchubertContext &p); +void lStringEquiv(Partition &pi, const SchubertContext &p); +void lStringEquiv(Partition &pi, const SubSet &q, const SchubertContext &p); +void rStringEquiv(Partition &pi, const SchubertContext &p); +void rStringEquiv(Partition &pi, const SubSet &q, const SchubertContext &p); +void lrStringEquiv(Partition &pi, const SchubertContext &p); +void lrStringEquiv(Partition &pi, const SubSet &q, const SchubertContext &p); +void lGeneralizedTau(Partition &pi, const SchubertContext &p); +void rGeneralizedTau(Partition &pi, const SchubertContext &p); +void lGraph(OrientedGraph &X, kl::KLContext &kl); +void lrGraph(OrientedGraph &X, kl::KLContext &kl); +void rGraph(OrientedGraph &X, kl::KLContext &kl); +void lGraph(OrientedGraph &X, uneqkl::KLContext &kl); +void lrGraph(OrientedGraph &X, uneqkl::KLContext &kl); +void rGraph(OrientedGraph &X, uneqkl::KLContext &kl); +void lWGraph(WGraph &X, kl::KLContext &kl); +void lWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl); +void rWGraph(WGraph &X, kl::KLContext &kl); +void rWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl); +void lrWGraph(WGraph &X, kl::KLContext &kl); +void lrWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl); +void printCellPartition(FILE *file, const kl::KLContext &kl); +} // namespace cells #endif diff --git a/commands.cpp b/commands.cpp index 99d1493..5a37b14 100644 --- a/commands.cpp +++ b/commands.cpp @@ -16,269 +16,264 @@ #include "typeA.h" namespace commands { - using namespace directories; - using namespace error; - using namespace fcoxgroup; - using namespace help; - using namespace interactive; -}; +using namespace directories; +using namespace error; +using namespace fcoxgroup; +using namespace help; +using namespace interactive; +}; // namespace commands namespace { - using namespace commands; - using namespace stack; - - bool wgraph_warning = true; - - /* used in the definition of command trees */ - - struct Empty_tag {}; - struct Interface_tag {}; - struct Main_tag {}; - struct Uneq_tag {}; - - Stack treeStack; - CoxGroup* W = 0; - - void activate(CommandTree* tree); - void ambigAction(CommandTree* tree, const String& str); - CommandData* ambigCommand(); - void cellCompletion(DictCell* cell); - void commandCompletion(DictCell* cell); - void empty_error(char* str); - CommandTree* emptyCommandTree(); - template CommandTree* initCommandTree(); - void printCommandTree(FILE* file, DictCell* cell); - void startup(); - - void interface_entry(); - void interface_exit(); - - void main_entry(); - void main_exit(); - - void uneq_entry(); - void uneq_exit(); - - void author_f(); - void betti_f(); - void coatoms_f(); - void compute_f(); - void descent_f(); - void duflo_f(); - void extremals_f(); - void fullcontext_f(); - void help_f(); - void ihbetti_f(); - void inorder_f(); - void interface_f(); - void interval_f(); - void invpol_f(); - void klbasis_f(); - void lcorder_f(); - void lcells_f(); - void lcwgraphs_f(); - void lrcorder_f(); - void lrcells_f(); - void lrcwgraphs_f(); - void lrwgraph_f(); - void lwgraph_f(); - void matrix_f(); - void mu_f(); - void not_implemented_f(); - void pol_f(); - void q_f(); - void qq_f(); - void rank_f(); - void rcorder_f(); - void rcells_f(); - void rcwgraphs_f(); - void rwgraph_f(); - void schubert_f(); - void show_f(); - void showmu_f(); - void slocus_f(); - void sstratification_f(); - void type_f(); - void uneq_f(); - - const char* author_tag = "prints a message about the author"; - const char* betti_tag = "prints the ordinary betti numbers"; - const char* coatoms_tag = "prints out the coatoms of an element"; - const char* compute_tag = "prints out the normal form of an element"; - const char* descent_tag = "prints out the descent sets"; - const char* duflo_tag = "prints out the Duflo involutions"; - const char* extremals_tag = +using namespace commands; +using namespace stack; + +bool wgraph_warning = true; + +/* used in the definition of command trees */ + +struct Empty_tag {}; +struct Interface_tag {}; +struct Main_tag {}; +struct Uneq_tag {}; + +Stack treeStack; +CoxGroup *W = 0; + +void activate(CommandTree *tree); +void ambigAction(CommandTree *tree, const String &str); +CommandData *ambigCommand(); +void cellCompletion(DictCell *cell); +void commandCompletion(DictCell *cell); +void empty_error(char *str); +CommandTree *emptyCommandTree(); +template CommandTree *initCommandTree(); +void printCommandTree(FILE *file, DictCell *cell); +void startup(); + +void interface_entry(); +void interface_exit(); + +void main_entry(); +void main_exit(); + +void uneq_entry(); +void uneq_exit(); + +void author_f(); +void betti_f(); +void coatoms_f(); +void compute_f(); +void descent_f(); +void duflo_f(); +void extremals_f(); +void fullcontext_f(); +void help_f(); +void ihbetti_f(); +void inorder_f(); +void interface_f(); +void interval_f(); +void invpol_f(); +void klbasis_f(); +void lcorder_f(); +void lcells_f(); +void lcwgraphs_f(); +void lrcorder_f(); +void lrcells_f(); +void lrcwgraphs_f(); +void lrwgraph_f(); +void lwgraph_f(); +void matrix_f(); +void mu_f(); +void not_implemented_f(); +void pol_f(); +void q_f(); +void qq_f(); +void rank_f(); +void rcorder_f(); +void rcells_f(); +void rcwgraphs_f(); +void rwgraph_f(); +void schubert_f(); +void show_f(); +void showmu_f(); +void slocus_f(); +void sstratification_f(); +void type_f(); +void uneq_f(); + +const char *author_tag = "prints a message about the author"; +const char *betti_tag = "prints the ordinary betti numbers"; +const char *coatoms_tag = "prints out the coatoms of an element"; +const char *compute_tag = "prints out the normal form of an element"; +const char *descent_tag = "prints out the descent sets"; +const char *duflo_tag = "prints out the Duflo involutions"; +const char *extremals_tag = "prints out the k-l polynomials for the extremal pairs"; - const char* fullcontext_tag = "sets the context to the full group"; - const char* help_tag = "enters help mode"; - const char* ihbetti_tag = "prints the IH betti numbers"; - const char* input_tag = "(in help mode only) explains the input conventions"; - const char* interface_tag = "changes the interface"; - const char* interval_tag = "prints an interval in the Bruhat ordering"; - const char* intro_tag = +const char *fullcontext_tag = "sets the context to the full group"; +const char *help_tag = "enters help mode"; +const char *ihbetti_tag = "prints the IH betti numbers"; +const char *input_tag = "(in help mode only) explains the input conventions"; +const char *interface_tag = "changes the interface"; +const char *interval_tag = "prints an interval in the Bruhat ordering"; +const char *intro_tag = "(in help mode only) prints a message for first time users"; - const char* inorder_tag = "tells whether two elements are in Bruhat order"; - const char* invpol_tag = "prints a single inverse k-l polynomial"; - const char* klbasis_tag = "prints an element of the k-l basis"; - const char* lcorder_tag = "prints the left cell order"; - const char* lcells_tag = "prints out the left k-l cells"; - const char* lcwgraphs_tag = "prints out the W-graphs of the left k-l cells"; - const char* lrcorder_tag = "prints the two-sided cell order"; - const char* lrcells_tag = "prints out the tow-sided k-l cells"; - const char* lrcwgraphs_tag = +const char *inorder_tag = "tells whether two elements are in Bruhat order"; +const char *invpol_tag = "prints a single inverse k-l polynomial"; +const char *klbasis_tag = "prints an element of the k-l basis"; +const char *lcorder_tag = "prints the left cell order"; +const char *lcells_tag = "prints out the left k-l cells"; +const char *lcwgraphs_tag = "prints out the W-graphs of the left k-l cells"; +const char *lrcorder_tag = "prints the two-sided cell order"; +const char *lrcells_tag = "prints out the tow-sided k-l cells"; +const char *lrcwgraphs_tag = "prints out the W-graphs of the two-sided k-l cells"; - const char* lrwgraph_tag = "prints out the two-sided W-graph"; - const char* lwgraph_tag = "prints out the left W-graph"; - const char* matrix_tag = "prints the current Coxeter matrix"; - const char* mu_tag = "prints a single mu-coefficient"; - const char* pol_tag = "prints a single k-l polynomial"; - const char* q_tag = "exits the current mode"; - const char* qq_tag = "exits the program"; - const char* rank_tag = "resets the rank"; - const char* rcorder_tag = "prints the right cell order"; - const char* rcells_tag = "prints out the right k-l cells"; - const char* rcwgraphs_tag = "prints out the W-graphs of the right k-l cells"; - const char* rwgraph_tag = "prints out the right W-graph"; - const char* schubert_tag = "prints out the kl data for a schubert variety"; - const char* show_tag = "maps out the computation of a k-l polynomial"; - const char* showmu_tag = "maps out the computation of a mu coefficient"; - const char* slocus_tag = +const char *lrwgraph_tag = "prints out the two-sided W-graph"; +const char *lwgraph_tag = "prints out the left W-graph"; +const char *matrix_tag = "prints the current Coxeter matrix"; +const char *mu_tag = "prints a single mu-coefficient"; +const char *pol_tag = "prints a single k-l polynomial"; +const char *q_tag = "exits the current mode"; +const char *qq_tag = "exits the program"; +const char *rank_tag = "resets the rank"; +const char *rcorder_tag = "prints the right cell order"; +const char *rcells_tag = "prints out the right k-l cells"; +const char *rcwgraphs_tag = "prints out the W-graphs of the right k-l cells"; +const char *rwgraph_tag = "prints out the right W-graph"; +const char *schubert_tag = "prints out the kl data for a schubert variety"; +const char *show_tag = "maps out the computation of a k-l polynomial"; +const char *showmu_tag = "maps out the computation of a mu coefficient"; +const char *slocus_tag = "prints the rational singular locus of the Schubert variety"; - const char* sstratification_tag = +const char *sstratification_tag = "prints the rational singular stratification of the Schubert variety"; - const char* type_tag = - "resets the type and rank (hence restarts the program)"; - const char* uneq_tag = "puts the program in unequal-parameter mode"; - - namespace uneq { - void klbasis_f(); - void lcorder_f(); - void lrcorder_f(); - void lcells_f(); - void lrcells_f(); - void mu_f(); - void pol_f(); - void rcells_f(); - void rcorder_f(); - - const char* lcorder_tag = "prints the left cell order"; - const char* lrcorder_tag = "prints the two-sided cell order"; - const char* lcells_tag = "prints out the left k-l cells"; - const char* lrcells_tag = "prints out the two-sided k-l cells"; - const char* mu_tag = "prints out a mu-coefficient"; - const char* pol_tag = "prints out a single k-l polynomial"; - const char* rcells_tag = "prints out the right k-l cells"; - const char* rcorder_tag = "prints the right cell order"; - }; -}; +const char *type_tag = "resets the type and rank (hence restarts the program)"; +const char *uneq_tag = "puts the program in unequal-parameter mode"; + +namespace uneq { +void klbasis_f(); +void lcorder_f(); +void lrcorder_f(); +void lcells_f(); +void lrcells_f(); +void mu_f(); +void pol_f(); +void rcells_f(); +void rcorder_f(); + +const char *lcorder_tag = "prints the left cell order"; +const char *lrcorder_tag = "prints the two-sided cell order"; +const char *lcells_tag = "prints out the left k-l cells"; +const char *lrcells_tag = "prints out the two-sided k-l cells"; +const char *mu_tag = "prints out a mu-coefficient"; +const char *pol_tag = "prints out a single k-l polynomial"; +const char *rcells_tag = "prints out the right k-l cells"; +const char *rcorder_tag = "prints the right cell order"; +}; // namespace uneq +}; // namespace namespace commands { - void (*default_help)() = &help::default_h; +void (*default_help)() = &help::default_h; }; namespace commands { - namespace interface { - - GroupEltInterface* in_buf = 0; - - struct In_tag {}; - struct Out_tag {}; - - void in_entry(); - void in_exit(); - void out_entry(); - void out_exit(); - - void abort_f(); - void alphabetic_f(); - void bourbaki_f(); - void default_f(); - void decimal_f(); - void gap_f(); - void hexadecimal_f(); - void in_f(); - void out_f(); - void permutation_f(); - void symbol_f(); - void terse_f(); - void ordering_f(); - - const char* abort_tag = "leaves without modifying the interface"; - const char* alphabetic_tag = "sets alphabetic generator symbols"; - const char* bourbaki_tag = "sets Bourbaki conventions for i/o"; - const char* decimal_tag = "sets decimal generator symbols"; - const char* default_tag = "sets i/o to default mode"; - const char* gap_tag = "sets i/o to GAP mode"; - const char* hexadecimal_tag = "sets hexadecimal generator symbols"; - const char* in_tag = "enters reset-input mode"; - const char* out_tag = "enters reset-output mode"; - const char* permutation_tag = - "sets permutation notation for i/o (in type A only)"; - const char* ordering_tag = "modifies the ordering of the generators"; - const char* terse_tag = "sets i/o to terse mode"; - - namespace in { - void alphabetic_f(); - void bourbaki_f(); - void decimal_f(); - void default_f(); - void gap_f(); - void hexadecimal_f(); - void permutation_f(); - void postfix_f(); - void prefix_f(); - void separator_f(); - void terse_f(); - const char* alphabetic_tag = - "sets alphabetic generator symbols for input"; - const char* bourbaki_tag = "sets Bourbaki conventions for input"; - const char* decimal_tag = "sets decimal generator symbols for input"; - const char* default_tag = "sets default conventions for input"; - const char* gap_tag = "sets GAP conventions for input"; - const char* hexadecimal_tag = - "sets hexadecimal generator symbols for input"; - const char* permutation_tag = - "sets permutation notation for input (in type A only)"; - const char* postfix_tag = "resets the input postfix"; - const char* prefix_tag = "resets the input prefix"; - const char* separator_tag = "resets the input separator"; - const char* symbol_tag = "resets an input symbol"; - const char* terse_tag = "sets terse conventions for input"; - }; - - namespace out { - void alphabetic_f(); - void bourbaki_f(); - void decimal_f(); - void default_f(); - void gap_f(); - void hexadecimal_f(); - void permutation_f(); - void postfix_f(); - void prefix_f(); - void separator_f(); - void terse_f(); - const char* alphabetic_tag = - "sets alphabetic generator symbols for output"; - const char* bourbaki_tag = "sets Bourbaki conventions for output"; - const char* decimal_tag = "sets decimal generator symbols for output"; - const char* default_tag = "sets default conventions for output"; - const char* gap_tag = "sets GAP conventions for output"; - const char* hexadecimal_tag = - "sets hexadecimal generator symbols for output"; - const char* permutation_tag = - "sets permutation notation for output (in type A only)"; - const char* postfix_tag = "resets the output postfix"; - const char* prefix_tag = "resets the output prefix"; - const char* separator_tag = "resets the output separator"; - const char* symbol_tag = "resets an output symbol"; - const char* terse_tag = "sets terse conventions for output"; - }; -}; - -}; +namespace interface { + +GroupEltInterface *in_buf = 0; + +struct In_tag {}; +struct Out_tag {}; + +void in_entry(); +void in_exit(); +void out_entry(); +void out_exit(); + +void abort_f(); +void alphabetic_f(); +void bourbaki_f(); +void default_f(); +void decimal_f(); +void gap_f(); +void hexadecimal_f(); +void in_f(); +void out_f(); +void permutation_f(); +void symbol_f(); +void terse_f(); +void ordering_f(); + +const char *abort_tag = "leaves without modifying the interface"; +const char *alphabetic_tag = "sets alphabetic generator symbols"; +const char *bourbaki_tag = "sets Bourbaki conventions for i/o"; +const char *decimal_tag = "sets decimal generator symbols"; +const char *default_tag = "sets i/o to default mode"; +const char *gap_tag = "sets i/o to GAP mode"; +const char *hexadecimal_tag = "sets hexadecimal generator symbols"; +const char *in_tag = "enters reset-input mode"; +const char *out_tag = "enters reset-output mode"; +const char *permutation_tag = + "sets permutation notation for i/o (in type A only)"; +const char *ordering_tag = "modifies the ordering of the generators"; +const char *terse_tag = "sets i/o to terse mode"; + +namespace in { +void alphabetic_f(); +void bourbaki_f(); +void decimal_f(); +void default_f(); +void gap_f(); +void hexadecimal_f(); +void permutation_f(); +void postfix_f(); +void prefix_f(); +void separator_f(); +void terse_f(); +const char *alphabetic_tag = "sets alphabetic generator symbols for input"; +const char *bourbaki_tag = "sets Bourbaki conventions for input"; +const char *decimal_tag = "sets decimal generator symbols for input"; +const char *default_tag = "sets default conventions for input"; +const char *gap_tag = "sets GAP conventions for input"; +const char *hexadecimal_tag = "sets hexadecimal generator symbols for input"; +const char *permutation_tag = + "sets permutation notation for input (in type A only)"; +const char *postfix_tag = "resets the input postfix"; +const char *prefix_tag = "resets the input prefix"; +const char *separator_tag = "resets the input separator"; +const char *symbol_tag = "resets an input symbol"; +const char *terse_tag = "sets terse conventions for input"; +}; // namespace in + +namespace out { +void alphabetic_f(); +void bourbaki_f(); +void decimal_f(); +void default_f(); +void gap_f(); +void hexadecimal_f(); +void permutation_f(); +void postfix_f(); +void prefix_f(); +void separator_f(); +void terse_f(); +const char *alphabetic_tag = "sets alphabetic generator symbols for output"; +const char *bourbaki_tag = "sets Bourbaki conventions for output"; +const char *decimal_tag = "sets decimal generator symbols for output"; +const char *default_tag = "sets default conventions for output"; +const char *gap_tag = "sets GAP conventions for output"; +const char *hexadecimal_tag = "sets hexadecimal generator symbols for output"; +const char *permutation_tag = + "sets permutation notation for output (in type A only)"; +const char *postfix_tag = "resets the output postfix"; +const char *prefix_tag = "resets the output prefix"; +const char *separator_tag = "resets the output separator"; +const char *symbol_tag = "resets an output symbol"; +const char *terse_tag = "sets terse conventions for output"; +}; // namespace out +}; // namespace interface + +}; // namespace commands /***************************************************************************** @@ -346,51 +341,50 @@ void run() activate(emptyCommandTree()); if (ERRNO) { - Error (ERRNO); + Error(ERRNO); return; } while (1) { /* the only way to exit from this loop is the "qq" command */ - CommandTree* tree = treeStack.top(); + CommandTree *tree = treeStack.top(); tree->prompt(); - getInput(stdin,name); - CommandData* cd = tree->find(name); + getInput(stdin, name); + CommandData *cd = tree->find(name); if (cd == 0) { tree->error(name.ptr()); continue; } if (cd == ambigCommand()) { - ambigAction(tree,name); + ambigAction(tree, name); continue; } cd->action(); if (cd->autorepeat) { - tree->setAction("",cd->action); - tree->setRepeat("",true); - } - else { - tree->setAction("",&relax_f); - tree->setRepeat("",false); + tree->setAction("", cd->action); + tree->setRepeat("", true); + } else { + tree->setAction("", &relax_f); + tree->setRepeat("", false); } } } -void default_error(char* str) +void default_error(char *str) /* Default response to an unknown command. */ { - Error(COMMAND_NOT_FOUND,str); + Error(COMMAND_NOT_FOUND, str); return; } -}; +}; // namespace commands namespace { -void activate(CommandTree* tree) +void activate(CommandTree *tree) /* Puts the tree on top of treeStack, and executes the initialization function. @@ -410,7 +404,7 @@ void activate(CommandTree* tree) return; } -void ambigAction(CommandTree* tree, const String& str) +void ambigAction(CommandTree *tree, const String &str) /* Response to ambiguous commands. Prints a warning and the list of possible @@ -421,28 +415,28 @@ void ambigAction(CommandTree* tree, const String& str) static String name(0); bool b = true; - print(stderr,str); - fprintf(stderr," : ambiguous ("); - DictCell* cell = tree->findCell(str); - new(&name) String(str); - printExtensions(stderr,cell->left,name,b); - fprintf(stderr,")\n"); + print(stderr, str); + fprintf(stderr, " : ambiguous ("); + DictCell *cell = tree->findCell(str); + new (&name) String(str); + printExtensions(stderr, cell->left, name, b); + fprintf(stderr, ")\n"); return; } -void empty_error(char* str) +void empty_error(char *str) { - CommandTree* tree = mainCommandTree(); + CommandTree *tree = mainCommandTree(); - CommandData* cd = tree->find(str); + CommandData *cd = tree->find(str); if (cd == 0) { default_error(str); return; } if (cd == ambigCommand()) { - ambigAction(tree,str); + ambigAction(tree, str); return; } activate(tree); @@ -454,12 +448,11 @@ void empty_error(char* str) if ((cd != tree->find("type")) && (cd != tree->find("rank"))) cd->action(); if (cd->autorepeat) { - tree->setAction("",cd->action); - tree->setRepeat("",true); - } - else { - tree->setAction("",&relax_f); - tree->setRepeat("",false); + tree->setAction("", cd->action); + tree->setRepeat("", true); + } else { + tree->setAction("", &relax_f); + tree->setRepeat("", false); } return; } @@ -480,7 +473,7 @@ void startup() return; } -}; +}; // namespace /***************************************************************************** @@ -538,13 +531,9 @@ void startup() namespace commands { -CommandTree::CommandTree(const char* prompt, - void (*a)(), - void (*entry)(), - void (*error)(char*), - void (*exit)(), - void (*h)()) - :d_prompt(prompt), d_entry(entry), d_error(error), d_exit(exit) +CommandTree::CommandTree(const char *prompt, void (*a)(), void (*entry)(), + void (*error)(char *), void (*exit)(), void (*h)()) + : d_prompt(prompt), d_entry(entry), d_error(error), d_exit(exit) /* Initializes a command tree with the given prompt and action for the @@ -552,12 +541,12 @@ CommandTree::CommandTree(const char* prompt, */ { - d_root->ptr = new CommandData("","",a,&relax_f,false); + d_root->ptr = new CommandData("", "", a, &relax_f, false); if (h) { /* add help functionality */ - d_help = new CommandTree("help",&cr_h,h); - d_help->add("q",q_tag,&q_f,0,false); - add("help",help_tag,&help_f,&help_h,false); + d_help = new CommandTree("help", &cr_h, h); + d_help->add("q", q_tag, &q_f, 0, false); + add("help", help_tag, &help_f, &help_h, false); } } @@ -581,13 +570,13 @@ void CommandTree::prompt() const */ { - printf("%s : ",d_prompt.ptr()); + printf("%s : ", d_prompt.ptr()); } /******** manipulators ******************************************************/ -void CommandTree::add(const char* name, const char* tag, void (*a)(), - void (*h)(), bool rep) +void CommandTree::add(const char *name, const char *tag, void (*a)(), + void (*h)(), bool rep) /* This function adds a new command to the tree, adding new cells as @@ -595,15 +584,15 @@ void CommandTree::add(const char* name, const char* tag, void (*a)(), */ { - CommandData *cd = new CommandData(name,tag,a,h,rep); + CommandData *cd = new CommandData(name, tag, a, h, rep); - insert(name,cd); + insert(name, cd); if (d_help && h) { /* add help functionality */ - d_help->add(name,tag,h,0,false); + d_help->add(name, tag, h, 0, false); } } -void CommandTree::setAction(const char* str, void (*a)()) +void CommandTree::setAction(const char *str, void (*a)()) /* Assuming that str is a fullname on the command tree, sets the response @@ -613,13 +602,13 @@ void CommandTree::setAction(const char* str, void (*a)()) */ { - CommandData* cd = find(str); + CommandData *cd = find(str); cd->action = a; return; } -void CommandTree::setRepeat(const char* str, bool b) +void CommandTree::setRepeat(const char *str, bool b) /* Assuming that str is a fullname on the command tree, sets the autorepeat @@ -627,13 +616,13 @@ void CommandTree::setRepeat(const char* str, bool b) */ { - CommandData* cd = find(str); + CommandData *cd = find(str); cd->autorepeat = b; return; } -}; +}; // namespace commands /***************************************************************************** @@ -648,9 +637,9 @@ void CommandTree::setRepeat(const char* str, bool b) namespace commands { -CommandData::CommandData(const char* const& str, const char* const& t, - void (*a)(), void (*h)(), bool rep) - :name(str), tag(t), action(a), help(h), autorepeat(rep) +CommandData::CommandData(const char *const &str, const char *const &t, + void (*a)(), void (*h)(), bool rep) + : name(str), tag(t), action(a), help(h), autorepeat(rep) {} @@ -662,7 +651,7 @@ CommandData::~CommandData() {} -}; +}; // namespace commands /***************************************************************************** @@ -690,7 +679,7 @@ CommandData::~CommandData() namespace { -CommandData* ambigCommand() +CommandData *ambigCommand() /* Returns a dummy command cell which is a placeholder indicating that @@ -699,11 +688,11 @@ CommandData* ambigCommand() */ { - static CommandData cd("","",0,0,false); + static CommandData cd("", "", 0, 0, false); return &cd; } -void cellCompletion(DictCell* cell) +void cellCompletion(DictCell *cell) /* This function fills in the value fields of the cells which do not @@ -728,7 +717,7 @@ void cellCompletion(DictCell* cell) } } -void commandCompletion(DictCell* cell) +void commandCompletion(DictCell *cell) /* This function finishes up the command tree by implementing command @@ -749,7 +738,8 @@ void commandCompletion(DictCell* cell) commandCompletion(cell->right); } -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the initial command tree of the program. The idea @@ -759,22 +749,22 @@ template<> CommandTree* initCommandTree() */ { - static CommandTree tree("coxeter",&startup,&relax_f,&empty_error,&relax_f, - &intro_h); + static CommandTree tree("coxeter", &startup, &relax_f, &empty_error, &relax_f, + &intro_h); - tree.add("author","author_tag",&author_f,&relax_f,false); - tree.add("qq",qq_tag,&qq_f,&qq_h,false); + tree.add("author", "author_tag", &author_f, &relax_f, false); + tree.add("qq", qq_tag, &qq_f, &qq_h, false); commandCompletion(tree.root()); - tree.helpMode()->add("intro",intro_tag,&intro_h,0,false); + tree.helpMode()->add("intro", intro_tag, &intro_h, 0, false); commandCompletion(tree.helpMode()->root()); return &tree; } -CommandTree* emptyCommandTree() +CommandTree *emptyCommandTree() /* Returns a pointer to the initial command tree of the program, building it on @@ -782,11 +772,12 @@ CommandTree* emptyCommandTree() */ { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the interface command tree; this makes available the @@ -795,34 +786,35 @@ template<> CommandTree* initCommandTree() */ { - static CommandTree tree("interface",&relax_f,&interface_entry,&default_error, - &interface_exit,&interface_help); - - tree.add("alphabetic",commands::interface::alphabetic_tag, - &commands::interface::alphabetic_f,&help::interface::alphabetic_h); - tree.add("bourbaki",commands::interface::bourbaki_tag, - &commands::interface::bourbaki_f,&help::interface::bourbaki_h); - tree.add("decimal",commands::interface::decimal_tag, - &commands::interface::decimal_f,&help::interface::decimal_h); - tree.add("default",commands::interface::default_tag, - &commands::interface::default_f,&help::interface::default_h); - tree.add("gap",commands::interface::out::gap_tag, - &commands::interface::out::gap_f, &help::interface::gap_h); - tree.add("hexadecimal",commands::interface::hexadecimal_tag, - &commands::interface::hexadecimal_f, - &help::interface::hexadecimal_h); - tree.add("in",commands::interface::in_tag,&commands::interface::in_f, - help::interface::in_h,false); - tree.add("ordering",commands::interface::ordering_tag, - &commands::interface::ordering_f,help::interface::ordering_h,false); - tree.add("out",commands::interface::out_tag,&commands::interface::out_f, - help::interface::out_h,false); - tree.add("permutation",commands::interface::permutation_tag, - &commands::interface::permutation_f, - &help::interface::permutation_h); - tree.add("q",q_tag,&q_f,0,false); - tree.add("terse",commands::interface::out::terse_tag, - &commands::interface::out::terse_f, &help::interface::out::terse_h); + static CommandTree tree("interface", &relax_f, &interface_entry, + &default_error, &interface_exit, &interface_help); + + tree.add("alphabetic", commands::interface::alphabetic_tag, + &commands::interface::alphabetic_f, &help::interface::alphabetic_h); + tree.add("bourbaki", commands::interface::bourbaki_tag, + &commands::interface::bourbaki_f, &help::interface::bourbaki_h); + tree.add("decimal", commands::interface::decimal_tag, + &commands::interface::decimal_f, &help::interface::decimal_h); + tree.add("default", commands::interface::default_tag, + &commands::interface::default_f, &help::interface::default_h); + tree.add("gap", commands::interface::out::gap_tag, + &commands::interface::out::gap_f, &help::interface::gap_h); + tree.add("hexadecimal", commands::interface::hexadecimal_tag, + &commands::interface::hexadecimal_f, + &help::interface::hexadecimal_h); + tree.add("in", commands::interface::in_tag, &commands::interface::in_f, + help::interface::in_h, false); + tree.add("ordering", commands::interface::ordering_tag, + &commands::interface::ordering_f, help::interface::ordering_h, + false); + tree.add("out", commands::interface::out_tag, &commands::interface::out_f, + help::interface::out_h, false); + tree.add("permutation", commands::interface::permutation_tag, + &commands::interface::permutation_f, + &help::interface::permutation_h); + tree.add("q", q_tag, &q_f, 0, false); + tree.add("terse", commands::interface::out::terse_tag, + &commands::interface::out::terse_f, &help::interface::out::terse_h); commandCompletion(tree.root()); commandCompletion(tree.helpMode()->root()); @@ -830,7 +822,8 @@ template<> CommandTree* initCommandTree() return &tree; } -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the command tree for the input-modification mode. @@ -839,34 +832,33 @@ template<> CommandTree* initCommandTree() { using namespace commands::interface; - static CommandTree tree("in",&relax_f,&in_entry,&default_error, - &in_exit,&help::interface::in_help); - - tree.add("q",q_tag,&q_f,0,false); - - tree.add("abort",abort_tag,&abort_f,&help::interface::abort_h); - tree.add("alphabetic",in::alphabetic_tag,&in::alphabetic_f, - &help::interface::in::alphabetic_h,false); - tree.add("bourbaki",in::bourbaki_tag,&in::bourbaki_f, - &help::interface::in::bourbaki_h); - tree.add("decimal",in::decimal_tag,&in::decimal_f, - &help::interface::in::decimal_h,false); - tree.add("default",in::default_tag,&in::default_f, - &help::interface::in::default_h); - tree.add("gap",in::gap_tag,&in::gap_f,&help::interface::in::gap_h); - tree.add("hexadecimal",in::hexadecimal_tag,&in::hexadecimal_f, - &help::interface::in::hexadecimal_h,false); - tree.add("permutation",in::permutation_tag,&in::permutation_f, - &help::interface::in::permutation_h,false); - tree.add("postfix",in::postfix_tag,&in::postfix_f, - &help::interface::in::postfix_h); - tree.add("prefix",in::prefix_tag,&in::prefix_f, - &help::interface::in::prefix_h); - tree.add("separator",in::separator_tag, - &in::separator_f,&help::interface::in::separator_h); - tree.add("symbol",in::symbol_tag,&symbol_f, - &help::interface::in::symbol_h); - tree.add("terse",in::terse_tag,&in::terse_f,&help::interface::in::terse_h); + static CommandTree tree("in", &relax_f, &in_entry, &default_error, &in_exit, + &help::interface::in_help); + + tree.add("q", q_tag, &q_f, 0, false); + + tree.add("abort", abort_tag, &abort_f, &help::interface::abort_h); + tree.add("alphabetic", in::alphabetic_tag, &in::alphabetic_f, + &help::interface::in::alphabetic_h, false); + tree.add("bourbaki", in::bourbaki_tag, &in::bourbaki_f, + &help::interface::in::bourbaki_h); + tree.add("decimal", in::decimal_tag, &in::decimal_f, + &help::interface::in::decimal_h, false); + tree.add("default", in::default_tag, &in::default_f, + &help::interface::in::default_h); + tree.add("gap", in::gap_tag, &in::gap_f, &help::interface::in::gap_h); + tree.add("hexadecimal", in::hexadecimal_tag, &in::hexadecimal_f, + &help::interface::in::hexadecimal_h, false); + tree.add("permutation", in::permutation_tag, &in::permutation_f, + &help::interface::in::permutation_h, false); + tree.add("postfix", in::postfix_tag, &in::postfix_f, + &help::interface::in::postfix_h); + tree.add("prefix", in::prefix_tag, &in::prefix_f, + &help::interface::in::prefix_h); + tree.add("separator", in::separator_tag, &in::separator_f, + &help::interface::in::separator_h); + tree.add("symbol", in::symbol_tag, &symbol_f, &help::interface::in::symbol_h); + tree.add("terse", in::terse_tag, &in::terse_f, &help::interface::in::terse_h); commandCompletion(tree.root()); commandCompletion(tree.helpMode()->root()); @@ -874,7 +866,8 @@ template<> CommandTree* initCommandTree() return &tree; } -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the command tree for the output-modification mode. @@ -883,35 +876,34 @@ template<> CommandTree* initCommandTree() { using namespace commands::interface; - static CommandTree tree("out",&relax_f,&out_entry,&default_error, - &out_exit,&help::interface::out_help); - - tree.add("q",q_tag,&q_f,0,false); - - tree.add("alphabetic",out::alphabetic_tag,&out::alphabetic_f, - &help::interface::out::alphabetic_h,false); - tree.add("bourbaki",out::bourbaki_tag,&out::bourbaki_f, - &help::interface::out::bourbaki_h); - tree.add("decimal",out::decimal_tag,&out::decimal_f, - &help::interface::out::decimal_h,false); - tree.add("default",out::default_tag,&out::default_f, - &help::interface::out::default_h); - tree.add("gap",out::gap_tag,&out::gap_f, - &help::interface::out::gap_h); - tree.add("hexadecimal",out::hexadecimal_tag,&out::hexadecimal_f, - &help::interface::out::hexadecimal_h,false); - tree.add("permutation",out::permutation_tag,&out::permutation_f, - &help::interface::out::permutation_h,false); - tree.add("postfix",out::postfix_tag,&out::postfix_f, - &help::interface::out::postfix_h); - tree.add("prefix",out::prefix_tag,&out::prefix_f, - &help::interface::out::prefix_h); - tree.add("separator",out::separator_tag, - &out::separator_f,&help::interface::out::separator_h); - tree.add("symbol",out::symbol_tag,&symbol_f, - &help::interface::out::symbol_h); - tree.add("terse",out::terse_tag,&out::terse_f, - &help::interface::out::terse_h); + static CommandTree tree("out", &relax_f, &out_entry, &default_error, + &out_exit, &help::interface::out_help); + + tree.add("q", q_tag, &q_f, 0, false); + + tree.add("alphabetic", out::alphabetic_tag, &out::alphabetic_f, + &help::interface::out::alphabetic_h, false); + tree.add("bourbaki", out::bourbaki_tag, &out::bourbaki_f, + &help::interface::out::bourbaki_h); + tree.add("decimal", out::decimal_tag, &out::decimal_f, + &help::interface::out::decimal_h, false); + tree.add("default", out::default_tag, &out::default_f, + &help::interface::out::default_h); + tree.add("gap", out::gap_tag, &out::gap_f, &help::interface::out::gap_h); + tree.add("hexadecimal", out::hexadecimal_tag, &out::hexadecimal_f, + &help::interface::out::hexadecimal_h, false); + tree.add("permutation", out::permutation_tag, &out::permutation_f, + &help::interface::out::permutation_h, false); + tree.add("postfix", out::postfix_tag, &out::postfix_f, + &help::interface::out::postfix_h); + tree.add("prefix", out::prefix_tag, &out::prefix_f, + &help::interface::out::prefix_h); + tree.add("separator", out::separator_tag, &out::separator_f, + &help::interface::out::separator_h); + tree.add("symbol", out::symbol_tag, &symbol_f, + &help::interface::out::symbol_h); + tree.add("terse", out::terse_tag, &out::terse_f, + &help::interface::out::terse_h); commandCompletion(tree.root()); commandCompletion(tree.helpMode()->root()); @@ -919,25 +911,25 @@ template<> CommandTree* initCommandTree() return &tree; } -}; +}; // namespace namespace commands { -CommandTree* interface::inCommandTree() +CommandTree *interface::inCommandTree() { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -CommandTree* interface::outCommandTree() +CommandTree *interface::outCommandTree() { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -CommandTree* interfaceCommandTree() +CommandTree *interfaceCommandTree() /* Returns a pointer to the interface command tree, building it on the first @@ -945,15 +937,16 @@ CommandTree* interfaceCommandTree() */ { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -}; +}; // namespace commands namespace { -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the main command tree, the one that is being run on @@ -962,67 +955,67 @@ template<> CommandTree* initCommandTree() */ { - static CommandTree tree("coxeter",&relax_f,&main_entry,&default_error, - &main_exit,&main_help); - - tree.add("author",author_tag,&author_f,&relax_f,false); - tree.add("betti",betti_tag,&betti_f,&betti_h,false); - tree.add("coatoms",coatoms_tag,&coatoms_f,&coatoms_h); - tree.add("compute",compute_tag,&compute_f,&compute_h); - tree.add("descent",descent_tag,&descent_f,&descent_h); - tree.add("duflo",duflo_tag,&duflo_f,&duflo_h); - tree.add("extremals",extremals_tag,&extremals_f,&extremals_h); - tree.add("fullcontext",fullcontext_tag,&fullcontext_f,&fullcontext_h); - tree.add("ihbetti",ihbetti_tag,&ihbetti_f,&ihbetti_h,false); - tree.add("interface",interface_tag,&interface_f,&interface_h,false); - tree.add("interval",interval_tag,&interval_f,&interval_h,false); - tree.add("inorder",inorder_tag,&inorder_f,&inorder_h); - tree.add("invpol",invpol_tag,&invpol_f,&invpol_h); - tree.add("lcorder",lcorder_tag,&lcorder_f,&lcorder_h,false); - tree.add("lcells",lcells_tag,&lcells_f,&lcells_h,false); - tree.add("lcwgraphs",lcwgraphs_tag,&lcwgraphs_f,&lcwgraphs_h,false); - tree.add("lrcorder",lrcorder_tag,&lrcorder_f,&lrcorder_h,false); - tree.add("lrcells",lrcells_tag,&lrcells_f,&lrcells_h,false); - tree.add("lrcwgraphs",lrcwgraphs_tag,&lrcwgraphs_f,&lrcwgraphs_h,false); - tree.add("lrwgraph",lrwgraph_tag,&lrwgraph_f,&lrwgraph_h,false); - tree.add("lwgraph",lwgraph_tag,&lwgraph_f,&lwgraph_h,false); - tree.add("klbasis",klbasis_tag,&klbasis_f,&klbasis_h,true); - tree.add("matrix",matrix_tag,&matrix_f,&matrix_h); - tree.add("mu",mu_tag,&mu_f,&mu_h); - tree.add("pol",pol_tag,&pol_f,&pol_h); - tree.add("q",q_tag,&q_f,0,false); - tree.add("qq",qq_tag,&qq_f,&qq_h,false); - tree.add("rank",rank_tag,&rank_f,&rank_h,false); - tree.add("rcorder",rcorder_tag,&rcorder_f,&rcorder_h,false); - tree.add("rcells",rcells_tag,&rcells_f,&rcells_h,false); - tree.add("rcwgraphs",rcwgraphs_tag,&rcwgraphs_f,&rcwgraphs_h,false); - tree.add("rwgraph",rwgraph_tag,&rwgraph_f,&rwgraph_h,false); - tree.add("schubert",schubert_tag,&schubert_f,&schubert_h); - tree.add("show",show_tag,&show_f,&show_h); - tree.add("showmu",showmu_tag,&showmu_f,&showmu_h); - tree.add("slocus",slocus_tag,&slocus_f,&slocus_h); - tree.add("sstratification",sstratification_tag,&sstratification_f, - &sstratification_h); - tree.add("type",type_tag,&type_f,&type_h,false); - tree.add("uneq",uneq_tag,&uneq_f,&uneq_h,false); + static CommandTree tree("coxeter", &relax_f, &main_entry, &default_error, + &main_exit, &main_help); + + tree.add("author", author_tag, &author_f, &relax_f, false); + tree.add("betti", betti_tag, &betti_f, &betti_h, false); + tree.add("coatoms", coatoms_tag, &coatoms_f, &coatoms_h); + tree.add("compute", compute_tag, &compute_f, &compute_h); + tree.add("descent", descent_tag, &descent_f, &descent_h); + tree.add("duflo", duflo_tag, &duflo_f, &duflo_h); + tree.add("extremals", extremals_tag, &extremals_f, &extremals_h); + tree.add("fullcontext", fullcontext_tag, &fullcontext_f, &fullcontext_h); + tree.add("ihbetti", ihbetti_tag, &ihbetti_f, &ihbetti_h, false); + tree.add("interface", interface_tag, &interface_f, &interface_h, false); + tree.add("interval", interval_tag, &interval_f, &interval_h, false); + tree.add("inorder", inorder_tag, &inorder_f, &inorder_h); + tree.add("invpol", invpol_tag, &invpol_f, &invpol_h); + tree.add("lcorder", lcorder_tag, &lcorder_f, &lcorder_h, false); + tree.add("lcells", lcells_tag, &lcells_f, &lcells_h, false); + tree.add("lcwgraphs", lcwgraphs_tag, &lcwgraphs_f, &lcwgraphs_h, false); + tree.add("lrcorder", lrcorder_tag, &lrcorder_f, &lrcorder_h, false); + tree.add("lrcells", lrcells_tag, &lrcells_f, &lrcells_h, false); + tree.add("lrcwgraphs", lrcwgraphs_tag, &lrcwgraphs_f, &lrcwgraphs_h, false); + tree.add("lrwgraph", lrwgraph_tag, &lrwgraph_f, &lrwgraph_h, false); + tree.add("lwgraph", lwgraph_tag, &lwgraph_f, &lwgraph_h, false); + tree.add("klbasis", klbasis_tag, &klbasis_f, &klbasis_h, true); + tree.add("matrix", matrix_tag, &matrix_f, &matrix_h); + tree.add("mu", mu_tag, &mu_f, &mu_h); + tree.add("pol", pol_tag, &pol_f, &pol_h); + tree.add("q", q_tag, &q_f, 0, false); + tree.add("qq", qq_tag, &qq_f, &qq_h, false); + tree.add("rank", rank_tag, &rank_f, &rank_h, false); + tree.add("rcorder", rcorder_tag, &rcorder_f, &rcorder_h, false); + tree.add("rcells", rcells_tag, &rcells_f, &rcells_h, false); + tree.add("rcwgraphs", rcwgraphs_tag, &rcwgraphs_f, &rcwgraphs_h, false); + tree.add("rwgraph", rwgraph_tag, &rwgraph_f, &rwgraph_h, false); + tree.add("schubert", schubert_tag, &schubert_f, &schubert_h); + tree.add("show", show_tag, &show_f, &show_h); + tree.add("showmu", showmu_tag, &showmu_f, &showmu_h); + tree.add("slocus", slocus_tag, &slocus_f, &slocus_h); + tree.add("sstratification", sstratification_tag, &sstratification_f, + &sstratification_h); + tree.add("type", type_tag, &type_f, &type_h, false); + tree.add("uneq", uneq_tag, &uneq_f, &uneq_h, false); special::addSpecialCommands(&tree); commandCompletion(tree.root()); - tree.helpMode()->add("intro",intro_tag,&intro_h,0,false); - tree.helpMode()->add("input",input_tag,&input_h,0,false); + tree.helpMode()->add("intro", intro_tag, &intro_h, 0, false); + tree.helpMode()->add("input", input_tag, &input_h, 0, false); commandCompletion(tree.helpMode()->root()); return &tree; } -}; +}; // namespace namespace commands { -CommandTree* mainCommandTree() +CommandTree *mainCommandTree() /* Returns a pointer to the main command tree of the program, building it on @@ -1030,15 +1023,16 @@ CommandTree* mainCommandTree() */ { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -}; +}; // namespace commands namespace { -template<> CommandTree* initCommandTree() +template <> +CommandTree *initCommandTree() /* This function builds the unequal-parameter command tree. It contains @@ -1047,33 +1041,34 @@ template<> CommandTree* initCommandTree() */ { - static CommandTree tree("uneq",&relax_f,&uneq_entry,&default_error, - &uneq_exit,&uneq_help); - - tree.add("author",author_tag,&author_f,&relax_f,false); - tree.add("coatoms",coatoms_tag,&coatoms_f,&coatoms_h); - tree.add("compute",compute_tag,&compute_f,&compute_h); - tree.add("descent",descent_tag,&descent_f,&descent_h); - tree.add("fullcontext",fullcontext_tag,&fullcontext_f,&fullcontext_h); - tree.add("interface",interface_tag,&interface_f,&interface_h,false); - tree.add("klbasis",klbasis_tag,&uneq::klbasis_f,&help::uneq::klbasis_h,true); - tree.add("lcorder",uneq::lcorder_tag,&uneq::lcorder_f, - &help::uneq::lcorder_h,false); - tree.add("lrcorder",uneq::lrcorder_tag,&uneq::lrcorder_f, - &help::uneq::lrcorder_h,false); - tree.add("lcells",uneq::lcells_tag,&uneq::lcells_f,&help::uneq::lcells_h, - false); - tree.add("lrcells",uneq::lrcells_tag,&uneq::lrcells_f,&help::uneq::lrcells_h, - false); - tree.add("matrix",matrix_tag,&matrix_f,&matrix_h); - tree.add("mu",uneq::mu_tag,&uneq::mu_f,&help::uneq::mu_h); - tree.add("pol",uneq::pol_tag,&uneq::pol_f,&help::uneq::pol_h); - tree.add("rcells",uneq::rcells_tag,&uneq::rcells_f,&help::uneq::rcells_h, - false); - tree.add("rcorder",uneq::rcorder_tag,&uneq::rcorder_f, - &help::uneq::rcorder_h,false); - tree.add("q",q_tag,&q_f,0,false); - tree.add("qq",qq_tag,&qq_f,&qq_h,false); + static CommandTree tree("uneq", &relax_f, &uneq_entry, &default_error, + &uneq_exit, &uneq_help); + + tree.add("author", author_tag, &author_f, &relax_f, false); + tree.add("coatoms", coatoms_tag, &coatoms_f, &coatoms_h); + tree.add("compute", compute_tag, &compute_f, &compute_h); + tree.add("descent", descent_tag, &descent_f, &descent_h); + tree.add("fullcontext", fullcontext_tag, &fullcontext_f, &fullcontext_h); + tree.add("interface", interface_tag, &interface_f, &interface_h, false); + tree.add("klbasis", klbasis_tag, &uneq::klbasis_f, &help::uneq::klbasis_h, + true); + tree.add("lcorder", uneq::lcorder_tag, &uneq::lcorder_f, + &help::uneq::lcorder_h, false); + tree.add("lrcorder", uneq::lrcorder_tag, &uneq::lrcorder_f, + &help::uneq::lrcorder_h, false); + tree.add("lcells", uneq::lcells_tag, &uneq::lcells_f, &help::uneq::lcells_h, + false); + tree.add("lrcells", uneq::lrcells_tag, &uneq::lrcells_f, + &help::uneq::lrcells_h, false); + tree.add("matrix", matrix_tag, &matrix_f, &matrix_h); + tree.add("mu", uneq::mu_tag, &uneq::mu_f, &help::uneq::mu_h); + tree.add("pol", uneq::pol_tag, &uneq::pol_f, &help::uneq::pol_h); + tree.add("rcells", uneq::rcells_tag, &uneq::rcells_f, &help::uneq::rcells_h, + false); + tree.add("rcorder", uneq::rcorder_tag, &uneq::rcorder_f, + &help::uneq::rcorder_h, false); + tree.add("q", q_tag, &q_f, 0, false); + tree.add("qq", qq_tag, &qq_f, &qq_h, false); commandCompletion(tree.root()); commandCompletion(tree.helpMode()->root()); @@ -1081,22 +1076,22 @@ template<> CommandTree* initCommandTree() return &tree; } -}; +}; // namespace namespace commands { -CommandTree* uneqCommandTree() +CommandTree *uneqCommandTree() /* Returns a pointer to the uneq command tree, building it on the first call. */ { - static CommandTree* tree = initCommandTree(); + static CommandTree *tree = initCommandTree(); return tree; } -}; +}; // namespace commands /***************************************************************************** @@ -1206,7 +1201,7 @@ void author_f() */ { - printFile(stderr,"author.mess",MESSAGE_DIR); + printFile(stderr, "author.mess", MESSAGE_DIR); return; } @@ -1235,8 +1230,8 @@ void betti_f() return; } - OutputTraits& traits = W->outputTraits(); - printBetti(stdout,y,W->schubert(),traits); + OutputTraits &traits = W->outputTraits(); + printBetti(stdout, y, W->schubert(), traits); return; } @@ -1259,10 +1254,10 @@ void coatoms_f() } List c(0); - W->coatoms(c,g); + W->coatoms(c, g); for (Ulong j = 0; j < c.size(); ++j) { - W->print(stdout,c[j]); + W->print(stdout, c[j]); printf("\n"); } @@ -1285,15 +1280,15 @@ void compute_f() return; } W->normalForm(g); - W->print(stdout,g); - if (SmallCoxGroup* Ws = dynamic_cast (W)) { + W->print(stdout, g); + if (SmallCoxGroup *Ws = dynamic_cast(W)) { CoxNbr x = 0; - Ws->prodD(x,g); - printf(" (#%lu)",static_cast(x)); + Ws->prodD(x, g); + printf(" (#%lu)", static_cast(x)); } CoxNbr x = W->contextNumber(g); if (x != undef_coxnbr) - printf(" (%s%lu)","%",static_cast(x)); + printf(" (%s%lu)", "%", static_cast(x)); printf("\n"); return; @@ -1317,10 +1312,10 @@ void descent_f() LFlags f = W->ldescent(g); printf("L:"); - W->printFlags(stdout,f); + W->printFlags(stdout, f); printf("; R:"); f = W->rdescent(g); - W->printFlags(stdout,f); + W->printFlags(stdout, f); printf("\n"); return; @@ -1334,11 +1329,11 @@ void duflo_f() { if (!isFiniteType(W)) { - printFile(stderr,"duflo.mess",MESSAGE_DIR); + printFile(stderr, "duflo.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -1353,10 +1348,11 @@ void duflo_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),dufloH,traits); - printDuflo(file.f(),Wf->duflo(),Wf->lCell(),Wf->kl(),W->interface(),traits); + printHeader(file.f(), dufloH, traits); + printDuflo(file.f(), Wf->duflo(), Wf->lCell(), Wf->kl(), W->interface(), + traits); return; } @@ -1385,10 +1381,10 @@ void extremals_f() } interactive::OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),extremalsH,traits); - printExtremals(file.f(),y,W->kl(),W->interface(),traits); + printHeader(file.f(), extremalsH, traits); + printExtremals(file.f(), y, W->kl(), W->interface(), traits); return; } @@ -1402,11 +1398,11 @@ void fullcontext_f() { if (!isFiniteType(W)) { - printFile(stderr,"fullcontext.mess",MESSAGE_DIR); + printFile(stderr, "fullcontext.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -1449,8 +1445,8 @@ void ihbetti_f() return; } - OutputTraits& traits = W->outputTraits(); - printIHBetti(stdout,y,W->kl(),traits); + OutputTraits &traits = W->outputTraits(); + printIHBetti(stdout, y, W->kl(), traits); return; } @@ -1476,21 +1472,21 @@ void interval_f() CoxWord g(0); CoxWord h(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); h = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); return; } - if (not W->inOrder(g,h)) { - fprintf(stderr,"the two elements are not in order\n"); + if (not W->inOrder(g, h)) { + fprintf(stderr, "the two elements are not in order\n"); return; } @@ -1502,28 +1498,28 @@ void interval_f() OutputFile file; BitMap b(W->contextSize()); - W->extractClosure(b,y); + W->extractClosure(b, y); BitMap::ReverseIterator b_rend = b.rend(); List res(0); for (BitMap::ReverseIterator i = b.rbegin(); i != b_rend; ++i) - if (not W->inOrder(x,*i)) { + if (not W->inOrder(x, *i)) { BitMap bi(W->contextSize()); - W->extractClosure(bi,*i); + W->extractClosure(bi, *i); CoxNbr z = *i; // andnot will invalidate iterator b.andnot(bi); - b.setBit(z); // otherwise the decrement will not be correct + b.setBit(z); // otherwise the decrement will not be correct } else res.append(*i); - schubert::NFCompare nfc(W->schubert(),W->ordering()); + schubert::NFCompare nfc(W->schubert(), W->ordering()); Permutation a(res.size()); - sortI(res,nfc,a); + sortI(res, nfc, a); for (size_t j = 0; j < res.size(); ++j) { - W->print(file.f(),res[a[j]]); - fprintf(file.f(),"\n"); + W->print(file.f(), res[a[j]]); + fprintf(file.f(), "\n"); } return; @@ -1542,38 +1538,37 @@ void inorder_f() CoxWord h(0); List a(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); h = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); return; } - if (W->inOrder(a,g,h)) { - fprintf(stdout,"true : "); + if (W->inOrder(a, g, h)) { + fprintf(stdout, "true : "); Ulong i = 0; for (Ulong j = 0; j < a.size(); ++j) { while (i < a[j]) { - W->printSymbol(stdout,h[i]-1); - ++i; + W->printSymbol(stdout, h[i] - 1); + ++i; } - fprintf(stdout,"."); + fprintf(stdout, "."); ++i; } while (i < h.length()) { - W->printSymbol(stdout,h[i]-1); + W->printSymbol(stdout, h[i] - 1); ++i; } - fprintf(stdout,"\n"); - } - else - fprintf(stdout,"false\n"); + fprintf(stdout, "\n"); + } else + fprintf(stdout, "false\n"); } void invpol_f() @@ -1586,7 +1581,7 @@ void invpol_f() { CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -1598,7 +1593,7 @@ void invpol_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -1610,18 +1605,18 @@ void invpol_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - const invkl::KLPol& pol = W->invklPol(x,y); + const invkl::KLPol &pol = W->invklPol(x, y); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); return; } - print(stdout,pol,"q"); + print(stdout, pol, "q"); printf("\n"); return; @@ -1652,17 +1647,17 @@ void klbasis_f() kl::HeckeElt h(0); - W->cBasis(h,y); + W->cBasis(h, y); if (ERRNO) { Error(ERRNO); return; } interactive::OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),basisH,traits); - printAsBasisElt(file.f(),h,W->schubert(),W->interface(),traits); + printHeader(file.f(), basisH, traits); + printAsBasisElt(file.f(), h, W->schubert(), W->interface(), traits); return; } @@ -1676,11 +1671,11 @@ void lcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcorder.mess",MESSAGE_DIR); + printFile(stderr, "lcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -1695,10 +1690,10 @@ void lcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lCOrderH,traits); - printLCOrder(file.f(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), lCOrderH, traits); + printLCOrder(file.f(), Wf->kl(), Wf->interface(), traits); return; } @@ -1711,17 +1706,17 @@ void lcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcells.mess",MESSAGE_DIR); + printFile(stderr, "lcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lCellsH,traits); - printLCells(file.f(),Wf->lCell(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), lCellsH, traits); + printLCells(file.f(), Wf->lCell(), Wf->kl(), Wf->interface(), traits); return; } @@ -1735,17 +1730,17 @@ void lcwgraphs_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcells.mess",MESSAGE_DIR); + printFile(stderr, "lcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lCellWGraphsH,traits); - printLCellWGraphs(file.f(),Wf->lCell(),Wf->kl(),W->interface(),traits); + printHeader(file.f(), lCellWGraphsH, traits); + printLCellWGraphs(file.f(), Wf->lCell(), Wf->kl(), W->interface(), traits); return; } @@ -1759,11 +1754,11 @@ void lrcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"lrcorder.mess",MESSAGE_DIR); + printFile(stderr, "lrcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -1778,10 +1773,10 @@ void lrcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lrCOrderH,traits); - printLRCOrder(file.f(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), lrCOrderH, traits); + printLRCOrder(file.f(), Wf->kl(), Wf->interface(), traits); return; } @@ -1795,11 +1790,11 @@ void lrcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"lrcells.mess",MESSAGE_DIR); + printFile(stderr, "lrcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -1814,10 +1809,10 @@ void lrcells_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lrCellsH,traits); - printLRCells(file.f(),Wf->lrCell(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), lrCellsH, traits); + printLRCells(file.f(), Wf->lrCell(), Wf->kl(), Wf->interface(), traits); return; } @@ -1831,17 +1826,17 @@ void lrcwgraphs_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcells.mess",MESSAGE_DIR); + printFile(stderr, "lcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lrCellWGraphsH,traits); - printLRCellWGraphs(file.f(),Wf->lrCell(),Wf->kl(),W->interface(),traits); + printHeader(file.f(), lrCellWGraphsH, traits); + printLRCellWGraphs(file.f(), Wf->lrCell(), Wf->kl(), W->interface(), traits); return; } @@ -1854,7 +1849,7 @@ void lrwgraph_f() { if (!W->isFullContext() && wgraph_warning) { - printFile(stderr,"wgraph.mess",MESSAGE_DIR); + printFile(stderr, "wgraph.mess", MESSAGE_DIR); printf("continue ? y/n\n"); if (!yesNo()) return; @@ -1870,10 +1865,10 @@ void lrwgraph_f() } OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),lrWGraphH,traits); - printLRWGraph(file.f(),W->kl(),W->interface(),traits); + printHeader(file.f(), lrWGraphH, traits); + printLRWGraph(file.f(), W->kl(), W->interface(), traits); return; } @@ -1886,7 +1881,7 @@ void lwgraph_f() { if (!W->isFullContext() && wgraph_warning) { - printFile(stderr,"wgraph.mess",MESSAGE_DIR); + printFile(stderr, "wgraph.mess", MESSAGE_DIR); printf("continue ? y/n\n"); if (!yesNo()) return; @@ -1902,10 +1897,10 @@ void lwgraph_f() } OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),lWGraphH,traits); - printLWGraph(file.f(),W->kl(),W->interface(),traits); + printHeader(file.f(), lWGraphH, traits); + printLWGraph(file.f(), W->kl(), W->interface(), traits); return; } @@ -1917,7 +1912,7 @@ void matrix_f() */ { - interactive::printMatrix(stdout,W); + interactive::printMatrix(stdout, W); return; } @@ -1929,9 +1924,8 @@ void not_implemented_f() */ { - fprintf(stderr,"Sorry, not implemented yet\n"); + fprintf(stderr, "Sorry, not implemented yet\n"); return; - } void mu_f() @@ -1944,7 +1938,7 @@ void mu_f() { static CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); CoxNbr x = W->extendContext(g); if (ERRNO) { @@ -1952,7 +1946,7 @@ void mu_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -1964,18 +1958,18 @@ void mu_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - KLCoeff mu = W->mu(x,y); + KLCoeff mu = W->mu(x, y); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); return; } - printf("%lu\n",static_cast(mu)); + printf("%lu\n", static_cast(mu)); return; } @@ -1990,7 +1984,7 @@ void pol_f() { static CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2002,7 +1996,7 @@ void pol_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2014,18 +2008,18 @@ void pol_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - const kl::KLPol& pol = W->klPol(x,y); + const kl::KLPol &pol = W->klPol(x, y); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); return; } - print(stdout,pol,"q"); + print(stdout, pol, "q"); printf("\n"); return; @@ -2039,7 +2033,7 @@ void q_f() */ { - CommandTree* tree = treeStack.top(); + CommandTree *tree = treeStack.top(); tree->exit(); if (ERRNO) { @@ -2059,8 +2053,8 @@ void qq_f() */ { - while(treeStack.size()) { - CommandTree* tree = treeStack.top(); + while (treeStack.size()) { + CommandTree *tree = treeStack.top(); tree->exit(); treeStack.pop(); } @@ -2075,12 +2069,11 @@ void rank_f() */ { - CoxGroup* Wloc = interactive::allocCoxGroup(W->type()); + CoxGroup *Wloc = interactive::allocCoxGroup(W->type()); if (ERRNO) { Error(ERRNO); - } - else { + } else { W = Wloc; } @@ -2096,11 +2089,11 @@ void rcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"rcorder.mess",MESSAGE_DIR); + printFile(stderr, "rcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2115,10 +2108,10 @@ void rcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),rCOrderH,traits); - printRCOrder(file.f(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), rCOrderH, traits); + printRCOrder(file.f(), Wf->kl(), Wf->interface(), traits); return; } @@ -2132,11 +2125,11 @@ void rcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"rcells.mess",MESSAGE_DIR); + printFile(stderr, "rcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2151,10 +2144,10 @@ void rcells_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),rCellsH,traits); - printRCells(file.f(),Wf->rCell(),Wf->kl(),Wf->interface(),traits); + printHeader(file.f(), rCellsH, traits); + printRCells(file.f(), Wf->rCell(), Wf->kl(), Wf->interface(), traits); return; } @@ -2168,17 +2161,17 @@ void rcwgraphs_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcells.mess",MESSAGE_DIR); + printFile(stderr, "lcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),rCellWGraphsH,traits); - printRCellWGraphs(file.f(),Wf->rCell(),Wf->kl(),W->interface(),traits); + printHeader(file.f(), rCellWGraphsH, traits); + printRCellWGraphs(file.f(), Wf->rCell(), Wf->kl(), W->interface(), traits); return; } @@ -2191,7 +2184,7 @@ void rwgraph_f() { if (!W->isFullContext() && wgraph_warning) { - printFile(stderr,"wgraph.mess",MESSAGE_DIR); + printFile(stderr, "wgraph.mess", MESSAGE_DIR); printf("continue ? y/n\n"); if (!yesNo()) return; @@ -2207,10 +2200,10 @@ void rwgraph_f() } OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),rWGraphH,traits); - printRWGraph(file.f(),W->kl(),W->interface(),traits); + printHeader(file.f(), rWGraphH, traits); + printRWGraph(file.f(), W->kl(), W->interface(), traits); return; } @@ -2241,10 +2234,10 @@ void schubert_f() } interactive::OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),closureH,traits); - printClosure(file.f(),y,W->kl(),W->interface(),traits); + printHeader(file.f(), closureH, traits); + printClosure(file.f(), y, W->kl(), W->interface(), traits); return; } @@ -2261,7 +2254,7 @@ void show_f() { static CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2273,7 +2266,7 @@ void show_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2285,21 +2278,21 @@ void show_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - fprintf(stdout,"generator (carriage return for default) : "); + fprintf(stdout, "generator (carriage return for default) : "); LFlags f = W->descent(y); - Generator s = interactive::getGenerator(W,f); + Generator s = interactive::getGenerator(W, f); if (ERRNO) { - Error (ERRNO); + Error(ERRNO); return; } interactive::OutputFile file; - showKLPol(file.f(),W->kl(),x,y,W->interface(),s); + showKLPol(file.f(), W->kl(), x, y, W->interface(), s); return; } @@ -2316,7 +2309,7 @@ void showmu_f() { static CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2328,7 +2321,7 @@ void showmu_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2340,18 +2333,18 @@ void showmu_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } interactive::OutputFile file; - showMu(file.f(),W->kl(),x,y,W->interface()); + showMu(file.f(), W->kl(), x, y, W->interface()); return; } -void slocus_f () +void slocus_f() /* Response to the slocus command. Prints out the singular locus of the @@ -2375,15 +2368,15 @@ void slocus_f () } OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),slocusH,traits); - printSingularLocus(file.f(),y,W->kl(),W->interface(),traits); + printHeader(file.f(), slocusH, traits); + printSingularLocus(file.f(), y, W->kl(), W->interface(), traits); return; } -void sstratification_f () +void sstratification_f() /* Response to the slocus command. Prints out the singular locus of the @@ -2407,10 +2400,10 @@ void sstratification_f () } OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),sstratificationH,traits); - printSingularStratification(file.f(),y,W->kl(),W->interface(),traits); + printHeader(file.f(), sstratificationH, traits); + printSingularStratification(file.f(), y, W->kl(), W->interface(), traits); return; } @@ -2423,12 +2416,11 @@ void type_f() */ { - CoxGroup* Wloc = interactive::allocCoxGroup(); + CoxGroup *Wloc = interactive::allocCoxGroup(); if (ERRNO) { Error(ERRNO); - } - else { + } else { delete W; wgraph_warning = true; W = Wloc; @@ -2475,17 +2467,17 @@ void klbasis_f() uneqkl::HeckeElt h(0); - W->uneqcBasis(h,y); + W->uneqcBasis(h, y); if (ERRNO) { Error(ERRNO); return; } interactive::OutputFile file; - OutputTraits& traits = W->outputTraits(); + OutputTraits &traits = W->outputTraits(); - printHeader(file.f(),basisH,traits); - printAsBasisElt(file.f(),h,W->schubert(),W->interface(),traits); + printHeader(file.f(), basisH, traits); + printAsBasisElt(file.f(), h, W->schubert(), W->interface(), traits); return; } @@ -2498,11 +2490,11 @@ void lcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcells.mess",MESSAGE_DIR); + printFile(stderr, "lcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2517,10 +2509,10 @@ void lcells_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lCellsH,traits); - printLCells(file.f(),Wf->lUneqCell(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), lCellsH, traits); + printLCells(file.f(), Wf->lUneqCell(), Wf->uneqkl(), Wf->interface(), traits); return; } @@ -2534,11 +2526,11 @@ void lcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"lcorder.mess",MESSAGE_DIR); + printFile(stderr, "lcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2553,10 +2545,10 @@ void lcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lCOrderH,traits); - printLCOrder(file.f(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), lCOrderH, traits); + printLCOrder(file.f(), Wf->uneqkl(), Wf->interface(), traits); return; } @@ -2570,11 +2562,11 @@ void lrcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"uneq/lrcorder.mess",MESSAGE_DIR); + printFile(stderr, "uneq/lrcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2589,10 +2581,10 @@ void lrcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lrCOrderH,traits); - printLRCOrder(file.f(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), lrCOrderH, traits); + printLRCOrder(file.f(), Wf->uneqkl(), Wf->interface(), traits); return; } @@ -2606,11 +2598,11 @@ void lrcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"uneq/lrcells.mess",MESSAGE_DIR); + printFile(stderr, "uneq/lrcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2625,10 +2617,11 @@ void lrcells_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),lrCellsH,traits); - printLRCells(file.f(),Wf->lrUneqCell(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), lrCellsH, traits); + printLRCells(file.f(), Wf->lrUneqCell(), Wf->uneqkl(), Wf->interface(), + traits); return; } @@ -2646,7 +2639,7 @@ void mu_f() static CoxWord g(0); bool leftAction = false; - fprintf(stdout,"generator : "); + fprintf(stdout, "generator : "); Generator s = getGenerator(W); if (s >= W->rank()) { // action is on the left @@ -2654,12 +2647,12 @@ void mu_f() leftAction = true; } - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (leftAction) W->inverse(g); - if (!W->isDescent(g,s)) { // mu(s,x,y) is undefined - fprintf(stderr,"xs is greater than x\n"); + if (!W->isDescent(g, s)) { // mu(s,x,y) is undefined + fprintf(stderr, "xs is greater than x\n"); return; } CoxNbr x = W->extendContext(g); @@ -2668,12 +2661,12 @@ void mu_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (leftAction) W->inverse(g); - if (W->isDescent(g,s)) { // mu(s,x,y) is undefined - fprintf(stderr,"ys is smaller than y\n"); + if (W->isDescent(g, s)) { // mu(s,x,y) is undefined + fprintf(stderr, "ys is smaller than y\n"); return; } if (ERRNO) { @@ -2687,22 +2680,22 @@ void mu_f() } if (x == y) { - fprintf(stderr,"the two elements are equal\n"); + fprintf(stderr, "the two elements are equal\n"); return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - const uneqkl::MuPol& mu = W->uneqmu(s,x,y); + const uneqkl::MuPol &mu = W->uneqmu(s, x, y); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); return; } - print(stdout,mu,"v"); + print(stdout, mu, "v"); printf("\n"); return; @@ -2717,7 +2710,7 @@ void pol_f() { static CoxWord g(0); - fprintf(stdout,"first : "); + fprintf(stdout, "first : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2729,7 +2722,7 @@ void pol_f() return; } - fprintf(stdout,"second : "); + fprintf(stdout, "second : "); g = interactive::getCoxWord(W); if (ERRNO) { Error(ERRNO); @@ -2741,18 +2734,18 @@ void pol_f() return; } - if (!W->inOrder(x,y)) { - fprintf(stderr,"the two elements are not in Bruhat order\n"); + if (!W->inOrder(x, y)) { + fprintf(stderr, "the two elements are not in Bruhat order\n"); return; } - const uneqkl::KLPol& pol = W->uneqklPol(x,y); + const uneqkl::KLPol &pol = W->uneqklPol(x, y); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); return; } - print(stdout,pol,"q"); + print(stdout, pol, "q"); printf("\n"); return; @@ -2767,11 +2760,11 @@ void rcells_f() { if (!isFiniteType(W)) { - printFile(stderr,"rcells.mess",MESSAGE_DIR); + printFile(stderr, "rcells.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2786,10 +2779,10 @@ void rcells_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),rCellsH,traits); - printRCells(file.f(),Wf->rUneqCell(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), rCellsH, traits); + printRCells(file.f(), Wf->rUneqCell(), Wf->uneqkl(), Wf->interface(), traits); return; } @@ -2803,11 +2796,11 @@ void rcorder_f() { if (!isFiniteType(W)) { - printFile(stderr,"rcorder.mess",MESSAGE_DIR); + printFile(stderr, "rcorder.mess", MESSAGE_DIR); return; } - FiniteCoxGroup* Wf = dynamic_cast (W); + FiniteCoxGroup *Wf = dynamic_cast(W); Wf->fullContext(); if (ERRNO) { @@ -2822,17 +2815,17 @@ void rcorder_f() } OutputFile file; - OutputTraits& traits = Wf->outputTraits(); + OutputTraits &traits = Wf->outputTraits(); - printHeader(file.f(),rCOrderH,traits); - printRCOrder(file.f(),Wf->uneqkl(),Wf->interface(),traits); + printHeader(file.f(), rCOrderH, traits); + printRCOrder(file.f(), Wf->uneqkl(), Wf->interface(), traits); return; } -}; +}; // namespace uneq -}; +}; // namespace namespace commands { @@ -2861,7 +2854,7 @@ void interface::alphabetic_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),Alphabetic()); + in_buf = new GroupEltInterface(W->rank(), Alphabetic()); W->interface().setIn(*in_buf); W->interface().setOut(*in_buf); @@ -2901,7 +2894,7 @@ void interface::decimal_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),Decimal()); + in_buf = new GroupEltInterface(W->rank(), Decimal()); W->interface().setIn(*in_buf); W->interface().setOut(*in_buf); @@ -2942,7 +2935,7 @@ void interface::gap_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); in::bourbaki_f(); W->interface().setIn(*in_buf); @@ -2965,7 +2958,7 @@ void interface::hexadecimal_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),Hexadecimal()); + in_buf = new GroupEltInterface(W->rank(), Hexadecimal()); W->interface().setIn(*in_buf); W->interface().setOut(*in_buf); @@ -2989,7 +2982,7 @@ void interface::ordering_f() { static Permutation in_order(W->rank()); - changeOrdering(W,in_order); + changeOrdering(W, in_order); if (ERRNO) { Error(ERRNO); @@ -3018,11 +3011,11 @@ void interface::permutation_f() using namespace coxeter; if (!isTypeA(W->type())) { - printFile(stderr,"permutation.mess",MESSAGE_DIR); + printFile(stderr, "permutation.mess", MESSAGE_DIR); return; } - TypeACoxGroup* WA = dynamic_cast(W); + TypeACoxGroup *WA = dynamic_cast(W); WA->setPermutationInput(true); WA->setPermutationOutput(true); @@ -3044,7 +3037,7 @@ void interface::symbol_f() { static String buf(0); - const Interface& I = W->interface(); + const Interface &I = W->interface(); Generator s = undef_generator; reset(buf); @@ -3052,21 +3045,21 @@ void interface::symbol_f() if (ERRNO) Error(ERRNO); printf("enter the generator symbol you wish to change, ? to abort:\n"); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); if (buf[0] == '?') return; - io::skipSpaces(buf,0); + io::skipSpaces(buf, 0); Token tok; - I.symbolTree().find(buf,0,tok); - if (tokenType(tok) != generator_type)/* error */ + I.symbolTree().find(buf, 0, tok); + if (tokenType(tok) != generator_type) /* error */ ERRNO = NOT_GENERATOR; else - s = tok-1; + s = tok - 1; } while (ERRNO); printf("enter the new symbol (finish with a carriage return):\n"); - getInput(stdin,buf,0); - in_buf->setSymbol(s,buf); + getInput(stdin, buf, 0); + in_buf->setSymbol(s, buf); return; } @@ -3082,7 +3075,7 @@ void interface::terse_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); W->interface().setIn(*in_buf); W->interface().setOut(*in_buf); @@ -3099,7 +3092,7 @@ void interface::in::alphabetic_f() */ { - const String* alpha = alphabeticSymbols(in_buf->symbol.size()); + const String *alpha = alphabeticSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = alpha[j]; @@ -3116,7 +3109,7 @@ void interface::in::bourbaki_f() */ { - const Type& x = W->type(); + const Type &x = W->type(); if (!isFiniteType(x)) return; @@ -3124,7 +3117,7 @@ void interface::in::bourbaki_f() return; for (Generator s = 0; s < W->rank(); ++s) { - in_buf->symbol[s] = W->interface().inSymbol(W->rank()-s-1); + in_buf->symbol[s] = W->interface().inSymbol(W->rank() - s - 1); } return; @@ -3137,7 +3130,7 @@ void interface::in::decimal_f() */ { - const String* dec = decimalSymbols(in_buf->symbol.size()); + const String *dec = decimalSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = dec[j]; @@ -3167,7 +3160,7 @@ void interface::in::gap_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); in::bourbaki_f(); return; @@ -3180,7 +3173,7 @@ void interface::in::hexadecimal_f() */ { - const String* hex = hexSymbols(in_buf->symbol.size()); + const String *hex = hexSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = hex[j]; @@ -3199,11 +3192,11 @@ void interface::in::permutation_f() using namespace coxeter; if (!isTypeA(W->type())) { - printFile(stderr,"permutation.mess",MESSAGE_DIR); + printFile(stderr, "permutation.mess", MESSAGE_DIR); return; } - TypeACoxGroup* WA = dynamic_cast(W); + TypeACoxGroup *WA = dynamic_cast(W); WA->setPermutationInput(true); delete in_buf; @@ -3221,7 +3214,7 @@ void interface::in::postfix_f() { printf("Enter the new input postfix (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setPostfix(buf); return; } @@ -3235,7 +3228,7 @@ void interface::in::prefix_f() { printf("Enter the new input prefix (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setPrefix(buf); return; } @@ -3249,7 +3242,7 @@ void interface::in::separator_f() { printf("Enter the new input separator (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setSeparator(buf); return; } @@ -3262,7 +3255,7 @@ void interface::in::terse_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); return; } @@ -3274,7 +3267,7 @@ void interface::out::alphabetic_f() */ { - const String* alpha = alphabeticSymbols(in_buf->symbol.size()); + const String *alpha = alphabeticSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = alpha[j]; @@ -3292,7 +3285,7 @@ void interface::out::bourbaki_f() */ { - const Type& x = W->type(); + const Type &x = W->type(); if (!isFiniteType(x)) return; @@ -3302,13 +3295,13 @@ void interface::out::bourbaki_f() } for (Generator s = 0; s < W->rank(); ++s) { - in_buf->symbol[s] = W->interface().outSymbol(W->rank()-s-1); + in_buf->symbol[s] = W->interface().outSymbol(W->rank() - s - 1); } Permutation a(W->rank()); for (Generator s = 0; s < W->rank(); ++s) { - a[s] = W->rank()-1-s; + a[s] = W->rank() - 1 - s; } W->setOrdering(a); @@ -3323,7 +3316,7 @@ void interface::out::decimal_f() */ { - const String* dec = decimalSymbols(in_buf->symbol.size()); + const String *dec = decimalSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = dec[j]; @@ -3356,7 +3349,7 @@ void interface::out::gap_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); W->setOrdering(identityOrder(W->rank())); out::bourbaki_f(); @@ -3375,7 +3368,7 @@ void interface::out::hexadecimal_f() */ { - const String* hex = hexSymbols(in_buf->symbol.size()); + const String *hex = hexSymbols(in_buf->symbol.size()); for (Ulong j = 0; j < in_buf->symbol.size(); ++j) { in_buf->symbol[j] = hex[j]; @@ -3394,11 +3387,11 @@ void interface::out::permutation_f() using namespace coxeter; if (!isTypeA(W->type())) { - printFile(stderr,"permutation.mess",MESSAGE_DIR); + printFile(stderr, "permutation.mess", MESSAGE_DIR); return; } - TypeACoxGroup* WA = dynamic_cast(W); + TypeACoxGroup *WA = dynamic_cast(W); WA->setPermutationOutput(true); @@ -3421,7 +3414,7 @@ void interface::out::postfix_f() { printf("enter the new output postfix (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setPostfix(buf); return; } @@ -3435,7 +3428,7 @@ void interface::out::prefix_f() { printf("Enter the new output prefix (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setPrefix(buf); return; } @@ -3449,7 +3442,7 @@ void interface::out::separator_f() { printf("Enter the new output separator (finish with a carriage return):\n"); String buf(0); - getInput(stdin,buf,0); + getInput(stdin, buf, 0); in_buf->setSeparator(buf); return; } @@ -3462,7 +3455,7 @@ void interface::out::terse_f() { delete in_buf; - in_buf = new GroupEltInterface(W->rank(),GAP()); + in_buf = new GroupEltInterface(W->rank(), GAP()); W->interface().setDescent(Default()); W->interface().setOut(*in_buf); // has to be done here so that output @@ -3472,7 +3465,7 @@ void interface::out::terse_f() return; } -}; +}; // namespace commands /***************************************************************************** @@ -3499,7 +3492,7 @@ void interface::out::terse_f() namespace commands { -void printCommands(FILE* file, CommandTree* tree) +void printCommands(FILE *file, CommandTree *tree) /* Prints one line for each command on the tree (sorted in alphabetical order) @@ -3507,13 +3500,13 @@ void printCommands(FILE* file, CommandTree* tree) */ { - printCommandTree(file,tree->root()->left); + printCommandTree(file, tree->root()->left); return; } -}; +}; // namespace commands -CoxGroup* commands::currentGroup() +CoxGroup *commands::currentGroup() /* Returns the "current" Coxeter group. @@ -3527,19 +3520,19 @@ CoxGroup* commands::currentGroup() namespace { -void printCommandTree(FILE* file, DictCell* cell) +void printCommandTree(FILE *file, DictCell *cell) { if (cell == 0) return; if (cell->fullname) { /* print command info */ - CommandData* cd = cell->value(); - fprintf(file," - %s : %s;\n",cd->name.ptr(),cd->tag.ptr()); + CommandData *cd = cell->value(); + fprintf(file, " - %s : %s;\n", cd->name.ptr(), cd->tag.ptr()); }; - printCommandTree(file,cell->left); - printCommandTree(file,cell->right); + printCommandTree(file, cell->left); + printCommandTree(file, cell->right); return; } @@ -3578,7 +3571,7 @@ void main_entry() return; } -}; +}; // namespace namespace commands { @@ -3594,7 +3587,7 @@ void interface::in_entry() a.inverse(); printf("current input symbols are the following :\n\n"); - printInterface(stdout,W->interface().inInterface(),a); + printInterface(stdout, W->interface().inInterface(), a); printf("\n"); in_buf = new GroupEltInterface(W->interface().inInterface()); @@ -3622,36 +3615,36 @@ void interface::in_exit() /* at this point in_buf holds the full putative new interface; we need to check for reserved or repeated non-empty symbols */ - const String* str = checkLeadingWhite(*in_buf); + const String *str = checkLeadingWhite(*in_buf); if (str) { - Error(LEADING_WHITESPACE,in_buf,&W->interface().inInterface(),&a,str); + Error(LEADING_WHITESPACE, in_buf, &W->interface().inInterface(), &a, str); goto error_exit; } - str = checkReserved(*in_buf,W->interface()); + str = checkReserved(*in_buf, W->interface()); if (str) { - Error(RESERVED_SYMBOL,in_buf,&W->interface().inInterface(),&a,str); + Error(RESERVED_SYMBOL, in_buf, &W->interface().inInterface(), &a, str); goto error_exit; } if (!checkRepeated(*in_buf)) { - Error(REPEATED_SYMBOL,in_buf,&W->interface().inInterface(),&a); + Error(REPEATED_SYMBOL, in_buf, &W->interface().inInterface(), &a); goto error_exit; } /* if we reach this point, the new interface is ok */ printf("new input symbols:\n\n"); - printInterface(stdout,*in_buf,a); + printInterface(stdout, *in_buf, a); printf("\n"); W->interface().setIn(*in_buf); return; - error_exit: +error_exit: ERRNO = ERROR_WARNING; return; } @@ -3671,7 +3664,7 @@ void interface::out_entry() a.inverse(); printf("current output symbols are the following :\n\n"); - printInterface(stdout,*in_buf,W->interface().inInterface(),a); + printInterface(stdout, *in_buf, W->interface().inInterface(), a); printf("\n"); return; @@ -3692,7 +3685,7 @@ void interface::out_exit() a.inverse(); printf("new output symbols:\n\n"); - printInterface(stdout,*in_buf,W->interface().inInterface(),a); + printInterface(stdout, *in_buf, W->interface().inInterface(), a); printf("\n"); W->interface().setOut(*in_buf); @@ -3700,7 +3693,7 @@ void interface::out_exit() return; } -}; +}; // namespace commands namespace { @@ -3734,4 +3727,4 @@ void uneq_exit() return; } -}; +}; // namespace diff --git a/commands.h b/commands.h index 532ab9f..e75e483 100644 --- a/commands.h +++ b/commands.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef COMMANDS_H /* guard against multiple inclusions */ +#ifndef COMMANDS_H /* guard against multiple inclusions */ #define COMMANDS_H #include "globals.h" @@ -14,34 +14,34 @@ #include "io.h" namespace commands { - using namespace coxeter; - using namespace dictionary; - using namespace io; +using namespace coxeter; +using namespace dictionary; +using namespace io; /******** type declarations ************************************************/ - struct CommandData; - class CommandTree; +struct CommandData; +class CommandTree; /******** constants ********************************************************/ - extern void (*default_help)(); +extern void (*default_help)(); /******** function declarations ********************************************/ - CoxGroup* currentGroup(); - void default_error(char* str); - void execute(); - CommandTree* interfaceCommandTree(); - CommandTree* mainCommandTree(); - void printCommands(FILE* file, CommandTree* tree); - void relax_f(); - void run(); - CommandTree* uneqCommandTree(); - namespace interface { - CommandTree* inCommandTree(); - CommandTree* outCommandTree(); - }; +CoxGroup *currentGroup(); +void default_error(char *str); +void execute(); +CommandTree *interfaceCommandTree(); +CommandTree *mainCommandTree(); +void printCommands(FILE *file, CommandTree *tree); +void relax_f(); +void run(); +CommandTree *uneqCommandTree(); +namespace interface { +CommandTree *inCommandTree(); +CommandTree *outCommandTree(); +}; // namespace interface /******** Type definitions *************************************************/ @@ -51,53 +51,56 @@ struct CommandData { void (*action)(); void (*help)(); bool autorepeat; -/* Constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CommandData));} - CommandData(const char* const& str, const char* const& t, void (*a)(), - void (*h)(), bool rep); + /* Constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(CommandData)); + } + CommandData(const char *const &str, const char *const &t, void (*a)(), + void (*h)(), bool rep); ~CommandData(); }; -class CommandTree:public Dictionary { - private: +class CommandTree : public Dictionary { +private: String d_prompt; - CommandTree* d_help; + CommandTree *d_help; void (*d_entry)(); - void (*d_error)(char* str); + void (*d_error)(char *str); void (*d_exit)(); - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CommandTree));} + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(CommandTree)); + } CommandTree(const char *str, void (*action)(), void (*entry)() = &relax_f, - void (*error)(char*) = &default_error, - void (*exit)() = &relax_f, void (*h)() = 0); + void (*error)(char *) = &default_error, void (*exit)() = &relax_f, + void (*h)() = 0); ~CommandTree(); -/* modifiers */ - void add(const char* name, const char* tag, void (*action)(), - void (*help)() = default_help, bool rep = true); - void setAction(const char* str, void (*a)()); - void setRepeat(const char* str, bool b); - void setEntry(void (*a)()); /* inlined */ -/* accessors */ + /* modifiers */ + void add(const char *name, const char *tag, void (*action)(), + void (*help)() = default_help, bool rep = true); + void setAction(const char *str, void (*a)()); + void setRepeat(const char *str, bool b); + void setEntry(void (*a)()); /* inlined */ + /* accessors */ void prompt() const; - void entry() const; /* inlined */ - void error(char *str) const; /* inlined */ - void exit() const; /* inlined */ - CommandTree* helpMode() const; /* inlined */ + void entry() const; /* inlined */ + void error(char *str) const; /* inlined */ + void exit() const; /* inlined */ + CommandTree *helpMode() const; /* inlined */ }; /******** Inline definitions *********************************************/ -inline void CommandTree::setEntry(void (*a)()) {d_entry = a;} -inline void CommandTree::entry() const {return d_entry();} -inline void CommandTree::error(char *str) const {return d_error(str);} -inline void CommandTree::exit() const {return d_exit();} -inline CommandTree* CommandTree::helpMode() const {return d_help;} +inline void CommandTree::setEntry(void (*a)()) { d_entry = a; } +inline void CommandTree::entry() const { return d_entry(); } +inline void CommandTree::error(char *str) const { return d_error(str); } +inline void CommandTree::exit() const { return d_exit(); } +inline CommandTree *CommandTree::helpMode() const { return d_help; } -} +} // namespace commands #endif diff --git a/constants.cpp b/constants.cpp index 08b4c7b..632953f 100644 --- a/constants.cpp +++ b/constants.cpp @@ -1,6 +1,6 @@ /* This is constants.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -8,11 +8,11 @@ #include "constants.h" namespace constants { - Ulong *lmask; - Ulong *leqmask; - unsigned *firstbit; - unsigned *lastbit; -}; +Ulong *lmask; +Ulong *leqmask; +unsigned *firstbit; +unsigned *lastbit; +}; // namespace constants /**************************************************************************** @@ -37,26 +37,25 @@ void initConstants() leqmask[0] = 1L; lmask[0] = 1L; - for (Ulong j = 1; j < BITS(Ulong); j++) - { - lmask[j] = lmask[j-1] << 1; - leqmask[j] = leqmask[j-1] + lmask[j]; - } + for (Ulong j = 1; j < BITS(Ulong); j++) { + lmask[j] = lmask[j - 1] << 1; + leqmask[j] = leqmask[j - 1] + lmask[j]; + } - static unsigned d_firstbit[1<>1]+1; + lastbit[j] = lastbit[j >> 1] + 1; return; } @@ -67,17 +66,16 @@ unsigned firstBit(Ulong f) Returns the bit position of the first set bit in f. */ -{ +{ if (f == 0) return BITS(Ulong); - if (f&CHARFLAGS) - return firstbit[f&CHARFLAGS]; + if (f & CHARFLAGS) + return firstbit[f & CHARFLAGS]; else - return firstBit(f>>CHAR_BIT)+CHAR_BIT; + return firstBit(f >> CHAR_BIT) + CHAR_BIT; } - unsigned lastBit(Ulong f) /* @@ -86,9 +84,9 @@ unsigned lastBit(Ulong f) { if (f >> CHAR_BIT) - return lastBit(f>>CHAR_BIT)+CHAR_BIT; + return lastBit(f >> CHAR_BIT) + CHAR_BIT; else return lastbit[f]; } -}; +}; // namespace constants diff --git a/constants.h b/constants.h index 98efeeb..5b62215 100644 --- a/constants.h +++ b/constants.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CONSTANTS_H /* guard against multiple inclusions */ +#ifndef CONSTANTS_H /* guard against multiple inclusions */ #define CONSTANTS_H #include @@ -13,20 +13,20 @@ #include "globals.h" namespace constants { - using namespace coxeter; +using namespace coxeter; -#define BITS(x) (CHAR_BIT*sizeof(x)) /* size of x in bits */ +#define BITS(x) (CHAR_BIT * sizeof(x)) /* size of x in bits */ - const Ulong CHARFLAGS = ~(Ulong)0 >> CHAR_BIT*(sizeof(Ulong)-1); +const Ulong CHARFLAGS = ~(Ulong)0 >> CHAR_BIT *(sizeof(Ulong) - 1); - extern Ulong *lmask; - extern Ulong *leqmask; - extern unsigned *firstbit; - extern unsigned *lastbit; +extern Ulong *lmask; +extern Ulong *leqmask; +extern unsigned *firstbit; +extern unsigned *lastbit; - unsigned firstBit(Ulong f); - void initConstants(); - unsigned lastBit(Ulong f); -} +unsigned firstBit(Ulong f); +void initConstants(); +unsigned lastBit(Ulong f); +} // namespace constants #endif diff --git a/coxgroup.cpp b/coxgroup.cpp index 1c30c26..828a763 100644 --- a/coxgroup.cpp +++ b/coxgroup.cpp @@ -57,20 +57,22 @@ namespace coxeter { - class CoxGroup::CoxHelper { - private: - CoxGroup* d_W; - public: - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CoxHelper));} - CoxHelper(CoxGroup* W); - ~CoxHelper (); - void sortContext(); - void checkInverses(); - }; - -CoxGroup::CoxGroup(const Type& x, const Rank& l) +class CoxGroup::CoxHelper { +private: + CoxGroup *d_W; + +public: + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(CoxHelper)); + } + CoxHelper(CoxGroup *W); + ~CoxHelper(); + void sortContext(); + void checkInverses(); +}; + +CoxGroup::CoxGroup(const Type &x, const Rank &l) /* Constructor for the abstract CoxGroup class. Does the basic initializations @@ -83,17 +85,17 @@ CoxGroup::CoxGroup(const Type& x, const Rank& l) */ { - d_graph = new CoxGraph(x,l); + d_graph = new CoxGraph(x, l); if (ERRNO) /* problem with the Coxeter matrix */ return; d_mintable = new MinTable(graph()); - SchubertContext* p = new StandardSchubertContext(graph()); + SchubertContext *p = new StandardSchubertContext(graph()); d_klsupport = new KLSupport(p); - d_interface = new Interface(x,l); - d_outputTraits = new OutputTraits(graph(),interface(),Pretty()); + d_interface = new Interface(x, l); + d_outputTraits = new OutputTraits(graph(), interface(), Pretty()); d_help = new CoxHelper(this); @@ -118,7 +120,7 @@ CoxGroup::~CoxGroup() /******** accessors **********************************************************/ -void CoxGroup::coatoms(List& c, const CoxWord& g) const +void CoxGroup::coatoms(List &c, const CoxWord &g) const /* This is a simple-minded "local" function that puts a list of reduced @@ -135,10 +137,10 @@ void CoxGroup::coatoms(List& c, const CoxWord& g) const h.append(g[i]); ++i; for (; i < g.length(); ++i) { - Generator s = g[i]-1; - int d = prod(h,s); + Generator s = g[i] - 1; + int d = prod(h, s); if (d == -1) - goto next; + goto next; } // if we get here, h is a coatom c.append(h); @@ -149,7 +151,7 @@ void CoxGroup::coatoms(List& c, const CoxWord& g) const return; } -bool CoxGroup::isDescent(const CoxWord& g, const Generator& s) const +bool CoxGroup::isDescent(const CoxWord &g, const Generator &s) const /* Tells if s is a descent of g. @@ -163,7 +165,7 @@ bool CoxGroup::isDescent(const CoxWord& g, const Generator& s) const return false; } -bool CoxGroup::isDihedral(const CoxWord& g) const +bool CoxGroup::isDihedral(const CoxWord &g) const /* Tells if g is a dihedral element. @@ -177,20 +179,19 @@ bool CoxGroup::isDihedral(const CoxWord& g) const CoxLetter t = g[1]; for (Ulong j = 2; j < g.length(); ++j) { - if (j%2) { // g[j] should be t + if (j % 2) { // g[j] should be t if (g[j] != t) - return false; - } - else { // g[j] should be s + return false; + } else { // g[j] should be s if (g[j] != s) - return false; + return false; } } return true; } -void CoxGroup::modify(ParseInterface& P, const Token& tok) const +void CoxGroup::modify(ParseInterface &P, const Token &tok) const /* Executes the modification indicated by tok, which is assumed to be of @@ -207,12 +208,12 @@ void CoxGroup::modify(ParseInterface& P, const Token& tok) const } if (isPower(tok)) { - Ulong m = readCoxNbr(P,ULONG_MAX); - CoxGroup::power(P.c,m); + Ulong m = readCoxNbr(P, ULONG_MAX); + CoxGroup::power(P.c, m); } } -void CoxGroup::parse(ParseInterface& P) const +void CoxGroup::parse(ParseInterface &P) const /* This function parses a group element from the line, starting @@ -260,7 +261,7 @@ void CoxGroup::parse(ParseInterface& P) const for (;;) { if (parseGroupElement(P)) { if (ERRNO) - return; + return; continue; } if (parseBeginGroup(P)) { /* enter new nesting level */ @@ -282,14 +283,13 @@ void CoxGroup::parse(ParseInterface& P) const /* flush the current group element */ - prod(P.a[0],P.c); + prod(P.a[0], P.c); P.c.reset(); return; - } -bool CoxGroup::parseBeginGroup(ParseInterface& P) const +bool CoxGroup::parseBeginGroup(ParseInterface &P) const /* Tries to parse a begingroup token off P; in case of success, advances @@ -299,9 +299,9 @@ bool CoxGroup::parseBeginGroup(ParseInterface& P) const { Token tok = 0; - const Interface& I = interface(); + const Interface &I = interface(); - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -310,14 +310,14 @@ bool CoxGroup::parseBeginGroup(ParseInterface& P) const return false; P.nestlevel++; - P.a.setSize(P.nestlevel+1); + P.a.setSize(P.nestlevel + 1); P.a[P.nestlevel].reset(); P.offset += p; return true; } -bool CoxGroup::parseContextNumber(ParseInterface& P) const +bool CoxGroup::parseContextNumber(ParseInterface &P) const /* Tries to parse a ContextNumber from P. This is a '%' character, followed @@ -326,10 +326,10 @@ bool CoxGroup::parseContextNumber(ParseInterface& P) const */ { - const Interface& I = interface(); + const Interface &I = interface(); Token tok = 0; - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -340,20 +340,19 @@ bool CoxGroup::parseContextNumber(ParseInterface& P) const // if we get to this point, we must read a valid integer P.offset += p; - CoxNbr x = interface::readCoxNbr(P,contextSize()); + CoxNbr x = interface::readCoxNbr(P, contextSize()); - if (x == undef_coxnbr) { //error + if (x == undef_coxnbr) { // error P.offset -= p; - Error(CONTEXTNBR_OVERFLOW,contextSize()); + Error(CONTEXTNBR_OVERFLOW, contextSize()); ERRNO = PARSE_ERROR; - } - else // x is valid - prod(P.c,x); + } else // x is valid + prod(P.c, x); return true; } -bool CoxGroup::parseEndGroup(ParseInterface& P) const +bool CoxGroup::parseEndGroup(ParseInterface &P) const /* Tries to parse an endgroup token; in case of success, reduces the nestlevel @@ -362,9 +361,9 @@ bool CoxGroup::parseEndGroup(ParseInterface& P) const { Token tok = 0; - const Interface& I = interface(); + const Interface &I = interface(); - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -392,13 +391,13 @@ bool CoxGroup::parseEndGroup(ParseInterface& P) const // flush modified group into accumulator - prod(P.a[P.nestlevel],P.c); + prod(P.a[P.nestlevel], P.c); P.c.reset(); return true; } -bool CoxGroup::parseGroupElement(ParseInterface& P) const +bool CoxGroup::parseGroupElement(ParseInterface &P) const /* This function parses a group element from the string. A group element @@ -412,7 +411,7 @@ bool CoxGroup::parseGroupElement(ParseInterface& P) const Ulong r = P.offset; if (parseContextNumber(P)) { // the next token is a ContextNumber - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; @@ -421,19 +420,18 @@ bool CoxGroup::parseGroupElement(ParseInterface& P) const // if we get to this point, we have to read a CoxWord { - interface().parseCoxWord(P,mintable()); - - if (ERRNO) { // no CoxWord could be parsed - if (P.offset == r) { // nothing was parsed - ERRNO = 0; - return false; - } - else // parse error - return true; + interface().parseCoxWord(P, mintable()); + + if (ERRNO) { // no CoxWord could be parsed + if (P.offset == r) { // nothing was parsed + ERRNO = 0; + return false; + } else // parse error + return true; } } - modify: +modify: // if we get to this point, a group element was successfully read @@ -444,7 +442,7 @@ bool CoxGroup::parseGroupElement(ParseInterface& P) const // flush the current group element - prod(P.a[P.nestlevel],P.c); + prod(P.a[P.nestlevel], P.c); P.c.reset(); if (P.offset == r) // nothing was read; c is unchanged @@ -453,7 +451,7 @@ bool CoxGroup::parseGroupElement(ParseInterface& P) const return true; } -bool CoxGroup::parseModifier(ParseInterface& P) const +bool CoxGroup::parseModifier(ParseInterface &P) const /* This function parses a modifier from P.str at P.offset, and acts upon @@ -466,9 +464,9 @@ bool CoxGroup::parseModifier(ParseInterface& P) const { Token tok = 0; - const Interface& I = interface(); + const Interface &I = interface(); - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -482,12 +480,12 @@ bool CoxGroup::parseModifier(ParseInterface& P) const } P.offset += p; - modify(P,tok); + modify(P, tok); return true; } -int CoxGroup::prod(CoxNbr& x, const Generator& s) const +int CoxGroup::prod(CoxNbr &x, const Generator &s) const /* This function increments x by right multiplication with s (i.e., it could @@ -497,7 +495,7 @@ int CoxGroup::prod(CoxNbr& x, const Generator& s) const { CoxNbr x_old = x; - x = schubert().shift(x,s); + x = schubert().shift(x, s); if (x > x_old) return 1; @@ -505,7 +503,7 @@ int CoxGroup::prod(CoxNbr& x, const Generator& s) const return -1; } -int CoxGroup::prod(CoxNbr& x, const CoxWord& g) const +int CoxGroup::prod(CoxNbr &x, const CoxWord &g) const /* Multiplies x consecutively by the terms in g. Stops at the first undefined @@ -516,7 +514,7 @@ int CoxGroup::prod(CoxNbr& x, const CoxWord& g) const int l = 0; for (Ulong j = 0; j < g.length(); ++j) { - l += prod(x,g[j]-1); + l += prod(x, g[j] - 1); if (x == undef_coxnbr) break; } @@ -524,7 +522,7 @@ int CoxGroup::prod(CoxNbr& x, const CoxWord& g) const return l; } -int CoxGroup::prod(CoxWord& g, const CoxNbr& d_x) const +int CoxGroup::prod(CoxWord &g, const CoxNbr &d_x) const /* Multiplies g by the terms in x. Returns the length increase. @@ -534,10 +532,10 @@ int CoxGroup::prod(CoxWord& g, const CoxNbr& d_x) const int l = 0; CoxNbr x = d_x; - while(x) { + while (x) { Generator s = firstBit(ldescent(x)); - l += prod(g,s); - prod(x,s+rank()); + l += prod(g, s); + prod(x, s + rank()); } return l; @@ -591,7 +589,7 @@ void CoxGroup::activateUEKL() { if (d_uneqkl == 0) { - d_uneqkl = new uneqkl::KLContext(d_klsupport,graph(),interface()); + d_uneqkl = new uneqkl::KLContext(d_klsupport, graph(), interface()); if (ERRNO) { Error(ERRNO); delete d_uneqkl; @@ -602,7 +600,7 @@ void CoxGroup::activateUEKL() return; } -void CoxGroup::cBasis(kl::HeckeElt& h, const CoxNbr& y) +void CoxGroup::cBasis(kl::HeckeElt &h, const CoxNbr &y) /* Puts in h the data of the full row for y in the k-l context corresponding @@ -612,11 +610,11 @@ void CoxGroup::cBasis(kl::HeckeElt& h, const CoxNbr& y) { activateKL(); - kl::cBasis(h,y,*d_kl); + kl::cBasis(h, y, *d_kl); return; } -CoxNbr CoxGroup::extendContext(const CoxWord& g) +CoxNbr CoxGroup::extendContext(const CoxWord &g) /* This function extends the active contexts to acccomodate g. An active @@ -641,23 +639,23 @@ CoxNbr CoxGroup::extendContext(const CoxWord& g) if (d_kl) { d_kl->setSize(contextSize()); - if (ERRNO) - goto revert; + if (ERRNO) + goto revert; } if (d_uneqkl) { d_uneqkl->setSize(contextSize()); - if (ERRNO) - goto revert; + if (ERRNO) + goto revert; } if (d_invkl) { d_invkl->setSize(contextSize()); - if (ERRNO) - goto revert; + if (ERRNO) + goto revert; } return x; - revert: +revert: d_klsupport->revertSize(prev_size); if (d_kl) d_kl->revertSize(prev_size); @@ -757,7 +755,7 @@ void CoxGroup::fillUEMu() return; } -const invkl::KLPol& CoxGroup::invklPol(const CoxNbr& x, const CoxNbr& y) +const invkl::KLPol &CoxGroup::invklPol(const CoxNbr &x, const CoxNbr &y) /* Returns the inverse k-l polynomial Q_{x,y}, after activating the context @@ -767,10 +765,10 @@ const invkl::KLPol& CoxGroup::invklPol(const CoxNbr& x, const CoxNbr& y) { activateIKL(); - return d_invkl->klPol(x,y); + return d_invkl->klPol(x, y); } -void CoxGroup::invklRow(invkl::HeckeElt& h, const CoxNbr& y) +void CoxGroup::invklRow(invkl::HeckeElt &h, const CoxNbr &y) /* Puts in h the data of the full row for y in the inverse k-l context @@ -780,11 +778,11 @@ void CoxGroup::invklRow(invkl::HeckeElt& h, const CoxNbr& y) { activateIKL(); - d_invkl->row(h,y); + d_invkl->row(h, y); return; } -const kl::KLPol& CoxGroup::klPol(const CoxNbr& x, const CoxNbr& y) +const kl::KLPol &CoxGroup::klPol(const CoxNbr &x, const CoxNbr &y) /* Returns the ordinary k-l polynomial P_{x,y}, after activating the context @@ -794,10 +792,10 @@ const kl::KLPol& CoxGroup::klPol(const CoxNbr& x, const CoxNbr& y) { activateKL(); - return d_kl->klPol(x,y); + return d_kl->klPol(x, y); } -void CoxGroup::klRow(kl::HeckeElt& h, const CoxNbr& y) +void CoxGroup::klRow(kl::HeckeElt &h, const CoxNbr &y) /* Puts in h the data of the full row for y in the k-l context corresponding @@ -807,11 +805,11 @@ void CoxGroup::klRow(kl::HeckeElt& h, const CoxNbr& y) { activateKL(); - d_kl->row(h,y); + d_kl->row(h, y); return; } -KLCoeff CoxGroup::mu(const CoxNbr& x, const CoxNbr& y) +KLCoeff CoxGroup::mu(const CoxNbr &x, const CoxNbr &y) /* Returns the ordinary mu-coefficent mu(x,y), after activating the context @@ -821,10 +819,10 @@ KLCoeff CoxGroup::mu(const CoxNbr& x, const CoxNbr& y) { activateKL(); - return d_kl->mu(x,y); + return d_kl->mu(x, y); } -void CoxGroup::permute(const Permutation& a) +void CoxGroup::permute(const Permutation &a) /* This function permutes all the active contexts w.r.t. the permutation a. @@ -876,7 +874,7 @@ void CoxGroup::permute(const Permutation& a) return; } -void CoxGroup::uneqcBasis(uneqkl::HeckeElt& h, const CoxNbr& y) +void CoxGroup::uneqcBasis(uneqkl::HeckeElt &h, const CoxNbr &y) /* Puts in h the data of the full row for y in the k-l context corresponding @@ -886,11 +884,11 @@ void CoxGroup::uneqcBasis(uneqkl::HeckeElt& h, const CoxNbr& y) { activateUEKL(); - uneqkl::cBasis(h,y,*d_uneqkl); + uneqkl::cBasis(h, y, *d_uneqkl); return; } -const uneqkl::KLPol& CoxGroup::uneqklPol(const CoxNbr& x, const CoxNbr& y) +const uneqkl::KLPol &CoxGroup::uneqklPol(const CoxNbr &x, const CoxNbr &y) /* Returns the unequal-parameter k-l polynomial P_{x,y}, after activating the @@ -900,11 +898,11 @@ const uneqkl::KLPol& CoxGroup::uneqklPol(const CoxNbr& x, const CoxNbr& y) { activateUEKL(); - return d_uneqkl->klPol(x,y); + return d_uneqkl->klPol(x, y); } -const uneqkl::MuPol& CoxGroup::uneqmu(const Generator& s, const CoxNbr& x, - const CoxNbr& y) +const uneqkl::MuPol &CoxGroup::uneqmu(const Generator &s, const CoxNbr &x, + const CoxNbr &y) /* Returns the unequal-parameter mu-polynomial mu_{s,x,y}, after activating @@ -914,10 +912,10 @@ const uneqkl::MuPol& CoxGroup::uneqmu(const Generator& s, const CoxNbr& x, { activateUEKL(); - return d_uneqkl->mu(s,x,y); + return d_uneqkl->mu(s, x, y); } -void CoxGroup::uneqklRow(uneqkl::HeckeElt& h, const CoxNbr& y) +void CoxGroup::uneqklRow(uneqkl::HeckeElt &h, const CoxNbr &y) /* Puts in e_row and kl_row the data of the full row of the unequal-parameter @@ -928,7 +926,7 @@ void CoxGroup::uneqklRow(uneqkl::HeckeElt& h, const CoxNbr& y) { activateUEKL(); - d_uneqkl->row(h,y); + d_uneqkl->row(h, y); return; } @@ -945,7 +943,8 @@ void CoxGroup::uneqklRow(uneqkl::HeckeElt& h, const CoxNbr& y) *****************************************************************************/ -CoxGroup::CoxHelper::CoxHelper(CoxGroup* W):d_W(W) +CoxGroup::CoxHelper::CoxHelper(CoxGroup *W) + : d_W(W) {} @@ -960,27 +959,27 @@ void CoxGroup::CoxHelper::sortContext() */ { - KLSupport* kls = d_W->d_klsupport; + KLSupport *kls = d_W->d_klsupport; for (CoxNbr y = 0; y < d_W->contextSize(); ++y) { if (!kls->isExtrAllocated(y)) continue; Permutation a(0); - sortI(d_W->extrList(y),a); + sortI(d_W->extrList(y), a); - kls->applyIPermutation(y,a); + kls->applyIPermutation(y, a); /* apply to the various klcontexts */ if (d_W->d_kl) { - d_W->d_kl->applyIPermutation(y,a); + d_W->d_kl->applyIPermutation(y, a); } if (d_W->d_invkl) { - d_W->d_invkl->applyIPermutation(y,a); + d_W->d_invkl->applyIPermutation(y, a); } if (d_W->d_uneqkl) { - d_W->d_uneqkl->applyIPermutation(y,a); + d_W->d_uneqkl->applyIPermutation(y, a); } } @@ -996,7 +995,7 @@ void CoxGroup::CoxHelper::checkInverses() */ { - KLSupport& kls = *(d_W->d_klsupport); + KLSupport &kls = *(d_W->d_klsupport); for (CoxNbr y = 0; y < d_W->contextSize(); ++y) { CoxNbr yi = d_W->inverse(y); @@ -1017,4 +1016,4 @@ void CoxGroup::CoxHelper::checkInverses() return; } -}; +}; // namespace coxeter diff --git a/coxgroup.h b/coxgroup.h index afa6c0f..d65f4a6 100644 --- a/coxgroup.h +++ b/coxgroup.h @@ -26,9 +26,9 @@ FiniteMedRankCoxGroup(a) GeneralFMRCoxGroup(c) FiniteSmallRankCoxGroup(a) - GeneralFSRCoxGroup(c) - SmallCoxGroup(a) - GeneralSCoxGroup(c) + GeneralFSRCoxGroup(c) + SmallCoxGroup(a) + GeneralSCoxGroup(c) TypeACoxGroup(a) TypeABigRankCoxGroup(c) TypeAMedRankCoxGroup(c) @@ -51,7 +51,7 @@ */ -#ifndef COXGROUP_H /* guarantee single inclusion */ +#ifndef COXGROUP_H /* guarantee single inclusion */ #define COXGROUP_H #include "globals.h" @@ -71,60 +71,59 @@ namespace coxeter { //******** type definitions ************************************************** - using namespace coxtypes; - using namespace files; - using namespace graph; - using namespace hecke; - using namespace interface; - using namespace klsupport; - using namespace minroots; - using namespace transducer; +using namespace coxtypes; +using namespace files; +using namespace graph; +using namespace hecke; +using namespace interface; +using namespace klsupport; +using namespace minroots; +using namespace transducer; class CoxGroup { - protected: - - CoxGraph* d_graph; - MinTable* d_mintable; - KLSupport* d_klsupport; - kl::KLContext* d_kl; - invkl::KLContext* d_invkl; - uneqkl::KLContext* d_uneqkl; - Interface* d_interface; - OutputTraits* d_outputTraits; - - struct CoxHelper; /* provides helper functions */ - CoxHelper* d_help; +protected: + CoxGraph *d_graph; + MinTable *d_mintable; + KLSupport *d_klsupport; + kl::KLContext *d_kl; + invkl::KLContext *d_invkl; + uneqkl::KLContext *d_uneqkl; + Interface *d_interface; + OutputTraits *d_outputTraits; + + struct CoxHelper; /* provides helper functions */ + CoxHelper *d_help; friend struct CoxHelper; - public: +public: + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(CoxGroup)); + } - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CoxGroup));} + //******** Chapter 0 : CoxGroup objects ************************************* -//******** Chapter 0 : CoxGroup objects ************************************* - - CoxGroup(const Type& x, const Rank& l); + CoxGroup(const Type &x, const Rank &l); virtual ~CoxGroup(); - CoxGraph& graph(); /* inlined */ - virtual Interface& interface(); /* inlined */ - MinTable& mintable(); /* inlined */ - KLSupport& klsupport(); /* inlined */ - kl::KLContext& kl(); /* inlined */ - invkl::KLContext& invkl(); /* inlined */ - uneqkl::KLContext& uneqkl(); /* inlined */ - virtual OutputTraits& outputTraits(); /* inlined */ - - const CoxGraph& graph() const; /* inlined */ - virtual const Interface& interface() const; /* inlined */ - const MinTable& mintable() const; /* inlined */ - const KLSupport& klsupport() const; /* inlined */ - const kl::KLContext& kl() const; /* inlined */ - const uneqkl::KLContext& uneqkl() const; /* inlined */ - const SchubertContext& schubert() const; /* inlined */ - virtual const OutputTraits& outputTraits() const; /* inlined */ + CoxGraph &graph(); /* inlined */ + virtual Interface &interface(); /* inlined */ + MinTable &mintable(); /* inlined */ + KLSupport &klsupport(); /* inlined */ + kl::KLContext &kl(); /* inlined */ + invkl::KLContext &invkl(); /* inlined */ + uneqkl::KLContext &uneqkl(); /* inlined */ + virtual OutputTraits &outputTraits(); /* inlined */ + + const CoxGraph &graph() const; /* inlined */ + virtual const Interface &interface() const; /* inlined */ + const MinTable &mintable() const; /* inlined */ + const KLSupport &klsupport() const; /* inlined */ + const kl::KLContext &kl() const; /* inlined */ + const uneqkl::KLContext &uneqkl() const; /* inlined */ + const SchubertContext &schubert() const; /* inlined */ + virtual const OutputTraits &outputTraits() const; /* inlined */ void activateKL(); void activateIKL(); @@ -132,269 +131,324 @@ class CoxGroup { /* graph data */ - CoxEntry M(Generator s, Generator t) const; /* inlined */ - Rank rank() const; /* inlined */ - const Type& type() const; /* inlined */ + CoxEntry M(Generator s, Generator t) const; /* inlined */ + Rank rank() const; /* inlined */ + const Type &type() const; /* inlined */ virtual CoxSize order() const = 0; - virtual bool isFullContext() const; /* inlined */ + virtual bool isFullContext() const; /* inlined */ -//******* Chapter I : Elementary operations ******************************** + //******* Chapter I : Elementary operations ******************************** /* word operations */ - virtual int insert(CoxWord& g, const Generator& s) const; /* inlined */ - virtual const CoxWord& inverse(CoxWord& g) const; /* inlined */ - virtual const CoxWord& normalForm(CoxWord& g) const; /* inlined */ - virtual const CoxWord& power(CoxWord& g, const Ulong& m) const; - /* inlined */ - virtual int prod(CoxWord& g, const Generator& s) const; /* inlined */ - virtual int prod(CoxWord& g, const CoxWord& h) const; /* inlined */ - virtual const CoxWord& reduced(CoxWord& g, CoxWord& h) const; /* inlined */ + virtual int insert(CoxWord &g, const Generator &s) const; /* inlined */ + virtual const CoxWord &inverse(CoxWord &g) const; /* inlined */ + virtual const CoxWord &normalForm(CoxWord &g) const; /* inlined */ + virtual const CoxWord &power(CoxWord &g, const Ulong &m) const; + /* inlined */ + virtual int prod(CoxWord &g, const Generator &s) const; /* inlined */ + virtual int prod(CoxWord &g, const CoxWord &h) const; /* inlined */ + virtual const CoxWord &reduced(CoxWord &g, CoxWord &h) const; /* inlined */ /* descent sets */ - virtual LFlags descent(const CoxWord& g) const; /* inlined */ - virtual LFlags ldescent(const CoxWord& g) const; /* inlined */ - virtual LFlags rdescent(const CoxWord& g) const; /* inlined */ - bool isDescent(const CoxWord& g, const Generator& s) const; + virtual LFlags descent(const CoxWord &g) const; /* inlined */ + virtual LFlags ldescent(const CoxWord &g) const; /* inlined */ + virtual LFlags rdescent(const CoxWord &g) const; /* inlined */ + bool isDescent(const CoxWord &g, const Generator &s) const; -//******** Chapter II : Schubert context ************************************** + //******** Chapter II : Schubert context + //************************************** - virtual CoxNbr contextNumber(const CoxWord& g) const; /* inlined */ - CoxNbr contextSize() const; /* inlined */ - Length length(const CoxNbr& x) const; /* inlined */ + virtual CoxNbr contextNumber(const CoxWord &g) const; /* inlined */ + CoxNbr contextSize() const; /* inlined */ + Length length(const CoxNbr &x) const; /* inlined */ - virtual CoxNbr extendContext(const CoxWord& g); - virtual void permute(const Permutation& a); + virtual CoxNbr extendContext(const CoxWord &g); + virtual void permute(const Permutation &a); - virtual LFlags descent(const CoxNbr& x) const; /* inlined */ - virtual LFlags ldescent(const CoxNbr& x) const; /* inlined */ - virtual LFlags rdescent(const CoxNbr& x) const; /* inlined */ + virtual LFlags descent(const CoxNbr &x) const; /* inlined */ + virtual LFlags ldescent(const CoxNbr &x) const; /* inlined */ + virtual LFlags rdescent(const CoxNbr &x) const; /* inlined */ - virtual CoxNbr inverse(const CoxNbr& x) const; /* inlined */ - virtual int prod(CoxNbr& x, const Generator& s) const; - virtual int lprod(CoxNbr& x, const Generator& s) const; /* inlined */ - virtual int prod(CoxWord& g, const CoxNbr& x) const; - virtual int prod(CoxNbr& x, const CoxWord& g) const; + virtual CoxNbr inverse(const CoxNbr &x) const; /* inlined */ + virtual int prod(CoxNbr &x, const Generator &s) const; + virtual int lprod(CoxNbr &x, const Generator &s) const; /* inlined */ + virtual int prod(CoxWord &g, const CoxNbr &x) const; + virtual int prod(CoxNbr &x, const CoxWord &g) const; - virtual const List& extrList(const CoxNbr& x) const; /* inlined */ + virtual const List &extrList(const CoxNbr &x) const; /* inlined */ -//******** Chapter III : Bruhat ordering ************************************** + //******** Chapter III : Bruhat ordering + //************************************** - virtual void coatoms(List& c, const CoxWord& g) const; - virtual const CoatomList& coatoms(const CoxNbr& x) const ; /* inlined */ - virtual void extractClosure(BitMap& b, const CoxNbr& x) const; /* inlined */ - virtual bool inOrder(const CoxWord& h, const CoxWord& g) const; /* inlined */ - virtual bool inOrder(List& a, const CoxWord& h, const CoxWord& g) - const; /* inlined */ - virtual bool inOrder(const CoxNbr& x, const CoxNbr& y) const; /* inlined */ - virtual bool isDihedral(const CoxWord& g) const; + virtual void coatoms(List &c, const CoxWord &g) const; + virtual const CoatomList &coatoms(const CoxNbr &x) const; /* inlined */ + virtual void extractClosure(BitMap &b, const CoxNbr &x) const; /* inlined */ + virtual bool inOrder(const CoxWord &h, const CoxWord &g) const; /* inlined */ + virtual bool inOrder(List &a, const CoxWord &h, + const CoxWord &g) const; /* inlined */ + virtual bool inOrder(const CoxNbr &x, const CoxNbr &y) const; /* inlined */ + virtual bool isDihedral(const CoxWord &g) const; -//******** Chapter IV : Kazhdan-Lusztig functions ***************************** + //******** Chapter IV : Kazhdan-Lusztig functions + //***************************** - virtual void cBasis(kl::HeckeElt& h, const CoxNbr& y); + virtual void cBasis(kl::HeckeElt &h, const CoxNbr &y); virtual void fillKL(); virtual void fillMu(); - virtual const kl::KLPol& klPol(const CoxNbr& x, const CoxNbr& y); - virtual void klRow(kl::HeckeElt& h, const CoxNbr& y); - virtual KLCoeff mu(const CoxNbr& x, const CoxNbr& y); + virtual const kl::KLPol &klPol(const CoxNbr &x, const CoxNbr &y); + virtual void klRow(kl::HeckeElt &h, const CoxNbr &y); + virtual KLCoeff mu(const CoxNbr &x, const CoxNbr &y); virtual void fillIKL(); virtual void fillIMu(); - virtual const invkl::KLPol& invklPol(const CoxNbr& x, const CoxNbr& y); - virtual void invklRow(invkl::HeckeElt& h, const CoxNbr& y); + virtual const invkl::KLPol &invklPol(const CoxNbr &x, const CoxNbr &y); + virtual void invklRow(invkl::HeckeElt &h, const CoxNbr &y); virtual void fillUEKL(); virtual void fillUEMu(); - virtual const uneqkl::KLPol& uneqklPol(const CoxNbr& x, const CoxNbr& y); - virtual const uneqkl::MuPol& uneqmu(const Generator& s, const CoxNbr& x, - const CoxNbr& y); - virtual void uneqcBasis(uneqkl::HeckeElt& h, const CoxNbr& y); - virtual void uneqklRow(uneqkl::HeckeElt& h, const CoxNbr& y); + virtual const uneqkl::KLPol &uneqklPol(const CoxNbr &x, const CoxNbr &y); + virtual const uneqkl::MuPol &uneqmu(const Generator &s, const CoxNbr &x, + const CoxNbr &y); + virtual void uneqcBasis(uneqkl::HeckeElt &h, const CoxNbr &y); + virtual void uneqklRow(uneqkl::HeckeElt &h, const CoxNbr &y); -//******** Chapter V : I/O *************************************************** + //******** Chapter V : I/O *************************************************** /* elementary i/o functions */ - const Permutation& ordering() const; /* inlined */ + const Permutation &ordering() const; /* inlined */ - String& append(String& str, const Generator& s) const; /* inlined */ - String& append(String& str, const CoxWord& g) const; /* inlined */ - String& append(String& str, const LFlags& f) const; /* inlined */ + String &append(String &str, const Generator &s) const; /* inlined */ + String &append(String &str, const CoxWord &g) const; /* inlined */ + String &append(String &str, const LFlags &f) const; /* inlined */ - void printSymbol(FILE* file, const Generator& s) const; /* inlined */ - void print(FILE* file, const CoxWord& g) const; /* inlined */ - void print(FILE* file, const CoxNbr& x) const; /* inlined */ - void printFlags(FILE* file, const LFlags& f) const; /* inlined */ + void printSymbol(FILE *file, const Generator &s) const; /* inlined */ + void print(FILE *file, const CoxWord &g) const; /* inlined */ + void print(FILE *file, const CoxNbr &x) const; /* inlined */ + void printFlags(FILE *file, const LFlags &f) const; /* inlined */ - void parse(ParseInterface& P) const; - virtual bool parseGroupElement(ParseInterface& P) const; - bool parseBeginGroup(ParseInterface& P) const; - bool parseContextNumber(ParseInterface& P) const; - bool parseEndGroup(ParseInterface& P) const; - virtual bool parseModifier(ParseInterface& P) const; - virtual void modify(ParseInterface& P, const Token& tok) const; + void parse(ParseInterface &P) const; + virtual bool parseGroupElement(ParseInterface &P) const; + bool parseBeginGroup(ParseInterface &P) const; + bool parseContextNumber(ParseInterface &P) const; + bool parseEndGroup(ParseInterface &P) const; + virtual bool parseModifier(ParseInterface &P) const; + virtual void modify(ParseInterface &P, const Token &tok) const; /* modifying the interface */ - template void setOutputTraits(C); + template void setOutputTraits(C); - void setInPostfix(const String& a); /* inlined */ - void setInPrefix(const String& a); /* inlined */ - void setInSeparator(const String& a); /* inlined */ - void setInSymbol(const Generator& s, const String& a); /* inlined */ - void setOrdering(const Permutation& order); /* inlined */ - void setOutPostfix(const String& a); /* inlined */ - void setOutPrefix(const String& a); /* inlined */ - void setOutSeparator(const String& a); /* inlined */ - void setOutSymbol(const Generator& s, const String& a); /* inlined */ + void setInPostfix(const String &a); /* inlined */ + void setInPrefix(const String &a); /* inlined */ + void setInSeparator(const String &a); /* inlined */ + void setInSymbol(const Generator &s, const String &a); /* inlined */ + void setOrdering(const Permutation &order); /* inlined */ + void setOutPostfix(const String &a); /* inlined */ + void setOutPrefix(const String &a); /* inlined */ + void setOutSeparator(const String &a); /* inlined */ + void setOutSymbol(const Generator &s, const String &a); /* inlined */ - template void printHeckeElt(FILE* file, const H& h); /* inlined */ + template void printHeckeElt(FILE *file, const H &h); /* inlined */ }; //******** Inline implementations ****************************************** /* Chapter 0 */ -inline CoxGraph& CoxGroup::graph() {return *d_graph;} -inline MinTable& CoxGroup::mintable() {return *d_mintable;} -inline KLSupport& CoxGroup::klsupport() {return *d_klsupport;} -inline kl::KLContext& CoxGroup::kl() {activateKL(); return *d_kl;} -inline invkl::KLContext& CoxGroup::invkl() {activateIKL(); return *d_invkl;} -inline uneqkl::KLContext& CoxGroup::uneqkl() - {activateUEKL(); return *d_uneqkl;} -inline Interface& CoxGroup::interface() {return *d_interface;} -inline OutputTraits& CoxGroup::outputTraits() {return *d_outputTraits;} - -inline const CoxGraph& CoxGroup::graph() const {return *d_graph;} -inline const MinTable& CoxGroup::mintable() const {return *d_mintable;} -inline const KLSupport& CoxGroup::klsupport() const {return *d_klsupport;} -inline const kl::KLContext& CoxGroup::kl() const {return *d_kl;} -inline const uneqkl::KLContext& CoxGroup::uneqkl() const {return *d_uneqkl;} -inline const SchubertContext& CoxGroup::schubert() const - {return d_klsupport->schubert();} -inline const Interface& CoxGroup::interface() const {return *d_interface;} -inline const OutputTraits& CoxGroup::outputTraits() const - {return *d_outputTraits;} - -inline CoxEntry CoxGroup::M(Generator s, Generator t) const - {return(graph().M(s,t));} -inline Rank CoxGroup::rank() const {return(graph().rank());} -inline const Type& CoxGroup::type() const {return graph().type();} - -inline bool CoxGroup::isFullContext() const {return false;} +inline CoxGraph &CoxGroup::graph() { return *d_graph; } +inline MinTable &CoxGroup::mintable() { return *d_mintable; } +inline KLSupport &CoxGroup::klsupport() { return *d_klsupport; } +inline kl::KLContext &CoxGroup::kl() { + activateKL(); + return *d_kl; +} +inline invkl::KLContext &CoxGroup::invkl() { + activateIKL(); + return *d_invkl; +} +inline uneqkl::KLContext &CoxGroup::uneqkl() { + activateUEKL(); + return *d_uneqkl; +} +inline Interface &CoxGroup::interface() { return *d_interface; } +inline OutputTraits &CoxGroup::outputTraits() { return *d_outputTraits; } + +inline const CoxGraph &CoxGroup::graph() const { return *d_graph; } +inline const MinTable &CoxGroup::mintable() const { return *d_mintable; } +inline const KLSupport &CoxGroup::klsupport() const { return *d_klsupport; } +inline const kl::KLContext &CoxGroup::kl() const { return *d_kl; } +inline const uneqkl::KLContext &CoxGroup::uneqkl() const { return *d_uneqkl; } +inline const SchubertContext &CoxGroup::schubert() const { + return d_klsupport->schubert(); +} +inline const Interface &CoxGroup::interface() const { return *d_interface; } +inline const OutputTraits &CoxGroup::outputTraits() const { + return *d_outputTraits; +} + +inline CoxEntry CoxGroup::M(Generator s, Generator t) const { + return (graph().M(s, t)); +} +inline Rank CoxGroup::rank() const { return (graph().rank()); } +inline const Type &CoxGroup::type() const { return graph().type(); } + +inline bool CoxGroup::isFullContext() const { return false; } /* Chapter I */ -inline int CoxGroup::insert(CoxWord& g, const Generator& s) const - {return mintable().insert(g,s,ordering());} -inline const CoxWord& CoxGroup::inverse(CoxWord& g) const - {return mintable().inverse(g);} -inline const CoxWord& CoxGroup::normalForm(CoxWord& g) const - {return mintable().normalForm(g,interface().order());} - -inline const CoxWord& CoxGroup::power(CoxWord& g, const Ulong& m) const - {return mintable().power(g,m);} -inline int CoxGroup::prod(CoxWord& g, const Generator& s) const - {return mintable().prod(g,s);} -inline int CoxGroup::prod(CoxWord& g, const CoxWord& h) const - {return mintable().prod(g,h);} -inline const CoxWord& CoxGroup::reduced(CoxWord& g, CoxWord& h) const - {return mintable().reduced(g,h);} - -inline LFlags CoxGroup::descent(const CoxWord& g) const - {return mintable().descent(g);} -inline LFlags CoxGroup::ldescent(const CoxWord& g) const - {return mintable().ldescent(g);} -inline LFlags CoxGroup::rdescent(const CoxWord& g) const - {return mintable().rdescent(g);} +inline int CoxGroup::insert(CoxWord &g, const Generator &s) const { + return mintable().insert(g, s, ordering()); +} +inline const CoxWord &CoxGroup::inverse(CoxWord &g) const { + return mintable().inverse(g); +} +inline const CoxWord &CoxGroup::normalForm(CoxWord &g) const { + return mintable().normalForm(g, interface().order()); +} + +inline const CoxWord &CoxGroup::power(CoxWord &g, const Ulong &m) const { + return mintable().power(g, m); +} +inline int CoxGroup::prod(CoxWord &g, const Generator &s) const { + return mintable().prod(g, s); +} +inline int CoxGroup::prod(CoxWord &g, const CoxWord &h) const { + return mintable().prod(g, h); +} +inline const CoxWord &CoxGroup::reduced(CoxWord &g, CoxWord &h) const { + return mintable().reduced(g, h); +} + +inline LFlags CoxGroup::descent(const CoxWord &g) const { + return mintable().descent(g); +} +inline LFlags CoxGroup::ldescent(const CoxWord &g) const { + return mintable().ldescent(g); +} +inline LFlags CoxGroup::rdescent(const CoxWord &g) const { + return mintable().rdescent(g); +} /* Chapter II */ -inline CoxNbr CoxGroup::contextNumber(const CoxWord& g) const - {return schubert().contextNumber(g);} -inline CoxNbr CoxGroup::contextSize() const {return d_klsupport->size();} -inline Length CoxGroup::length(const CoxNbr& x) const - {return d_klsupport->length(x);} +inline CoxNbr CoxGroup::contextNumber(const CoxWord &g) const { + return schubert().contextNumber(g); +} +inline CoxNbr CoxGroup::contextSize() const { return d_klsupport->size(); } +inline Length CoxGroup::length(const CoxNbr &x) const { + return d_klsupport->length(x); +} -inline LFlags CoxGroup::descent(const CoxNbr& x) const - {return schubert().descent(x);} -inline LFlags CoxGroup::ldescent(const CoxNbr& x) const - {return schubert().ldescent(x);} -inline LFlags CoxGroup::rdescent(const CoxNbr& x) const - {return schubert().rdescent(x);} +inline LFlags CoxGroup::descent(const CoxNbr &x) const { + return schubert().descent(x); +} +inline LFlags CoxGroup::ldescent(const CoxNbr &x) const { + return schubert().ldescent(x); +} +inline LFlags CoxGroup::rdescent(const CoxNbr &x) const { + return schubert().rdescent(x); +} -inline CoxNbr CoxGroup::inverse(const CoxNbr& x) const - {return d_klsupport->inverse(x);} -inline int CoxGroup::lprod(CoxNbr& x, const Generator& s) const - {return prod(x,s+rank());} +inline CoxNbr CoxGroup::inverse(const CoxNbr &x) const { + return d_klsupport->inverse(x); +} +inline int CoxGroup::lprod(CoxNbr &x, const Generator &s) const { + return prod(x, s + rank()); +} -inline const List& CoxGroup::extrList(const CoxNbr& x) const - {return d_klsupport->extrList(x);} +inline const List &CoxGroup::extrList(const CoxNbr &x) const { + return d_klsupport->extrList(x); +} /* Chapter III */ -inline const CoatomList& CoxGroup::coatoms(const CoxNbr& x) const - {return schubert().hasse(x);} -inline void CoxGroup::extractClosure(BitMap& b, const CoxNbr& x) const - {return schubert().extractClosure(b,x);} -inline bool CoxGroup::inOrder(const CoxWord& g, const CoxWord& h) const - {return mintable().inOrder(g,h);} -inline bool CoxGroup::inOrder(List& a, const CoxWord& g, - const CoxWord& h) const - {return mintable().inOrder(a,g,h);} -inline bool CoxGroup::inOrder(const CoxNbr& x, const CoxNbr& y) const - {return schubert().inOrder(x,y);} +inline const CoatomList &CoxGroup::coatoms(const CoxNbr &x) const { + return schubert().hasse(x); +} +inline void CoxGroup::extractClosure(BitMap &b, const CoxNbr &x) const { + return schubert().extractClosure(b, x); +} +inline bool CoxGroup::inOrder(const CoxWord &g, const CoxWord &h) const { + return mintable().inOrder(g, h); +} +inline bool CoxGroup::inOrder(List &a, const CoxWord &g, + const CoxWord &h) const { + return mintable().inOrder(a, g, h); +} +inline bool CoxGroup::inOrder(const CoxNbr &x, const CoxNbr &y) const { + return schubert().inOrder(x, y); +} /* Chapter V */ -inline const Permutation& CoxGroup::ordering() const - {return interface().order();} - -inline String& CoxGroup::append(String& str, const Generator& s) - const {return appendSymbol(str,s,interface());} -inline String& CoxGroup::append(String& str, const CoxWord& g) const - {return interface::append(str,g,interface());} -inline String& CoxGroup::append(String& str, const LFlags& f) const - {return interface::append(str,f,interface());} - -inline void CoxGroup::printSymbol(FILE* file, const Generator& s) - const {return interface::printSymbol(file,s,interface());} -inline void CoxGroup::print(FILE* file, const CoxWord& g) const - {return interface().print(file,g);} -inline void CoxGroup::print(FILE* file, const CoxNbr& x) const - {return schubert().print(file,x,interface());} -inline void CoxGroup::printFlags(FILE* file, const LFlags& f) const - {return interface::print(file,f,interface());} - -inline void CoxGroup::setInPostfix(const String& a) - {interface().setInPostfix(a);} -inline void CoxGroup::setInPrefix(const String& a) - {interface().setInPrefix(a);} -inline void CoxGroup::setInSeparator(const String& a) - {interface().setInSeparator(a);} -inline void CoxGroup::setInSymbol(const Generator& s, const String& a) - {interface().setInSymbol(s,a);} -inline void CoxGroup::setOrdering(const Permutation& order) - {interface().setOrder(order);} -inline void CoxGroup::setOutPostfix(const String& a) - {interface().setOutPostfix(a);} -inline void CoxGroup::setOutPrefix(const String& a) - {interface().setOutPrefix(a);} -inline void CoxGroup::setOutSeparator(const String& a) - {interface().setOutSeparator(a);} -inline void CoxGroup::setOutSymbol(const Generator& s, const String& a) - {interface().setOutSymbol(s,a);} - -template -inline void CoxGroup::printHeckeElt(FILE* file, const H& h) - {files::printHeckeElt(file,h,schubert(),outputTraits());} +inline const Permutation &CoxGroup::ordering() const { + return interface().order(); +} -//******** template definitions *********************************************** +inline String &CoxGroup::append(String &str, const Generator &s) const { + return appendSymbol(str, s, interface()); +} +inline String &CoxGroup::append(String &str, const CoxWord &g) const { + return interface::append(str, g, interface()); +} +inline String &CoxGroup::append(String &str, const LFlags &f) const { + return interface::append(str, f, interface()); +} + +inline void CoxGroup::printSymbol(FILE *file, const Generator &s) const { + return interface::printSymbol(file, s, interface()); +} +inline void CoxGroup::print(FILE *file, const CoxWord &g) const { + return interface().print(file, g); +} +inline void CoxGroup::print(FILE *file, const CoxNbr &x) const { + return schubert().print(file, x, interface()); +} +inline void CoxGroup::printFlags(FILE *file, const LFlags &f) const { + return interface::print(file, f, interface()); +} -template void CoxGroup::setOutputTraits(C) - {new(d_outputTraits) OutputTraits(graph(),interface(),C());} +inline void CoxGroup::setInPostfix(const String &a) { + interface().setInPostfix(a); +} +inline void CoxGroup::setInPrefix(const String &a) { + interface().setInPrefix(a); +} +inline void CoxGroup::setInSeparator(const String &a) { + interface().setInSeparator(a); +} +inline void CoxGroup::setInSymbol(const Generator &s, const String &a) { + interface().setInSymbol(s, a); +} +inline void CoxGroup::setOrdering(const Permutation &order) { + interface().setOrder(order); +} +inline void CoxGroup::setOutPostfix(const String &a) { + interface().setOutPostfix(a); +} +inline void CoxGroup::setOutPrefix(const String &a) { + interface().setOutPrefix(a); +} +inline void CoxGroup::setOutSeparator(const String &a) { + interface().setOutSeparator(a); +} +inline void CoxGroup::setOutSymbol(const Generator &s, const String &a) { + interface().setOutSymbol(s, a); +} +template inline void CoxGroup::printHeckeElt(FILE *file, const H &h) { + files::printHeckeElt(file, h, schubert(), outputTraits()); } +//******** template definitions *********************************************** + +template void CoxGroup::setOutputTraits(C) { + new (d_outputTraits) OutputTraits(graph(), interface(), C()); +} + +} // namespace coxeter + #endif diff --git a/coxtypes.cpp b/coxtypes.cpp index 8307add..678a2c1 100644 --- a/coxtypes.cpp +++ b/coxtypes.cpp @@ -1,6 +1,6 @@ /* This is coxtypes.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -27,7 +27,8 @@ namespace coxtypes { -CoxWord::CoxWord(const Ulong& n):d_list(n+1) +CoxWord::CoxWord(const Ulong &n) + : d_list(n + 1) { d_list.setSize(1); @@ -37,7 +38,7 @@ CoxWord::~CoxWord() {} -CoxWord& CoxWord::append(const CoxLetter& a) +CoxWord &CoxWord::append(const CoxLetter &a) /* Appends a to the end of g, resizing as necessary. Recall that for now @@ -45,14 +46,13 @@ CoxWord& CoxWord::append(const CoxLetter& a) */ { - d_list[d_list.size()-1] = a; + d_list[d_list.size() - 1] = a; d_list.append('\0'); return *this; } - -CoxWord& CoxWord::append(const CoxWord& h) +CoxWord &CoxWord::append(const CoxWord &h) /* Appends h to the end of g. @@ -63,46 +63,46 @@ CoxWord& CoxWord::append(const CoxWord& h) */ { - d_list.setData(h.d_list.ptr(),d_list.size()-1,h.d_list.size()); + d_list.setData(h.d_list.ptr(), d_list.size() - 1, h.d_list.size()); return *this; } -CoxWord& CoxWord::erase(const Length& j) +CoxWord &CoxWord::erase(const Length &j) /* Erases the j-th letter from g. NOTE : care should be exercised in applying this function, that the result - be reduced; otherwise we would violate the basic principle that only + be reduced; otherwise we would violate the basic principle that only reduced words enter the program. */ { - d_list.setData(d_list.ptr()+j+1,j,d_list.size()-1-j); - d_list.setSize(d_list.size()-1); + d_list.setData(d_list.ptr() + j + 1, j, d_list.size() - 1 - j); + d_list.setSize(d_list.size() - 1); return *this; } -CoxWord& CoxWord::insert(const Length& j, const CoxLetter& a) +CoxWord &CoxWord::insert(const Length &j, const CoxLetter &a) /* Inserts a at the j-th place in g. NOTE : care should be exercised in applying this function, that the result - be reduced; otherwise we would violate the basic principle that only + be reduced; otherwise we would violate the basic principle that only reduced words enter the program. */ { - d_list.setSize(d_list.size()+1); - d_list.setData(d_list.ptr()+j,j+1,d_list.size()-1-j); + d_list.setSize(d_list.size() + 1); + d_list.setData(d_list.ptr() + j, j + 1, d_list.size() - 1 - j); d_list[j] = a; return *this; } -CoxWord& CoxWord::reset() +CoxWord &CoxWord::reset() /* Sets g to the identity. @@ -115,15 +115,15 @@ CoxWord& CoxWord::reset() return *this; } -CoxWord& CoxWord::setSubWord(const CoxWord& h, const Length& first, - const Length& r) +CoxWord &CoxWord::setSubWord(const CoxWord &h, const Length &first, + const Length &r) -{ - d_list.setData(h.d_list.ptr(),first,r); +{ + d_list.setData(h.d_list.ptr(), first, r); return *this; } -}; +}; // namespace coxtypes /***************************************************************************** @@ -140,7 +140,7 @@ CoxWord& CoxWord::setSubWord(const CoxWord& h, const Length& first, namespace coxtypes { -bool operator== (const CoxWord& g, const CoxWord& h) +bool operator==(const CoxWord &g, const CoxWord &h) /* Tells if g and h are equal as words. @@ -158,7 +158,7 @@ bool operator== (const CoxWord& g, const CoxWord& h) return true; } -bool operator< (const CoxWord& g, const CoxWord& h) +bool operator<(const CoxWord &g, const CoxWord &h) /* Tells if g < h length-lexicographically @@ -182,13 +182,13 @@ bool operator< (const CoxWord& g, const CoxWord& h) return false; } -}; +}; // namespace coxtypes /**************************************************************************** Chapter III -- Input/Output. - This section provides some input/output functions for the basic types + This section provides some input/output functions for the basic types defined in this module. The following functions are provided : - append(str,x) : appends a CoxNbr to the string; @@ -198,16 +198,16 @@ bool operator< (const CoxWord& g, const CoxWord& h) namespace coxtypes { -String& append(String& str, const CoxNbr& x) +String &append(String &str, const CoxNbr &x) /* Appends x to str in numeral form; uses buf to write out the value. */ { - static String buf(digits(COXNBR_MAX,10)+1); - buf.setLength(sprintf(buf.ptr(),"%lu",static_cast(x))); - append(str,buf); + static String buf(digits(COXNBR_MAX, 10) + 1); + buf.setLength(sprintf(buf.ptr(), "%lu", static_cast(x))); + append(str, buf); return str; } @@ -218,20 +218,19 @@ void print(FILE *outputfile, CoxArr a, Rank l) */ { - fprintf(outputfile,"["); + fprintf(outputfile, "["); - for (Ulong j = 0; j < l; ++j) + for (Ulong j = 0; j < l; ++j) { + fprintf(outputfile, "%d", a[j]); + if (j + 1 < l) /* there is more to come */ { - fprintf(outputfile,"%d",a[j]); - if (j+1 < l) /* there is more to come */ - { - fprintf(outputfile,","); - } + fprintf(outputfile, ","); } + } - fprintf(outputfile,"]"); + fprintf(outputfile, "]"); return; } -}; +}; // namespace coxtypes diff --git a/coxtypes.h b/coxtypes.h index 8a9f29f..2d27203 100644 --- a/coxtypes.h +++ b/coxtypes.h @@ -11,7 +11,7 @@ ****************************************************************************/ -#ifndef COXTYPES_H /* guard against multiple inclusions */ +#ifndef COXTYPES_H /* guard against multiple inclusions */ #define COXTYPES_H #include @@ -21,100 +21,103 @@ #include "list.h" namespace coxtypes { - using namespace coxeter; - using namespace io; - using namespace list; +using namespace coxeter; +using namespace io; +using namespace list; /* type declarations and bounds */ - typedef unsigned short Rank; - typedef Ulong CoxSize; /* should hold at least 32 bits */ - typedef Ulong BettiNbr; /* should hold at least 32 bits */ - typedef unsigned CoxNbr; /* should fit into a CoxSize */ - typedef CoxNbr ParSize; /* this should not be changed */ - typedef unsigned short ParNbr; /* should fit into a CoxNbr */ - typedef ParNbr *CoxArr; - typedef unsigned char CoxLetter; /* for string representations */ - typedef CoxLetter Generator; /* internal representation of generators*/ - typedef unsigned short Length; - typedef Ulong StarOp; /* for numbering star operations */ +typedef unsigned short Rank; +typedef Ulong CoxSize; /* should hold at least 32 bits */ +typedef Ulong BettiNbr; /* should hold at least 32 bits */ +typedef unsigned CoxNbr; /* should fit into a CoxSize */ +typedef CoxNbr ParSize; /* this should not be changed */ +typedef unsigned short ParNbr; /* should fit into a CoxNbr */ +typedef ParNbr *CoxArr; +typedef unsigned char CoxLetter; /* for string representations */ +typedef CoxLetter Generator; /* internal representation of generators*/ +typedef unsigned short Length; +typedef Ulong StarOp; /* for numbering star operations */ - class CoxWord; +class CoxWord; /* constants */ - // const Rank RANK_MAX = 255; /* to enable string representations */ - // MEDRANK_MAX bits should fit in a LFlags - const Rank MEDRANK_MAX = CHAR_BIT*sizeof(Ulong); - // 2*SMALLRANK_MAX bits should fit in a LFlags - const Rank SMALLRANK_MAX = CHAR_BIT*sizeof(Ulong)/2; - const Rank RANK_MAX = SMALLRANK_MAX; /* temporary restriction */ - const Generator GENERATOR_MAX = RANK_MAX-1; /* top value is reserved */ - const Generator undef_generator = RANK_MAX; - const CoxSize COXSIZE_MAX = ULONG_MAX-2; /* top values are reserved */ - const CoxSize infinite_coxsize = COXSIZE_MAX+1; - const CoxSize undef_coxsize = COXSIZE_MAX+2; - const BettiNbr BETTI_MAX = ULONG_MAX-1; /* top value is reserved */ - const BettiNbr undef_betti = BETTI_MAX+1; - const CoxNbr COXNBR_MAX = UINT_MAX-1; /* top value is reserved */ - const CoxNbr undef_coxnbr = COXNBR_MAX+1; - const ParSize LPARNBR_MAX = COXNBR_MAX-RANK_MAX-1;/* top value is reserved */ - const ParNbr PARNBR_MAX = USHRT_MAX-RANK_MAX-1; /* top value is reserved */ - const Length LENGTH_MAX = USHRT_MAX-1; /* top value is reserved */ - const Length undef_length = LENGTH_MAX+1; - const StarOp STAR_MAX = ULONG_MAX-1; /* top value is reserved */ - const StarOp undef_starop = STAR_MAX+1; +// const Rank RANK_MAX = 255; /* to enable string representations */ +// MEDRANK_MAX bits should fit in a LFlags +const Rank MEDRANK_MAX = CHAR_BIT * sizeof(Ulong); +// 2*SMALLRANK_MAX bits should fit in a LFlags +const Rank SMALLRANK_MAX = CHAR_BIT * sizeof(Ulong) / 2; +const Rank RANK_MAX = SMALLRANK_MAX; /* temporary restriction */ +const Generator GENERATOR_MAX = RANK_MAX - 1; /* top value is reserved */ +const Generator undef_generator = RANK_MAX; +const CoxSize COXSIZE_MAX = ULONG_MAX - 2; /* top values are reserved */ +const CoxSize infinite_coxsize = COXSIZE_MAX + 1; +const CoxSize undef_coxsize = COXSIZE_MAX + 2; +const BettiNbr BETTI_MAX = ULONG_MAX - 1; /* top value is reserved */ +const BettiNbr undef_betti = BETTI_MAX + 1; +const CoxNbr COXNBR_MAX = UINT_MAX - 1; /* top value is reserved */ +const CoxNbr undef_coxnbr = COXNBR_MAX + 1; +const ParSize LPARNBR_MAX = + COXNBR_MAX - RANK_MAX - 1; /* top value is reserved */ +const ParNbr PARNBR_MAX = USHRT_MAX - RANK_MAX - 1; /* top value is reserved */ +const Length LENGTH_MAX = USHRT_MAX - 1; /* top value is reserved */ +const Length undef_length = LENGTH_MAX + 1; +const StarOp STAR_MAX = ULONG_MAX - 1; /* top value is reserved */ +const StarOp undef_starop = STAR_MAX + 1; /* functions provided by coxtypes.h */ - bool operator== (const CoxWord& g, const CoxWord& h); - bool operator< (const CoxWord& g, const CoxWord& h); - bool operator> (const CoxWord& g, const CoxWord& h); /* inlined */ - String& append(String& str, const CoxNbr& x); - void print(FILE *outputfile, CoxArr a, Rank l); +bool operator==(const CoxWord &g, const CoxWord &h); +bool operator<(const CoxWord &g, const CoxWord &h); +bool operator>(const CoxWord &g, const CoxWord &h); /* inlined */ +String &append(String &str, const CoxNbr &x); +void print(FILE *outputfile, CoxArr a, Rank l); /******** Implementation ****************************************************/ class CoxWord { - private: +private: List d_list; - public: -/* constructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CoxWord));} - CoxWord():d_list(0) {}; /* empty word */ - CoxWord(const Ulong& n); + +public: + /* constructors */ + void operator delete(void *ptr) { return arena().free(ptr, sizeof(CoxWord)); } + CoxWord() : d_list(0){}; /* empty word */ + CoxWord(const Ulong &n); ~CoxWord(); -/* accessors */ - const CoxLetter& operator[] (const Length& j) const; /* inlined */ - Length length() const; /* inlined */ -/* modifiers */ - CoxWord& operator= (const CoxWord& h); /* inlined */ - CoxLetter& operator[] (const Length& j); /* inlined */ - CoxWord& append(const CoxLetter& a); - CoxWord& append(const CoxWord& h); - CoxWord& erase(const Length& j); - CoxWord& insert(const Length& j, const CoxLetter& a); - CoxWord& reset(); - void setLength(Length n); /* inlined */ - CoxWord& setSubWord(const CoxWord& h, const Length& first, - const Length& r); + /* accessors */ + const CoxLetter &operator[](const Length &j) const; /* inlined */ + Length length() const; /* inlined */ + /* modifiers */ + CoxWord &operator=(const CoxWord &h); /* inlined */ + CoxLetter &operator[](const Length &j); /* inlined */ + CoxWord &append(const CoxLetter &a); + CoxWord &append(const CoxWord &h); + CoxWord &erase(const Length &j); + CoxWord &insert(const Length &j, const CoxLetter &a); + CoxWord &reset(); + void setLength(Length n); /* inlined */ + CoxWord &setSubWord(const CoxWord &h, const Length &first, const Length &r); }; /******** Inline definitions ***********************************************/ - inline bool operator> (const CoxWord& g, const CoxWord& h) {return h < g;} +inline bool operator>(const CoxWord &g, const CoxWord &h) { return h < g; } - /* class CoxWord */ +/* class CoxWord */ - inline const CoxLetter& CoxWord::operator[] (const Length& j) const - {return d_list[j];} - inline Length CoxWord::length() const {return d_list.size()-1;} +inline const CoxLetter &CoxWord::operator[](const Length &j) const { + return d_list[j]; +} +inline Length CoxWord::length() const { return d_list.size() - 1; } - inline CoxWord& CoxWord::operator=(const CoxWord & h) - {d_list.assign(h.d_list); return *this;} - inline CoxLetter& CoxWord::operator[] (const Length& j) {return d_list[j];} - inline void CoxWord::setLength(Length n) {d_list.setSize(n+1);} +inline CoxWord &CoxWord::operator=(const CoxWord &h) { + d_list.assign(h.d_list); + return *this; } +inline CoxLetter &CoxWord::operator[](const Length &j) { return d_list[j]; } +inline void CoxWord::setLength(Length n) { d_list.setSize(n + 1); } +} // namespace coxtypes #endif diff --git a/dictionary.h b/dictionary.h index ce30edf..bce8b02 100644 --- a/dictionary.h +++ b/dictionary.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef DICTIONARY_H /* guard against multiple inclusions */ +#ifndef DICTIONARY_H /* guard against multiple inclusions */ #define DICTIONARY_H #include "globals.h" @@ -13,61 +13,61 @@ #include "io.h" namespace dictionary { - using namespace coxeter; - using namespace memory; - using namespace io; +using namespace coxeter; +using namespace memory; +using namespace io; /******** type declarations *************************************************/ - template class Dictionary; - template struct DictCell; +template class Dictionary; +template struct DictCell; /******** function declarations *********************************************/ - template - void printExtensions(FILE* file, DictCell* cell, String& name, - bool& first, const char* sep = ","); +template +void printExtensions(FILE *file, DictCell *cell, String &name, bool &first, + const char *sep = ","); /* class definitions */ -template -struct DictCell { +template struct DictCell { T *ptr; DictCell *left; DictCell *right; char letter; bool fullname; bool uniquePrefix; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(DictCell));} - DictCell() {/* not implemented */}; - DictCell(char c, T* v, bool f, bool u, DictCell *l = 0, DictCell *r = 0) - :ptr(v), left(l), right(r), letter(c), fullname(f), uniquePrefix(u) {}; + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(DictCell)); + } + DictCell(){/* not implemented */}; + DictCell(char c, T *v, bool f, bool u, DictCell *l = 0, DictCell *r = 0) + : ptr(v), left(l), right(r), letter(c), fullname(f), uniquePrefix(u){}; ~DictCell(); -/* accessors */ - T* value() const {return ptr;} + /* accessors */ + T *value() const { return ptr; } }; -template -class Dictionary { - protected: - DictCell* d_root; - public: -/* creators and destructors */ +template class Dictionary { +protected: + DictCell *d_root; + +public: + /* creators and destructors */ Dictionary(); virtual ~Dictionary(); -/* modifiers */ - void insert(const String& str, T* const value); - void remove(const String& str); -/* accessors */ - T* find(const String& str) const; - DictCell* findCell(const String& str) const; - DictCell* root() {return d_root;} + /* modifiers */ + void insert(const String &str, T *const value); + void remove(const String &str); + /* accessors */ + T *find(const String &str) const; + DictCell *findCell(const String &str) const; + DictCell *root() { return d_root; } }; -} +} // namespace dictionary #include "dictionary.hpp" diff --git a/dictionary.hpp b/dictionary.hpp index e593deb..8700544 100644 --- a/dictionary.hpp +++ b/dictionary.hpp @@ -1,6 +1,6 @@ /* This is dictionary.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -10,7 +10,7 @@ This module contains an implementation of dictionaries. For us, a dictionary is a search structure (in practice, a tree) recognizing strings. The operations which are allowed are inserting and deleting a string, and - searching for a given string. The return value is a pointer; this allows us + searching for a given string. The return value is a pointer; this allows us to have a unique typesize. ****************************************************************************/ @@ -23,7 +23,8 @@ namespace dictionary { -template Dictionary::Dictionary() +template +Dictionary::Dictionary() /* Default constructor for the Dictionary class. A dictionary is always @@ -31,10 +32,11 @@ template Dictionary::Dictionary() */ { - d_root = new DictCell(0,0,true,false); + d_root = new DictCell(0, 0, true, false); } -template Dictionary::~Dictionary() +template +Dictionary::~Dictionary() /* Destructor for the Dictionary class. The destructor has to run through @@ -45,8 +47,8 @@ template Dictionary::~Dictionary() delete d_root; } -template DictCell* Dictionary::findCell(const String& str) - const +template +DictCell *Dictionary::findCell(const String &str) const /* Searches for a value in the dictionary. Returns NULL in case of failure. @@ -59,26 +61,26 @@ template DictCell* Dictionary::findCell(const String& str) { DictCell *cell = d_root; - - for (Ulong j = 0; str[j]; ++j) - { - if (cell->left == 0) /* leaf reached */ - return 0; - cell = cell->left; - char c = str[j]; - while ((cell->right) && (c > cell->letter)) - cell = cell->right; - if (c != cell->letter) - return 0; - } + + for (Ulong j = 0; str[j]; ++j) { + if (cell->left == 0) /* leaf reached */ + return 0; + cell = cell->left; + char c = str[j]; + while ((cell->right) && (c > cell->letter)) + cell = cell->right; + if (c != cell->letter) + return 0; + } return cell; } -template T* Dictionary::find(const String& str) const +template +T *Dictionary::find(const String &str) const { - DictCell* dc = findCell(str); + DictCell *dc = findCell(str); if (dc) return dc->value(); @@ -86,19 +88,19 @@ template T* Dictionary::find(const String& str) const return 0; } -template void Dictionary::insert(const String& str, - T* const value) +template +void Dictionary::insert(const String &str, T *const value) /* Inserts a new word in the dictionary. The root of the tree always corresponds to the empty string "" (which may or may not be considered to be in the dictionary.) The nodes are classified in three types : dictionary words, unique prefixes (i.e., strings which are prefixes - to a unique dictionary word) and non-unique prefixes. + to a unique dictionary word) and non-unique prefixes. */ { - DictCell* cell = findCell(str); + DictCell *cell = findCell(str); if (cell && cell->fullname) { /* word was already in the dictionary */ cell->ptr = value; @@ -110,51 +112,52 @@ template void Dictionary::insert(const String& str, cell = d_root; - for (Ulong j = 0; str[j]; ++j) - { - if (cell->left == 0) { /* leaf reached */ - if (str[j+1]) /* add non-leaf */ - cell->left = new DictCell(str[j],0,false,true); - else /* add leaf */ - cell->left = new DictCell(str[j],value,true,false); - cell = cell->left; - continue; - } - - /* if we reach this point we are at a non-leaf */ - - if (str[j] < cell->left->letter) { /* insert at - beginning */ - if (str[j+1]) /* add non-leaf */ - cell->left = new DictCell(str[j],0,false,true,0,cell->left); - else /* add leaf */ - cell->left = new DictCell(str[j],value,true,false,0,cell->left); - cell = cell->left; - continue; - } + for (Ulong j = 0; str[j]; ++j) { + if (cell->left == 0) { /* leaf reached */ + if (str[j + 1]) /* add non-leaf */ + cell->left = new DictCell(str[j], 0, false, true); + else /* add leaf */ + cell->left = new DictCell(str[j], value, true, false); cell = cell->left; - while (cell->right && (cell->right->letter <= str[j])) - cell = cell->right; - if (cell->letter < str[j]) { /* add new cell */ - if (str[j+1]) /* add non-leaf */ - cell->right = new DictCell(str[j],0,false,true,0,cell->right); - else /* add leaf */ - cell->right = new DictCell(str[j],value,true,false,0,cell->right); - cell = cell->right; - continue; - } - - /* if we reach this point cell->letter = str[j] */ - - cell->uniquePrefix = false; - if (str[j+1] == 0) { /* word is complete */ - cell->fullname = true; - cell->ptr = value; - } + continue; } + + /* if we reach this point we are at a non-leaf */ + + if (str[j] < cell->left->letter) { /* insert at + beginning */ + if (str[j + 1]) /* add non-leaf */ + cell->left = new DictCell(str[j], 0, false, true, 0, cell->left); + else /* add leaf */ + cell->left = new DictCell(str[j], value, true, false, 0, cell->left); + cell = cell->left; + continue; + } + cell = cell->left; + while (cell->right && (cell->right->letter <= str[j])) + cell = cell->right; + if (cell->letter < str[j]) { /* add new cell */ + if (str[j + 1]) /* add non-leaf */ + cell->right = new DictCell(str[j], 0, false, true, 0, cell->right); + else /* add leaf */ + cell->right = + new DictCell(str[j], value, true, false, 0, cell->right); + cell = cell->right; + continue; + } + + /* if we reach this point cell->letter = str[j] */ + + cell->uniquePrefix = false; + if (str[j + 1] == 0) { /* word is complete */ + cell->fullname = true; + cell->ptr = value; + } + } } -template void Dictionary::remove(const String& str) +template +void Dictionary::remove(const String &str) /* Not implemented. @@ -162,8 +165,7 @@ template void Dictionary::remove(const String& str) {} -}; - +}; // namespace dictionary /**************************************************************************** @@ -173,7 +175,8 @@ template void Dictionary::remove(const String& str) namespace dictionary { -template DictCell::~DictCell() +template +DictCell::~DictCell() /* This destructor will recursively remove the dictionary. It is assumed @@ -194,19 +197,19 @@ template void DictCell::operator delete(void* ptr, size_t size) } */ -}; +}; // namespace dictionary /****** Auxiliary functions ************************************************/ namespace dictionary { -template - void printExtensions(FILE* file, DictCell* cell, String& name, - bool &first, const char* sep) +template +void printExtensions(FILE *file, DictCell *cell, String &name, bool &first, + const char *sep) /* This function prints all the possible extensions of the prefix corresponding - to str on stdout. It is an auxiliary to the interactive treatment of + to str on stdout. It is an auxiliary to the interactive treatment of ambiguities. It is assumed that name contains the name of the parent of the string. */ @@ -214,17 +217,17 @@ template { if (cell == 0) return; - append(name,cell->letter); + append(name, cell->letter); if (cell->fullname) { /* print */ - if (first) /* first time a name is found */ + if (first) /* first time a name is found */ first = false; else - fprintf(file,"%s",sep); - fprintf(file,"%s",name.ptr()); + fprintf(file, "%s", sep); + fprintf(file, "%s", name.ptr()); } - printExtensions(file,cell->left,name,first,sep); - erase(name,1); - printExtensions(file,cell->right,name,first,sep); + printExtensions(file, cell->left, name, first, sep); + erase(name, 1); + printExtensions(file, cell->right, name, first, sep); } -}; +}; // namespace dictionary diff --git a/directories.h b/directories.h index 496dff5..d9da303 100644 --- a/directories.h +++ b/directories.h @@ -1,12 +1,12 @@ /* This is directories.h - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux Coxeter version 3.1 Copyright (C) 2015 Travis Scrimshaw See file main.cpp for full copyright notice */ -#ifndef DIRECTORIES_H /* guard against multiple inclusions */ +#ifndef DIRECTORIES_H /* guard against multiple inclusions */ #define DIRECTORIES_H /* @@ -25,9 +25,9 @@ */ namespace directories { - const char* const COXMATRIX_DIR = "/usr/local/coxeter/coxeter_matrices"; - const char* const HEADER_DIR = "/usr/local/coxeter/headers"; - const char* const MESSAGE_DIR = "/usr/local/coxeter/messages"; -}; +const char *const COXMATRIX_DIR = "/usr/local/coxeter/coxeter_matrices"; +const char *const HEADER_DIR = "/usr/local/coxeter/headers"; +const char *const MESSAGE_DIR = "/usr/local/coxeter/messages"; +}; // namespace directories #endif diff --git a/dotval.h b/dotval.h index 62aa154..3db0369 100644 --- a/dotval.h +++ b/dotval.h @@ -1,30 +1,30 @@ /* This is dotval.h - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ -#ifndef DOTVAL_H /* guard against multiple inclusions */ +#ifndef DOTVAL_H /* guard against multiple inclusions */ #define DOTVAL_H namespace dotval { - enum DotVal { - undef_dotval = -8, - locked = -6, - undef_negdot = -5, - neg_cos = -4, - neg_cos2 = -3, - neg_half = -2, - neg_hinvgold = -1, - zero = 0, - hinvgold = 1, - half = 2, - cos2 = 3, - cos = 4, - undef_posdot = 5, - one = 6 - }; +enum DotVal { + undef_dotval = -8, + locked = -6, + undef_negdot = -5, + neg_cos = -4, + neg_cos2 = -3, + neg_half = -2, + neg_hinvgold = -1, + zero = 0, + hinvgold = 1, + half = 2, + cos2 = 3, + cos = 4, + undef_posdot = 5, + one = 6 +}; }; #endif diff --git a/error.cpp b/error.cpp index 614e885..849e075 100644 --- a/error.cpp +++ b/error.cpp @@ -20,75 +20,73 @@ #include "version.h" namespace error { - using namespace directories; - using namespace io; - using namespace interactive; - using namespace interface; - using namespace kl; - using namespace coxtypes; - using namespace graph; - using namespace schubert; - using namespace version; -}; +using namespace directories; +using namespace io; +using namespace interactive; +using namespace interface; +using namespace kl; +using namespace coxtypes; +using namespace graph; +using namespace schubert; +using namespace version; +}; // namespace error namespace error { - bool CATCH_MEMORY_OVERFLOW = false; - int ERRNO = 0; -}; +bool CATCH_MEMORY_OVERFLOW = false; +int ERRNO = 0; +}; // namespace error namespace { - using namespace error; - - void abortError(); - void badCoxEntry(); - void badFile(); - void badInput(char *s); - void badLength(const long& l); - void badLine(char *filename,Rank l,Rank i,Rank j); - void badRCycField(); - void checkminFail(); - void commandRedefinition(char *a); - void commandNotFound(char *a); - void contextNbrOverflow(Ulong size); - void coxAllocFail(); - void coxNbrOverflow(); - void denseArrayOverflow(Ulong size); - void extensionFail(); - void fileNotFound(char *s); - void klCoeffNegative(const CoxNbr& x, const CoxNbr& y); - void klCoeffOverflow(const CoxNbr& x, const CoxNbr& y); - void klFail(const CoxNbr& x, const CoxNbr& y); - void leadingWhitespace(const GroupEltInterface& I, - const GroupEltInterface& J, const Permutation& a, const String& str); - void lengthOverflow(); - void memoryWarning(); - void minRootOverflow(); - void modeChangeFail(); - void muFail(const KLContext& kl, const CoxNbr& x, const CoxNbr& y); - void muNegative(const KLContext& kl, const CoxNbr& x, const CoxNbr& y); - void muOverflow(const KLContext& kl, const CoxNbr& x, const CoxNbr& y); - void notAffine(); - void notCoxelt(); - void notDescent(const char *const str); - void notFinite(); - void notGenerator(); - void notPermutation(); - void notSymmetric(char *filename, CoxMatrix& m, Rank l, - Rank i, Rank j); - void outOfMemory(); - void parNbrOverflow(); - void parseError(const char *const str); - void repeatedSymbol(const GroupEltInterface& I, const GroupEltInterface& J, - const Permutation& a); - void reservedSymbol(const GroupEltInterface& I, const GroupEltInterface& J, - const Permutation& a, const String& str); - void ueMuFail(const CoxNbr& x, const CoxNbr& y); - void undefCoxarr(); - void wrongCoxeterEntry(Rank i, Rank j, Ulong m); - void wrongRank(const Type& type, Rank* l, int* mess); - void wrongType(); -}; - +using namespace error; + +void abortError(); +void badCoxEntry(); +void badFile(); +void badInput(char *s); +void badLength(const long &l); +void badLine(char *filename, Rank l, Rank i, Rank j); +void badRCycField(); +void checkminFail(); +void commandRedefinition(char *a); +void commandNotFound(char *a); +void contextNbrOverflow(Ulong size); +void coxAllocFail(); +void coxNbrOverflow(); +void denseArrayOverflow(Ulong size); +void extensionFail(); +void fileNotFound(char *s); +void klCoeffNegative(const CoxNbr &x, const CoxNbr &y); +void klCoeffOverflow(const CoxNbr &x, const CoxNbr &y); +void klFail(const CoxNbr &x, const CoxNbr &y); +void leadingWhitespace(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a, const String &str); +void lengthOverflow(); +void memoryWarning(); +void minRootOverflow(); +void modeChangeFail(); +void muFail(const KLContext &kl, const CoxNbr &x, const CoxNbr &y); +void muNegative(const KLContext &kl, const CoxNbr &x, const CoxNbr &y); +void muOverflow(const KLContext &kl, const CoxNbr &x, const CoxNbr &y); +void notAffine(); +void notCoxelt(); +void notDescent(const char *const str); +void notFinite(); +void notGenerator(); +void notPermutation(); +void notSymmetric(char *filename, CoxMatrix &m, Rank l, Rank i, Rank j); +void outOfMemory(); +void parNbrOverflow(); +void parseError(const char *const str); +void repeatedSymbol(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a); +void reservedSymbol(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a, const String &str); +void ueMuFail(const CoxNbr &x, const CoxNbr &y); +void undefCoxarr(); +void wrongCoxeterEntry(Rank i, Rank j, Ulong m); +void wrongRank(const Type &type, Rank *l, int *mess); +void wrongType(); +}; // namespace /******************************************************************** @@ -96,7 +94,7 @@ namespace { ********************************************************************/ -void error::Error(int number, ... ) +void error::Error(int number, ...) /* This function dispatches the error messages to their respective @@ -114,234 +112,210 @@ void error::Error(int number, ... ) ERRNO = 0; - va_start(ap,number); - - switch (number) - { - case 0: - break; - case ABORT: - abortError(); - break; - case BAD_COXENTRY: - badCoxEntry(); - break; - case BAD_INPUT: { - char *a = va_arg(ap,char *); - badInput(a); - } - break; - case BAD_LENGTH: { - Ulong l = va_arg(ap,long); - badLength(l); - } - break; - case BAD_LINE: { - char *filename = va_arg(ap,char *); - Rank l = va_arg(ap,int); - Rank i = va_arg(ap,int); - Rank j = va_arg(ap,int); - badLine(filename,l,i,j); - } - break; - case BAD_RCYCFIELD: - badRCycField(); - break; - case CHECKMIN_FAIL: - checkminFail(); - break; - case COMMAND_NOT_FOUND: { - char *a = va_arg(ap, char *); - commandNotFound(a); - } - break; - case COMMAND_REDEFINITION: { - char *a = va_arg(ap, char *); - commandRedefinition(a); - } - break; - case CONTEXTNBR_OVERFLOW: { - Ulong size = va_arg(ap,Ulong); - contextNbrOverflow(size); - } - break; - case COXALLOC_FAIL: - coxAllocFail(); - break; - case COXNBR_OVERFLOW: - coxNbrOverflow(); - break; - case DENSEARRAY_OVERFLOW: { - Ulong size = va_arg(ap,Ulong); - denseArrayOverflow(size); - } - break; - case ERROR_WARNING: - break; - case EXTENSION_FAIL: - extensionFail(); - break; - case FILE_NOT_FOUND: - fileNotFound(va_arg(ap,char *)); - break; - case KLCOEFF_NEGATIVE: { - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - klCoeffNegative(x,y); - } - break; - case KLCOEFF_OVERFLOW: { - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - klCoeffOverflow(x,y); - } - break; - case KL_FAIL: { - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - klFail(x,y); - } - break; - case LEADING_WHITESPACE: { - const GroupEltInterface* I = va_arg(ap, const GroupEltInterface*); - const GroupEltInterface* J = va_arg(ap, const GroupEltInterface*); - const Permutation* a = va_arg(ap, const Permutation*); - const String* str = va_arg(ap, const String*); - leadingWhitespace(*I,*J,*a,*str); - } - break; - case LENGTH_OVERFLOW: - lengthOverflow(); - break; - case MEMORY_WARNING: - memoryWarning(); - break; - case MINROOT_OVERFLOW: - minRootOverflow(); - break; - case MODECHANGE_FAIL: - modeChangeFail(); - break; - case MU_FAIL: { - const KLContext& kl = *va_arg(ap, KLContext*); - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - muFail(kl,x,y); - } - break; - case MU_OVERFLOW: { - const KLContext& kl = *va_arg(ap, KLContext*); - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - muOverflow(kl,x,y); - } - break; - case MU_NEGATIVE: { - const KLContext& kl = *va_arg(ap, KLContext*); - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - muNegative(kl,x,y); - } - break; - case NOT_AFFINE: - notAffine(); - break; - case NOT_COXELT: - notCoxelt(); - break; - case NOT_DESCENT: { - const char *str = va_arg(ap,const char *); - notDescent(str); - break; - } - case NOT_FINITE: - notFinite(); - break; - case NOT_GENERATOR: - notGenerator(); - break; - case NOT_PERMUTATION: - notPermutation(); - break; - case NOT_SYMMETRIC: { - char *filename = va_arg(ap,char*); - CoxMatrix& m = *va_arg(ap,CoxMatrix*); - Rank l = va_arg(ap,int); - Rank i = va_arg(ap,int); - Rank j = va_arg(ap,int); - notSymmetric(filename,m,l,i,j); - } - break; - case OUT_OF_MEMORY: { - outOfMemory(); - } - break; - case PARNBR_OVERFLOW: - parNbrOverflow(); - break; - case PARSE_ERROR: { - const char *str = va_arg(ap,const char *); - parseError(str); - } - break; - case REPEATED_SYMBOL: { - const GroupEltInterface* I = va_arg(ap, const GroupEltInterface*); - const GroupEltInterface* J = va_arg(ap, const GroupEltInterface*); - const Permutation* a = va_arg(ap, const Permutation*); - repeatedSymbol(*I,*J,*a); - } - break; - case RESERVED_SYMBOL: { - const GroupEltInterface* I = va_arg(ap, const GroupEltInterface*); - const GroupEltInterface* J = va_arg(ap, const GroupEltInterface*); - const Permutation* a = va_arg(ap, const Permutation*); - const String* str = va_arg(ap, const String*); - reservedSymbol(*I,*J,*a,*str); - } - break; - case UEMU_FAIL: { - CoxNbr x = va_arg(ap, CoxNbr); - CoxNbr y = va_arg(ap, CoxNbr); - ueMuFail(x,y); - } - case UNDEF_COXARR: - undefCoxarr(); - break; - case WRONG_COXETER_ENTRY: { - Rank i = va_arg(ap,int); - Rank j = va_arg(ap,int); - Ulong m = va_arg(ap,Ulong); - wrongCoxeterEntry(i,j,m); - } - break; - case WRONG_RANK: { - Type* t = va_arg(ap,Type*); - Rank* l = va_arg(ap,Rank*); - int* mess = va_arg(ap,int*); - wrongRank(*t,l,mess); - } - break; - case WRONG_TYPE: - wrongType(); - break; - default: - abortError(); - break; - } + va_start(ap, number); + + switch (number) { + case 0: + break; + case ABORT: + abortError(); + break; + case BAD_COXENTRY: + badCoxEntry(); + break; + case BAD_INPUT: { + char *a = va_arg(ap, char *); + badInput(a); + } break; + case BAD_LENGTH: { + Ulong l = va_arg(ap, long); + badLength(l); + } break; + case BAD_LINE: { + char *filename = va_arg(ap, char *); + Rank l = va_arg(ap, int); + Rank i = va_arg(ap, int); + Rank j = va_arg(ap, int); + badLine(filename, l, i, j); + } break; + case BAD_RCYCFIELD: + badRCycField(); + break; + case CHECKMIN_FAIL: + checkminFail(); + break; + case COMMAND_NOT_FOUND: { + char *a = va_arg(ap, char *); + commandNotFound(a); + } break; + case COMMAND_REDEFINITION: { + char *a = va_arg(ap, char *); + commandRedefinition(a); + } break; + case CONTEXTNBR_OVERFLOW: { + Ulong size = va_arg(ap, Ulong); + contextNbrOverflow(size); + } break; + case COXALLOC_FAIL: + coxAllocFail(); + break; + case COXNBR_OVERFLOW: + coxNbrOverflow(); + break; + case DENSEARRAY_OVERFLOW: { + Ulong size = va_arg(ap, Ulong); + denseArrayOverflow(size); + } break; + case ERROR_WARNING: + break; + case EXTENSION_FAIL: + extensionFail(); + break; + case FILE_NOT_FOUND: + fileNotFound(va_arg(ap, char *)); + break; + case KLCOEFF_NEGATIVE: { + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + klCoeffNegative(x, y); + } break; + case KLCOEFF_OVERFLOW: { + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + klCoeffOverflow(x, y); + } break; + case KL_FAIL: { + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + klFail(x, y); + } break; + case LEADING_WHITESPACE: { + const GroupEltInterface *I = va_arg(ap, const GroupEltInterface *); + const GroupEltInterface *J = va_arg(ap, const GroupEltInterface *); + const Permutation *a = va_arg(ap, const Permutation *); + const String *str = va_arg(ap, const String *); + leadingWhitespace(*I, *J, *a, *str); + } break; + case LENGTH_OVERFLOW: + lengthOverflow(); + break; + case MEMORY_WARNING: + memoryWarning(); + break; + case MINROOT_OVERFLOW: + minRootOverflow(); + break; + case MODECHANGE_FAIL: + modeChangeFail(); + break; + case MU_FAIL: { + const KLContext &kl = *va_arg(ap, KLContext *); + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + muFail(kl, x, y); + } break; + case MU_OVERFLOW: { + const KLContext &kl = *va_arg(ap, KLContext *); + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + muOverflow(kl, x, y); + } break; + case MU_NEGATIVE: { + const KLContext &kl = *va_arg(ap, KLContext *); + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + muNegative(kl, x, y); + } break; + case NOT_AFFINE: + notAffine(); + break; + case NOT_COXELT: + notCoxelt(); + break; + case NOT_DESCENT: { + const char *str = va_arg(ap, const char *); + notDescent(str); + break; + } + case NOT_FINITE: + notFinite(); + break; + case NOT_GENERATOR: + notGenerator(); + break; + case NOT_PERMUTATION: + notPermutation(); + break; + case NOT_SYMMETRIC: { + char *filename = va_arg(ap, char *); + CoxMatrix &m = *va_arg(ap, CoxMatrix *); + Rank l = va_arg(ap, int); + Rank i = va_arg(ap, int); + Rank j = va_arg(ap, int); + notSymmetric(filename, m, l, i, j); + } break; + case OUT_OF_MEMORY: { + outOfMemory(); + } break; + case PARNBR_OVERFLOW: + parNbrOverflow(); + break; + case PARSE_ERROR: { + const char *str = va_arg(ap, const char *); + parseError(str); + } break; + case REPEATED_SYMBOL: { + const GroupEltInterface *I = va_arg(ap, const GroupEltInterface *); + const GroupEltInterface *J = va_arg(ap, const GroupEltInterface *); + const Permutation *a = va_arg(ap, const Permutation *); + repeatedSymbol(*I, *J, *a); + } break; + case RESERVED_SYMBOL: { + const GroupEltInterface *I = va_arg(ap, const GroupEltInterface *); + const GroupEltInterface *J = va_arg(ap, const GroupEltInterface *); + const Permutation *a = va_arg(ap, const Permutation *); + const String *str = va_arg(ap, const String *); + reservedSymbol(*I, *J, *a, *str); + } break; + case UEMU_FAIL: { + CoxNbr x = va_arg(ap, CoxNbr); + CoxNbr y = va_arg(ap, CoxNbr); + ueMuFail(x, y); + } + case UNDEF_COXARR: + undefCoxarr(); + break; + case WRONG_COXETER_ENTRY: { + Rank i = va_arg(ap, int); + Rank j = va_arg(ap, int); + Ulong m = va_arg(ap, Ulong); + wrongCoxeterEntry(i, j, m); + } break; + case WRONG_RANK: { + Type *t = va_arg(ap, Type *); + Rank *l = va_arg(ap, Rank *); + int *mess = va_arg(ap, int *); + wrongRank(*t, l, mess); + } break; + case WRONG_TYPE: + wrongType(); + break; + default: + abortError(); + break; + } va_end(ap); return; } - /******************************************************************** Chapter II --- Specific error handling functions. ********************************************************************/ - namespace { void abortError() @@ -352,7 +326,7 @@ void abortError() */ { - fprintf(stderr,"aborted\n"); + fprintf(stderr, "aborted\n"); return; } @@ -365,7 +339,7 @@ void badCoxEntry() */ { - fprintf(stderr,"sorry, bad entry in coxeter matrix\n"); + fprintf(stderr, "sorry, bad entry in coxeter matrix\n"); return; } @@ -373,12 +347,12 @@ void badInput(char *s) { fprintf(stderr, - "illegal character after this : (enter new input, ? to abort)\n"); - printf("%s",s); + "illegal character after this : (enter new input, ? to abort)\n"); + printf("%s", s); return; } -void badLength(const long& l) +void badLength(const long &l) /* Handles the error BAD_LENGTH. This means that the user has entered a @@ -387,14 +361,14 @@ void badLength(const long& l) */ { - fprintf(stderr,"bad length value; should be between 0 and %lu\n", - static_cast(LENGTH_MAX)); - fprintf(stderr,"value read was %ld\n",l); + fprintf(stderr, "bad length value; should be between 0 and %lu\n", + static_cast(LENGTH_MAX)); + fprintf(stderr, "value read was %ld\n", l); return; } -void badLine(char *filename,Rank l,Rank i,Rank j) +void badLine(char *filename, Rank l, Rank i, Rank j) /* Handles the error BAD_LINE. The first argument is the line number @@ -404,14 +378,14 @@ void badLine(char *filename,Rank l,Rank i,Rank j) */ { - fprintf(stderr,"error : line #%lu too short in %s/%s\n", - static_cast(i+1),COXMATRIX_DIR,filename); + fprintf(stderr, "error : line #%lu too short in %s/%s\n", + static_cast(i + 1), COXMATRIX_DIR, filename); if (j == 1) - fprintf(stderr,"one entry found; %lu entries expected\n", - static_cast(l)); + fprintf(stderr, "one entry found; %lu entries expected\n", + static_cast(l)); else - fprintf(stderr,"%lu entries found; %lu entries expected\n", - static_cast(j),static_cast(l)); + fprintf(stderr, "%lu entries found; %lu entries expected\n", + static_cast(j), static_cast(l)); return; } @@ -419,7 +393,7 @@ void badLine(char *filename,Rank l,Rank i,Rank j) void badRCycField() { - fprintf(stderr,"Illegal variation parameter in RCyclotomicField\n"); + fprintf(stderr, "Illegal variation parameter in RCyclotomicField\n"); return; } @@ -431,7 +405,7 @@ void checkminFail() */ { - fprintf(stderr,"error : failure in checkMinimal\n"); + fprintf(stderr, "error : failure in checkMinimal\n"); return; } @@ -442,12 +416,11 @@ void commandNotFound(char *a) as an (even partial) command name. */ -{ - fprintf(stderr,"%s : not found in current mode\n",a); +{ + fprintf(stderr, "%s : not found in current mode\n", a); return; } - void commandRedefinition(char *a) /* @@ -456,12 +429,11 @@ void commandRedefinition(char *a) message is printed. */ -{ - fprintf(stderr,"warning : redefining command \"%s\"\n",a); +{ + fprintf(stderr, "warning : redefining command \"%s\"\n", a); return; } - void contextNbrOverflow(Ulong size) /* @@ -470,11 +442,10 @@ void contextNbrOverflow(Ulong size) */ { - fprintf(stderr,"number too big --- %lu is the limit\n",size-1); + fprintf(stderr, "number too big --- %lu is the limit\n", size - 1); return; } - void coxAllocFail() /* @@ -484,11 +455,10 @@ void coxAllocFail() */ { - fprintf(stderr,"error : allocation failed\n"); + fprintf(stderr, "error : allocation failed\n"); return; } - void coxNbrOverflow() /* @@ -498,11 +468,10 @@ void coxNbrOverflow() */ { - fprintf(stderr,"error : CoxNbr overflow\n"); + fprintf(stderr, "error : CoxNbr overflow\n"); return; } - void denseArrayOverflow(Ulong size) /* @@ -511,11 +480,10 @@ void denseArrayOverflow(Ulong size) */ { - fprintf(stderr,"number too big --- %lu is the limit\n",size-1); + fprintf(stderr, "number too big --- %lu is the limit\n", size - 1); return; } - void extensionFail() /* @@ -525,11 +493,10 @@ void extensionFail() */ { - fprintf(stderr,"error : could not extend the context\n"); + fprintf(stderr, "error : could not extend the context\n"); return; } - void fileNotFound(char *s) /* @@ -538,12 +505,11 @@ void fileNotFound(char *s) */ { - fprintf(stderr,"%s : file not found\n",s); + fprintf(stderr, "%s : file not found\n", s); return; } - -void klCoeffNegative(const CoxNbr& x, const CoxNbr& y) +void klCoeffNegative(const CoxNbr &x, const CoxNbr &y) /* Handles the error KLCOEFF_NEGATIVE. This means that a negative coefficient @@ -559,15 +525,14 @@ void klCoeffNegative(const CoxNbr& x, const CoxNbr& y) { fprintf(stderr, - "A negative coefficient occurred in a Kazhdan-Lusztig polynomial\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%", - static_cast(x),"%",static_cast(y)); - printFile(stderr,"neg_coeff.err",MESSAGE_DIR); + "A negative coefficient occurred in a Kazhdan-Lusztig polynomial\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); + printFile(stderr, "neg_coeff.err", MESSAGE_DIR); return; } - -void klCoeffOverflow(const CoxNbr& x, const CoxNbr& y) +void klCoeffOverflow(const CoxNbr &x, const CoxNbr &y) /* Handles the error KLCOEFF_OVERFLOW; this means that in the course of the @@ -575,7 +540,7 @@ void klCoeffOverflow(const CoxNbr& x, const CoxNbr& y) (this will then always happen during the computation of P_{xs,ys}+P_{x,ys}) NOTE : it would be slightly better to trigger this error only if the - overflow occurs in the actual value of the coefficient; to do this + overflow occurs in the actual value of the coefficient; to do this rigorously without using types bigger than KLCoeff is a bit more than I'm willing to cope with right now. We'll see about it when it becomes a real problem. @@ -585,14 +550,13 @@ void klCoeffOverflow(const CoxNbr& x, const CoxNbr& y) { fprintf(stderr, - "Overflow in the coefficients of Kazhdan-Lusztig polynomial\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%",static_cast(x),"%", - static_cast(y)); + "Overflow in the coefficients of Kazhdan-Lusztig polynomial\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); return; } - -void klFail(const CoxNbr& x, const CoxNbr& y) +void klFail(const CoxNbr &x, const CoxNbr &y) /* Handles the error KL_FAIL. This means that an error occurred during the @@ -602,31 +566,30 @@ void klFail(const CoxNbr& x, const CoxNbr& y) { fprintf(stderr, - "error in the computation of the Kazhdan-Lusztig polynomial\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%",static_cast(x),"%", - static_cast(y)); + "error in the computation of the Kazhdan-Lusztig polynomial\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); return; } - -void leadingWhitespace(const GroupEltInterface& I, const GroupEltInterface& J, - const Permutation& a, const String& str) +void leadingWhitespace(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a, const String &str) /* Handles the error LEADING_WHITESPACE; this means that I contains a symbol starting with whitespace. */ -{ +{ fprintf(stderr, - "error: one of the new input symbols begins with whitespace\n"); - fprintf(stderr,"these are the symbols you submitted :\n\n"); - printInterface(stderr,I,J,a); - fprintf(stderr,"\nsymbol \""); - print(stderr,str); - fprintf(stderr,"\" begins with whitespace\n"); + "error: one of the new input symbols begins with whitespace\n"); + fprintf(stderr, "these are the symbols you submitted :\n\n"); + printInterface(stderr, I, J, a); + fprintf(stderr, "\nsymbol \""); + print(stderr, str); + fprintf(stderr, "\" begins with whitespace\n"); fprintf(stderr, - "interface not modified. Please change offending symbol or abort.\n"); + "interface not modified. Please change offending symbol or abort.\n"); } void lengthOverflow() @@ -639,7 +602,6 @@ void lengthOverflow() return; } - void memoryWarning() /* @@ -651,11 +613,10 @@ void memoryWarning() */ { - fprintf(stderr,"sorry, insufficient memory\n"); + fprintf(stderr, "sorry, insufficient memory\n"); return; } - void minRootOverflow() /* @@ -664,7 +625,7 @@ void minRootOverflow() */ { - fprintf(stderr,"error : overflow in size of minroot table\n"); + fprintf(stderr, "error : overflow in size of minroot table\n"); return; } @@ -676,11 +637,11 @@ void modeChangeFail() */ { - fprintf(stderr,"aborted\n"); + fprintf(stderr, "aborted\n"); return; } -void muFail(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) +void muFail(const KLContext &kl, const CoxNbr &x, const CoxNbr &y) /* Handles the error MU_FAIL : this means that an error occurred during the @@ -688,15 +649,14 @@ void muFail(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) */ { - fprintf(stderr,"error in the computation of a mu-coefficient\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%",static_cast(x),"%", - static_cast(y)); + fprintf(stderr, "error in the computation of a mu-coefficient\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); return; } - -void muNegative(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) +void muNegative(const KLContext &kl, const CoxNbr &x, const CoxNbr &y) /* Handles the error MU_NEGATIVE; this means that a negative mu-coefficient @@ -705,16 +665,15 @@ void muNegative(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) */ { - fprintf(stderr,"Negative value in the computation of a mu-coeffient\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%",static_cast(x),"%", - static_cast(y)); - printFile(stderr,"neg_coeff.err",MESSAGE_DIR); + fprintf(stderr, "Negative value in the computation of a mu-coeffient\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); + printFile(stderr, "neg_coeff.err", MESSAGE_DIR); return; } - -void muOverflow(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) +void muOverflow(const KLContext &kl, const CoxNbr &x, const CoxNbr &y) /* Handles the error MU_OVERFLOW; this means that overflow has occurred @@ -722,14 +681,13 @@ void muOverflow(const KLContext& kl, const CoxNbr& x, const CoxNbr& y) */ { - fprintf(stderr,"Overflow in the computation of a mu-coeffient\n"); - fprintf(stderr,"(x = %s%lu, y = %s%lu)\n","%",static_cast(x),"%", - static_cast(y)); + fprintf(stderr, "Overflow in the computation of a mu-coeffient\n"); + fprintf(stderr, "(x = %s%lu, y = %s%lu)\n", "%", static_cast(x), "%", + static_cast(y)); return; } - void notAffine() /* @@ -738,11 +696,10 @@ void notAffine() */ { - fprintf(stderr,"error : type of group is not affine\n"); + fprintf(stderr, "error : type of group is not affine\n"); return; } - void notCoxelt() /* @@ -751,11 +708,10 @@ void notCoxelt() */ { - fprintf(stderr,"error : not a Coxeter element\n"); + fprintf(stderr, "error : not a Coxeter element\n"); return; } - void notDescent(const char *const str) /* @@ -765,14 +721,13 @@ void notDescent(const char *const str) */ { - fprintf(stderr,"that is not a descent generator for y\n"); - fprintf(stderr,"enter new input or ? to abort\n"); - fprintf(stderr,"%s",str); - + fprintf(stderr, "that is not a descent generator for y\n"); + fprintf(stderr, "enter new input or ? to abort\n"); + fprintf(stderr, "%s", str); + return; } - void notFinite() /* @@ -781,11 +736,10 @@ void notFinite() */ { - fprintf(stderr,"error : type of group is not finite\n"); + fprintf(stderr, "error : type of group is not finite\n"); return; } - void notGenerator() /* @@ -794,11 +748,10 @@ void notGenerator() */ { - fprintf(stderr,"error : not a generator symbol\n"); + fprintf(stderr, "error : not a generator symbol\n"); return; } - void notPermutation() /* @@ -807,29 +760,27 @@ void notPermutation() */ { - fprintf(stderr,"error : that is not a permutation\n"); + fprintf(stderr, "error : that is not a permutation\n"); return; } - -void notSymmetric(char *filename,CoxMatrix& m,Rank l,Rank i, Rank j) +void notSymmetric(char *filename, CoxMatrix &m, Rank l, Rank i, Rank j) /* Handles the error NOT_SYMMETRIC. This means that j < i, and that m[i,j] != m[j,i] in the coxeter matrix being read from the file. */ -{ - fprintf(stderr,"error : %s/%s not symmetric\n",COXMATRIX_DIR,filename); - fprintf(stderr,"m[%lu,%lu] = %lu; m[%lu,%lu] = %lu\n", - static_cast(i+1),static_cast(j+1), - static_cast(m[i*l + j]),static_cast(j+1), - static_cast(i+1),static_cast(m[j*l + i])); +{ + fprintf(stderr, "error : %s/%s not symmetric\n", COXMATRIX_DIR, filename); + fprintf(stderr, "m[%lu,%lu] = %lu; m[%lu,%lu] = %lu\n", + static_cast(i + 1), static_cast(j + 1), + static_cast(m[i * l + j]), static_cast(j + 1), + static_cast(i + 1), static_cast(m[j * l + i])); return; } - void outOfMemory() /* @@ -838,20 +789,19 @@ void outOfMemory() Fatal error. */ -{ +{ if (CATCH_MEMORY_OVERFLOW) { /* error is handled elsewhere */ ERRNO = MEMORY_WARNING; return; } - fprintf(stderr,"memory allocation failed\n"); - fprintf(stderr,"memory usage :\n\n"); + fprintf(stderr, "memory allocation failed\n"); + fprintf(stderr, "memory usage :\n\n"); memory::arena().print(stderr); exit(0); } - void parNbrOverflow() /* @@ -859,11 +809,10 @@ void parNbrOverflow() */ { - fprintf(stderr,"warning : overflow in the automaton construction\n"); + fprintf(stderr, "warning : overflow in the automaton construction\n"); return; } - void parseError(const char *const str) /* @@ -873,50 +822,48 @@ void parseError(const char *const str) */ { - fprintf(stderr,"parse error after this : (enter new input or ? to abort)\n"); - fprintf(stderr,"%s",str); - + fprintf(stderr, "parse error after this : (enter new input or ? to abort)\n"); + fprintf(stderr, "%s", str); + return; } -void reservedSymbol(const GroupEltInterface& I, const GroupEltInterface& J, - const Permutation& a, const String& str) +void reservedSymbol(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a, const String &str) /* Handles the error RESERVED_SYMBOL; this means that I contains a symbol that was reserved by the ambient interface. */ -{ - fprintf(stderr, - "error: new interface contains a reserved symbol\n"); - fprintf(stderr,"these are the symbols you submitted :\n\n"); - printInterface(stderr,I,J,a); - fprintf(stderr,"\nsymbol \""); - print(stderr,str); - fprintf(stderr,"\" is reserved\n"); +{ + fprintf(stderr, "error: new interface contains a reserved symbol\n"); + fprintf(stderr, "these are the symbols you submitted :\n\n"); + printInterface(stderr, I, J, a); + fprintf(stderr, "\nsymbol \""); + print(stderr, str); + fprintf(stderr, "\" is reserved\n"); fprintf(stderr, - "interface not modified. Please change reserved symbol or abort.\n"); + "interface not modified. Please change reserved symbol or abort.\n"); } -void repeatedSymbol(const GroupEltInterface& I, const GroupEltInterface& J, - const Permutation& a) +void repeatedSymbol(const GroupEltInterface &I, const GroupEltInterface &J, + const Permutation &a) /* Handles the error REPEATED_SYMBOL; this means that I contains repeated non-empty strings. */ -{ - fprintf(stderr, - "error: new interface contains non-empty repeated symbols\n"); - fprintf(stderr,"these are the symbols you submitted :\n\n"); - printInterface(stderr,I,J,a); +{ + fprintf(stderr, "error: new interface contains non-empty repeated symbols\n"); + fprintf(stderr, "these are the symbols you submitted :\n\n"); + printInterface(stderr, I, J, a); fprintf(stderr, - "\ninterface not modified. Please eliminate repetitions or abort.\n"); + "\ninterface not modified. Please eliminate repetitions or abort.\n"); } -void ueMuFail(const CoxNbr& x, const CoxNbr& y) +void ueMuFail(const CoxNbr &x, const CoxNbr &y) /* Handles the error UEMU_FAIL : this means that an error occurred during the @@ -927,13 +874,14 @@ void ueMuFail(const CoxNbr& x, const CoxNbr& y) */ { - fprintf(stderr,"error in the computation of a mu-coefficient\n"); - fprintf(stderr,"(x = %s%lu; ","%",static_cast(x)); - fprintf(stderr,"y = %s%lu)\n","%",static_cast(y)); - fprintf(stderr, - "use %ccompute%c to get reduced expressions from these context numbers\n", - '"','"'); - + fprintf(stderr, "error in the computation of a mu-coefficient\n"); + fprintf(stderr, "(x = %s%lu; ", "%", static_cast(x)); + fprintf(stderr, "y = %s%lu)\n", "%", static_cast(y)); + fprintf( + stderr, + "use %ccompute%c to get reduced expressions from these context numbers\n", + '"', '"'); + return; } @@ -944,7 +892,7 @@ void undefCoxarr() */ { - fprintf(stderr,"error : undefined coxarr encountered\n"); + fprintf(stderr, "error : undefined coxarr encountered\n"); return; } @@ -952,86 +900,91 @@ void wrongCoxeterEntry(Rank i, Rank j, Ulong m) { if (i == j) { - fprintf(stderr,"\nDiagonal matrix entries should be 1\n"); + fprintf(stderr, "\nDiagonal matrix entries should be 1\n"); return; } - fprintf(stderr,"\nMatrix entry (%d,%d) out of range; should be 0 or lie between 2 and %u",i,j,COXENTRY_MAX); - fprintf(stderr,"\nValue read was %lu\n",m); - - return; -} - -void wrongRank(const Type& type, Rank *l, int *mess) - -{ - switch (type[0]) - { - case 'A': - fprintf(stderr,"\nIn type %c the rank should lie between 1 and %d\n", - type[0],RANK_MAX); - break; - case 'B': - case 'D': - fprintf(stderr,"\nIn type %c the rank should lie between 2 and %d\n", - type[0],RANK_MAX); - break; - case 'E': - fprintf(stderr,"\nIn type E the rank should lie between 3 and 8\n"); - break; - case 'F': - fprintf(stderr,"\nIn type F the rank should be 3 or 4\n"); - break; - case 'G': - fprintf(stderr,"\nIn type G the rank should be 2, so I'm setting it to 2\n\n"); - l[0] = 2; - mess[0] = 1; - break; - case 'H': - fprintf(stderr,"\nIn type H the rank should lie between 2 and 4\n"); - break; - case 'I': - fprintf(stderr,"\nIn type I the rank should be 2, so I'm setting it to 2\n\n"); - l[0] = 2; - mess[0] = 1; - break; - case 'a': - fprintf(stderr,"\nIn type %c the rank should lie between 2 and %d\n", - type[0],RANK_MAX); - break; - case 'b': - case 'c': - fprintf(stderr,"\nIn type %c the rank should lie between 3 and %d\n", - type[0],RANK_MAX); - break; - case 'd': - fprintf(stderr,"\nIn type %c the rank should lie between 5 and %d\n", - type[0],RANK_MAX); - break; - case 'e': - fprintf(stderr,"\nIn type e the rank should lie between 7 and 9\n"); - break; - case 'f': - fprintf(stderr,"\nIn type f the rank should be 5, so I'm setting it to 5\n\n"); - l[0] = 5; - mess[0] = 1; - break; - case 'g': - fprintf(stderr,"\nIn type g the rank should be 3, so I'm setting it to 3\n\n"); - l[0] = 3; - mess[0] = 1; - break; - case 'X': - case 'x': - fprintf(stderr,"\nIn type %c the rank should lie between 1 and %d\n", - type[0],RANK_MAX); - break; - } + fprintf(stderr, + "\nMatrix entry (%d,%d) out of range; should be 0 or lie between 2 " + "and %u", + i, j, COXENTRY_MAX); + fprintf(stderr, "\nValue read was %lu\n", m); + + return; +} + +void wrongRank(const Type &type, Rank *l, int *mess) + +{ + switch (type[0]) { + case 'A': + fprintf(stderr, "\nIn type %c the rank should lie between 1 and %d\n", + type[0], RANK_MAX); + break; + case 'B': + case 'D': + fprintf(stderr, "\nIn type %c the rank should lie between 2 and %d\n", + type[0], RANK_MAX); + break; + case 'E': + fprintf(stderr, "\nIn type E the rank should lie between 3 and 8\n"); + break; + case 'F': + fprintf(stderr, "\nIn type F the rank should be 3 or 4\n"); + break; + case 'G': + fprintf(stderr, + "\nIn type G the rank should be 2, so I'm setting it to 2\n\n"); + l[0] = 2; + mess[0] = 1; + break; + case 'H': + fprintf(stderr, "\nIn type H the rank should lie between 2 and 4\n"); + break; + case 'I': + fprintf(stderr, + "\nIn type I the rank should be 2, so I'm setting it to 2\n\n"); + l[0] = 2; + mess[0] = 1; + break; + case 'a': + fprintf(stderr, "\nIn type %c the rank should lie between 2 and %d\n", + type[0], RANK_MAX); + break; + case 'b': + case 'c': + fprintf(stderr, "\nIn type %c the rank should lie between 3 and %d\n", + type[0], RANK_MAX); + break; + case 'd': + fprintf(stderr, "\nIn type %c the rank should lie between 5 and %d\n", + type[0], RANK_MAX); + break; + case 'e': + fprintf(stderr, "\nIn type e the rank should lie between 7 and 9\n"); + break; + case 'f': + fprintf(stderr, + "\nIn type f the rank should be 5, so I'm setting it to 5\n\n"); + l[0] = 5; + mess[0] = 1; + break; + case 'g': + fprintf(stderr, + "\nIn type g the rank should be 3, so I'm setting it to 3\n\n"); + l[0] = 3; + mess[0] = 1; + break; + case 'X': + case 'x': + fprintf(stderr, "\nIn type %c the rank should lie between 1 and %d\n", + type[0], RANK_MAX); + break; + } return; } - void wrongType() /* @@ -1039,9 +992,9 @@ void wrongType() illegal type. */ -{ - printFile(stderr,"wrongtype.mess",MESSAGE_DIR); +{ + printFile(stderr, "wrongtype.mess", MESSAGE_DIR); return; } -}; +}; // namespace diff --git a/error.h b/error.h index 4336460..d3d9de8 100644 --- a/error.h +++ b/error.h @@ -5,77 +5,77 @@ See file main.cpp for full copyright notice */ -#ifndef ERROR_H /* guard against multiple inclusions */ +#ifndef ERROR_H /* guard against multiple inclusions */ #define ERROR_H #include "globals.h" namespace error { - using namespace coxeter; +using namespace coxeter; - enum ErrorCodes { - ABORT=1, - BAD_COXENTRY, - BAD_INPUT, - BAD_LENGTH, - BAD_LINE, - BAD_RCYCFIELD, - CHECKCOMM_FAIL, - CHECKMIN_FAIL, - COMMAND_NOT_FOUND, - COMMAND_REDEFINITION, - CONTEXTNBR_OVERFLOW, - COXALLOC_FAIL, - COXNBR_OVERFLOW, - DENSEARRAY_OVERFLOW, - EMPTY_POP, - EMPTY_READ, - ERROR_WARNING, - EXTENSION_FAIL, - FILE_NOT_FOUND, - LEADING_WHITESPACE, - LENGTH_OVERFLOW, - KLCOEFF_OVERFLOW, - KLCOEFF_NEGATIVE, - KLCOEFF_UNDERFLOW, - KL_FAIL, - MEMORY_WARNING, - MINROOT_FAIL, - MINROOT_OVERFLOW, - MODECHANGE_FAIL, - MU_FAIL, - MU_NEGATIVE, - MU_OVERFLOW, - NOT_AFFINE, - NOT_COXELT, - NOT_DESCENT, - NOT_FINITE, - NOT_GENERATOR, - NOT_PERMUTATION, - NOT_SYMMETRIC, - NOT_YN, - OUT_OF_MEMORY, - PARNBR_OVERFLOW, - PARSE_ERROR, - RANKSET_FAILED, - READ_FAILED, - REPEATED_SYMBOL, - RESERVED_SYMBOL, - SKLCOEFF_OVERFLOW, - SKLCOEFF_UNDERFLOW, - TYPESET_FAILED, - UEMU_FAIL, - UNDEF_COXARR, - UNDEFINED_SHIFT, - WRONG_COXETER_ENTRY, - WRONG_RANK, - WRONG_TYPE - }; +enum ErrorCodes { + ABORT = 1, + BAD_COXENTRY, + BAD_INPUT, + BAD_LENGTH, + BAD_LINE, + BAD_RCYCFIELD, + CHECKCOMM_FAIL, + CHECKMIN_FAIL, + COMMAND_NOT_FOUND, + COMMAND_REDEFINITION, + CONTEXTNBR_OVERFLOW, + COXALLOC_FAIL, + COXNBR_OVERFLOW, + DENSEARRAY_OVERFLOW, + EMPTY_POP, + EMPTY_READ, + ERROR_WARNING, + EXTENSION_FAIL, + FILE_NOT_FOUND, + LEADING_WHITESPACE, + LENGTH_OVERFLOW, + KLCOEFF_OVERFLOW, + KLCOEFF_NEGATIVE, + KLCOEFF_UNDERFLOW, + KL_FAIL, + MEMORY_WARNING, + MINROOT_FAIL, + MINROOT_OVERFLOW, + MODECHANGE_FAIL, + MU_FAIL, + MU_NEGATIVE, + MU_OVERFLOW, + NOT_AFFINE, + NOT_COXELT, + NOT_DESCENT, + NOT_FINITE, + NOT_GENERATOR, + NOT_PERMUTATION, + NOT_SYMMETRIC, + NOT_YN, + OUT_OF_MEMORY, + PARNBR_OVERFLOW, + PARSE_ERROR, + RANKSET_FAILED, + READ_FAILED, + REPEATED_SYMBOL, + RESERVED_SYMBOL, + SKLCOEFF_OVERFLOW, + SKLCOEFF_UNDERFLOW, + TYPESET_FAILED, + UEMU_FAIL, + UNDEF_COXARR, + UNDEFINED_SHIFT, + WRONG_COXETER_ENTRY, + WRONG_RANK, + WRONG_TYPE +}; - extern bool CATCH_MEMORY_OVERFLOW; - extern int ERRNO; +extern bool CATCH_MEMORY_OVERFLOW; +extern int ERRNO; - void Error(int number, ... ); -} +void Error(int number, ...); +} // namespace error #endif diff --git a/fcoxgroup.cpp b/fcoxgroup.cpp index 0a28968..b01af09 100644 --- a/fcoxgroup.cpp +++ b/fcoxgroup.cpp @@ -1,6 +1,6 @@ /* This is fcoxgroup.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -12,33 +12,34 @@ #define undefined (ParNbr)(PARNBR_MAX + 1) namespace fcoxgroup { - using namespace cells; +using namespace cells; }; /* local type definitions */ namespace { - using namespace fcoxgroup; - - class Workspace { - List d_ica_arr; - List d_nfca_arr; - List d_prca_arr; - List d_rdcw_arr; - public: - Workspace(); - void setSize(Ulong n); - ParNbr *ica_arr() {return d_ica_arr.ptr();} - ParNbr *nfca_arr() {return d_nfca_arr.ptr();} - ParNbr *prca_arr() {return d_prca_arr.ptr();} - ParNbr *rdcw_arr() {return d_rdcw_arr.ptr();} - }; - - void fillLongest(FiniteCoxGroup *W); - CoxSize order(FiniteCoxGroup *W); - Workspace& workspace(); +using namespace fcoxgroup; + +class Workspace { + List d_ica_arr; + List d_nfca_arr; + List d_prca_arr; + List d_rdcw_arr; + +public: + Workspace(); + void setSize(Ulong n); + ParNbr *ica_arr() { return d_ica_arr.ptr(); } + ParNbr *nfca_arr() { return d_nfca_arr.ptr(); } + ParNbr *prca_arr() { return d_prca_arr.ptr(); } + ParNbr *rdcw_arr() { return d_rdcw_arr.ptr(); } }; +void fillLongest(FiniteCoxGroup *W); +CoxSize order(FiniteCoxGroup *W); +Workspace &workspace(); +}; // namespace + /**************************************************************************** NOTE : unfinished. @@ -49,7 +50,7 @@ namespace { The first one, which will work for any rank <= 255, represents the elements as arrays of rank ParNbr's. The computations in this representation are - made through a cascade of small transducers. The drawback of this + made through a cascade of small transducers. The drawback of this representation is that the size of the automata depends strongly on the choice of ordering (as opposed to the minimal root machine, which is completely canonical.) @@ -70,10 +71,7 @@ namespace { namespace { Workspace::Workspace() - :d_ica_arr(), - d_nfca_arr(), - d_prca_arr(), - d_rdcw_arr() + : d_ica_arr(), d_nfca_arr(), d_prca_arr(), d_rdcw_arr() {} @@ -88,7 +86,7 @@ void Workspace::setSize(Ulong n) return; } -inline Workspace& workspace() +inline Workspace &workspace() /* Returns its static object, which is initialized on first call. @@ -99,7 +97,7 @@ inline Workspace& workspace() return wspace; } -}; +}; // namespace /**************************************************************************** @@ -136,31 +134,31 @@ namespace fcoxgroup { /******** constructor *******************************************************/ -FiniteCoxGroup::FiniteCoxGroup(const Type& x, const Rank& l) - :CoxGroup(x,l) +FiniteCoxGroup::FiniteCoxGroup(const Type &x, const Rank &l) + : CoxGroup(x, l) /* Constructor for FiniteCoxGroup. */ -{ +{ d_transducer = new Transducer(graph()); workspace().setSize(l); for (Rank j = 0; j < rank(); ++j) transducer(j)->fill(graph()); - d_longest_coxarr = new(arena()) ParNbr[rank()]; + d_longest_coxarr = new (arena()) ParNbr[rank()]; /* fill longest elements */ - for (FiltrationTerm* X = transducer(); X; X = X->next()) - d_longest_coxarr[X->rank()-1] = X->size()-1; + for (FiltrationTerm *X = transducer(); X; X = X->next()) + d_longest_coxarr[X->rank() - 1] = X->size() - 1; Ulong maxlength = length(d_longest_coxarr); - new(&d_longest_coxword) CoxWord(maxlength); - reducedArr(d_longest_coxword,d_longest_coxarr); + new (&d_longest_coxword) CoxWord(maxlength); + reducedArr(d_longest_coxword, d_longest_coxarr); d_longest_coxword.setLength(maxlength); d_maxlength = longest_coxword().length(); @@ -176,7 +174,7 @@ FiniteCoxGroup::~FiniteCoxGroup() */ { - arena().free(d_longest_coxarr,rank()*sizeof(ParNbr)); + arena().free(d_longest_coxarr, rank() * sizeof(ParNbr)); delete d_transducer; return; @@ -193,7 +191,7 @@ bool FiniteCoxGroup::isFullContext() const */ { - CoxNbr x = schubert().size()-1; + CoxNbr x = schubert().size() - 1; LFlags f = ldescent(x); if (f == graph().supp()) @@ -204,7 +202,7 @@ bool FiniteCoxGroup::isFullContext() const /******** operations with arrays ********************************************/ -const CoxArr& FiniteCoxGroup::assign(CoxArr& a, const CoxWord& g) const +const CoxArr &FiniteCoxGroup::assign(CoxArr &a, const CoxWord &g) const /* This functions returns the array-form of the element of W represented @@ -214,14 +212,13 @@ const CoxArr& FiniteCoxGroup::assign(CoxArr& a, const CoxWord& g) const { setZero(a); - for(Length i = 0; g[i]; ++i) - prodArr(a,g[i]-1); + for (Length i = 0; g[i]; ++i) + prodArr(a, g[i] - 1); return a; } - -const CoxArr& FiniteCoxGroup::inverseArr(CoxArr& a) const +const CoxArr &FiniteCoxGroup::inverseArr(CoxArr &a) const /* Inverse a. This is a "composite-assignment" type function, in consistency @@ -233,24 +230,22 @@ const CoxArr& FiniteCoxGroup::inverseArr(CoxArr& a) const { CoxArr b = workspace().ica_arr(); - assign(b,a); + assign(b, a); setZero(a); - for (const FiltrationTerm* X = transducer(); X; X = X->next()) - { - const CoxWord& g = X->np(b[X->rank()-1]); - Ulong j = g.length(); - while (j) { - j--; - prodArr(a,g[j]-1); - } + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { + const CoxWord &g = X->np(b[X->rank() - 1]); + Ulong j = g.length(); + while (j) { + j--; + prodArr(a, g[j] - 1); } + } return a; } - -Length FiniteCoxGroup::length(const CoxArr& a) const +Length FiniteCoxGroup::length(const CoxArr &a) const /* Returns the length of a --- overflow is not checked. @@ -259,16 +254,15 @@ Length FiniteCoxGroup::length(const CoxArr& a) const { Length c = 0; - for (const FiltrationTerm* X = transducer(); X; X = X->next()) - { - ParNbr x = a[X->rank()-1]; - c += X->length(x); - } + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { + ParNbr x = a[X->rank() - 1]; + c += X->length(x); + } return c; } -const CoxArr& FiniteCoxGroup::powerArr(CoxArr& a, const Ulong& m) const +const CoxArr &FiniteCoxGroup::powerArr(CoxArr &a, const Ulong &m) const /* Raises a to the m-th power. This can be done very quickly, by squarings @@ -289,24 +283,22 @@ const CoxArr& FiniteCoxGroup::powerArr(CoxArr& a, const Ulong& m) const CoxArr b = buf.ptr(); Ulong p; - assign(b,a); + assign(b, a); - for (p = m; ~p & hi_bit; p <<= 1) /* shift m up to high powers */ + for (p = m; ~p & hi_bit; p <<= 1) /* shift m up to high powers */ ; - - for (Ulong j = m >> 1; j; j >>= 1) - { - p <<= 1; - prodArr(a,a); /* a = a*a */ - if (p & hi_bit) - prodArr(a,b); /* a = a*b */ - } + + for (Ulong j = m >> 1; j; j >>= 1) { + p <<= 1; + prodArr(a, a); /* a = a*a */ + if (p & hi_bit) + prodArr(a, b); /* a = a*b */ + } return a; } - -int FiniteCoxGroup::prodArr(CoxArr& a, const CoxArr& b) const +int FiniteCoxGroup::prodArr(CoxArr &a, const CoxArr &b) const /* Composite assignment operator : increments a by b (i.e., does a *= b). @@ -319,42 +311,39 @@ int FiniteCoxGroup::prodArr(CoxArr& a, const CoxArr& b) const { CoxArr c = workspace().prca_arr(); - assign(c,b); + assign(c, b); int l = 0; for (Ulong j = 0; j < rank(); ++j) - l += prodArr(a,transducer(rank()-1-j)->np(c[j])); + l += prodArr(a, transducer(rank() - 1 - j)->np(c[j])); return l; } - -int FiniteCoxGroup::prodArr(CoxArr& a, Generator s) const +int FiniteCoxGroup::prodArr(CoxArr &a, Generator s) const /* Transforms the contents of a into a.s. */ { - for (const FiltrationTerm* X = transducer(); X; X = X->next()) - { - ParNbr x = a[X->rank()-1]; - ParNbr xs = X->shift(a[X->rank()-1],s); - if (xs < undefined) { - a[X->rank()-1] = xs; - if (xs < x) - return -1; - else - return 1; - } - s = xs - undefined - 1; + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { + ParNbr x = a[X->rank() - 1]; + ParNbr xs = X->shift(a[X->rank() - 1], s); + if (xs < undefined) { + a[X->rank() - 1] = xs; + if (xs < x) + return -1; + else + return 1; } + s = xs - undefined - 1; + } return 0; // this is unreachable } - -int FiniteCoxGroup::prodArr(CoxArr& a, const CoxWord& g) const +int FiniteCoxGroup::prodArr(CoxArr &a, const CoxWord &g) const /* Shifts a by the whole string g. Returns the increase in length. @@ -364,13 +353,12 @@ int FiniteCoxGroup::prodArr(CoxArr& a, const CoxWord& g) const int l = 0; for (Length j = 0; g[j]; ++j) - l += prodArr(a,g[j]-1); - + l += prodArr(a, g[j] - 1); + return l; } - -LFlags FiniteCoxGroup::rDescent(const CoxArr& a) const +LFlags FiniteCoxGroup::rDescent(const CoxArr &a) const /* Returns the right descent set of a. @@ -382,29 +370,27 @@ LFlags FiniteCoxGroup::rDescent(const CoxArr& a) const LFlags f = 0; for (Generator s = 0; s < rank(); s++) /* multiply by s */ - { - Generator t = s; - for (const FiltrationTerm* X = transducer(); X; X = X->next()) - { - ParNbr x = a[X->rank()-1]; - ParNbr xt = X->shift(x,t); - if (xt <= undefined) { /* we can decide */ - if (xt < x) - f |= bits::lmask[s]; - break; - } - t = xt - undefined - 1; - } + { + Generator t = s; + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { + ParNbr x = a[X->rank() - 1]; + ParNbr xt = X->shift(x, t); + if (xt <= undefined) { /* we can decide */ + if (xt < x) + f |= bits::lmask[s]; + break; + } + t = xt - undefined - 1; } + } return f; } - -const CoxWord& FiniteCoxGroup::reducedArr(CoxWord& g, const CoxArr& a) const +const CoxWord &FiniteCoxGroup::reducedArr(CoxWord &g, const CoxArr &a) const /* - Returns in g a reduced expression (actually the ShortLex normal form in + Returns in g a reduced expression (actually the ShortLex normal form in the internal numbering of the generators) of a. Here it is assumed that g is large enough to hold the result. @@ -414,19 +400,18 @@ const CoxWord& FiniteCoxGroup::reducedArr(CoxWord& g, const CoxArr& a) const Length p = length(a); g[p] = '\0'; - for (const FiltrationTerm* X = transducer(); X; X = X->next()) - { - ParNbr x = a[X->rank()-1]; - p -= X->length(x); - g.setSubWord(X->np(x),p,X->length(x)); - } + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { + ParNbr x = a[X->rank() - 1]; + p -= X->length(x); + g.setSubWord(X->np(x), p, X->length(x)); + } return g; } /******** input/output ******************************************************/ -void FiniteCoxGroup::modify(ParseInterface& P, const Token& tok) const +void FiniteCoxGroup::modify(ParseInterface &P, const Token &tok) const /* Executes the modification indicated by tok, which is assumed to be of @@ -439,7 +424,7 @@ void FiniteCoxGroup::modify(ParseInterface& P, const Token& tok) const { if (isLongest(tok)) { - CoxGroup::prod(P.c,d_longest_coxword); + CoxGroup::prod(P.c, d_longest_coxword); } if (isInverse(tok)) { @@ -447,12 +432,12 @@ void FiniteCoxGroup::modify(ParseInterface& P, const Token& tok) const } if (isPower(tok)) { - Ulong m = readCoxNbr(P,ULONG_MAX); - CoxGroup::power(P.c,m); + Ulong m = readCoxNbr(P, ULONG_MAX); + CoxGroup::power(P.c, m); } } -bool FiniteCoxGroup::parseModifier(ParseInterface& P) const +bool FiniteCoxGroup::parseModifier(ParseInterface &P) const /* This function parses a modifier from P.str at P.offset, and acts upon @@ -463,9 +448,9 @@ bool FiniteCoxGroup::parseModifier(ParseInterface& P) const { Token tok = 0; - const Interface& I = interface(); + const Interface &I = interface(); - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -474,14 +459,14 @@ bool FiniteCoxGroup::parseModifier(ParseInterface& P) const return false; P.offset += p; - modify(P,tok); + modify(P, tok); return true; } /******** kazhdan-lusztig cells *********************************************/ -const List& FiniteCoxGroup::duflo() +const List &FiniteCoxGroup::duflo() /* This function returns the list of Duflo involutions in the group, in the @@ -500,17 +485,17 @@ const List& FiniteCoxGroup::duflo() { if (d_duflo.size() == 0) { /* find duflo involutions */ - kl::KLContext& kl = d_kl[0]; - const SchubertContext& p = kl.schubert(); - + kl::KLContext &kl = d_kl[0]; + const SchubertContext &p = kl.schubert(); + SubSet q(0); /* make sure left cell partition is available */ - + lCell(); - + /* load involutions in q */ - + q.bitMap().assign(kl.involution()); q.readBitMap(); @@ -525,31 +510,30 @@ const List& FiniteCoxGroup::duflo() /* find Duflo involution in each cell */ for (PartitionIterator i(pi); i; ++i) { - const List& c = i(); + const List &c = i(); if (c.size() == 1) { /* cell has single involution */ - d_duflo.append(q[c[0]]); - continue; + d_duflo.append(q[c[0]]); + continue; } Length m = d_maxlength; CoxNbr d = c[0]; for (Ulong j = 0; j < c.size(); ++j) { - CoxNbr x = q[c[j]]; /* current involution */ - const kl::KLPol& pol = kl.klPol(0,x); - Length m1 = p.length(x) - 2*pol.deg(); - if (m1 < m) { - m = m1; - d = x; - } + CoxNbr x = q[c[j]]; /* current involution */ + const kl::KLPol &pol = kl.klPol(0, x); + Length m1 = p.length(x) - 2 * pol.deg(); + if (m1 < m) { + m = m1; + d = x; + } } d_duflo.append(d); } - } return d_duflo; } -const Partition& FiniteCoxGroup::lCell() +const Partition &FiniteCoxGroup::lCell() /* Returns the partition into left cells, making it from the right cell @@ -560,7 +544,7 @@ const Partition& FiniteCoxGroup::lCell() if (d_lcell.classCount()) /* partition was already computed */ return d_lcell; - const Partition& r = rCell(); + const Partition &r = rCell(); d_lcell.setSize(r.size()); d_lcell.setClassCount(r.classCount()); @@ -572,7 +556,7 @@ const Partition& FiniteCoxGroup::lCell() return d_lcell; } -const Partition& FiniteCoxGroup::lrCell() +const Partition &FiniteCoxGroup::lrCell() /* Similar to rCell, but for two-sided cells. @@ -592,16 +576,16 @@ const Partition& FiniteCoxGroup::lrCell() } if (d_lrcell.size() == 0) /* size is either zero or group order */ - cells::lrCells(d_lrcell,kl()); + cells::lrCells(d_lrcell, kl()); return d_lrcell; - abort: +abort: Error(ERRNO); return d_lrcell; } -const Partition& FiniteCoxGroup::lrUneqCell() +const Partition &FiniteCoxGroup::lrUneqCell() /* Similar to lCell, but for two-sided cells. @@ -622,29 +606,29 @@ const Partition& FiniteCoxGroup::lrUneqCell() { OrientedGraph X(0); - lrGraph(X,uneqkl()); + lrGraph(X, uneqkl()); X.cells(d_lruneqcell); } return d_lruneqcell; - abort: +abort: Error(ERRNO); return d_lruneqcell; } -const Partition& FiniteCoxGroup::lUneqCell() +const Partition &FiniteCoxGroup::lUneqCell() /* Returns the partition in left cells for unequal parameters. The partition is gotten from the right one, by inversing. */ -{ +{ if (d_luneqcell.classCount()) /* partition was already computed */ return d_luneqcell; - const Partition& r = rUneqCell(); + const Partition &r = rUneqCell(); d_luneqcell.setSize(r.size()); d_luneqcell.setClassCount(r.classCount()); @@ -656,13 +640,13 @@ const Partition& FiniteCoxGroup::lUneqCell() return d_luneqcell; } -const Partition& FiniteCoxGroup::rCell() +const Partition &FiniteCoxGroup::rCell() /* This function returns the partition of the group in right cells. NOTE : to be on the safe side, we allow this function to respond only - for the full group context. If the context is not full, it extends it + for the full group context. If the context is not full, it extends it first to the full group. NOTE : because this is a potentially very expensive operation, the @@ -687,25 +671,24 @@ const Partition& FiniteCoxGroup::rCell() if (ERRNO) goto abort; - cells::rCells(d_rcell,kl()); + cells::rCells(d_rcell, kl()); d_rcell.normalize(); return d_rcell; - abort: +abort: Error(ERRNO); return d_rcell; - } -const Partition& FiniteCoxGroup::rUneqCell() +const Partition &FiniteCoxGroup::rUneqCell() /* This function returns the partition of the group in right cells for unequal parameters. NOTE : to be on the safe side, we allow this function to respond only - for the full group context. If the context is not full, it extends it + for the full group context. If the context is not full, it extends it first to the full group. NOTE : because this is a potentially very expensive operation, the @@ -728,19 +711,19 @@ const Partition& FiniteCoxGroup::rUneqCell() { OrientedGraph Y(0); - rGraph(Y,uneqkl()); + rGraph(Y, uneqkl()); Y.cells(d_runeqcell); d_runeqcell.normalize(); } return d_runeqcell; - abort: +abort: Error(ERRNO); return d_runeqcell; } -const Partition& FiniteCoxGroup::lDescent() +const Partition &FiniteCoxGroup::lDescent() /* Returns the partition of the group in left descent classes, where two @@ -765,16 +748,16 @@ const Partition& FiniteCoxGroup::lDescent() for (CoxNbr x = 0; x < order(); ++x) d_ldescent[x] = ldescent(x); - d_ldescent.setClassCount(1<next()) { + for (const FiltrationTerm *X = transducer(); X; X = X->next()) { x *= X->size(); - x += a[X->rank()-1]; + x += a[X->rank() - 1]; } } -bool SmallCoxGroup::parseDenseArray(ParseInterface& P) const +bool SmallCoxGroup::parseDenseArray(ParseInterface &P) const /* Tries to parse a DenseArray from P. This is a '#' character, followed @@ -1106,10 +1089,10 @@ bool SmallCoxGroup::parseDenseArray(ParseInterface& P) const */ { - const Interface& I = interface(); + const Interface &I = interface(); Token tok = 0; - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -1120,23 +1103,22 @@ bool SmallCoxGroup::parseDenseArray(ParseInterface& P) const // if we get to this point, we must read a valid integer P.offset += p; - CoxNbr x = interface::readCoxNbr(P,d_order); + CoxNbr x = interface::readCoxNbr(P, d_order); - if (x == undef_coxnbr) { //error + if (x == undef_coxnbr) { // error P.offset -= p; - Error(DENSEARRAY_OVERFLOW,d_order); + Error(DENSEARRAY_OVERFLOW, d_order); ERRNO = PARSE_ERROR; - } - else { // x is valid + } else { // x is valid CoxWord g(0); - prodD(g,x); - CoxGroup::prod(P.c,g); + prodD(g, x); + CoxGroup::prod(P.c, g); } return true; } -bool SmallCoxGroup::parseGroupElement(ParseInterface& P) const +bool SmallCoxGroup::parseGroupElement(ParseInterface &P) const /* This is the parseGroupElement function for the SmallCoxGroup type. In @@ -1153,14 +1135,14 @@ bool SmallCoxGroup::parseGroupElement(ParseInterface& P) const Ulong r = P.offset; if (parseContextNumber(P)) { // next token is a context number - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; } if (parseDenseArray(P)) { // next token is a dense array - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; @@ -1168,18 +1150,17 @@ bool SmallCoxGroup::parseGroupElement(ParseInterface& P) const // if we get to this point, we have to read a CoxWord - interface().parseCoxWord(P,mintable()); - - if (ERRNO) { // no CoxWord could be parsed + interface().parseCoxWord(P, mintable()); + + if (ERRNO) { // no CoxWord could be parsed if (P.offset == r) { // nothing was parsed ERRNO = 0; return false; - } - else // parse error + } else // parse error return true; } - modify: +modify: // if we get to this point, a group element was successfully read @@ -1190,7 +1171,7 @@ bool SmallCoxGroup::parseGroupElement(ParseInterface& P) const // flush the current group element - prod(P.a[P.nestlevel],P.c); + prod(P.a[P.nestlevel], P.c); P.c.reset(); if (P.offset == r) // nothing was read; c is unchanged @@ -1199,7 +1180,7 @@ bool SmallCoxGroup::parseGroupElement(ParseInterface& P) const return true; } -int SmallCoxGroup::prodD(CoxWord& g, const DenseArray& d_x) const +int SmallCoxGroup::prodD(CoxWord &g, const DenseArray &d_x) const /* Does the multiplication of g by x, by recovering the normal pieces of x. @@ -1207,22 +1188,22 @@ int SmallCoxGroup::prodD(CoxWord& g, const DenseArray& d_x) const */ { - const Transducer& T = d_transducer[0]; + const Transducer &T = d_transducer[0]; DenseArray x = d_x; int l = 0; for (Ulong j = 0; j < rank(); ++j) { - const FiltrationTerm& X = T.transducer(rank()-1-j)[0]; - ParNbr c = x%X.size(); - l += CoxGroup::prod(g,X.np(c)); + const FiltrationTerm &X = T.transducer(rank() - 1 - j)[0]; + ParNbr c = x % X.size(); + l += CoxGroup::prod(g, X.np(c)); x /= X.size(); } return l; } -int SmallCoxGroup::prodD(DenseArray& x, const CoxWord& g) const +int SmallCoxGroup::prodD(DenseArray &x, const CoxWord &g) const /* Does the multiplication of x by g. @@ -1233,14 +1214,14 @@ int SmallCoxGroup::prodD(DenseArray& x, const CoxWord& g) const al.setSize(rank()); CoxArr a = al.ptr(); - assign(a,x); - int l = prodArr(a,g); - assign(x,a); + assign(a, x); + int l = prodArr(a, g); + assign(x, a); return l; } -}; +}; // namespace fcoxgroup /**************************************************************************** @@ -1270,7 +1251,6 @@ void fillLongest(FiniteCoxGroup *W) return; } - CoxSize order(FiniteCoxGroup *W) /* @@ -1284,17 +1264,16 @@ CoxSize order(FiniteCoxGroup *W) { CoxSize order = 1; - for (const FiltrationTerm* X = W->transducer(); X; X = X->next()) - { - if (X->size() > COXSIZE_MAX/order) /* overflow */ - return 0; - order *= X->size(); - } + for (const FiltrationTerm *X = W->transducer(); X; X = X->next()) { + if (X->size() > COXSIZE_MAX / order) /* overflow */ + return 0; + order *= X->size(); + } return order; } -}; +}; // namespace /**************************************************************************** @@ -1305,7 +1284,7 @@ CoxSize order(FiniteCoxGroup *W) The functions provided are : - - isFiniteType(W) : recognizes a finite group --- defines the notion of + - isFiniteType(W) : recognizes a finite group --- defines the notion of a finite group in this program. - maxSmallRank : the maximum rank for a SmallCoxGroup on the current machine; @@ -1326,8 +1305,7 @@ bool fcoxgroup::isFiniteType(CoxGroup *W) return isFiniteType(W->type()); } - -Rank fcoxgroup::maxSmallRank(const Type& x) +Rank fcoxgroup::maxSmallRank(const Type &x) /* Returns the smallest rank for which a CoxNbr holds the given element. @@ -1338,50 +1316,49 @@ Rank fcoxgroup::maxSmallRank(const Type& x) Rank l; unsigned long c; - switch(x[0]) - { - case 'A': - c = 1; - for (l = 1; l < RANK_MAX; l++) { - if (c > COXNBR_MAX/(l+1)) /* l is too big */ - return l-1; - c *= (l+1); - } - return l; - case 'B': - case 'C': - c = 2; - for (l = 2; l < RANK_MAX; l++) { - if (c > COXNBR_MAX/2*l) /* l is too big */ - return l-1; - c *= 2*l; - } - return l; - case 'D': - c = 4; - for (l = 3; l < RANK_MAX; l++) { - if (c > COXNBR_MAX/2*l) /* l is too big */ - return l-1; - c *= 2*l; - } - return l; - return l; - case 'E': - if (COXNBR_MAX < 2903040) - return 6; - else if (COXNBR_MAX < 696729600) - return 7; - else - return 8; - case 'F': - return 4; - case 'G': - return 2; - case 'H': - return 4; - case 'I': - return 2; - default: // unreachable - return 0; - }; + switch (x[0]) { + case 'A': + c = 1; + for (l = 1; l < RANK_MAX; l++) { + if (c > COXNBR_MAX / (l + 1)) /* l is too big */ + return l - 1; + c *= (l + 1); + } + return l; + case 'B': + case 'C': + c = 2; + for (l = 2; l < RANK_MAX; l++) { + if (c > COXNBR_MAX / 2 * l) /* l is too big */ + return l - 1; + c *= 2 * l; + } + return l; + case 'D': + c = 4; + for (l = 3; l < RANK_MAX; l++) { + if (c > COXNBR_MAX / 2 * l) /* l is too big */ + return l - 1; + c *= 2 * l; + } + return l; + return l; + case 'E': + if (COXNBR_MAX < 2903040) + return 6; + else if (COXNBR_MAX < 696729600) + return 7; + else + return 8; + case 'F': + return 4; + case 'G': + return 2; + case 'H': + return 4; + case 'I': + return 2; + default: // unreachable + return 0; + }; } diff --git a/fcoxgroup.h b/fcoxgroup.h index b0a1e44..a0bdb09 100644 --- a/fcoxgroup.h +++ b/fcoxgroup.h @@ -16,39 +16,38 @@ ****************************************************************************/ -#ifndef FCOXGROUP_H /* guard against multiple inclusions */ +#ifndef FCOXGROUP_H /* guard against multiple inclusions */ #define FCOXGROUP_H #include "globals.h" #include "coxgroup.h" namespace fcoxgroup { - using namespace coxeter; +using namespace coxeter; /******** type declarations *************************************************/ - class FiniteCoxGroup; - class FiniteBigRankCoxGroup; - class GeneralFBRCoxGroup; - class FiniteMedRankCoxGroup; - class GeneralFMRCoxGroup; - class FiniteSmallRankCoxGroup; - class GeneralFSRCoxGroup; - class SmallCoxGroup; - class GeneralSCoxGroup; - typedef CoxNbr DenseArray; +class FiniteCoxGroup; +class FiniteBigRankCoxGroup; +class GeneralFBRCoxGroup; +class FiniteMedRankCoxGroup; +class GeneralFMRCoxGroup; +class FiniteSmallRankCoxGroup; +class GeneralFSRCoxGroup; +class SmallCoxGroup; +class GeneralSCoxGroup; +typedef CoxNbr DenseArray; /******** function declarations *********************************************/ - bool isFiniteType(CoxGroup *W); - Rank maxSmallRank(const Type& x); +bool isFiniteType(CoxGroup *W); +Rank maxSmallRank(const Type &x); /******** type definitions **************************************************/ class FiniteCoxGroup : public CoxGroup { - protected: - +protected: CoxArr d_longest_coxarr; CoxWord d_longest_coxword; Length d_maxlength; @@ -68,182 +67,196 @@ class FiniteCoxGroup : public CoxGroup { Partition d_rstring; List d_duflo; - public: - -/* constructors */ +public: + /* constructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(FiniteCoxGroup));} + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(FiniteCoxGroup)); + } - FiniteCoxGroup(const Type& x, const Rank& l); + FiniteCoxGroup(const Type &x, const Rank &l); virtual ~FiniteCoxGroup(); -/* accessors */ + /* accessors */ bool isFullContext() const; - const CoxArr& longest_coxarr() const; /* inlined */ - const CoxWord& longest_coxword() const; /* inlined */ - Length maxLength() const; /* inlined */ - void modify(ParseInterface& P, const Token& tok) const; - CoxSize order() const; /* inlined */ - bool parseModifier(ParseInterface& P) const; - const FiltrationTerm *transducer(const Rank& l = 0) const; /* inlined */ - -/* modifiers */ - - FiltrationTerm *transducer(const Rank& l = 0) - {return d_transducer->transducer(l);} - -/* array operations */ - - const CoxArr& assign(CoxArr& a, const CoxArr& b) const; /* inlined */ - virtual const CoxArr& inverseArr(CoxArr& a) const; - Length length(const CoxArr& a) const; - const CoxArr& powerArr(CoxArr& a, const Ulong& m) const; - int prodArr(CoxArr& a, const CoxArr& b) const; - LFlags rDescent(const CoxArr& a) const; - const CoxWord& reducedArr(CoxWord& g, const CoxArr& a) const; - const CoxArr& setZero(CoxArr& a) const; /* inlined */ - -/* mixed operations */ - - const CoxArr& assign(CoxArr& a, const CoxWord& g) const; - int prodArr(CoxArr& a, Generator s) const; - int prodArr(CoxArr& a, const CoxWord& g) const; - -// manipulators - - void fullContext(); /* inlined */ - -/* kazhdan-lusztig cells and realted partitions */ - - const Partition& lCell(); - const Partition& lrCell(); - const Partition& rCell(); - const List& duflo(); - const Partition& lUneqCell(); - const Partition& lrUneqCell(); - const Partition& rUneqCell(); - const Partition& lDescent(); - const Partition& rDescent(); - const Partition& lString(); - const Partition& rString(); - const Partition& lTau(); - const Partition& rTau(); - + const CoxArr &longest_coxarr() const; /* inlined */ + const CoxWord &longest_coxword() const; /* inlined */ + Length maxLength() const; /* inlined */ + void modify(ParseInterface &P, const Token &tok) const; + CoxSize order() const; /* inlined */ + bool parseModifier(ParseInterface &P) const; + const FiltrationTerm *transducer(const Rank &l = 0) const; /* inlined */ + + /* modifiers */ + + FiltrationTerm *transducer(const Rank &l = 0) { + return d_transducer->transducer(l); + } + + /* array operations */ + + const CoxArr &assign(CoxArr &a, const CoxArr &b) const; /* inlined */ + virtual const CoxArr &inverseArr(CoxArr &a) const; + Length length(const CoxArr &a) const; + const CoxArr &powerArr(CoxArr &a, const Ulong &m) const; + int prodArr(CoxArr &a, const CoxArr &b) const; + LFlags rDescent(const CoxArr &a) const; + const CoxWord &reducedArr(CoxWord &g, const CoxArr &a) const; + const CoxArr &setZero(CoxArr &a) const; /* inlined */ + + /* mixed operations */ + + const CoxArr &assign(CoxArr &a, const CoxWord &g) const; + int prodArr(CoxArr &a, Generator s) const; + int prodArr(CoxArr &a, const CoxWord &g) const; + + // manipulators + + void fullContext(); /* inlined */ + + /* kazhdan-lusztig cells and realted partitions */ + + const Partition &lCell(); + const Partition &lrCell(); + const Partition &rCell(); + const List &duflo(); + const Partition &lUneqCell(); + const Partition &lrUneqCell(); + const Partition &rUneqCell(); + const Partition &lDescent(); + const Partition &rDescent(); + const Partition &lString(); + const Partition &rString(); + const Partition &lTau(); + const Partition &rTau(); }; class FiniteBigRankCoxGroup : public FiniteCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(FiniteBigRankCoxGroup));} - FiniteBigRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(FiniteBigRankCoxGroup)); + } + FiniteBigRankCoxGroup(const Type &x, const Rank &l); virtual ~FiniteBigRankCoxGroup(); -/* accessors */ - kl::KLContext& kl() const; /* inlined */ + /* accessors */ + kl::KLContext &kl() const; /* inlined */ }; - class GeneralFBRCoxGroup : public FiniteBigRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralFBRCoxGroup));} - GeneralFBRCoxGroup(const Type& x, const Rank& l); +class GeneralFBRCoxGroup : public FiniteBigRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralFBRCoxGroup)); + } + GeneralFBRCoxGroup(const Type &x, const Rank &l); ~GeneralFBRCoxGroup(); }; class FiniteMedRankCoxGroup : public FiniteCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(FiniteMedRankCoxGroup));} - FiniteMedRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(FiniteMedRankCoxGroup)); + } + FiniteMedRankCoxGroup(const Type &x, const Rank &l); virtual ~FiniteMedRankCoxGroup(); -/* accessors */ - kl::KLContext& kl() const; /* inlined */ + /* accessors */ + kl::KLContext &kl() const; /* inlined */ }; - class GeneralFMRCoxGroup : public FiniteMedRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralFMRCoxGroup));} - GeneralFMRCoxGroup(const Type& x, const Rank& l); +class GeneralFMRCoxGroup : public FiniteMedRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralFMRCoxGroup)); + } + GeneralFMRCoxGroup(const Type &x, const Rank &l); ~GeneralFMRCoxGroup(); }; class FiniteSmallRankCoxGroup : public FiniteMedRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(FiniteSmallRankCoxGroup));} - FiniteSmallRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(FiniteSmallRankCoxGroup)); + } + FiniteSmallRankCoxGroup(const Type &x, const Rank &l); virtual ~FiniteSmallRankCoxGroup(); -/* accessors */ - kl::KLContext& kl() const; /* inlined */ + /* accessors */ + kl::KLContext &kl() const; /* inlined */ }; - class GeneralFSRCoxGroup : public FiniteSmallRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralFSRCoxGroup));} - GeneralFSRCoxGroup(const Type& x, const Rank& l); +class GeneralFSRCoxGroup : public FiniteSmallRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralFSRCoxGroup)); + } + GeneralFSRCoxGroup(const Type &x, const Rank &l); ~GeneralFSRCoxGroup(); }; class SmallCoxGroup : public FiniteSmallRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(SmallCoxGroup));} - SmallCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(SmallCoxGroup)); + } + SmallCoxGroup(const Type &x, const Rank &l); virtual ~SmallCoxGroup(); -/* accessors */ - const CoxArr& assign(CoxArr& a, const DenseArray& x) const; - void assign(DenseArray& x, const CoxArr& a) const; - bool parseDenseArray(ParseInterface& P) const; - virtual bool parseGroupElement(ParseInterface& P) const; - int prodD(CoxWord& g, const DenseArray& x) const; - int prodD(DenseArray& x, const CoxWord& g) const; + /* accessors */ + const CoxArr &assign(CoxArr &a, const DenseArray &x) const; + void assign(DenseArray &x, const CoxArr &a) const; + bool parseDenseArray(ParseInterface &P) const; + virtual bool parseGroupElement(ParseInterface &P) const; + int prodD(CoxWord &g, const DenseArray &x) const; + int prodD(DenseArray &x, const CoxWord &g) const; }; - class GeneralSCoxGroup : public SmallCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralSCoxGroup));} - GeneralSCoxGroup(const Type& x, const Rank& l); +class GeneralSCoxGroup : public SmallCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralSCoxGroup)); + } + GeneralSCoxGroup(const Type &x, const Rank &l); ~GeneralSCoxGroup(); }; /******** Inline implementations ******************************************/ -inline const CoxArr& FiniteCoxGroup::assign(CoxArr& a, const CoxArr& b) const - {memmove(a,b,rank()*sizeof(ParNbr)); return a;} -inline void FiniteCoxGroup::fullContext() - {extendContext(d_longest_coxword);} -inline const CoxArr& FiniteCoxGroup::longest_coxarr() const - {return d_longest_coxarr;} -inline const CoxWord& FiniteCoxGroup::longest_coxword() const - {return d_longest_coxword;} -inline Length FiniteCoxGroup::maxLength() const {return d_maxlength;} -inline CoxSize FiniteCoxGroup::order() const {return d_order;} -inline const CoxArr& FiniteCoxGroup::setZero(CoxArr& a) const - {memset(a,0,rank()*sizeof(ParNbr)); return a;} -inline const FiltrationTerm* FiniteCoxGroup::transducer(const Rank& l) const - {return d_transducer->transducer(l);} - +inline const CoxArr &FiniteCoxGroup::assign(CoxArr &a, const CoxArr &b) const { + memmove(a, b, rank() * sizeof(ParNbr)); + return a; +} +inline void FiniteCoxGroup::fullContext() { extendContext(d_longest_coxword); } +inline const CoxArr &FiniteCoxGroup::longest_coxarr() const { + return d_longest_coxarr; } +inline const CoxWord &FiniteCoxGroup::longest_coxword() const { + return d_longest_coxword; +} +inline Length FiniteCoxGroup::maxLength() const { return d_maxlength; } +inline CoxSize FiniteCoxGroup::order() const { return d_order; } +inline const CoxArr &FiniteCoxGroup::setZero(CoxArr &a) const { + memset(a, 0, rank() * sizeof(ParNbr)); + return a; +} +inline const FiltrationTerm *FiniteCoxGroup::transducer(const Rank &l) const { + return d_transducer->transducer(l); +} + +} // namespace fcoxgroup #endif diff --git a/files.cpp b/files.cpp index c87e5e6..3ee2cf4 100644 --- a/files.cpp +++ b/files.cpp @@ -1,6 +1,6 @@ /* This is files.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -13,9 +13,9 @@ #include "version.h" namespace files { - using namespace directories; - using namespace wgraph; -} +using namespace directories; +using namespace wgraph; +} // namespace files /**************************************************************************** @@ -39,16 +39,16 @@ namespace files { *****************************************************************************/ namespace { - using namespace files; - Ulong maxLength(const Homology& h); -}; +using namespace files; +Ulong maxLength(const Homology &h); +}; // namespace namespace { - using namespace files; +using namespace files; - void makeVersionString(String& vstr, const String& str); - void makeTypeString(String& tstr, const String& str, const CoxGraph& G); -}; +void makeVersionString(String &vstr, const String &str); +void makeTypeString(String &tstr, const String &str, const CoxGraph &G); +}; // namespace /**************************************************************************** @@ -69,85 +69,43 @@ namespace { namespace files { -OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, Pretty) - :versionString(""), - typeString(""), - closureSeparator1("P_{x,y} for x extremal w.r.t. y:\n\n"), - closureSeparator2(""), - closureSeparator3("rational singular locus:\n\n"), - closureSeparator4("rational singular stratification:\n\n"), - closureSeparator5("betti numbers:\n\n"), - closureSeparator6("IH betti numbers:\n\n"), - eltList("context :\n\n"), - singularLocus("singular locus :\n\n"), - singularStratification("rational singular stratification :\n\n"), - emptySingularLocus("rational singular locus is empty\n"), - emptySingularStratification("rational singular stratification is empty\n"), - bettiPrefix(""), - bettiPostfix(""), - bettiSeparator(""), - bettiRankPrefix("h["), - bettiRankPostfix("] = "), - cellNumberPrefix(""), - cellNumberPostfix(" : "), - closureSizePrefix("size : "), - closureSizePostfix(""), - coatomPrefix("coatoms :\n\n"), - coatomPostfix("\n"), - coatomSeparator("\n"), - compCountPrefix("components : "), - compCountPostfix(""), - dufloPrefix(""), - dufloPostfix(""), - dufloSeparator(":"), - dufloListPrefix(""), - dufloListPostfix(""), - dufloListSeparator("\n"), - dufloNumberPrefix(""), - dufloNumberPostfix(" : "), - eltNumberPrefix(""), - eltNumberPostfix(":"), - eltListPrefix(""), - eltListPostfix(""), - eltListSeparator("\n"), - eltPrefix("y = "), - eltPostfix(""), - eltDataPrefix(""), - eltDataPostfix("\n"), - graphListPrefix(""), - graphListPostfix(""), - graphListSeparator("\n\n"), - lDescentPrefix(" L:"), - lDescentPostfix(""), - rDescentPrefix(" R:"), - rDescentPostfix(""), - lengthPrefix(" length "), - lengthPostfix(""), - closeString("\n"), - bettiHyphens("h"), - lineSize(LINESIZE), - polTraits(Pretty()), - heckeTraits(I,Pretty()), - addHeckeTraits(I,Pretty()), - partitionTraits(Pretty()), - wgraphTraits(Pretty()), - posetTraits(Pretty()), - printBettiRank(true), - printCellNumber(true), - printClosureSize(true), - printCoatoms(true), - printCompCount(true), - printDufloNumber(true), - printEltDescents(true), - printElt(true), - printEltData(true), - printEltNumber(true), - printLength(true), - printType(false), - printVersion(false), - hasBettiPadding(true) - -{ +OutputTraits::OutputTraits(const CoxGraph &G, const Interface &I, Pretty) + : versionString(""), typeString(""), + closureSeparator1("P_{x,y} for x extremal w.r.t. y:\n\n"), + closureSeparator2(""), closureSeparator3("rational singular locus:\n\n"), + closureSeparator4("rational singular stratification:\n\n"), + closureSeparator5("betti numbers:\n\n"), + closureSeparator6("IH betti numbers:\n\n"), eltList("context :\n\n"), + singularLocus("singular locus :\n\n"), + singularStratification("rational singular stratification :\n\n"), + emptySingularLocus("rational singular locus is empty\n"), + emptySingularStratification( + "rational singular stratification is empty\n"), + bettiPrefix(""), bettiPostfix(""), bettiSeparator(""), + bettiRankPrefix("h["), bettiRankPostfix("] = "), cellNumberPrefix(""), + cellNumberPostfix(" : "), closureSizePrefix("size : "), + closureSizePostfix(""), coatomPrefix("coatoms :\n\n"), + coatomPostfix("\n"), coatomSeparator("\n"), + compCountPrefix("components : "), compCountPostfix(""), dufloPrefix(""), + dufloPostfix(""), dufloSeparator(":"), dufloListPrefix(""), + dufloListPostfix(""), dufloListSeparator("\n"), dufloNumberPrefix(""), + dufloNumberPostfix(" : "), eltNumberPrefix(""), eltNumberPostfix(":"), + eltListPrefix(""), eltListPostfix(""), eltListSeparator("\n"), + eltPrefix("y = "), eltPostfix(""), eltDataPrefix(""), + eltDataPostfix("\n"), graphListPrefix(""), graphListPostfix(""), + graphListSeparator("\n\n"), lDescentPrefix(" L:"), lDescentPostfix(""), + rDescentPrefix(" R:"), rDescentPostfix(""), lengthPrefix(" length "), + lengthPostfix(""), closeString("\n"), bettiHyphens("h"), + lineSize(LINESIZE), polTraits(Pretty()), heckeTraits(I, Pretty()), + addHeckeTraits(I, Pretty()), partitionTraits(Pretty()), + wgraphTraits(Pretty()), posetTraits(Pretty()), printBettiRank(true), + printCellNumber(true), printClosureSize(true), printCoatoms(true), + printCompCount(true), printDufloNumber(true), printEltDescents(true), + printElt(true), printEltData(true), printEltNumber(true), + printLength(true), printType(false), printVersion(false), + hasBettiPadding(true) + +{ prefix[basisH] = ""; prefix[bettiH] = ""; prefix[closureH] = ""; @@ -212,60 +170,33 @@ OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, Pretty) hasHeader[sstratificationH] = false; } -OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, Terse) - :versionString(""), - typeString(""), - closureSeparator1("# extremal pairs\n"), - closureSeparator2(""), - closureSeparator3("# rational singular locus\n"), - closureSeparator4("# rational singular stratification\n"), - closureSeparator5("# betti numbers\n"), - closureSeparator6("# IH betti numbers\n"), - eltList("# context enumeration\n"), - singularLocus("# rational singular locus\n"), - singularStratification("# rational singular stratification\n"), - emptySingularLocus("# rational singular locus is empty"), - emptySingularStratification("# rational singular stratification is empty"), - bettiPrefix(""), - bettiPostfix(""), - bettiSeparator(","), - dufloPrefix(""), - dufloPostfix(""), - dufloSeparator(":"), - dufloListPrefix(""), - dufloListPostfix(""), - dufloListSeparator("\n"), - eltListPrefix(""), - eltListPostfix(""), - eltListSeparator("\n"), - eltPrefix(""), - eltPostfix(""), - eltDataPrefix("# the element y\n"), - eltDataPostfix(""), - graphListPrefix(""), - graphListPostfix(""), - graphListSeparator("\n#\n"), - closeString(""), - polTraits(Terse()), - heckeTraits(I,Terse()), - addHeckeTraits(I,Terse()), - partitionTraits(Terse()), - wgraphTraits(Terse()), - posetTraits(Terse()), - printBettiRank(false), - printCellNumber(false), - printClosureSize(false), - printCoatoms(false), - printCompCount(false), - printDufloNumber(false), - printEltDescents(false), - printElt(true), - printEltData(true), - printEltNumber(false), - printLength(false), - printType(true), - printVersion(true), - hasBettiPadding(false) +OutputTraits::OutputTraits(const CoxGraph &G, const Interface &I, Terse) + : versionString(""), typeString(""), + closureSeparator1("# extremal pairs\n"), closureSeparator2(""), + closureSeparator3("# rational singular locus\n"), + closureSeparator4("# rational singular stratification\n"), + closureSeparator5("# betti numbers\n"), + closureSeparator6("# IH betti numbers\n"), + eltList("# context enumeration\n"), + singularLocus("# rational singular locus\n"), + singularStratification("# rational singular stratification\n"), + emptySingularLocus("# rational singular locus is empty"), + emptySingularStratification( + "# rational singular stratification is empty"), + bettiPrefix(""), bettiPostfix(""), bettiSeparator(","), dufloPrefix(""), + dufloPostfix(""), dufloSeparator(":"), dufloListPrefix(""), + dufloListPostfix(""), dufloListSeparator("\n"), eltListPrefix(""), + eltListPostfix(""), eltListSeparator("\n"), eltPrefix(""), eltPostfix(""), + eltDataPrefix("# the element y\n"), eltDataPostfix(""), + graphListPrefix(""), graphListPostfix(""), graphListSeparator("\n#\n"), + closeString(""), polTraits(Terse()), heckeTraits(I, Terse()), + addHeckeTraits(I, Terse()), partitionTraits(Terse()), + wgraphTraits(Terse()), posetTraits(Terse()), printBettiRank(false), + printCellNumber(false), printClosureSize(false), printCoatoms(false), + printCompCount(false), printDufloNumber(false), printEltDescents(false), + printElt(true), printEltData(true), printEltNumber(false), + printLength(false), printType(true), printVersion(true), + hasBettiPadding(false) { prefix[basisH] = ""; @@ -350,64 +281,33 @@ OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, Terse) hasHeader[slocusH] = true; hasHeader[sstratificationH] = true; - makeVersionString(versionString,"#"); - makeTypeString(typeString,"#",G); + makeVersionString(versionString, "#"); + makeTypeString(typeString, "#", G); } -OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, GAP) - :versionString(""), - typeString(""), - closureSeparator1(""), - closureSeparator2(""), - closureSeparator3(""), - closureSeparator4(""), - closureSeparator5(""), - closureSeparator6(""), - eltList("coxeter_contextEnumeration:="), - singularLocus("coxeter_slocus:="), - singularStratification("coxeter_sstratification:="), - emptySingularLocus("coxeter_slocus:=[];"), - emptySingularStratification("coxeter_sstratification:=[];"), - bettiPrefix("["), - bettiPostfix("]"), - bettiSeparator(","), - dufloPrefix("["), - dufloPostfix("]"), - dufloSeparator(","), - dufloListPrefix("[\n"), - dufloListPostfix("]"), - dufloListSeparator(",\n"), - eltListPrefix("[\n"), - eltListPostfix("]"), - eltListSeparator(",\n"), - eltPrefix("coxeter_currentElement:="), - eltPostfix(";"), - eltDataPrefix(""), - eltDataPostfix(""), - graphListPrefix("[\n"), - graphListPostfix("]"), - graphListSeparator(",\n"), - closeString(";"), - polTraits(GAP()), - heckeTraits(I,GAP()), - addHeckeTraits(I,GAP()), - partitionTraits(GAP()), - wgraphTraits(GAP()), - posetTraits(GAP()), - printBettiRank(false), - printCellNumber(false), - printClosureSize(false), - printCoatoms(false), - printCompCount(false), - printDufloNumber(false), - printEltDescents(false), - printElt(true), - printEltData(true), - printEltNumber(false), - printLength(false), - printType(true), - printVersion(true), - hasBettiPadding(false) +OutputTraits::OutputTraits(const CoxGraph &G, const Interface &I, GAP) + : versionString(""), typeString(""), closureSeparator1(""), + closureSeparator2(""), closureSeparator3(""), closureSeparator4(""), + closureSeparator5(""), closureSeparator6(""), + eltList("coxeter_contextEnumeration:="), + singularLocus("coxeter_slocus:="), + singularStratification("coxeter_sstratification:="), + emptySingularLocus("coxeter_slocus:=[];"), + emptySingularStratification("coxeter_sstratification:=[];"), + bettiPrefix("["), bettiPostfix("]"), bettiSeparator(","), + dufloPrefix("["), dufloPostfix("]"), dufloSeparator(","), + dufloListPrefix("[\n"), dufloListPostfix("]"), dufloListSeparator(",\n"), + eltListPrefix("[\n"), eltListPostfix("]"), eltListSeparator(",\n"), + eltPrefix("coxeter_currentElement:="), eltPostfix(";"), eltDataPrefix(""), + eltDataPostfix(""), graphListPrefix("[\n"), graphListPostfix("]"), + graphListSeparator(",\n"), closeString(";"), polTraits(GAP()), + heckeTraits(I, GAP()), addHeckeTraits(I, GAP()), partitionTraits(GAP()), + wgraphTraits(GAP()), posetTraits(GAP()), printBettiRank(false), + printCellNumber(false), printClosureSize(false), printCoatoms(false), + printCompCount(false), printDufloNumber(false), printEltDescents(false), + printElt(true), printEltData(true), printEltNumber(false), + printLength(false), printType(true), printVersion(true), + hasBettiPadding(false) { prefix[basisH] = "coxeter_cbasis:="; @@ -492,15 +392,15 @@ OutputTraits::OutputTraits(const CoxGraph& G, const Interface& I, GAP) hasHeader[slocusH] = true; hasHeader[sstratificationH] = true; - makeVersionString(versionString,"##"); - makeTypeString(typeString,"##",G); + makeVersionString(versionString, "##"); + makeTypeString(typeString, "##", G); } OutputTraits::~OutputTraits() {} -} +} // namespace files /**************************************************************************** @@ -526,61 +426,28 @@ OutputTraits::~OutputTraits() namespace files { -HeckeTraits::HeckeTraits(const Interface& I, Pretty) - :prefix(""), - postfix(""), - evenSeparator(""), - oddSeparator("\n"), - monomialPrefix(""), - monomialPostfix(""), - monomialSeparator(" : "), - muMark(" *"), - hyphens("+"), - lineSize(LINESIZE), - indent(4), - evenWidth(HALFLINESIZE), - oddWidth(0), - padChar(' '), - doShift(false), - reversePrint(false), - twoSided(true) +HeckeTraits::HeckeTraits(const Interface &I, Pretty) + : prefix(""), postfix(""), evenSeparator(""), oddSeparator("\n"), + monomialPrefix(""), monomialPostfix(""), monomialSeparator(" : "), + muMark(" *"), hyphens("+"), lineSize(LINESIZE), indent(4), + evenWidth(HALFLINESIZE), oddWidth(0), padChar(' '), doShift(false), + reversePrint(false), twoSided(true) {} -HeckeTraits::HeckeTraits(const Interface& I, Terse) - :prefix(""), - postfix(""), - evenSeparator(""), - oddSeparator("\n"), - monomialPrefix(""), - monomialPostfix(""), - monomialSeparator(":"), - muMark(""), - lineSize(0), - evenWidth(0), - oddWidth(0), - padChar(' '), - doShift(false), - reversePrint(false), - twoSided(false) +HeckeTraits::HeckeTraits(const Interface &I, Terse) + : prefix(""), postfix(""), evenSeparator(""), oddSeparator("\n"), + monomialPrefix(""), monomialPostfix(""), monomialSeparator(":"), + muMark(""), lineSize(0), evenWidth(0), oddWidth(0), padChar(' '), + doShift(false), reversePrint(false), twoSided(false) {} -HeckeTraits::HeckeTraits(const Interface& I, GAP) - :prefix("[\n"), - postfix("]"), - evenSeparator(""), - oddSeparator(",\n"), - monomialPrefix("["), - monomialPostfix("]"), - monomialSeparator(","), - muMark(""), - lineSize(0), - evenWidth(0), - oddWidth(0), - doShift(false), - reversePrint(false), - twoSided(false) +HeckeTraits::HeckeTraits(const Interface &I, GAP) + : prefix("[\n"), postfix("]"), evenSeparator(""), oddSeparator(",\n"), + monomialPrefix("["), monomialPostfix("]"), monomialSeparator(","), + muMark(""), lineSize(0), evenWidth(0), oddWidth(0), doShift(false), + reversePrint(false), twoSided(false) {} @@ -588,23 +455,23 @@ HeckeTraits::~HeckeTraits() {} -AddHeckeTraits::AddHeckeTraits(const Interface& I, Pretty) - :HeckeTraits(I,Pretty()) +AddHeckeTraits::AddHeckeTraits(const Interface &I, Pretty) + : HeckeTraits(I, Pretty()) -{ +{ eltTraits = new GroupEltInterface(I.outInterface()); } -AddHeckeTraits::AddHeckeTraits(const Interface& I, Terse) - :HeckeTraits(I,Terse()) +AddHeckeTraits::AddHeckeTraits(const Interface &I, Terse) + : HeckeTraits(I, Terse()) { eltTraits = new GroupEltInterface(I.outInterface()); doShift = true; } -AddHeckeTraits::AddHeckeTraits(const Interface& I, GAP) - :HeckeTraits(I,GAP()) +AddHeckeTraits::AddHeckeTraits(const Interface &I, GAP) + : HeckeTraits(I, GAP()) { eltTraits = new GroupEltInterface(I.outInterface()); @@ -627,7 +494,7 @@ AddHeckeTraits::~AddHeckeTraits() delete eltTraits; } -}; +}; // namespace files /**************************************************************************** @@ -647,41 +514,23 @@ AddHeckeTraits::~AddHeckeTraits() namespace files { PartitionTraits::PartitionTraits(Pretty) - :prefix(""), - postfix(""), - separator("\n"), - classPrefix("{"), - classPostfix("}"), - classSeparator(","), - classNumberPrefix(""), - classNumberPostfix(" : "), - printClassNumber(true) + : prefix(""), postfix(""), separator("\n"), classPrefix("{"), + classPostfix("}"), classSeparator(","), classNumberPrefix(""), + classNumberPostfix(" : "), printClassNumber(true) {} PartitionTraits::PartitionTraits(Terse) - :prefix(""), - postfix(""), - separator("\n"), - classPrefix(""), - classPostfix(""), - classSeparator(","), - classNumberPrefix(""), - classNumberPostfix(""), - printClassNumber(false) + : prefix(""), postfix(""), separator("\n"), classPrefix(""), + classPostfix(""), classSeparator(","), classNumberPrefix(""), + classNumberPostfix(""), printClassNumber(false) {} PartitionTraits::PartitionTraits(GAP) - :prefix("[\n"), - postfix("]"), - separator(",\n"), - classPrefix("["), - classPostfix("]"), - classSeparator(","), - classNumberPrefix(""), - classNumberPostfix(""), - printClassNumber(false) + : prefix("[\n"), postfix("]"), separator(",\n"), classPrefix("["), + classPostfix("]"), classSeparator(","), classNumberPrefix(""), + classNumberPostfix(""), printClassNumber(false) {} @@ -689,7 +538,7 @@ PartitionTraits::~PartitionTraits() {} -}; +}; // namespace files /**************************************************************************** @@ -708,68 +557,29 @@ PartitionTraits::~PartitionTraits() namespace files { PolynomialTraits::PolynomialTraits(Pretty) - :prefix(""), - postfix(""), - indeterminate("q"), - sqrtIndeterminate("u"), - posSeparator("+"), - negSeparator(""), - product(""), - exponent("^"), - expPrefix(""), - expPostfix(""), - zeroPol("0"), - one(""), - negOne("-"), - modifierPrefix(""), - modifierPostfix(""), - modifierSeparator(""), - printExponent(true), - printModifier(false) + : prefix(""), postfix(""), indeterminate("q"), sqrtIndeterminate("u"), + posSeparator("+"), negSeparator(""), product(""), exponent("^"), + expPrefix(""), expPostfix(""), zeroPol("0"), one(""), negOne("-"), + modifierPrefix(""), modifierPostfix(""), modifierSeparator(""), + printExponent(true), printModifier(false) {} PolynomialTraits::PolynomialTraits(Terse) - :prefix("["), - postfix("]"), - indeterminate(""), - sqrtIndeterminate(""), - posSeparator(","), - negSeparator(","), - product(""), - exponent(""), - expPrefix(""), - expPostfix(""), - zeroPol("[]"), - one("1"), - negOne("-1"), - modifierPrefix("("), - modifierPostfix(")"), - modifierSeparator(","), - printExponent(false), - printModifier(true) + : prefix("["), postfix("]"), indeterminate(""), sqrtIndeterminate(""), + posSeparator(","), negSeparator(","), product(""), exponent(""), + expPrefix(""), expPostfix(""), zeroPol("[]"), one("1"), negOne("-1"), + modifierPrefix("("), modifierPostfix(")"), modifierSeparator(","), + printExponent(false), printModifier(true) {} PolynomialTraits::PolynomialTraits(GAP) - :prefix(""), - postfix(""), - indeterminate("q"), - sqrtIndeterminate("u"), - posSeparator("+"), - negSeparator(""), - product(""), - exponent("^"), - expPrefix(""), - expPostfix(""), - zeroPol("0"), - one(""), - negOne("-"), - modifierPrefix(""), - modifierPostfix(""), - modifierSeparator(""), - printExponent(true), - printModifier(false) + : prefix(""), postfix(""), indeterminate("q"), sqrtIndeterminate("u"), + posSeparator("+"), negSeparator(""), product(""), exponent("^"), + expPrefix(""), expPostfix(""), zeroPol("0"), one(""), negOne("-"), + modifierPrefix(""), modifierPostfix(""), modifierSeparator(""), + printExponent(true), printModifier(false) {} @@ -777,7 +587,7 @@ PolynomialTraits::~PolynomialTraits() {} -}; +}; // namespace files /**************************************************************************** @@ -797,44 +607,23 @@ PolynomialTraits::~PolynomialTraits() namespace files { PosetTraits::PosetTraits(Pretty) - :prefix(""), - postfix(""), - separator("\n"), - edgePrefix(""), - edgePostfix(""), - edgeSeparator(","), - nodePrefix(""), - nodePostfix(" : "), - nodeShift(0), - printNode(true) + : prefix(""), postfix(""), separator("\n"), edgePrefix(""), edgePostfix(""), + edgeSeparator(","), nodePrefix(""), nodePostfix(" : "), nodeShift(0), + printNode(true) {} PosetTraits::PosetTraits(Terse) - :prefix(""), - postfix(""), - separator("\n"), - edgePrefix(""), - edgePostfix(""), - edgeSeparator(","), - nodePrefix(""), - nodePostfix(""), - nodeShift(0), - printNode(false) + : prefix(""), postfix(""), separator("\n"), edgePrefix(""), edgePostfix(""), + edgeSeparator(","), nodePrefix(""), nodePostfix(""), nodeShift(0), + printNode(false) {} PosetTraits::PosetTraits(GAP) - :prefix("[\n"), - postfix("]"), - separator(",\n"), - edgePrefix("["), - edgePostfix("]"), - edgeSeparator(","), - nodePrefix(""), - nodePostfix(""), - nodeShift(1), - printNode(false) + : prefix("[\n"), postfix("]"), separator(",\n"), edgePrefix("["), + edgePostfix("]"), edgeSeparator(","), nodePrefix(""), nodePostfix(""), + nodeShift(1), printNode(false) {} @@ -842,7 +631,7 @@ PosetTraits::~PosetTraits() {} -}; +}; // namespace files /**************************************************************************** @@ -862,62 +651,29 @@ PosetTraits::~PosetTraits() namespace files { WgraphTraits::WgraphTraits(Pretty) - :prefix(""), - postfix(""), - separator("\n"), - edgeListPrefix("{"), - edgeListPostfix("}"), - edgeListSeparator(","), - edgePrefix("("), - edgePostfix(")"), - edgeSeparator(","), - nodePrefix(""), - nodePostfix(""), - nodeSeparator(":"), - nodeNumberPrefix(""), - nodeNumberPostfix(":"), - nodeShift(0), - hasPadding(true), - printNodeNumber(true) + : prefix(""), postfix(""), separator("\n"), edgeListPrefix("{"), + edgeListPostfix("}"), edgeListSeparator(","), edgePrefix("("), + edgePostfix(")"), edgeSeparator(","), nodePrefix(""), nodePostfix(""), + nodeSeparator(":"), nodeNumberPrefix(""), nodeNumberPostfix(":"), + nodeShift(0), hasPadding(true), printNodeNumber(true) {} WgraphTraits::WgraphTraits(Terse) - :prefix(""), - postfix(""), - separator("\n"), - edgeListPrefix("{"), - edgeListPostfix("}"), - edgeListSeparator(","), - edgePrefix("("), - edgePostfix(")"), - edgeSeparator(","), - nodePrefix(""), - nodePostfix(""), - nodeSeparator(":"), - nodeShift(0), - padSize(0), - hasPadding(false), - printNodeNumber(false) + : prefix(""), postfix(""), separator("\n"), edgeListPrefix("{"), + edgeListPostfix("}"), edgeListSeparator(","), edgePrefix("("), + edgePostfix(")"), edgeSeparator(","), nodePrefix(""), nodePostfix(""), + nodeSeparator(":"), nodeShift(0), padSize(0), hasPadding(false), + printNodeNumber(false) {} WgraphTraits::WgraphTraits(GAP) - :prefix("[\n"), - postfix("]"), - separator(",\n"), - edgeListPrefix("["), - edgeListPostfix("]"), - edgeListSeparator(","), - edgePrefix("["), - edgePostfix("]"), - edgeSeparator(","), - nodePrefix("["), - nodePostfix("]"), - nodeSeparator(","), - nodeShift(0), - hasPadding(false), - printNodeNumber(false) + : prefix("[\n"), postfix("]"), separator(",\n"), edgeListPrefix("["), + edgeListPostfix("]"), edgeListSeparator(","), edgePrefix("["), + edgePostfix("]"), edgeSeparator(","), nodePrefix("["), nodePostfix("]"), + nodeSeparator(","), nodeShift(0), hasPadding(false), + printNodeNumber(false) {} @@ -925,7 +681,7 @@ WgraphTraits::~WgraphTraits() {} -} +} // namespace files /**************************************************************************** @@ -936,7 +692,7 @@ WgraphTraits::~WgraphTraits() - appendHomology(str,h,traits) : appends a homology vector; - printBetti(file,y,p,traits) : prints the betti numbers of [e,y]; - - printCellOrder(file,X,p,order,traits) : prints the set of cells in X as + - printCellOrder(file,X,p,order,traits) : prints the set of cells in X as an abstract poset; - printCoatoms(file,y,p,traits) : prints data about the element y; - printDescents(file,df,f,traits) : prints df as a descent set; @@ -950,7 +706,7 @@ WgraphTraits::~WgraphTraits() namespace files { -void appendHomology(String& str, const Homology& h, OutputTraits& traits) +void appendHomology(String &str, const Homology &h, OutputTraits &traits) /* Appends the homology vector to str. @@ -960,136 +716,134 @@ void appendHomology(String& str, const Homology& h, OutputTraits& traits) Ulong initLength = str.length(); Ulong maxWidth = maxLength(h); // maximum width of output - io::append(str,traits.bettiPrefix); + io::append(str, traits.bettiPrefix); for (Ulong j = 0; j < h.size(); ++j) { if (traits.printBettiRank) { - io::append(str,traits.bettiRankPrefix); - io::append(str,j); - io::append(str,traits.bettiRankPostfix); + io::append(str, traits.bettiRankPrefix); + io::append(str, j); + io::append(str, traits.bettiRankPostfix); } - io::append(str,static_cast(h[j])); + io::append(str, static_cast(h[j])); if (traits.hasBettiPadding) - io::pad(str,(j+1)*(maxWidth+1)+initLength); - if (j+1 < h.size()) // there is more to come - io::append(str,traits.bettiSeparator); + io::pad(str, (j + 1) * (maxWidth + 1) + initLength); + if (j + 1 < h.size()) // there is more to come + io::append(str, traits.bettiSeparator); } - io::append(str,traits.bettiPostfix); + io::append(str, traits.bettiPostfix); return; } -void printBetti(FILE* file, const CoxNbr& y, const SchubertContext& p, - OutputTraits& traits) +void printBetti(FILE *file, const CoxNbr &y, const SchubertContext &p, + OutputTraits &traits) { Homology h(0); - betti(h,y,p); + betti(h, y, p); - io::print(file,traits.prefix[bettiH]); - printHomology(file,h,traits); - io::print(file,traits.postfix[bettiH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[bettiH]); + printHomology(file, h, traits); + io::print(file, traits.postfix[bettiH]); + fprintf(file, "\n"); return; } -void printCellOrder(FILE* file, const OrientedGraph& X, - const SchubertContext& p, const Interface& I, - PosetTraits& traits) +void printCellOrder(FILE *file, const OrientedGraph &X, + const SchubertContext &p, const Interface &I, + PosetTraits &traits) /* This function prints out the poset of cells defined by the graph X. The - interface parameter is needed to determine the shortLex ordering of the + interface parameter is needed to determine the shortLex ordering of the elements. */ -{ +{ OrientedGraph P(0); Partition pi(0); - X.cells(pi,&P); + X.cells(pi, &P); posets::Poset Q(P); OrientedGraph H(0); Q.hasseDiagram(H); - List > lc(0); - writeClasses(lc,pi); + List> lc(0); + writeClasses(lc, pi); - schubert::NFCompare nfc(p,I.order()); + schubert::NFCompare nfc(p, I.order()); Permutation a(0); - sortLists(lc,nfc,a); + sortLists(lc, nfc, a); a.inverse(); H.permute(a); - io::print(file,traits.prefix); + io::print(file, traits.prefix); for (Ulong j = 0; j < pi.classCount(); ++j) { if (traits.printNode) { - io::print(file,traits.nodePrefix); - fprintf(file,"%lu",j+traits.nodeShift); - io::print(file,traits.nodePostfix); + io::print(file, traits.nodePrefix); + fprintf(file, "%lu", j + traits.nodeShift); + io::print(file, traits.nodePostfix); } - const EdgeList& e = H.edge(j); - io::print(file,traits.edgePrefix); + const EdgeList &e = H.edge(j); + io::print(file, traits.edgePrefix); for (Ulong i = 0; i < e.size(); ++i) { - fprintf(file,"%lu",e[i]+traits.nodeShift); - if (i+1 < e.size()) /* there is more to come */ - io::print(file,traits.edgeSeparator); + fprintf(file, "%lu", e[i] + traits.nodeShift); + if (i + 1 < e.size()) /* there is more to come */ + io::print(file, traits.edgeSeparator); } - io::print(file,traits.edgePostfix); + io::print(file, traits.edgePostfix); - if (j+1 < pi.classCount()) // there is more to come - io::print(file,traits.separator); + if (j + 1 < pi.classCount()) // there is more to come + io::print(file, traits.separator); } - io::print(file,traits.postfix); + io::print(file, traits.postfix); return; } -void printCoatoms(FILE* file, const CoxNbr& y, const SchubertContext& p, - const Interface& I, OutputTraits& traits) +void printCoatoms(FILE *file, const CoxNbr &y, const SchubertContext &p, + const Interface &I, OutputTraits &traits) /* Prints out the coatoms of y. */ { - const CoatomList& c = p.hasse(y); + const CoatomList &c = p.hasse(y); - io::print(file,traits.coatomPrefix); + io::print(file, traits.coatomPrefix); for (Ulong j = 0; j < c.size(); ++j) { - p.print(file,c[j],I); - if (j+1 < c.size()) // there is more to come - io::print(file,traits.coatomSeparator); + p.print(file, c[j], I); + if (j + 1 < c.size()) // there is more to come + io::print(file, traits.coatomSeparator); } - io::print(file,traits.coatomPostfix); - + io::print(file, traits.coatomPostfix); + return; } -void printDescents(FILE* file, const LFlags& df, const LFlags& f, - const Interface& I, WgraphTraits& traits) +void printDescents(FILE *file, const LFlags &df, const LFlags &f, + const Interface &I, WgraphTraits &traits) { - if (!(f&1)) { // left descents - print(file,df,I); - } - else if ((f >> I.rank()) == 0) { // right descents - print(file,df,I); - } - else { // two-sided descents - printTwosided(file,df,I); + if (!(f & 1)) { // left descents + print(file, df, I); + } else if ((f >> I.rank()) == 0) { // right descents + print(file, df, I); + } else { // two-sided descents + printTwosided(file, df, I); } return; } -void printEltData(FILE* file, const CoxNbr& y, const SchubertContext& p, - const Interface& I, OutputTraits& traits) +void printEltData(FILE *file, const CoxNbr &y, const SchubertContext &p, + const Interface &I, OutputTraits &traits) /* This function prints out some data about the element y : @@ -1098,125 +852,125 @@ void printEltData(FILE* file, const CoxNbr& y, const SchubertContext& p, - length; */ -{ - io::print(file,traits.eltDataPrefix); +{ + io::print(file, traits.eltDataPrefix); if (traits.printElt) { - io::print(file,traits.eltPrefix); - p.print(file,y,I); - io::print(file,traits.eltPostfix); + io::print(file, traits.eltPrefix); + p.print(file, y, I); + io::print(file, traits.eltPostfix); } if (traits.printEltDescents) { - io::print(file,traits.lDescentPrefix); - print(file,p.ldescent(y),I); - io::print(file,traits.lDescentPostfix); - io::print(file,traits.rDescentPrefix); - print(file,p.rdescent(y),I); - io::print(file,traits.rDescentPostfix); + io::print(file, traits.lDescentPrefix); + print(file, p.ldescent(y), I); + io::print(file, traits.lDescentPostfix); + io::print(file, traits.rDescentPrefix); + print(file, p.rdescent(y), I); + io::print(file, traits.rDescentPostfix); } if (traits.printLength) { - io::print(file,traits.lengthPrefix); - fprintf(file,"%lu",static_cast(p.length(y))); - io::print(file,traits.lengthPostfix); + io::print(file, traits.lengthPrefix); + fprintf(file, "%lu", static_cast(p.length(y))); + io::print(file, traits.lengthPostfix); } - io::print(file,traits.eltDataPostfix); + io::print(file, traits.eltDataPostfix); return; } -void printHeader(FILE* file, const Header& header, OutputTraits& traits) +void printHeader(FILE *file, const Header &header, OutputTraits &traits) /* Prints the header part of the file. It has already been checked if the header has to be printed. */ -{ +{ using namespace directories; // preliminaries if (traits.printVersion) - io::print(file,traits.versionString); + io::print(file, traits.versionString); if (traits.printType) - io::print(file,traits.typeString); + io::print(file, traits.typeString); if (traits.hasHeader[header]) - printFile(file,traits.header[header].ptr(),HEADER_DIR); + printFile(file, traits.header[header].ptr(), HEADER_DIR); return; } -void printHomology(FILE* file, const Homology& h, OutputTraits& traits) +void printHomology(FILE *file, const Homology &h, OutputTraits &traits) { String buf(0); - appendHomology(buf,h,traits); + appendHomology(buf, h, traits); if (traits.lineSize) - foldLine(file,buf,traits.lineSize,0,traits.bettiHyphens.ptr()); + foldLine(file, buf, traits.lineSize, 0, traits.bettiHyphens.ptr()); else - io::print(file,buf); + io::print(file, buf); if (traits.printClosureSize) { - fprintf(file,"\n\n"); + fprintf(file, "\n\n"); Ulong size = 0; for (Ulong j = 0; j < h.size(); ++j) size += h[j]; - io::print(file,traits.closureSizePrefix); - fprintf(file,"%lu",size); - io::print(file,traits.closureSizePostfix); + io::print(file, traits.closureSizePrefix); + fprintf(file, "%lu", size); + io::print(file, traits.closureSizePostfix); } return; } -void printPartition(FILE* file, const Partition& pi, const SchubertContext& p, - const Interface& I, PartitionTraits& traits) +void printPartition(FILE *file, const Partition &pi, const SchubertContext &p, + const Interface &I, PartitionTraits &traits) /* Prints out the classes of the partition, according to the given traits. */ { - List > lc(0); - writeClasses(lc,pi); + List> lc(0); + writeClasses(lc, pi); - schubert::NFCompare nfc(p,I.order()); + schubert::NFCompare nfc(p, I.order()); Permutation a(0); - sortLists(lc,nfc,a); + sortLists(lc, nfc, a); - int d = digits(lc.size()-1,10); - io::print(file,traits.prefix); + int d = digits(lc.size() - 1, 10); + io::print(file, traits.prefix); for (Ulong j = 0; j < lc.size(); ++j) { List l = lc[a[j]]; if (traits.printClassNumber) { - io::print(file,traits.classNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.classNumberPostfix); + io::print(file, traits.classNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.classNumberPostfix); } - io::print(file,traits.classPrefix); + io::print(file, traits.classPrefix); for (Ulong i = 0; i < l.size(); ++i) { - p.print(file,l[i],I); - if (i+1 < l.size()) /* there is more to come */ - io::print(file,traits.classSeparator); + p.print(file, l[i], I); + if (i + 1 < l.size()) /* there is more to come */ + io::print(file, traits.classSeparator); } - io::print(file,traits.classPostfix); - if (j+1 < lc.size()) // there is more to come - io::print(file,traits.separator); + io::print(file, traits.classPostfix); + if (j + 1 < lc.size()) // there is more to come + io::print(file, traits.separator); } - io::print(file,traits.postfix); + io::print(file, traits.postfix); return; } -void printWGraph(FILE* file, const WGraph& X, const LFlags& f, - const Interface& I, WgraphTraits& traits) +void printWGraph(FILE *file, const WGraph &X, const LFlags &f, + const Interface &I, WgraphTraits &traits) /* This function prints out a W-graph. We represent a W-graph as a list of @@ -1226,46 +980,46 @@ void printWGraph(FILE* file, const WGraph& X, const LFlags& f, */ { - int d = digits(X.size()-1,10); + int d = digits(X.size() - 1, 10); - io::print(file,traits.prefix); + io::print(file, traits.prefix); for (Ulong j = 0; j < X.size(); ++j) { if (traits.printNodeNumber) { - io::print(file,traits.nodeNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.nodeNumberPostfix); + io::print(file, traits.nodeNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.nodeNumberPostfix); } - io::print(file,traits.nodePrefix); - printDescents(file,X.descent(j),f,I,traits); - io::print(file,traits.nodeSeparator); - const CoeffList& mu = X.coeffList(j); - const EdgeList& e = X.edge(j); - io::print(file,traits.edgeListPrefix); + io::print(file, traits.nodePrefix); + printDescents(file, X.descent(j), f, I, traits); + io::print(file, traits.nodeSeparator); + const CoeffList &mu = X.coeffList(j); + const EdgeList &e = X.edge(j); + io::print(file, traits.edgeListPrefix); for (Ulong i = 0; i < e.size(); ++i) { - io::print(file,traits.edgePrefix); - fprintf(file,"%lu",static_cast(e[i])); - io::print(file,traits.edgeSeparator); - fprintf(file,"%ld",static_cast(mu[i])); - io::print(file,traits.edgePostfix); - if (i+1 < e.size()) // there is more to come - io::print(file,traits.edgeListSeparator); + io::print(file, traits.edgePrefix); + fprintf(file, "%lu", static_cast(e[i])); + io::print(file, traits.edgeSeparator); + fprintf(file, "%ld", static_cast(mu[i])); + io::print(file, traits.edgePostfix); + if (i + 1 < e.size()) // there is more to come + io::print(file, traits.edgeListSeparator); } - io::print(file,traits.edgeListPostfix); - io::print(file,traits.nodePostfix); - if (j+1 < X.size()) { // there is more to come - io::print(file,traits.separator); + io::print(file, traits.edgeListPostfix); + io::print(file, traits.nodePostfix); + if (j + 1 < X.size()) { // there is more to come + io::print(file, traits.separator); if (traits.hasPadding) - fprintf(file,"%*s",traits.padSize,""); - } + fprintf(file, "%*s", traits.padSize, ""); + } } - io::print(file,traits.postfix); + io::print(file, traits.postfix); return; } -}; +}; // namespace files /**************************************************************************** @@ -1275,7 +1029,7 @@ void printWGraph(FILE* file, const WGraph& X, const LFlags& f, - appendModifier(str,d,m,traits) : does the printing of the modifier; - appendSeparator(str,n,traits) : does the printing of the separator; - - minReps(min,pi,c) : extracts minimal representatives of the classes in + - minReps(min,pi,c) : extracts minimal representatives of the classes in pi; - printModifier(str,d,m,traits) : does the printing of the modifier; - printSeparator(file,n,traits) : does the printing of the separator; @@ -1285,7 +1039,7 @@ void printWGraph(FILE* file, const WGraph& X, const LFlags& f, and some others private to the present module: - - makeVersionString(vstr,str) : makes the version string with str as + - makeVersionString(vstr,str) : makes the version string with str as prefix; - makeTypeString(tstr,str) : makes the type string with str as prefix; @@ -1293,39 +1047,38 @@ void printWGraph(FILE* file, const WGraph& X, const LFlags& f, namespace files { -void appendModifier(String& str, const Ulong& d, const long& m, - PolynomialTraits& traits) +void appendModifier(String &str, const Ulong &d, const long &m, + PolynomialTraits &traits) /* Appends the polynomial modifier to the string. */ { - io::append(str,traits.modifierPrefix); - io::append(str,static_cast(d)); - io::append(str,traits.modifierSeparator); - io::append(str,static_cast(m)); - io::append(str,traits.modifierPostfix); + io::append(str, traits.modifierPrefix); + io::append(str, static_cast(d)); + io::append(str, traits.modifierSeparator); + io::append(str, static_cast(m)); + io::append(str, traits.modifierPostfix); return; } -void appendSeparator(String& str, const Ulong& n, HeckeTraits& traits) +void appendSeparator(String &str, const Ulong &n, HeckeTraits &traits) { if (traits.twoSided) { // need to look at parity of n - if (n%2) - io::append(str,traits.oddSeparator); + if (n % 2) + io::append(str, traits.oddSeparator); else - io::append(str,traits.evenSeparator); - } - else - io::append(str,traits.oddSeparator); + io::append(str, traits.evenSeparator); + } else + io::append(str, traits.oddSeparator); return; } -void minReps(List& min, const Partition& pi, schubert::NFCompare& c) +void minReps(List &min, const Partition &pi, schubert::NFCompare &c) /* Extracts the minimal representative from each class in pi, for the comparison @@ -1334,14 +1087,14 @@ void minReps(List& min, const Partition& pi, schubert::NFCompare& c) { for (PartitionIterator i(pi); i; ++i) { - CoxNbr x = schubert::min(i(),c); + CoxNbr x = schubert::min(i(), c); min.append(x); } return; } -void pad(String& str, const Ulong& n, HeckeTraits& traits) +void pad(String &str, const Ulong &n, HeckeTraits &traits) /* Adds padding to the string, to make its length at least equal to @@ -1353,66 +1106,64 @@ void pad(String& str, const Ulong& n, HeckeTraits& traits) if (!traits.twoSided) return; - if (n%2 && traits.oddWidth) { + if (n % 2 && traits.oddWidth) { Ulong m = str.length(); if (m < traits.oddWidth) { // odd padding for (Ulong j = m; j < traits.oddWidth; ++j) - io::append(str,traits.padChar); + io::append(str, traits.padChar); } } - if (!(n%2) && traits.evenWidth) { + if (!(n % 2) && traits.evenWidth) { Ulong m = str.length(); if (m < traits.evenWidth) { // odd padding for (Ulong j = m; j < traits.evenWidth; ++j) - io::append(str,traits.padChar); + io::append(str, traits.padChar); } } return; } -void printModifier(FILE* file, const Ulong& d, const long& m, - PolynomialTraits& traits) +void printModifier(FILE *file, const Ulong &d, const long &m, + PolynomialTraits &traits) /* Prints the modifier parameters (d,m). */ { - io::print(file,traits.modifierPrefix); - fprintf(file,"%lu",d); - io::print(file,traits.modifierSeparator); - fprintf(file,"%ld",m); - io::print(file,traits.modifierPostfix); + io::print(file, traits.modifierPrefix); + fprintf(file, "%lu", d); + io::print(file, traits.modifierSeparator); + fprintf(file, "%ld", m); + io::print(file, traits.modifierPostfix); return; } -void printSeparator(FILE* file, const Ulong& n, HeckeTraits& traits) +void printSeparator(FILE *file, const Ulong &n, HeckeTraits &traits) { if (traits.twoSided) { // need to look at parity of n - if (n%2) - io::print(file,traits.oddSeparator); + if (n % 2) + io::print(file, traits.oddSeparator); else - io::print(file,traits.evenSeparator); - } - else - io::print(file,traits.oddSeparator); + io::print(file, traits.evenSeparator); + } else + io::print(file, traits.oddSeparator); return; } -void sortLists(List >& lc, schubert::NFCompare& nfc, - Permutation& a) +void sortLists(List> &lc, schubert::NFCompare &nfc, Permutation &a) /* This function sorts the various rows in lc, and puts in a the permutation which sorts ld according to the first term in each row. */ -{ +{ List lfirst(0); lfirst.setSize(lc.size()); @@ -1421,12 +1172,12 @@ void sortLists(List >& lc, schubert::NFCompare& nfc, lfirst[j] = lc[j][0]; } - sortI(lfirst,nfc,a); + sortI(lfirst, nfc, a); return; } -void writeClasses(List >& lc, const Partition& pi) +void writeClasses(List> &lc, const Partition &pi) /* This function writes out in lc the various classes of the partition pi. @@ -1437,53 +1188,53 @@ void writeClasses(List >& lc, const Partition& pi) Ulong j = 0; for (PartitionIterator i(pi); i; ++i) { - new(&lc[j]) List(i().begin(),i().end()); + new (&lc[j]) List(i().begin(), i().end()); ++j; } return; } -}; +}; // namespace files namespace { -void makeVersionString(String& vstr, const String& str) +void makeVersionString(String &vstr, const String &str) -{ +{ using namespace version; - append(vstr,str); - append(vstr,"\n"); - append(vstr,str); - append(vstr," This file has been created by "); - append(vstr,NAME); - append(vstr," version "); - append(vstr,VERSION); - append(vstr,"\n"); + append(vstr, str); + append(vstr, "\n"); + append(vstr, str); + append(vstr, " This file has been created by "); + append(vstr, NAME); + append(vstr, " version "); + append(vstr, VERSION); + append(vstr, "\n"); return; } -void makeTypeString(String& tstr, const String& str, const CoxGraph& G) +void makeTypeString(String &tstr, const String &str, const CoxGraph &G) -{ - append(tstr,str); - append(tstr,"\n"); - append(tstr,str); - append(tstr," Group type is "); - append(tstr,G.type().name()); - append(tstr,G.rank()); - append(tstr,"\n"); +{ + append(tstr, str); + append(tstr, "\n"); + append(tstr, str); + append(tstr, " Group type is "); + append(tstr, G.type().name()); + append(tstr, G.rank()); + append(tstr, "\n"); return; } -}; +}; // namespace namespace { -Ulong maxLength(const Homology& h) +Ulong maxLength(const Homology &h) /* Returns the maximal length of an entry in h. @@ -1496,10 +1247,10 @@ Ulong maxLength(const Homology& h) for (Ulong j = 0; j < h.size(); ++j) { reset(buf); - append(buf,"h["); - append(buf,j); - append(buf,"] = "); - append(buf,h[j]); + append(buf, "h["); + append(buf, j); + append(buf, "] = "); + append(buf, h[j]); if (maxl < buf.size()) maxl = buf.size(); } @@ -1507,4 +1258,4 @@ Ulong maxLength(const Homology& h) return maxl; } -}; +}; // namespace diff --git a/files.h b/files.h index 98a7350..ca6ca1f 100644 --- a/files.h +++ b/files.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef FILES_H /* guard against multiple inclusions */ +#ifndef FILES_H /* guard against multiple inclusions */ #define FILES_H #include "globals.h" @@ -16,168 +16,178 @@ #include "wgraph.h" namespace files { - using namespace coxeter; - using namespace hecke; - using namespace wgraph; - // do _not_ use namespace kl! creates conflicts in coxgroup +using namespace coxeter; +using namespace hecke; +using namespace wgraph; +// do _not_ use namespace kl! creates conflicts in coxgroup /******** type declarations *************************************************/ - enum Header { bettiH, basisH, closureH, dufloH, extremalsH, ihBettiH, - lCOrderH, lCellsH, lCellWGraphsH, lWGraphH, lrCOrderH, - lrCellsH, lrCellWGraphsH, lrWGraphH, rCOrderH, rCellsH, - rCellWGraphsH, rWGraphH, slocusH, sstratificationH, - numHeaders}; +enum Header { + bettiH, + basisH, + closureH, + dufloH, + extremalsH, + ihBettiH, + lCOrderH, + lCellsH, + lCellWGraphsH, + lWGraphH, + lrCOrderH, + lrCellsH, + lrCellWGraphsH, + lrWGraphH, + rCOrderH, + rCellsH, + rCellWGraphsH, + rWGraphH, + slocusH, + sstratificationH, + numHeaders +}; - struct AddHeckeTraits; - struct HeckeTraits; - struct OutputTraits; - struct PolynomialTraits; - struct PosetTraits; - struct PartitionTraits; - struct WgraphTraits; +struct AddHeckeTraits; +struct HeckeTraits; +struct OutputTraits; +struct PolynomialTraits; +struct PosetTraits; +struct PartitionTraits; +struct WgraphTraits; /******** function definitions **********************************************/ template - void appendCoefficient(String& str, const C& c, - PolynomialTraits& traits); +void appendCoefficient(String &str, const C &c, PolynomialTraits &traits); template - void appendExponent(String& str, const E& e, PolynomialTraits& traits); +void appendExponent(String &str, const E &e, PolynomialTraits &traits); template - void appendHeckeMonomial(String& str, const M& m, const SchubertContext& p, - const Interface& I, HeckeTraits& hTraits, - PolynomialTraits& pTraits, const Length& l); -void appendHomology(String& str, const Homology& h, OutputTraits& traits); +void appendHeckeMonomial(String &str, const M &m, const SchubertContext &p, + const Interface &I, HeckeTraits &hTraits, + PolynomialTraits &pTraits, const Length &l); +void appendHomology(String &str, const Homology &h, OutputTraits &traits); template - void appendMonomial(String& str, const C& c, const Ulong& e, - PolynomialTraits& traits, - const Ulong& d = 1, const long& m = 0); -void appendModifier(String& str, const Ulong& d, const long& m, - PolynomialTraits& traits); +void appendMonomial(String &str, const C &c, const Ulong &e, + PolynomialTraits &traits, const Ulong &d = 1, + const long &m = 0); +void appendModifier(String &str, const Ulong &d, const long &m, + PolynomialTraits &traits); template - void appendMuMark(String& str, const M& m, const SchubertContext& p, - const Length& l, HeckeTraits& traits); +void appendMuMark(String &str, const M &m, const SchubertContext &p, + const Length &l, HeckeTraits &traits); template - void appendPolynomial(String& str, const P& p, - PolynomialTraits& traits, - const Ulong& d = 1, const long& m = 0); -void appendSeparator(String& str, const Ulong& n, HeckeTraits& traits); +void appendPolynomial(String &str, const P &p, PolynomialTraits &traits, + const Ulong &d = 1, const long &m = 0); +void appendSeparator(String &str, const Ulong &n, HeckeTraits &traits); template - void makeWGraph(WGraph& X, const List& c, const LFlags& f, KL& kl); -void minReps(List& min, const Partition& pi, schubert::NFCompare& c); -void pad(String& str, const Ulong& n, HeckeTraits& traits); -template - void printAsBasisElt(FILE* file, const H& h, const SchubertContext& p, - Interface& I, OutputTraits& traits); -void printBetti(FILE* file, const CoxNbr& y, const SchubertContext& p, - OutputTraits& traits); -void printCellOrder(FILE* file, const OrientedGraph& X, - const SchubertContext& p, const Interface& I, - PosetTraits& traits); -void printCoatoms(FILE* file, const CoxNbr& y, const SchubertContext& p, - const Interface& I, OutputTraits& traits); +void makeWGraph(WGraph &X, const List &c, const LFlags &f, KL &kl); +void minReps(List &min, const Partition &pi, schubert::NFCompare &c); +void pad(String &str, const Ulong &n, HeckeTraits &traits); +template +void printAsBasisElt(FILE *file, const H &h, const SchubertContext &p, + Interface &I, OutputTraits &traits); +void printBetti(FILE *file, const CoxNbr &y, const SchubertContext &p, + OutputTraits &traits); +void printCellOrder(FILE *file, const OrientedGraph &X, + const SchubertContext &p, const Interface &I, + PosetTraits &traits); +void printCoatoms(FILE *file, const CoxNbr &y, const SchubertContext &p, + const Interface &I, OutputTraits &traits); template - void printClosure(FILE* file, const CoxNbr& y, KL& kl, const Interface& I, - OutputTraits& traits); +void printClosure(FILE *file, const CoxNbr &y, KL &kl, const Interface &I, + OutputTraits &traits); template - void printCoefficient(FILE* file, const C& c, - PolynomialTraits& traits); -void printDescents(FILE* file, const LFlags& df, const LFlags& f, - const Interface& I, WgraphTraits& traits); +void printCoefficient(FILE *file, const C &c, PolynomialTraits &traits); +void printDescents(FILE *file, const LFlags &df, const LFlags &f, + const Interface &I, WgraphTraits &traits); template - void printDuflo(FILE* file, const List& d, const Partition& pi, - KL& kl, const Interface& I, OutputTraits& traits); -void printEltData(FILE* file, const CoxNbr& y, const SchubertContext& p, - const Interface& I, OutputTraits& traits); +void printDuflo(FILE *file, const List &d, const Partition &pi, KL &kl, + const Interface &I, OutputTraits &traits); +void printEltData(FILE *file, const CoxNbr &y, const SchubertContext &p, + const Interface &I, OutputTraits &traits); template - void printExponent(FILE* file, const E& e, PolynomialTraits& traits); +void printExponent(FILE *file, const E &e, PolynomialTraits &traits); template - void printExtremals(FILE* file, const CoxNbr& y, const KL& kl, - const Interface& I, OutputTraits& traits); -void printHeader(FILE* file, const Header& header, OutputTraits& traits); +void printExtremals(FILE *file, const CoxNbr &y, const KL &kl, + const Interface &I, OutputTraits &traits); +void printHeader(FILE *file, const Header &header, OutputTraits &traits); template - void printHeckeElt(FILE* file, const H& h, const SchubertContext& p, - const Interface& I, OutputTraits& traits, - const Length& l = undef_length); +void printHeckeElt(FILE *file, const H &h, const SchubertContext &p, + const Interface &I, OutputTraits &traits, + const Length &l = undef_length); template - void printHeckeElt(FILE* file, const H& h, const Permutation& a, - const SchubertContext& p, const Interface& I, - HeckeTraits& hTraits, - PolynomialTraits& pTraits, - const Length& l = undef_length); -void printHomology(FILE* file, const Homology& h, OutputTraits& traits); +void printHeckeElt(FILE *file, const H &h, const Permutation &a, + const SchubertContext &p, const Interface &I, + HeckeTraits &hTraits, PolynomialTraits &pTraits, + const Length &l = undef_length); +void printHomology(FILE *file, const Homology &h, OutputTraits &traits); template - void printIHBetti(FILE* file, const CoxNbr& y, KL& kl, OutputTraits& traits); +void printIHBetti(FILE *file, const CoxNbr &y, KL &kl, OutputTraits &traits); template - void printLCOrder(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); +void printLCOrder(FILE *file, KL &kl, const Interface &I, OutputTraits &traits); template - void printLCells(FILE* file, const Partition& lp, KL& kl, const Interface& I, - OutputTraits& traits); +void printLCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits); template - void printLCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits); +void printLCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits); template - void printLRCOrder(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); +void printLRCOrder(FILE *file, KL &kl, const Interface &I, + OutputTraits &traits); template - void printLRCells(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits); +void printLRCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits); template - void printLRCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits); +void printLRCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits); template - void printLRWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); +void printLRWGraph(FILE *file, KL &kl, const Interface &I, + OutputTraits &traits); template - void printLWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); +void printLWGraph(FILE *file, KL &kl, const Interface &I, OutputTraits &traits); template - void printMonomial(FILE* file, const C& c, const Ulong& e, - PolynomialTraits& traits, - const Ulong& d = 1, const long& m = 0); -void printModifier(FILE* file, const Ulong& d, const long& m, - PolynomialTraits& traits); +void printMonomial(FILE *file, const C &c, const Ulong &e, + PolynomialTraits &traits, const Ulong &d = 1, + const long &m = 0); +void printModifier(FILE *file, const Ulong &d, const long &m, + PolynomialTraits &traits); template - void printMuMark(FILE* file, const M& m, const SchubertContext& p, - const Length& l, HeckeTraits& traits); -void printPartition(FILE* file, const Partition& pi, const SchubertContext& p, - const Interface& I, PartitionTraits& traits); +void printMuMark(FILE *file, const M &m, const SchubertContext &p, + const Length &l, HeckeTraits &traits); +void printPartition(FILE *file, const Partition &pi, const SchubertContext &p, + const Interface &I, PartitionTraits &traits); template - void printPolynomial(FILE* file, const P& p, PolynomialTraits& traits, - const Ulong& d = 1, const long& m = 0); +void printPolynomial(FILE *file, const P &p, PolynomialTraits &traits, + const Ulong &d = 1, const long &m = 0); template - void printRCOrder(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); +void printRCOrder(FILE *file, KL &kl, const Interface &I, OutputTraits &traits); template - void printRCells(FILE* file, const Partition& lp, KL& kl, const Interface& I, - OutputTraits& traits); +void printRCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits); template - void printRCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits); +void printRCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits); template - void printRWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits); -void printSeparator(FILE* file, const Ulong& n, HeckeTraits& traits); +void printRWGraph(FILE *file, KL &kl, const Interface &I, OutputTraits &traits); +void printSeparator(FILE *file, const Ulong &n, HeckeTraits &traits); template - void printSingularLocus(FILE* file, const CoxNbr& y, KL& kl, - const Interface& I, OutputTraits& traits); +void printSingularLocus(FILE *file, const CoxNbr &y, KL &kl, const Interface &I, + OutputTraits &traits); template - void printSingularStratification(FILE* file, const CoxNbr& y, KL& kl, - const Interface& I, OutputTraits& traits); -void printWGraph(FILE* file, const WGraph& X, const LFlags& f, - const Interface& I, WgraphTraits& traits); +void printSingularStratification(FILE *file, const CoxNbr &y, KL &kl, + const Interface &I, OutputTraits &traits); +void printWGraph(FILE *file, const WGraph &X, const LFlags &f, + const Interface &I, WgraphTraits &traits); template - void printWGraphList(FILE* file, const Partition& pi, const LFlags& f, - const Interface& I, KL& kl, OutputTraits& traits); +void printWGraphList(FILE *file, const Partition &pi, const LFlags &f, + const Interface &I, KL &kl, OutputTraits &traits); template - bool setTwoSided(const H& h, const Permutation& a, const SchubertContext& p, - const Interface& I, HeckeTraits& hTraits, - PolynomialTraits& pTraits, const Length& l = undef_length); -void sortLists(List >& lc, schubert::NFCompare& nfc, - Permutation& a); -void writeClasses(List >& lc, const Partition& pi); +bool setTwoSided(const H &h, const Permutation &a, const SchubertContext &p, + const Interface &I, HeckeTraits &hTraits, + PolynomialTraits &pTraits, const Length &l = undef_length); +void sortLists(List> &lc, schubert::NFCompare &nfc, + Permutation &a); +void writeClasses(List> &lc, const Partition &pi); /******** type definitions **************************************************/ @@ -200,10 +210,11 @@ struct PolynomialTraits { String modifierSeparator; bool printExponent; bool printModifier; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(PolynomialTraits));} + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(PolynomialTraits)); + } PolynomialTraits(Pretty); PolynomialTraits(Terse); PolynomialTraits(GAP); @@ -228,25 +239,27 @@ struct HeckeTraits { bool doShift; bool reversePrint; bool twoSided; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(HeckeTraits));} - HeckeTraits(const Interface& I, Pretty); - HeckeTraits(const Interface& I, Terse); - HeckeTraits(const Interface& I, GAP); + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(HeckeTraits)); + } + HeckeTraits(const Interface &I, Pretty); + HeckeTraits(const Interface &I, Terse); + HeckeTraits(const Interface &I, GAP); virtual ~HeckeTraits(); }; -struct AddHeckeTraits:public HeckeTraits { // Hecke traits for additive output - GroupEltInterface* eltTraits; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(AddHeckeTraits));} - AddHeckeTraits(const Interface& I, Pretty); - AddHeckeTraits(const Interface& I, Terse); - AddHeckeTraits(const Interface& I, GAP); +struct AddHeckeTraits : public HeckeTraits { // Hecke traits for additive output + GroupEltInterface *eltTraits; + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(AddHeckeTraits)); + } + AddHeckeTraits(const Interface &I, Pretty); + AddHeckeTraits(const Interface &I, Terse); + AddHeckeTraits(const Interface &I, GAP); ~AddHeckeTraits(); }; @@ -260,10 +273,11 @@ struct PartitionTraits { String classNumberPrefix; String classNumberPostfix; bool printClassNumber; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(PartitionTraits));} + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(PartitionTraits)); + } PartitionTraits(Pretty); PartitionTraits(Terse); PartitionTraits(GAP); @@ -281,10 +295,11 @@ struct PosetTraits { String nodePostfix; Ulong nodeShift; bool printNode; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(PosetTraits));} + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(PosetTraits)); + } PosetTraits(Pretty); PosetTraits(Terse); PosetTraits(GAP); @@ -310,10 +325,11 @@ struct WgraphTraits { int padSize; bool hasPadding; bool printNodeNumber; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(WgraphTraits));} + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(WgraphTraits)); + } WgraphTraits(Pretty); WgraphTraits(Terse); WgraphTraits(GAP); @@ -321,7 +337,7 @@ struct WgraphTraits { }; struct OutputTraits { -// strings + // strings String versionString; String typeString; // header file names @@ -385,18 +401,18 @@ struct OutputTraits { String closeString; String bettiHyphens; Ulong lineSize; -// traits for the output of a polynomial + // traits for the output of a polynomial PolynomialTraits polTraits; -// traits for the output of a Hecke element + // traits for the output of a Hecke element HeckeTraits heckeTraits; AddHeckeTraits addHeckeTraits; -// traits for the output of a partition + // traits for the output of a partition PartitionTraits partitionTraits; -// traits for the output of a W-graph + // traits for the output of a W-graph WgraphTraits wgraphTraits; -// traits for the output of a poset + // traits for the output of a poset PosetTraits posetTraits; -// flags + // flags bool printBettiRank; bool printCellNumber; bool printClosureSize; @@ -411,22 +427,23 @@ struct OutputTraits { bool printType; bool printVersion; bool hasBettiPadding; -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void* operator new(size_t size, void* ptr) {return ptr;} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(OutputTraits));} - void operator delete(void* p1, void* p2) {}; - OutputTraits(const CoxGraph& G, const Interface& I, Pretty); - OutputTraits(const CoxGraph& G, const Interface& I, Terse); - OutputTraits(const CoxGraph& G, const Interface& I, GAP); + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void *operator new(size_t size, void *ptr) { return ptr; } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(OutputTraits)); + } + void operator delete(void *p1, void *p2){}; + OutputTraits(const CoxGraph &G, const Interface &I, Pretty); + OutputTraits(const CoxGraph &G, const Interface &I, Terse); + OutputTraits(const CoxGraph &G, const Interface &I, GAP); ~OutputTraits(); -// manipulators - void setBasisTraits(HeckeTraits& hTraits); - void setDefaultTraits(HeckeTraits& hTraits); + // manipulators + void setBasisTraits(HeckeTraits &hTraits); + void setDefaultTraits(HeckeTraits &hTraits); }; -} +} // namespace files /******** inline definitions *************************************************/ diff --git a/files.hpp b/files.hpp index 1845a2c..8fca9bc 100644 --- a/files.hpp +++ b/files.hpp @@ -1,6 +1,6 @@ /* This is files.hpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -27,11 +27,11 @@ - printCoefficient(file,c,traits) : like appendCoefficient; - printHeckeElt(file,h,p,I,a,hTraits,pTraits,l) : same as preceding one, but data is sorted using the permutation a; - - printHeckeMonomial(file,m,p,I,pTraits,hTraits,l) : like + - printHeckeMonomial(file,m,p,I,pTraits,hTraits,l) : like appendHeckeMonomial; - printLCOrder(file,kl,I,G,traits) : outputs the left cell ordering as an abstract poset; - - printLRCOrder(file,kl,I,G,traits) : outputs the two-sided cell + - printLRCOrder(file,kl,I,G,traits) : outputs the two-sided cell ordering as an abstract poset; - printMonomial(file,c,e,traits,d,m) : like appendMonomial; - printMuMark(file,m,p,l,traits) : like appendMuMark; @@ -46,37 +46,36 @@ namespace files { template -void appendCoefficient(String& str, const C& c, PolynomialTraits& traits) +void appendCoefficient(String &str, const C &c, PolynomialTraits &traits) { - io::append(str,c); + io::append(str, c); return; } template -void appendExponent(String& str, const E& e, PolynomialTraits& traits) +void appendExponent(String &str, const E &e, PolynomialTraits &traits) /* Appends the exponent e*d+m according to the traits. */ -{ +{ if (!traits.printExponent) return; - io::append(str,traits.exponent); - io::append(str,traits.expPrefix); - io::append(str,static_cast(e)); - io::append(str,traits.expPostfix); + io::append(str, traits.exponent); + io::append(str, traits.expPrefix); + io::append(str, static_cast(e)); + io::append(str, traits.expPostfix); return; } template -void appendHeckeMonomial(String& str, const M& m, const SchubertContext& p, - const Interface& I, HeckeTraits& hTraits, - PolynomialTraits& pTraits, const Length& l) -{ +void appendHeckeMonomial(String &str, const M &m, const SchubertContext &p, + const Interface &I, HeckeTraits &hTraits, + PolynomialTraits &pTraits, const Length &l) { using namespace klsupport; typedef typename M::PolType P; @@ -89,27 +88,26 @@ void appendHeckeMonomial(String& str, const M& m, const SchubertContext& p, if ((l != undef_length) && hTraits.doShift) { // set shift parameters d = 2; - q = lx-l; + q = lx - l; pTraits.indeterminate = pTraits.sqrtIndeterminate; } - io::append(str,hTraits.monomialPrefix); + io::append(str, hTraits.monomialPrefix); if (hTraits.reversePrint) { - appendPolynomial(str,m.pol(),pTraits,d,q); - io::append(str,hTraits.monomialSeparator); - p.append(str,m.x(),I); - } - else { - p.append(str,m.x(),I); - io::append(str,hTraits.monomialSeparator); - appendPolynomial(str,m.pol(),pTraits,d,q); + appendPolynomial(str, m.pol(), pTraits, d, q); + io::append(str, hTraits.monomialSeparator); + p.append(str, m.x(), I); + } else { + p.append(str, m.x(), I); + io::append(str, hTraits.monomialSeparator); + appendPolynomial(str, m.pol(), pTraits, d, q); } - io::append(str,hTraits.monomialPostfix); + io::append(str, hTraits.monomialPostfix); if ((ptype == KLPOL) && (l != undef_length)) - appendMuMark(str,m,p,l,hTraits); + appendMuMark(str, m, p, l, hTraits); pTraits.indeterminate = indeterminate; @@ -117,40 +115,39 @@ void appendHeckeMonomial(String& str, const M& m, const SchubertContext& p, } template -void appendMonomial(String& str, const C& c, const Ulong& e, - PolynomialTraits& traits, const Ulong& d, - const long& m) +void appendMonomial(String &str, const C &c, const Ulong &e, + PolynomialTraits &traits, const Ulong &d, const long &m) /* We append a monomial of the form c.q^{e*d+m}. */ { - long e_s = e*d+m; + long e_s = e * d + m; if (e_s == 0) - appendCoefficient(str,c,traits); + appendCoefficient(str, c, traits); else { if (c == 1) - io::append(str,traits.one); + io::append(str, traits.one); else if (-c == 1) - io::append(str,traits.negOne); + io::append(str, traits.negOne); else { - appendCoefficient(str,c,traits); - io::append(str,traits.product); + appendCoefficient(str, c, traits); + io::append(str, traits.product); } - io::append(str,traits.indeterminate); + io::append(str, traits.indeterminate); if (e_s != 1) { - appendExponent(str,e_s,traits); + appendExponent(str, e_s, traits); } } - + return; } template -void appendMuMark(String& str, const M& m, const SchubertContext& p, - const Length& l, HeckeTraits& traits) +void appendMuMark(String &str, const M &m, const SchubertContext &p, + const Length &l, HeckeTraits &traits) /* Appends a marker if the degree of the polynomial is as big as it can @@ -159,27 +156,27 @@ void appendMuMark(String& str, const M& m, const SchubertContext& p, { Length lx = p.length(m.x()); - - if (static_cast(2*m.pol().deg()) == static_cast(l-lx-1)) - io::append(str,traits.muMark); + + if (static_cast(2 * m.pol().deg()) == static_cast(l - lx - 1)) + io::append(str, traits.muMark); return; } template -void appendPolynomial(String& str, const P& p, PolynomialTraits& traits, - const Ulong& d, const long& m) +void appendPolynomial(String &str, const P &p, PolynomialTraits &traits, + const Ulong &d, const long &m) { if (p.isZero()) { - io::append(str,traits.zeroPol); + io::append(str, traits.zeroPol); return; } if (traits.printModifier) - appendModifier(str,d,m,traits); + appendModifier(str, d, m, traits); - io::append(str,traits.prefix); + io::append(str, traits.prefix); bool firstTerm = true; @@ -190,20 +187,20 @@ void appendPolynomial(String& str, const P& p, PolynomialTraits& traits, firstTerm = false; else { // append separator if (p[j] > 0) - io::append(str,traits.posSeparator); + io::append(str, traits.posSeparator); else - io::append(str,traits.negSeparator); + io::append(str, traits.negSeparator); } - appendMonomial(str,p[j],j,traits,d,m); + appendMonomial(str, p[j], j, traits, d, m); } - io::append(str,traits.postfix); + io::append(str, traits.postfix); return; } template - void makeWGraph(WGraph& X, const List& c, const LFlags& f, KL& kl) +void makeWGraph(WGraph &X, const List &c, const LFlags &f, KL &kl) /* Puts in X the W-graph for the part of the context contained in c. The flags @@ -216,19 +213,19 @@ template for (Ulong j = 0; j < c.size(); ++j) q.add(c[j]); - if (!(f&1)) // left descents - cells::lWGraph(X,q,kl); + if (!(f & 1)) // left descents + cells::lWGraph(X, q, kl); else if (!(f >> kl.rank())) // right descents - cells::rWGraph(X,q,kl); + cells::rWGraph(X, q, kl); else // two-sided descents - cells::lrWGraph(X,q,kl); + cells::lrWGraph(X, q, kl); return; } template -void printAsBasisElt(FILE* file, const H& h, const SchubertContext& p, - Interface& I, OutputTraits& traits) +void printAsBasisElt(FILE *file, const H &h, const SchubertContext &p, + Interface &I, OutputTraits &traits) /* This function prints one element of the k-l basis, according to the @@ -239,26 +236,26 @@ void printAsBasisElt(FILE* file, const H& h, const SchubertContext& p, // sorting of the element typedef typename H::eltType::PolType P; - hecke::NFCompare

nfc(p,I.order()); + hecke::NFCompare

nfc(p, I.order()); // printing of the basis element proper GroupEltInterface GI(I.outInterface()); I.setOut(*traits.addHeckeTraits.eltTraits); - HeckeTraits& hTraits = traits.addHeckeTraits; - PolynomialTraits& pTraits = traits.polTraits; + HeckeTraits &hTraits = traits.addHeckeTraits; + PolynomialTraits &pTraits = traits.polTraits; + + CoxNbr y = h[h.size() - 1].x(); - CoxNbr y = h[h.size()-1].x(); - Permutation a(0); - sortI(h,nfc,a); + sortI(h, nfc, a); - io::print(file,traits.prefix[basisH]); - printHeckeElt(file,h,a,p,I,hTraits,pTraits,p.length(y)); - io::print(file,traits.postfix[basisH]); + io::print(file, traits.prefix[basisH]); + printHeckeElt(file, h, a, p, I, hTraits, pTraits, p.length(y)); + io::print(file, traits.postfix[basisH]); - io::print(file,"\n"); + io::print(file, "\n"); I.setOut(GI); @@ -266,8 +263,8 @@ void printAsBasisElt(FILE* file, const H& h, const SchubertContext& p, } template -void printClosure(FILE* file, const CoxNbr& y, KL& kl, const Interface& I, - OutputTraits& traits) +void printClosure(FILE *file, const CoxNbr &y, KL &kl, const Interface &I, + OutputTraits &traits) /* Assuming that h contains the extremal pairs for a given element y of @@ -277,73 +274,72 @@ void printClosure(FILE* file, const CoxNbr& y, KL& kl, const Interface& I, */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); // print out y and the descent sets if (traits.printEltData) { // print data about y - printEltData(file,y,p,I,traits); - fprintf(file,"\n"); + printEltData(file, y, p, I, traits); + fprintf(file, "\n"); } // print out the coatoms if (traits.printCoatoms) { - printCoatoms(file,y,p,I,traits); - fprintf(file,"\n"); + printCoatoms(file, y, p, I, traits); + fprintf(file, "\n"); } // print out the extremal pairs - io::print(file,traits.closureSeparator1); - printExtremals(file,y,kl,I,traits); + io::print(file, traits.closureSeparator1); + printExtremals(file, y, kl, I, traits); // print out the singular locus kl::HeckeElt h(0); - genericSingularities(h,y,kl); + genericSingularities(h, y, kl); if (h.size() == 0) { // Schubert variety is smooth - io::print(file,traits.closureSeparator2); - io::print(file,traits.emptySingularLocus); - fprintf(file,"\n"); - io::print(file,traits.emptySingularStratification); - fprintf(file,"\n"); - } - else { - io::print(file,traits.closureSeparator3); - printSingularLocus(file,y,kl,I,traits); + io::print(file, traits.closureSeparator2); + io::print(file, traits.emptySingularLocus); + fprintf(file, "\n"); + io::print(file, traits.emptySingularStratification); + fprintf(file, "\n"); + } else { + io::print(file, traits.closureSeparator3); + printSingularLocus(file, y, kl, I, traits); // print out the singular stratification - io::print(file,traits.closureSeparator4); - printSingularStratification(file,y,kl,I,traits); + io::print(file, traits.closureSeparator4); + printSingularStratification(file, y, kl, I, traits); } // print betti numbers - io::print(file,traits.closureSeparator5); - printBetti(file,y,p,traits); + io::print(file, traits.closureSeparator5); + printBetti(file, y, p, traits); // print IH betti numbers - io::print(file,traits.closureSeparator6); - printIHBetti(file,y,kl,traits); + io::print(file, traits.closureSeparator6); + printIHBetti(file, y, kl, traits); return; } template -void printCoefficient(FILE* file, const C& c, PolynomialTraits& traits) +void printCoefficient(FILE *file, const C &c, PolynomialTraits &traits) -{ - fprintf(file,"%ld",static_cast(c)); +{ + fprintf(file, "%ld", static_cast(c)); return; } template - void printDuflo(FILE* file, const List& dl, const Partition& pi, - KL& kl, const Interface& I, OutputTraits& traits) +void printDuflo(FILE *file, const List &dl, const Partition &pi, KL &kl, + const Interface &I, OutputTraits &traits) /* This function prints out the Duflo involutions on the file. The list @@ -353,138 +349,139 @@ template the cells by shortlex ordering of their shortlex-smallest elements. */ -{ - const SchubertContext& p = kl.schubert(); +{ + const SchubertContext &p = kl.schubert(); // print duflo involutions List min(0); - schubert::NFCompare nfc(p,I.order()); - minReps(min,pi,nfc); + schubert::NFCompare nfc(p, I.order()); + minReps(min, pi, nfc); Permutation a(0); - sortI(min,nfc,a); + sortI(min, nfc, a); - int d = digits(dl.size()-1,10); + int d = digits(dl.size() - 1, 10); - io::print(file,traits.prefix[dufloH]); - io::print(file,traits.dufloListPrefix); + io::print(file, traits.prefix[dufloH]); + io::print(file, traits.dufloListPrefix); for (Ulong j = 0; j < dl.size(); ++j) { if (traits.printDufloNumber) { - io::print(file,traits.dufloNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.dufloNumberPostfix); + io::print(file, traits.dufloNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.dufloNumberPostfix); } - const kl::KLPol& pol = kl.klPol(0,dl[a[j]]); - io::print(file,traits.dufloPrefix); - p.print(file,dl[a[j]],I); - io::print(file,traits.dufloSeparator); - printPolynomial(file,pol,traits.polTraits); - io::print(file,traits.dufloPostfix); - if (j+1 < dl.size()) // there is more to come - io::print(file,traits.dufloListSeparator); + const kl::KLPol &pol = kl.klPol(0, dl[a[j]]); + io::print(file, traits.dufloPrefix); + p.print(file, dl[a[j]], I); + io::print(file, traits.dufloSeparator); + printPolynomial(file, pol, traits.polTraits); + io::print(file, traits.dufloPostfix); + if (j + 1 < dl.size()) // there is more to come + io::print(file, traits.dufloListSeparator); } - io::print(file,traits.dufloListPostfix); - io::print(file,traits.postfix[dufloH]); - fprintf(file,"\n"); + io::print(file, traits.dufloListPostfix); + io::print(file, traits.postfix[dufloH]); + fprintf(file, "\n"); return; } template -void printExponent(FILE* file, const E& e, PolynomialTraits& traits) +void printExponent(FILE *file, const E &e, PolynomialTraits &traits) /* Prints the exponent d*e+m to the file. */ -{ +{ if (!traits.printExponent) return; - io::print(file,traits.exponent); - io::print(file,traits.expPrefix); - fprintf(file,"%ld",static_cast(e)); - io::print(file,traits.expPostfix); + io::print(file, traits.exponent); + io::print(file, traits.expPrefix); + fprintf(file, "%ld", static_cast(e)); + io::print(file, traits.expPostfix); return; } template -void printExtremals(FILE* file, const CoxNbr& y, KL& kl, const Interface& I, - OutputTraits& traits) +void printExtremals(FILE *file, const CoxNbr &y, KL &kl, const Interface &I, + OutputTraits &traits) { kl::HeckeElt h(0); - kl.row(h,y); + kl.row(h, y); if (ERRNO) { Error(ERRNO); return; } - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); Length ly = p.length(y); - io::print(file,traits.prefix[extremalsH]); - printHeckeElt(file,h,p,I,traits,ly); - io::print(file,traits.postfix[extremalsH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[extremalsH]); + printHeckeElt(file, h, p, I, traits, ly); + io::print(file, traits.postfix[extremalsH]); + fprintf(file, "\n"); return; } template - void printHeckeElt(FILE* file, const H& h, const SchubertContext& p, - const Interface& I, OutputTraits& traits, const Length& l) +void printHeckeElt(FILE *file, const H &h, const SchubertContext &p, + const Interface &I, OutputTraits &traits, const Length &l) /* Does the printing of the sorted Hecke algebra element. */ -{ +{ typedef typename H::eltType::PolType P; - hecke::NFCompare

nfc(p,I.order()); + hecke::NFCompare

nfc(p, I.order()); Permutation a(0); - sortI(h,nfc,a); + sortI(h, nfc, a); - printHeckeElt(file,h,a,p,I,traits.heckeTraits,traits.polTraits,l); + printHeckeElt(file, h, a, p, I, traits.heckeTraits, traits.polTraits, l); return; } template - void printHeckeElt(FILE* file, const H& h, const Permutation& a, - const SchubertContext& p, const Interface& I, - HeckeTraits& hTraits, - PolynomialTraits& pTraits, const Length& l) +void printHeckeElt(FILE *file, const H &h, const Permutation &a, + const SchubertContext &p, const Interface &I, + HeckeTraits &hTraits, PolynomialTraits &pTraits, + const Length &l) /* Prints out the Hecke algebra element h, permuted according to the permutation a, following the given traits. */ -{ +{ String buf(0); - bool oldTS = setTwoSided(h,a,p,I,hTraits,pTraits,l); + bool oldTS = setTwoSided(h, a, p, I, hTraits, pTraits, l); - io::print(file,hTraits.prefix); + io::print(file, hTraits.prefix); for (Ulong j = 0; j < h.size(); ++j) { - appendHeckeMonomial(buf,h[a[j]],p,I,hTraits,pTraits,l); - if (j < h.size()-1) // there is more to come - appendSeparator(buf,j,hTraits); - pad(buf,j,hTraits); + appendHeckeMonomial(buf, h[a[j]], p, I, hTraits, pTraits, l); + if (j < h.size() - 1) // there is more to come + appendSeparator(buf, j, hTraits); + pad(buf, j, hTraits); if (hTraits.lineSize) - foldLine(file,buf,hTraits.lineSize,hTraits.indent,hTraits.hyphens.ptr()); + foldLine(file, buf, hTraits.lineSize, hTraits.indent, + hTraits.hyphens.ptr()); else - io::print(file,buf); + io::print(file, buf); reset(buf); } - io::print(file,hTraits.postfix); + io::print(file, hTraits.postfix); hTraits.twoSided = oldTS; @@ -492,132 +489,128 @@ template } template - void printIHBetti(FILE* file, const CoxNbr& y, KL& kl, OutputTraits& traits) +void printIHBetti(FILE *file, const CoxNbr &y, KL &kl, OutputTraits &traits) -{ +{ Homology h(0); - ihBetti(h,y,kl); + ihBetti(h, y, kl); - io::print(file,traits.prefix[ihBettiH]); - printHomology(file,h,traits); - io::print(file,traits.postfix[ihBettiH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[ihBettiH]); + printHomology(file, h, traits); + io::print(file, traits.postfix[ihBettiH]); + fprintf(file, "\n"); return; } template -void printLCOrder(FILE* file, KL& kl, const Interface& I, OutputTraits& traits) +void printLCOrder(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) -{ +{ // make graph OrientedGraph X(0); - cells::lGraph(X,kl); + cells::lGraph(X, kl); // printout data - io::print(file,traits.prefix[lCOrderH]); - printCellOrder(file,X,kl.schubert(),I,traits.posetTraits); - io::print(file,traits.postfix[lCOrderH]); - io::print(file,"\n"); + io::print(file, traits.prefix[lCOrderH]); + printCellOrder(file, X, kl.schubert(), I, traits.posetTraits); + io::print(file, traits.postfix[lCOrderH]); + io::print(file, "\n"); return; } template -void printLCells(FILE* file, const Partition& lp, KL& kl, const Interface& I, - OutputTraits& traits) +void printLCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits) { // print out cells - io::print(file,traits.prefix[lCellsH]); - printPartition(file,lp,kl.schubert(),I,traits.partitionTraits); - io::print(file,traits.postfix[lCellsH]); - io::print(file,"\n"); + io::print(file, traits.prefix[lCellsH]); + printPartition(file, lp, kl.schubert(), I, traits.partitionTraits); + io::print(file, traits.postfix[lCellsH]); + io::print(file, "\n"); return; - } template -void printLCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits) +void printLCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits) -{ +{ // set flag parameter - LFlags f = leqmask[kl.rank()-1] << kl.rank(); + LFlags f = leqmask[kl.rank() - 1] << kl.rank(); // print W-graphs - io::print(file,traits.prefix[lCellWGraphsH]); - printWGraphList(file,lp,f,kl,I,traits); - io::print(file,traits.postfix[lCellWGraphsH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[lCellWGraphsH]); + printWGraphList(file, lp, f, kl, I, traits); + io::print(file, traits.postfix[lCellWGraphsH]); + fprintf(file, "\n"); return; } template -void printLRCOrder(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits) +void printLRCOrder(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) -{ +{ // make graph OrientedGraph X(0); - cells::lrGraph(X,kl); + cells::lrGraph(X, kl); // printout data - io::print(file,traits.prefix[lrCOrderH]); - printCellOrder(file,X,kl.schubert(),I,traits.posetTraits); - io::print(file,traits.postfix[lrCOrderH]); - io::print(file,"\n"); + io::print(file, traits.prefix[lrCOrderH]); + printCellOrder(file, X, kl.schubert(), I, traits.posetTraits); + io::print(file, traits.postfix[lrCOrderH]); + io::print(file, "\n"); return; } template -void printLRCells(FILE* file, const Partition& lp, KL& kl, const Interface& I, - OutputTraits& traits) +void printLRCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits) { // print out cells - io::print(file,traits.prefix[lrCellsH]); - printPartition(file,lp,kl.schubert(),I,traits.partitionTraits); - io::print(file,traits.postfix[lrCellsH]); - io::print(file,"\n"); + io::print(file, traits.prefix[lrCellsH]); + printPartition(file, lp, kl.schubert(), I, traits.partitionTraits); + io::print(file, traits.postfix[lrCellsH]); + io::print(file, "\n"); return; - } template -void printLRCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits) +void printLRCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits) -{ +{ // set flag parameter - LFlags f = leqmask[2*kl.rank()-1]; + LFlags f = leqmask[2 * kl.rank() - 1]; // print graphs - io::print(file,traits.prefix[lrCellWGraphsH]); - printWGraphList(file,lp,f,kl,I,traits); - io::print(file,traits.postfix[lrCellWGraphsH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[lrCellWGraphsH]); + printWGraphList(file, lp, f, kl, I, traits); + io::print(file, traits.postfix[lrCellWGraphsH]); + fprintf(file, "\n"); return; } template - void printLRWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits) +void printLRWGraph(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) /* This function prints out the W-graph data for the full context; the @@ -625,48 +618,47 @@ template current context, but it is guaranteed to contain all those edges. */ -{ +{ // print element list - int d = digits(kl.size()-1,10); + int d = digits(kl.size() - 1, 10); - io::print(file,traits.eltList); - io::print(file,traits.eltListPrefix); + io::print(file, traits.eltList); + io::print(file, traits.eltListPrefix); for (Ulong j = 0; j < kl.size(); ++j) { if (traits.printEltNumber) { - io::print(file,traits.eltNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.eltNumberPostfix); + io::print(file, traits.eltNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.eltNumberPostfix); } - kl.schubert().print(file,j,I); - if (j+1 < kl.size()) // there is more to come - io::print(file,traits.eltListSeparator); + kl.schubert().print(file, j, I); + if (j + 1 < kl.size()) // there is more to come + io::print(file, traits.eltListSeparator); } - io::print(file,traits.eltListPostfix); - io::print(file,traits.closeString); - fprintf(file,"\n"); + io::print(file, traits.eltListPostfix); + io::print(file, traits.closeString); + fprintf(file, "\n"); // print graph - io::print(file,traits.prefix[lrWGraphH]); + io::print(file, traits.prefix[lrWGraphH]); WGraph X(0); - cells::lrWGraph(X,kl); - LFlags f = leqmask[2*kl.rank()-1]; - printWGraph(file,X,f,I,traits.wgraphTraits); + cells::lrWGraph(X, kl); + LFlags f = leqmask[2 * kl.rank() - 1]; + printWGraph(file, X, f, I, traits.wgraphTraits); - io::print(file,traits.postfix[lrWGraphH]); + io::print(file, traits.postfix[lrWGraphH]); - fprintf(file,"\n"); + fprintf(file, "\n"); return; } template - void printLWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits) +void printLWGraph(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) /* This function prints out the W-graph data for the full context; the @@ -674,49 +666,48 @@ template current context, but it is guaranteed to contain all those edges. */ -{ +{ // print element list - int d = digits(kl.size()-1,10); + int d = digits(kl.size() - 1, 10); - io::print(file,traits.eltList); - io::print(file,traits.eltListPrefix); + io::print(file, traits.eltList); + io::print(file, traits.eltListPrefix); for (Ulong j = 0; j < kl.size(); ++j) { if (traits.printEltNumber) { - io::print(file,traits.eltNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.eltNumberPostfix); + io::print(file, traits.eltNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.eltNumberPostfix); } - kl.schubert().print(file,j,I); - if (j+1 < kl.size()) // there is more to come - io::print(file,traits.eltListSeparator); + kl.schubert().print(file, j, I); + if (j + 1 < kl.size()) // there is more to come + io::print(file, traits.eltListSeparator); } - io::print(file,traits.eltListPostfix); - io::print(file,traits.closeString); - fprintf(file,"\n"); + io::print(file, traits.eltListPostfix); + io::print(file, traits.closeString); + fprintf(file, "\n"); // print graph - io::print(file,traits.prefix[lWGraphH]); + io::print(file, traits.prefix[lWGraphH]); WGraph X(0); - cells::lWGraph(X,kl); - LFlags f = leqmask[kl.rank()-1] << kl.rank(); - printWGraph(file,X,f,I,traits.wgraphTraits); + cells::lWGraph(X, kl); + LFlags f = leqmask[kl.rank() - 1] << kl.rank(); + printWGraph(file, X, f, I, traits.wgraphTraits); - io::print(file,traits.postfix[lWGraphH]); + io::print(file, traits.postfix[lWGraphH]); - fprintf(file,"\n"); + fprintf(file, "\n"); return; } template -void printMonomial(FILE* file, const C& c, const Ulong& e, - PolynomialTraits& traits, const Ulong& d, - const long& m) +void printMonomial(FILE *file, const C &c, const Ulong &e, + PolynomialTraits &traits, const Ulong &d, const long &m) /* We print a monomial of the form c.q^e, where it is guaranteed that c is @@ -724,31 +715,31 @@ void printMonomial(FILE* file, const C& c, const Ulong& e, should probably also be a parameter. */ { - long e_s = e*d+m; + long e_s = e * d + m; if (e_s == 0) - printCoefficient(file,c,traits); + printCoefficient(file, c, traits); else { if (c == 1) - io::print(file,traits.one); + io::print(file, traits.one); else if (-c == 1) - io::print(file,traits.negOne); + io::print(file, traits.negOne); else { - printCoefficient(file,c,traits); - io::print(file,traits.product); + printCoefficient(file, c, traits); + io::print(file, traits.product); } - io::print(file,traits.indeterminate); + io::print(file, traits.indeterminate); if (e_s != 1) { - printExponent(file,e_s,traits); + printExponent(file, e_s, traits); } } - + return; } template -void printMuMark(FILE* file, const M& m, const SchubertContext& p, - const Length& l, HeckeTraits& traits) +void printMuMark(FILE *file, const M &m, const SchubertContext &p, + const Length &l, HeckeTraits &traits) /* Prints a marker if the degree of the polynomial is as big as it can @@ -757,27 +748,27 @@ void printMuMark(FILE* file, const M& m, const SchubertContext& p, { Length lx = p.length(m.x()); - - if (static_cast(2*m.pol().deg()) == static_cast(l-lx-1)) - io::print(file,traits.muMark); + + if (static_cast(2 * m.pol().deg()) == static_cast(l - lx - 1)) + io::print(file, traits.muMark); return; } template -void printPolynomial(FILE* file, const P& p, PolynomialTraits& traits, - const Ulong& d, const long& m) +void printPolynomial(FILE *file, const P &p, PolynomialTraits &traits, + const Ulong &d, const long &m) { if (p.isZero()) { - io::print(file,traits.zeroPol); + io::print(file, traits.zeroPol); return; } if (traits.printModifier) - printModifier(file,d,m,traits); + printModifier(file, d, m, traits); - io::print(file,traits.prefix); + io::print(file, traits.prefix); bool firstTerm = true; @@ -788,71 +779,69 @@ void printPolynomial(FILE* file, const P& p, PolynomialTraits& traits, firstTerm = false; else { // print separator if (p[j] > 0) - io::print(file,traits.posSeparator); + io::print(file, traits.posSeparator); else - io::print(file,traits.negSeparator); + io::print(file, traits.negSeparator); } - printMonomial(file,p[j],j,traits,d,m); + printMonomial(file, p[j], j, traits, d, m); } - io::print(file,traits.postfix); + io::print(file, traits.postfix); return; } template -void printRCOrder(FILE* file, KL& kl, const Interface& I, OutputTraits& traits) +void printRCOrder(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) -{ +{ // make graph OrientedGraph X(0); - cells::rGraph(X,kl); + cells::rGraph(X, kl); // printout data - io::print(file,traits.prefix[rCOrderH]); - printCellOrder(file,X,kl.schubert(),I,traits.posetTraits); - io::print(file,traits.postfix[rCOrderH]); - io::print(file,"\n"); + io::print(file, traits.prefix[rCOrderH]); + printCellOrder(file, X, kl.schubert(), I, traits.posetTraits); + io::print(file, traits.postfix[rCOrderH]); + io::print(file, "\n"); return; } template -void printRCells(FILE* file, const Partition& lp, KL& kl, const Interface& I, - OutputTraits& traits) +void printRCells(FILE *file, const Partition &lp, KL &kl, const Interface &I, + OutputTraits &traits) { // print out cells - io::print(file,traits.prefix[rCellsH]); - printPartition(file,lp,kl.schubert(),I,traits.partitionTraits); - io::print(file,traits.postfix[rCellsH]); - io::print(file,"\n"); + io::print(file, traits.prefix[rCellsH]); + printPartition(file, lp, kl.schubert(), I, traits.partitionTraits); + io::print(file, traits.postfix[rCellsH]); + io::print(file, "\n"); return; - } template -void printRCellWGraphs(FILE* file, const Partition& lp, KL& kl, - const Interface& I, OutputTraits& traits) +void printRCellWGraphs(FILE *file, const Partition &lp, KL &kl, + const Interface &I, OutputTraits &traits) -{ - LFlags f = leqmask[kl.rank()-1]; +{ + LFlags f = leqmask[kl.rank() - 1]; - io::print(file,traits.prefix[rCellWGraphsH]); - printWGraphList(file,lp,f,kl,I,traits); - io::print(file,traits.postfix[rCellWGraphsH]); - fprintf(file,"\n"); + io::print(file, traits.prefix[rCellWGraphsH]); + printWGraphList(file, lp, f, kl, I, traits); + io::print(file, traits.postfix[rCellWGraphsH]); + fprintf(file, "\n"); return; } template - void printRWGraph(FILE* file, KL& kl, const Interface& I, - OutputTraits& traits) +void printRWGraph(FILE *file, KL &kl, const Interface &I, OutputTraits &traits) /* This function prints out the W-graph data for the full context; the @@ -860,120 +849,120 @@ template current context, but it is guaranteed to contain all those edges. */ -{ +{ // print element list - int d = digits(kl.size()-1,10); + int d = digits(kl.size() - 1, 10); - io::print(file,traits.eltList); - io::print(file,traits.eltListPrefix); + io::print(file, traits.eltList); + io::print(file, traits.eltListPrefix); for (Ulong j = 0; j < kl.size(); ++j) { if (traits.printEltNumber) { - io::print(file,traits.eltNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.eltNumberPostfix); + io::print(file, traits.eltNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.eltNumberPostfix); } - kl.schubert().print(file,j,I); - if (j+1 < kl.size()) // there is more to come - io::print(file,traits.eltListSeparator); + kl.schubert().print(file, j, I); + if (j + 1 < kl.size()) // there is more to come + io::print(file, traits.eltListSeparator); } - io::print(file,traits.eltListPostfix); - io::print(file,traits.closeString); - fprintf(file,"\n"); + io::print(file, traits.eltListPostfix); + io::print(file, traits.closeString); + fprintf(file, "\n"); // print graph - io::print(file,traits.prefix[rWGraphH]); + io::print(file, traits.prefix[rWGraphH]); WGraph X(0); - cells::rWGraph(X,kl); - LFlags f = leqmask[kl.rank()-1]; - printWGraph(file,X,f,I,traits.wgraphTraits); + cells::rWGraph(X, kl); + LFlags f = leqmask[kl.rank() - 1]; + printWGraph(file, X, f, I, traits.wgraphTraits); - io::print(file,traits.postfix[rWGraphH]); + io::print(file, traits.postfix[rWGraphH]); - fprintf(file,"\n"); + fprintf(file, "\n"); return; } template - void printSingularLocus(FILE* file, const CoxNbr& y, KL& kl, - const Interface& I, OutputTraits& traits) +void printSingularLocus(FILE *file, const CoxNbr &y, KL &kl, const Interface &I, + OutputTraits &traits) -{ - const SchubertContext& p = kl.schubert(); +{ + const SchubertContext &p = kl.schubert(); kl::HeckeElt hs(0); - genericSingularities(hs,y,kl); + genericSingularities(hs, y, kl); if (hs.size() == 0) { // singular locus is empty - io::print(file,traits.emptySingularLocus); - fprintf(file,"\n"); + io::print(file, traits.emptySingularLocus); + fprintf(file, "\n"); return; } Length ly = p.length(y); - - io::print(file,traits.prefix[slocusH]); - printHeckeElt(file,hs,p,I,traits,ly); - io::print(file,traits.postfix[slocusH]); - fprintf(file,"\n"); + + io::print(file, traits.prefix[slocusH]); + printHeckeElt(file, hs, p, I, traits, ly); + io::print(file, traits.postfix[slocusH]); + fprintf(file, "\n"); if (traits.printCompCount) { - io::print(file,traits.compCountPrefix); - fprintf(file,"%lu",hs.size()); - io::print(file,traits.compCountPostfix); - io::print(file,traits.closeString); - fprintf(file,"\n"); + io::print(file, traits.compCountPrefix); + fprintf(file, "%lu", hs.size()); + io::print(file, traits.compCountPostfix); + io::print(file, traits.closeString); + fprintf(file, "\n"); } - + return; } template - void printSingularStratification(FILE* file, const CoxNbr& y, KL& kl, - const Interface& I, OutputTraits& traits) +void printSingularStratification(FILE *file, const CoxNbr &y, KL &kl, + const Interface &I, OutputTraits &traits) -{ - const SchubertContext& p = kl.schubert(); +{ + const SchubertContext &p = kl.schubert(); kl::HeckeElt h(0); - kl.row(h,y); + kl.row(h, y); if (ERRNO) { Error(ERRNO); return; } kl::HeckeElt hs(0); - hecke::singularStratification(hs,h,p); + hecke::singularStratification(hs, h, p); if (hs.size() == 0) { // singular locus is empty - io::print(file,traits.emptySingularStratification); - fprintf(file,"\n"); + io::print(file, traits.emptySingularStratification); + fprintf(file, "\n"); return; } Length ly = p.length(y); - - io::print(file,traits.prefix[sstratificationH]); - printHeckeElt(file,hs,p,I,traits,ly); - io::print(file,traits.postfix[sstratificationH]); - fprintf(file,"\n"); + + io::print(file, traits.prefix[sstratificationH]); + printHeckeElt(file, hs, p, I, traits, ly); + io::print(file, traits.postfix[sstratificationH]); + fprintf(file, "\n"); if (traits.printCompCount) { - io::print(file,traits.compCountPrefix); - fprintf(file,"%lu",hs.size()); - io::print(file,traits.compCountPostfix); - io::print(file,traits.closeString); - fprintf(file,"\n"); + io::print(file, traits.compCountPrefix); + fprintf(file, "%lu", hs.size()); + io::print(file, traits.compCountPostfix); + io::print(file, traits.closeString); + fprintf(file, "\n"); } - + return; } template -void printWGraphList(FILE* file, const Partition& pi, const LFlags& f, KL& kl, - const Interface& I, OutputTraits& traits) +void printWGraphList(FILE *file, const Partition &pi, const LFlags &f, KL &kl, + const Interface &I, OutputTraits &traits) /* This function prints out the W-graphs of the classes of the partition pi. @@ -985,44 +974,44 @@ void printWGraphList(FILE* file, const Partition& pi, const LFlags& f, KL& kl, printPartition. */ -{ - const SchubertContext& p = kl.schubert(); +{ + const SchubertContext &p = kl.schubert(); // write out cells - List > lc(0); - writeClasses(lc,pi); + List> lc(0); + writeClasses(lc, pi); // sort cells - schubert::NFCompare nfc(p,I.order()); + schubert::NFCompare nfc(p, I.order()); Permutation a(0); - sortLists(lc,nfc,a); + sortLists(lc, nfc, a); - int d = digits(lc.size()-1,10); - WgraphTraits& wTraits = traits.wgraphTraits; + int d = digits(lc.size() - 1, 10); + WgraphTraits &wTraits = traits.wgraphTraits; Ulong oldPadSize = wTraits.padSize; - wTraits.padSize = d + traits.cellNumberPrefix.length() + - traits.cellNumberPostfix.length(); + wTraits.padSize = + d + traits.cellNumberPrefix.length() + traits.cellNumberPostfix.length(); // print out graphs - io::print(file,traits.graphListPrefix); + io::print(file, traits.graphListPrefix); for (Ulong j = 0; j < lc.size(); ++j) { if (traits.printCellNumber) { - io::print(file,traits.cellNumberPrefix); - fprintf(file,"%*lu",d,j); - io::print(file,traits.cellNumberPostfix); + io::print(file, traits.cellNumberPrefix); + fprintf(file, "%*lu", d, j); + io::print(file, traits.cellNumberPostfix); } WGraph X(0); - makeWGraph(X,lc[a[j]],f,kl); - printWGraph(file,X,f,I,wTraits); - if (j+1 < lc.size()) - io::print(file,traits.graphListSeparator); + makeWGraph(X, lc[a[j]], f, kl); + printWGraph(file, X, f, I, wTraits); + if (j + 1 < lc.size()) + io::print(file, traits.graphListSeparator); } - io::print(file,traits.graphListPostfix); + io::print(file, traits.graphListPostfix); wTraits.padSize = oldPadSize; @@ -1030,9 +1019,9 @@ void printWGraphList(FILE* file, const Partition& pi, const LFlags& f, KL& kl, } template -bool setTwoSided(const H& h, const Permutation& a, const SchubertContext& p, - const Interface& I, HeckeTraits& hTraits, - PolynomialTraits& pTraits, const Length& l) +bool setTwoSided(const H &h, const Permutation &a, const SchubertContext &p, + const Interface &I, HeckeTraits &hTraits, + PolynomialTraits &pTraits, const Length &l) /* This function decides between one- and two-sided output. Currently it is @@ -1056,19 +1045,19 @@ bool setTwoSided(const H& h, const Permutation& a, const SchubertContext& p, String buf(0); for (Ulong j = 0; j < h.size(); ++j) { - appendHeckeMonomial(buf,h[a[j]],p,I,hTraits,pTraits,l); - if (j < h.size()-1) // there is more to come - appendSeparator(buf,j,hTraits); - if (j%2 && hTraits.oddWidth) { // look at odd side + appendHeckeMonomial(buf, h[a[j]], p, I, hTraits, pTraits, l); + if (j < h.size() - 1) // there is more to come + appendSeparator(buf, j, hTraits); + if (j % 2 && hTraits.oddWidth) { // look at odd side if (buf.length() >= hTraits.oddWidth) { // not fit or fit tight - hTraits.twoSided = false; - break; + hTraits.twoSided = false; + break; } } - if (!(j%2) && hTraits.evenWidth) { // look at even side + if (!(j % 2) && hTraits.evenWidth) { // look at even side if (buf.length() >= hTraits.evenWidth) { // not fit or fit tight - hTraits.twoSided = false; - break; + hTraits.twoSided = false; + break; } } reset(buf); @@ -1077,4 +1066,4 @@ bool setTwoSided(const H& h, const Permutation& a, const SchubertContext& p, return true; } -}; +}; // namespace files diff --git a/general.cpp b/general.cpp index eade182..1ea4493 100644 --- a/general.cpp +++ b/general.cpp @@ -1,6 +1,6 @@ /* This is general.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -23,8 +23,8 @@ namespace general { -GeneralCoxGroup::GeneralCoxGroup(const Type& x, const Rank& l) - :CoxGroup(x,l) +GeneralCoxGroup::GeneralCoxGroup(const Type &x, const Rank &l) + : CoxGroup(x, l) /* Initializes a GeneralCoxGroup structure of the given type and rank. @@ -44,8 +44,8 @@ GeneralCoxGroup::~GeneralCoxGroup() {} -BigRankCoxGroup::BigRankCoxGroup(const Type& x, const Rank& l) - :GeneralCoxGroup(x,l) +BigRankCoxGroup::BigRankCoxGroup(const Type &x, const Rank &l) + : GeneralCoxGroup(x, l) /* Initializes a GeneralCoxGroup structure of the given type and rank. @@ -63,8 +63,8 @@ BigRankCoxGroup::~BigRankCoxGroup() {} -GeneralBRCoxGroup::GeneralBRCoxGroup(const Type& x, const Rank& l) - :BigRankCoxGroup(x,l) +GeneralBRCoxGroup::GeneralBRCoxGroup(const Type &x, const Rank &l) + : BigRankCoxGroup(x, l) {} @@ -77,15 +77,15 @@ GeneralBRCoxGroup::~GeneralBRCoxGroup() {} -MedRankCoxGroup::MedRankCoxGroup(const Type& x, const Rank& l) - :GeneralCoxGroup(x,l) +MedRankCoxGroup::MedRankCoxGroup(const Type &x, const Rank &l) + : GeneralCoxGroup(x, l) /* Initializes a GeneralCoxGroup structure of the given type and rank. Used when SMALLRANK_MAX < rank <= MEDRANK_MAX. */ -{ +{ if (ERRNO) return; @@ -105,8 +105,8 @@ MedRankCoxGroup::~MedRankCoxGroup() {} -GeneralMRCoxGroup::GeneralMRCoxGroup(const Type& x, const Rank& l) - :MedRankCoxGroup(x,l) +GeneralMRCoxGroup::GeneralMRCoxGroup(const Type &x, const Rank &l) + : MedRankCoxGroup(x, l) {} @@ -119,8 +119,8 @@ GeneralMRCoxGroup::~GeneralMRCoxGroup() {} -SmallRankCoxGroup::SmallRankCoxGroup(const Type& x, const Rank& l) - :MedRankCoxGroup(x,l) +SmallRankCoxGroup::SmallRankCoxGroup(const Type &x, const Rank &l) + : MedRankCoxGroup(x, l) /* Initializes a GeneralCoxGroup structure of the given type and rank. @@ -141,8 +141,8 @@ SmallRankCoxGroup::~SmallRankCoxGroup() {} -GeneralSRCoxGroup::GeneralSRCoxGroup(const Type& x, const Rank& l) - :SmallRankCoxGroup(x,l) +GeneralSRCoxGroup::GeneralSRCoxGroup(const Type &x, const Rank &l) + : SmallRankCoxGroup(x, l) {} @@ -155,4 +155,4 @@ GeneralSRCoxGroup::~GeneralSRCoxGroup() {} -}; +}; // namespace general diff --git a/general.h b/general.h index 5be995d..b77a274 100644 --- a/general.h +++ b/general.h @@ -5,104 +5,111 @@ See file main.cpp for full copyright notice */ -#ifndef GENERAL_H /* guard against multiple inclusions */ +#ifndef GENERAL_H /* guard against multiple inclusions */ #define GENERAL_H #include "globals.h" #include "coxgroup.h" namespace general { - using namespace coxeter; +using namespace coxeter; /******** type declarations **************************************************/ - class GeneralCoxGroup; - class BigRankCoxGroup; - class GeneralBRCoxGroup; - class MedRankCoxGroup; - class GeneralMRCoxGroup; - class SmallRankCoxGroup; - class GeneralSRCoxGroup; +class GeneralCoxGroup; +class BigRankCoxGroup; +class GeneralBRCoxGroup; +class MedRankCoxGroup; +class GeneralMRCoxGroup; +class SmallRankCoxGroup; +class GeneralSRCoxGroup; /********* type definitions **************************************************/ class GeneralCoxGroup : public CoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralCoxGroup));} - - GeneralCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralCoxGroup)); + } + + GeneralCoxGroup(const Type &x, const Rank &l); virtual ~GeneralCoxGroup(); -/* accessors */ - virtual CoxSize order() const; /* inlined */ + /* accessors */ + virtual CoxSize order() const; /* inlined */ }; class BigRankCoxGroup : public GeneralCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(BigRankCoxGroup));} - BigRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(BigRankCoxGroup)); + } + BigRankCoxGroup(const Type &x, const Rank &l); virtual ~BigRankCoxGroup(); }; - class GeneralBRCoxGroup:public BigRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralBRCoxGroup));} - GeneralBRCoxGroup(const Type& x, const Rank& l); +class GeneralBRCoxGroup : public BigRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralBRCoxGroup)); + } + GeneralBRCoxGroup(const Type &x, const Rank &l); ~GeneralBRCoxGroup(); }; class MedRankCoxGroup : public GeneralCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(MedRankCoxGroup));} - MedRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(MedRankCoxGroup)); + } + MedRankCoxGroup(const Type &x, const Rank &l); virtual ~MedRankCoxGroup(); }; - class GeneralMRCoxGroup:public MedRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralMRCoxGroup));} - GeneralMRCoxGroup(const Type& x, const Rank& l); +class GeneralMRCoxGroup : public MedRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralMRCoxGroup)); + } + GeneralMRCoxGroup(const Type &x, const Rank &l); ~GeneralMRCoxGroup(); }; class SmallRankCoxGroup : public MedRankCoxGroup { - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(SmallRankCoxGroup));} - SmallRankCoxGroup(const Type& x, const Rank& l); +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(SmallRankCoxGroup)); + } + SmallRankCoxGroup(const Type &x, const Rank &l); virtual ~SmallRankCoxGroup(); }; - class GeneralSRCoxGroup:public SmallRankCoxGroup { /* leaf class */ - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralSRCoxGroup));} - GeneralSRCoxGroup(const Type& x, const Rank& l); +class GeneralSRCoxGroup : public SmallRankCoxGroup { /* leaf class */ +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralSRCoxGroup)); + } + GeneralSRCoxGroup(const Type &x, const Rank &l); ~GeneralSRCoxGroup(); }; /******** inline definitions *************************************************/ -inline CoxSize GeneralCoxGroup::order() const {return undef_coxsize;} +inline CoxSize GeneralCoxGroup::order() const { return undef_coxsize; } -} +} // namespace general #endif diff --git a/globals.h b/globals.h index 9ca089e..972331e 100644 --- a/globals.h +++ b/globals.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef GLOBALS_H /* guard against multiple inclusions */ +#ifndef GLOBALS_H /* guard against multiple inclusions */ #define GLOBALS_H // TODO: Check to make sure we need these @@ -16,7 +16,7 @@ #include namespace coxeter { - typedef unsigned long Ulong; /* shorthand */ +typedef unsigned long Ulong; /* shorthand */ }; #endif diff --git a/graph.cpp b/graph.cpp index 7e538f6..bbb72dc 100644 --- a/graph.cpp +++ b/graph.cpp @@ -11,41 +11,41 @@ #include "interactive.h" namespace { - using namespace graph; - - CoxSize dihedralOrder(CoxGraph& G, LFlags I); - ParSize extrQuotOrder(CoxGraph& G, LFlags I, Generator s); - void fillCoxAMatrix(CoxMatrix& m, Rank l); - void fillCoxBMatrix(CoxMatrix& m, Rank l); - void fillCoxDMatrix(CoxMatrix& m, Rank l); - void fillCoxEMatrix(CoxMatrix& m, Rank l); - void fillCoxFMatrix(CoxMatrix& m, Rank l); - void fillCoxGMatrix(CoxMatrix& m); - void fillCoxHMatrix(CoxMatrix& m, Rank l); - void fillCoxIMatrix(CoxMatrix& m); - void fillCoxaMatrix(CoxMatrix& m, Rank l); - void fillCoxbMatrix(CoxMatrix& m, Rank l); - void fillCoxcMatrix(CoxMatrix& m, Rank l); - void fillCoxdMatrix(CoxMatrix& m, Rank l); - void fillCoxeMatrix(CoxMatrix& m, Rank l); - void fillCoxfMatrix(CoxMatrix& m, Rank l); - void fillCoxgMatrix(CoxMatrix& m); - void fillCoxXMatrix(CoxMatrix& m, const Rank& l, const Type& t); - void fillCoxYMatrix(CoxMatrix& m, Rank l); - CoxSize finiteOrder(const Type& type, const Rank& rank); - Ulong gcd(Ulong a, Ulong b); - const Type& irrType(CoxGraph& G, LFlags I); - Generator lastGenerator(CoxGraph& G, LFlags I); - ParSize lastQuotOrder(const Type& type, Rank rank); - void makeCoxMatrix(CoxMatrix& m, const Type& x, const Rank& l); - void makeStar(List&star, const CoxMatrix& m, const Rank& l); - void makeStarOps(List&, const CoxMatrix& m, const Rank& l); - CoxEntry maxCoefficient(CoxGraph& G, LFlags I); - CoxEntry minCoefficient(CoxGraph& G, LFlags I); - CoxSize A_order(Rank rank); - CoxSize B_order(Rank rank); - CoxSize D_order(Rank rank); -}; +using namespace graph; + +CoxSize dihedralOrder(CoxGraph &G, LFlags I); +ParSize extrQuotOrder(CoxGraph &G, LFlags I, Generator s); +void fillCoxAMatrix(CoxMatrix &m, Rank l); +void fillCoxBMatrix(CoxMatrix &m, Rank l); +void fillCoxDMatrix(CoxMatrix &m, Rank l); +void fillCoxEMatrix(CoxMatrix &m, Rank l); +void fillCoxFMatrix(CoxMatrix &m, Rank l); +void fillCoxGMatrix(CoxMatrix &m); +void fillCoxHMatrix(CoxMatrix &m, Rank l); +void fillCoxIMatrix(CoxMatrix &m); +void fillCoxaMatrix(CoxMatrix &m, Rank l); +void fillCoxbMatrix(CoxMatrix &m, Rank l); +void fillCoxcMatrix(CoxMatrix &m, Rank l); +void fillCoxdMatrix(CoxMatrix &m, Rank l); +void fillCoxeMatrix(CoxMatrix &m, Rank l); +void fillCoxfMatrix(CoxMatrix &m, Rank l); +void fillCoxgMatrix(CoxMatrix &m); +void fillCoxXMatrix(CoxMatrix &m, const Rank &l, const Type &t); +void fillCoxYMatrix(CoxMatrix &m, Rank l); +CoxSize finiteOrder(const Type &type, const Rank &rank); +Ulong gcd(Ulong a, Ulong b); +const Type &irrType(CoxGraph &G, LFlags I); +Generator lastGenerator(CoxGraph &G, LFlags I); +ParSize lastQuotOrder(const Type &type, Rank rank); +void makeCoxMatrix(CoxMatrix &m, const Type &x, const Rank &l); +void makeStar(List &star, const CoxMatrix &m, const Rank &l); +void makeStarOps(List &, const CoxMatrix &m, const Rank &l); +CoxEntry maxCoefficient(CoxGraph &G, LFlags I); +CoxEntry minCoefficient(CoxGraph &G, LFlags I); +CoxSize A_order(Rank rank); +CoxSize B_order(Rank rank); +CoxSize D_order(Rank rank); +}; // namespace /**************************************************************************** @@ -67,29 +67,28 @@ namespace { namespace graph { -CoxGraph::CoxGraph(const Type& x, const Rank& l) - :d_type(x),d_rank(l),d_matrix(0),d_star(0) +CoxGraph::CoxGraph(const Type &x, const Rank &l) + : d_type(x), d_rank(l), d_matrix(0), d_star(0) /* Initializes a Coxeter graph of type x and rank l. */ { - makeCoxMatrix(d_matrix,x,d_rank); + makeCoxMatrix(d_matrix, x, d_rank); if (ERRNO) return; /* the restriction on the rank should be removed eventually */ - if (l <= MEDRANK_MAX) - { - d_S = (LFlags)1 << d_rank-1; - d_S += d_S - 1; - makeStar(d_star,d_matrix,d_rank); - } + if (l <= MEDRANK_MAX) { + d_S = (LFlags)1 << d_rank - 1; + d_S += d_S - 1; + makeStar(d_star, d_matrix, d_rank); + } - makeStarOps(d_starOps,d_matrix,l); + makeStarOps(d_starOps, d_matrix, l); return; } @@ -112,18 +111,17 @@ LFlags CoxGraph::component(LFlags I, Generator s) const LFlags nf = lmask[s]; LFlags f = 0; - while (nf) /* there are new elements to be considered */ - { - f |= nf; - for (LFlags f1 = nf; f1; f1 &= f1-1) - nf |= (I & d_star[firstBit(f1)]); - nf &= ~f; - } + while (nf) /* there are new elements to be considered */ + { + f |= nf; + for (LFlags f1 = nf; f1; f1 &= f1 - 1) + nf |= (I & d_star[firstBit(f1)]); + nf &= ~f; + } return f; } - LFlags CoxGraph::extremities(LFlags I) const /* @@ -135,18 +133,16 @@ LFlags CoxGraph::extremities(LFlags I) const LFlags f = 0; LFlags f1 = I; - while (f1) - { - Generator s = firstBit(f1); - if (bitCount(d_star[s]&I) == 1) /* s is an extremity */ - f |= lmask[s]; - f1 &= f1-1; - } + while (f1) { + Generator s = firstBit(f1); + if (bitCount(d_star[s] & I) == 1) /* s is an extremity */ + f |= lmask[s]; + f1 &= f1 - 1; + } return f; } - LFlags CoxGraph::nodes(LFlags I) const /* @@ -155,25 +151,23 @@ LFlags CoxGraph::nodes(LFlags I) const */ { - LFlags f,f1; + LFlags f, f1; Generator s; f = 0; f1 = I; - while (f1) - { - s = firstBit(f1); - if (bitCount(d_star[s]&I) > 2) /* s is a node */ - f |= lmask[s]; - f1 &= f1-1; - } + while (f1) { + s = firstBit(f1); + if (bitCount(d_star[s] & I) > 2) /* s is a node */ + f |= lmask[s]; + f1 &= f1 - 1; + } return f; } -}; - +}; // namespace graph /**************************************************************************** @@ -219,39 +213,37 @@ LFlags CoxGraph::nodes(LFlags I) const - makeCoxMatrix(m,x,l) : allocates and fills the Coxeter matrix; - makeStar(star,m,l) : allocates and fills the star array; - makeStarOps(ops,m,l) : allocates and fills the starOps array; - + ****************************************************************************/ namespace { -void fillCoxAMatrix(CoxMatrix& m, Rank l) +void fillCoxAMatrix(CoxMatrix &m, Rank l) { - for (Rank j = 1; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 1; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } return; } -void fillCoxBMatrix(CoxMatrix& m, Rank l) +void fillCoxBMatrix(CoxMatrix &m, Rank l) { m[1] = 4; m[l] = 4; - for (Rank j = 2; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 2; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } return; } -void fillCoxDMatrix(CoxMatrix& m, Rank l) +void fillCoxDMatrix(CoxMatrix &m, Rank l) { if (l == 2) @@ -259,58 +251,54 @@ void fillCoxDMatrix(CoxMatrix& m, Rank l) m[2] = 3; m[l + 2] = 3; - m[2*l] = 3; - m[2*l + 1] = 3; + m[2 * l] = 3; + m[2 * l + 1] = 3; - for (Rank j = 3; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 3; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } return; } -void fillCoxEMatrix(CoxMatrix& m, Rank l) +void fillCoxEMatrix(CoxMatrix &m, Rank l) { m[2] = 3; - m[2*l] = 3; + m[2 * l] = 3; if (l == 3) return; m[l + 3] = 3; - m[2*l + 3] = 3; - m[3*l + 1] = 3; - m[3*l + 2] = 3; + m[2 * l + 3] = 3; + m[3 * l + 1] = 3; + m[3 * l + 2] = 3; - for (Rank j = 4; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 4; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } return; } -void fillCoxFMatrix(CoxMatrix& m, Rank l) +void fillCoxFMatrix(CoxMatrix &m, Rank l) { - for (Rank j = 1; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 1; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } m[l + 2] = 4; - m[2*l + 1] = 4; + m[2 * l + 1] = 4; return; } - -void fillCoxGMatrix(CoxMatrix& m) +void fillCoxGMatrix(CoxMatrix &m) { m[1] = 6; @@ -319,27 +307,26 @@ void fillCoxGMatrix(CoxMatrix& m) return; } -void fillCoxHMatrix(CoxMatrix& m, Rank l) +void fillCoxHMatrix(CoxMatrix &m, Rank l) { m[1] = 5; m[l] = 5; - for (Rank j = 2; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 2; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } return; } -void fillCoxIMatrix(CoxMatrix& m) +void fillCoxIMatrix(CoxMatrix &m) { CoxEntry m_12; - m_12 = interactive::getCoxEntry(1,2); + m_12 = interactive::getCoxEntry(1, 2); if (ERRNO) return; @@ -350,162 +337,152 @@ void fillCoxIMatrix(CoxMatrix& m) return; } - -void fillCoxaMatrix(CoxMatrix& m, Rank l) +void fillCoxaMatrix(CoxMatrix &m, Rank l) { - if (l == 2) - { - m[1] = 0; - m[2] = 0; - return; - } + if (l == 2) { + m[1] = 0; + m[2] = 0; + return; + } - for (Rank j = 1; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 1; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } - m[l-1] = 3; - m[(l-1)*l] = 3; + m[l - 1] = 3; + m[(l - 1) * l] = 3; return; } -void fillCoxbMatrix(CoxMatrix& m, Rank l) +void fillCoxbMatrix(CoxMatrix &m, Rank l) { if (l == 3) { // go over to type c3 - fillCoxcMatrix(m,3); + fillCoxcMatrix(m, 3); return; } m[1] = 4; m[l] = 4; - for (Rank j = 2; j < l-1; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 2; j < l - 1; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } - m[(l-3)*l + (l-1)] = 3; - m[(l-1)*l + (l-3)] = 3; + m[(l - 3) * l + (l - 1)] = 3; + m[(l - 1) * l + (l - 3)] = 3; return; } -void fillCoxcMatrix(CoxMatrix& m, Rank l) +void fillCoxcMatrix(CoxMatrix &m, Rank l) { m[1] = 4; m[l] = 4; - for (Rank j = 2; j < l-1; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 2; j < l - 1; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } - m[(l-2)*l + (l-1)] = 4; - m[(l-1)*l + (l-2)] = 4; + m[(l - 2) * l + (l - 1)] = 4; + m[(l - 1) * l + (l - 2)] = 4; return; } -void fillCoxdMatrix(CoxMatrix& m, Rank l) +void fillCoxdMatrix(CoxMatrix &m, Rank l) { m[2] = 3; - m[2*l] = 3; + m[2 * l] = 3; - for (Rank j = 2; j < l-1; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 2; j < l - 1; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } - m[(l-3)*l + (l-1)] = 3; - m[(l-1)*l + (l-3)] = 3; + m[(l - 3) * l + (l - 1)] = 3; + m[(l - 1) * l + (l - 3)] = 3; return; } -void fillCoxeMatrix(CoxMatrix& m, Rank l) +void fillCoxeMatrix(CoxMatrix &m, Rank l) { m[2] = 3; - m[2*l] = 3; + m[2 * l] = 3; m[l + 3] = 3; - m[2*l + 3] = 3; - m[3*l + 1] = 3; - m[3*l + 2] = 3; + m[2 * l + 3] = 3; + m[3 * l + 1] = 3; + m[3 * l + 2] = 3; - for (Rank j = 4; j < l-1; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 4; j < l - 1; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } - switch (l) - { - case 5: - m[l-1] = 3; - m[l + (l-1)] = 3; - m[(l-1)*l] = 3; - m[(l-1)*l + 1] = 3; - break; - case 6: - m[2*l + (l-1)] = 3; - m[(l-1)*l + 2] = 3; - break; - case 7: - m[l + (l-1)] = 3; - m[(l-1)*l + 1] = 3; - break; - case 8: - m[l-1] = 3; - m[(l-1)*l] = 3; - break; - case 9: - m[(l-2)*l + (l-1)] = 3; - m[(l-1)*l + (l-2)] = 3; - break; - } + switch (l) { + case 5: + m[l - 1] = 3; + m[l + (l - 1)] = 3; + m[(l - 1) * l] = 3; + m[(l - 1) * l + 1] = 3; + break; + case 6: + m[2 * l + (l - 1)] = 3; + m[(l - 1) * l + 2] = 3; + break; + case 7: + m[l + (l - 1)] = 3; + m[(l - 1) * l + 1] = 3; + break; + case 8: + m[l - 1] = 3; + m[(l - 1) * l] = 3; + break; + case 9: + m[(l - 2) * l + (l - 1)] = 3; + m[(l - 1) * l + (l - 2)] = 3; + break; + } return; } -void fillCoxfMatrix(CoxMatrix& m, Rank l) +void fillCoxfMatrix(CoxMatrix &m, Rank l) { - for (Rank j = 1; j < l; j++) - { - m[(j-1)*l + j] = 3; - m[j*l + (j-1)] = 3; - } + for (Rank j = 1; j < l; j++) { + m[(j - 1) * l + j] = 3; + m[j * l + (j - 1)] = 3; + } m[l + 2] = 4; - m[2*l + 1] = 4; + m[2 * l + 1] = 4; return; } - -void fillCoxgMatrix(CoxMatrix& m) +void fillCoxgMatrix(CoxMatrix &m) { m[1] = 6; m[3] = 6; m[5] = 3; m[7] = 3; - + return; } -void fillCoxXMatrix(CoxMatrix& m, const Rank& l, const Type& t) +void fillCoxXMatrix(CoxMatrix &m, const Rank &l, const Type &t) /* Recall that in type X the type is really a string, where the name @@ -523,56 +500,56 @@ void fillCoxXMatrix(CoxMatrix& m, const Rank& l, const Type& t) static String buf(0); using directories::COXMATRIX_DIR; - const String& name = t.name(); - - buf.setLength(strlen(COXMATRIX_DIR)+1+name.length()); // one char for `\` - sprintf(buf.ptr(),"%s/%s",COXMATRIX_DIR,name.ptr()+1); - FILE *inputfile = fopen(buf.ptr(),"r"); + const String &name = t.name(); + + buf.setLength(strlen(COXMATRIX_DIR) + 1 + name.length()); // one char for `\` + sprintf(buf.ptr(), "%s/%s", COXMATRIX_DIR, name.ptr() + 1); + FILE *inputfile = fopen(buf.ptr(), "r"); for (Rank i = 0; i < l; i++) { for (Rank j = 0; j < l; j++) { - + /* check for EOL */ - + if (interactive::endOfLine(inputfile)) { - Error(BAD_LINE,name.ptr()+1,l,i,j); - ERRNO = ABORT; - return; + Error(BAD_LINE, name.ptr() + 1, l, i, j); + ERRNO = ABORT; + return; } - m[i*l + j] = interactive::readCoxEntry(i,j,inputfile); - + m[i * l + j] = interactive::readCoxEntry(i, j, inputfile); + if (ERRNO) { - Error(ERRNO,i,j); - ERRNO = ABORT; - return; + Error(ERRNO, i, j); + ERRNO = ABORT; + return; } - + /* check for symmetry */ - + if (j < i) - if (m[i*l + j] != m[j*l + i]) { - Error(NOT_SYMMETRIC,name.ptr()+1,&m,l,i,j); - ERRNO = ABORT; - return; - } + if (m[i * l + j] != m[j * l + i]) { + Error(NOT_SYMMETRIC, name.ptr() + 1, &m, l, i, j); + ERRNO = ABORT; + return; + } } - + /* flush remaining line of the inputfile */ - + char c; - - while((c = getc(inputfile)) != EOF) + + while ((c = getc(inputfile)) != EOF) if (c == '\n') - break; + break; } fclose(inputfile); - + return; } -void fillCoxYMatrix(CoxMatrix& m, Rank l) +void fillCoxYMatrix(CoxMatrix &m, Rank l) /* This is the type for arbitrary input, where the coxeter matrix is gotten @@ -586,21 +563,20 @@ void fillCoxYMatrix(CoxMatrix& m, Rank l) { for (Rank i = 0; i < l; i++) - for (Rank j = i+1; j < l; j++) { - m[i*l + j] = interactive::getCoxEntry(i+1,j+1); + for (Rank j = i + 1; j < l; j++) { + m[i * l + j] = interactive::getCoxEntry(i + 1, j + 1); if (ERRNO) { - Error(ERRNO); - ERRNO = ERROR_WARNING; - return; + Error(ERRNO); + ERRNO = ERROR_WARNING; + return; } - m[j*l + i] = m[i*l + j]; + m[j * l + i] = m[i * l + j]; } - + return; } - -void makeCoxMatrix(CoxMatrix& m, const Type& x, const Rank& l) +void makeCoxMatrix(CoxMatrix &m, const Type &x, const Rank &l) /* Allocates and fills in the Coxeter matrix. In the case of type X, @@ -612,95 +588,93 @@ void makeCoxMatrix(CoxMatrix& m, const Type& x, const Rank& l) */ { - m.setSize(l*l); + m.setSize(l * l); - for (Ulong j = 0; j < static_cast(l*l); ++j) + for (Ulong j = 0; j < static_cast(l * l); ++j) m[j] = 2; for (Ulong j = 0; j < l; ++j) - m[j*l+j] = 1; + m[j * l + j] = 1; - switch (x[0]) - { - case 'A': - fillCoxAMatrix(m,l); - break; - case 'B': - fillCoxBMatrix(m,l); - break; - case 'D': - fillCoxDMatrix(m,l); - break; - case 'E': - fillCoxEMatrix(m,l); - break; - case 'F': - fillCoxFMatrix(m,l); - break; - case 'G': - fillCoxGMatrix(m); - break; - case 'H': - fillCoxHMatrix(m,l); - break; - case 'I': - fillCoxIMatrix(m); - if (ERRNO) - return; - break; - case 'a': - fillCoxaMatrix(m,l); - break; - case 'b': - fillCoxbMatrix(m,l); - break; - case 'c': - fillCoxcMatrix(m,l); - break; - case 'd': - fillCoxdMatrix(m,l); - break; - case 'e': - fillCoxeMatrix(m,l); - break; - case 'f': - fillCoxfMatrix(m,l); - break; - case 'g': - fillCoxgMatrix(m); - break; - case 'X': - fillCoxXMatrix(m,l,x); - break; - case 'Y': - fillCoxYMatrix(m,l); - break; - } + switch (x[0]) { + case 'A': + fillCoxAMatrix(m, l); + break; + case 'B': + fillCoxBMatrix(m, l); + break; + case 'D': + fillCoxDMatrix(m, l); + break; + case 'E': + fillCoxEMatrix(m, l); + break; + case 'F': + fillCoxFMatrix(m, l); + break; + case 'G': + fillCoxGMatrix(m); + break; + case 'H': + fillCoxHMatrix(m, l); + break; + case 'I': + fillCoxIMatrix(m); + if (ERRNO) + return; + break; + case 'a': + fillCoxaMatrix(m, l); + break; + case 'b': + fillCoxbMatrix(m, l); + break; + case 'c': + fillCoxcMatrix(m, l); + break; + case 'd': + fillCoxdMatrix(m, l); + break; + case 'e': + fillCoxeMatrix(m, l); + break; + case 'f': + fillCoxfMatrix(m, l); + break; + case 'g': + fillCoxgMatrix(m); + break; + case 'X': + fillCoxXMatrix(m, l, x); + break; + case 'Y': + fillCoxYMatrix(m, l); + break; + } return; } - -void makeStar(List& star, const CoxMatrix& m, const Rank& l) +void makeStar(List &star, const CoxMatrix &m, const Rank &l) /* - Makes the star-array of the Coxeter graph. This is an array of l + Makes the star-array of the Coxeter graph. This is an array of l LFlags, flagging the "stars" of each generator in the Coxeter diagram. */ { star.setSize(l); - - for(Generator s = 0; s < l; s++) { + + for (Generator s = 0; s < l; s++) { star[s] = 0; for (Generator t = 0; t < l; t++) - if ((m[s*l + t] > 2) || (m[s*l + t] == 0)) - star[s] |= lmask[t]; + if ((m[s * l + t] > 2) || (m[s * l + t] == 0)) + star[s] |= lmask[t]; } return; } -void makeStarOps(List& ops, const CoxMatrix& m, const Rank& l) +void makeStarOps(List &ops, const CoxMatrix &m, const Rank &l) /* Makes the starOps array of the Coxeter graph. This array has an entry for @@ -714,9 +688,9 @@ void makeStarOps(List& ops, const CoxMatrix& m, const Rank& l) Ulong count = 0; for (Generator s = 0; s < l; ++s) { - for (Generator t = s+1; t < l; ++t) { - if ((m[s*l + t] > 2) && (m[s*l + t] != infty)) - count++; + for (Generator t = s + 1; t < l; ++t) { + if ((m[s * l + t] > 2) && (m[s * l + t] != infty)) + count++; } } @@ -725,10 +699,10 @@ void makeStarOps(List& ops, const CoxMatrix& m, const Rank& l) count = 0; for (Generator s = 0; s < l; ++s) { - for (Generator t = s+1; t < l; ++t) { - if ((m[s*l + t] > 2) && (m[s*l + t] != infty)) { + for (Generator t = s + 1; t < l; ++t) { + if ((m[s * l + t] > 2) && (m[s * l + t] != infty)) { ops[count] = lmask[s] | lmask[t]; - count++; + count++; } } } @@ -736,7 +710,7 @@ void makeStarOps(List& ops, const CoxMatrix& m, const Rank& l) return; } -}; +}; // namespace /**************************************************************************** @@ -761,7 +735,7 @@ void makeStarOps(List& ops, const CoxMatrix& m, const Rank& l) namespace graph { -bool isAffine(CoxGraph& G, LFlags I) +bool isAffine(CoxGraph &G, LFlags I) /* Returns true if the group generated by I is affine, false otherwise. Uses the @@ -771,16 +745,15 @@ bool isAffine(CoxGraph& G, LFlags I) */ { - const Type& type = irrType(G,I); + const Type &type = irrType(G, I); - if (strchr("abcdefg",type[0])) /* group is affine */ + if (strchr("abcdefg", type[0])) /* group is affine */ return true; else return false; } - -bool isConnected(CoxGraph& G, LFlags I) +bool isConnected(CoxGraph &G, LFlags I) /* Returns true if the graph induced on I is connected, false otherwise. @@ -792,14 +765,13 @@ bool isConnected(CoxGraph& G, LFlags I) Generator s = firstBit(I); - if (G.component(I,s) == I) + if (G.component(I, s) == I) return true; else return false; } - -bool isCrystallographic(CoxGraph& G, LFlags I) +bool isCrystallographic(CoxGraph &G, LFlags I) /* Checks if the restriction of the Coxeter graph to I is crystallographic, @@ -808,25 +780,23 @@ bool isCrystallographic(CoxGraph& G, LFlags I) { for (Generator s = 0; s < G.rank(); s++) - for (Generator t = s+1; t < G.rank(); t++) - { - switch (G.M(s,t)) { - case 0: - case 2: - case 3: - case 4: - case 6: - continue; - default: - return false; - }; - } + for (Generator t = s + 1; t < G.rank(); t++) { + switch (G.M(s, t)) { + case 0: + case 2: + case 3: + case 4: + case 6: + continue; + default: + return false; + }; + } return true; } - -bool isFinite(CoxGraph& G, LFlags I) +bool isFinite(CoxGraph &G, LFlags I) /* Returns true if the group generated by I is finite, false otherwise. Uses the @@ -834,21 +804,19 @@ bool isFinite(CoxGraph& G, LFlags I) */ { - while (I) - { - Generator s = firstBit(I); - LFlags f = G.component(I,s); - const Type& type = irrType(G,f); - if (strchr("ABCDEFGHI",type[0]) == NULL) - return false; - I &= ~f; - } - + while (I) { + Generator s = firstBit(I); + LFlags f = G.component(I, s); + const Type &type = irrType(G, f); + if (strchr("ABCDEFGHI", type[0]) == NULL) + return false; + I &= ~f; + } + return true; } - -bool isLoop(CoxGraph& G, LFlags I) +bool isLoop(CoxGraph &G, LFlags I) /* Returns 1 if the graph induced on I is a loop, 0 otherwise. Uses the @@ -857,21 +825,19 @@ bool isLoop(CoxGraph& G, LFlags I) */ { - if (!isConnected(G,I)) + if (!isConnected(G, I)) return false; - for (LFlags f = I; f; f &= f-1) - { - Generator s = firstBit(f); - if (bitCount(G.star(I,s)) != 2) - return false; - } + for (LFlags f = I; f; f &= f - 1) { + Generator s = firstBit(f); + if (bitCount(G.star(I, s)) != 2) + return false; + } return true; } - -bool isSimplyLaced(CoxGraph& G, LFlags I) +bool isSimplyLaced(CoxGraph &G, LFlags I) /* Returns true if the Coxeter graph restricted to I is simply laced (i.e., all @@ -879,21 +845,19 @@ bool isSimplyLaced(CoxGraph& G, LFlags I) */ { - for (LFlags fs = I; fs; fs &= fs-1) - { - Generator s = firstBit(fs); - for (LFlags ft = fs & fs-1; ft; ft &= ft-1) - { - Generator t = firstBit(ft); - if ((G.M(s,t) == 0) || (G.M(s,t) > 3)) - return false; - } + for (LFlags fs = I; fs; fs &= fs - 1) { + Generator s = firstBit(fs); + for (LFlags ft = fs & fs - 1; ft; ft &= ft - 1) { + Generator t = firstBit(ft); + if ((G.M(s, t) == 0) || (G.M(s, t) > 3)) + return false; } + } return true; } -bool isTree(CoxGraph& G, LFlags I) +bool isTree(CoxGraph &G, LFlags I) /* Returns 1 if the graph induced on I is a tree, 0 otherwise. Uses the @@ -902,18 +866,17 @@ bool isTree(CoxGraph& G, LFlags I) */ { - if (!isConnected(G,I)) + if (!isConnected(G, I)) return false; unsigned edgecount = 0; - for (LFlags f = I; f; f &= f-1) - { - Generator s = firstBit(f); - edgecount += bitCount(G.star(I,s)); - } + for (LFlags f = I; f; f &= f - 1) { + Generator s = firstBit(f); + edgecount += bitCount(G.star(I, s)); + } - edgecount /= 2; /* each edge was counted twice */ + edgecount /= 2; /* each edge was counted twice */ if (edgecount == (bitCount(I) - 1)) return true; @@ -921,18 +884,18 @@ bool isTree(CoxGraph& G, LFlags I) return false; } -}; +}; // namespace graph namespace { -const Type& irrType(CoxGraph& G, LFlags I) +const Type &irrType(CoxGraph &G, LFlags I) /* - Returns the type of the subgraph induced on I, if this subgraph is + Returns the type of the subgraph induced on I, if this subgraph is irreducible, finite or affine. Assumes that irreducibility has already been checked. Returns type "X" if the type is not defined. - The result is returned as type, which is a safe place until the next call + The result is returned as type, which is a safe place until the next call to irrType. */ @@ -944,258 +907,245 @@ const Type& irrType(CoxGraph& G, LFlags I) return type; } - if (bitCount(I) == 2) - { - Generator s = firstBit(I); - Generator t = firstBit(I & I-1); - CoxEntry m = G.M(s,t); - - switch (m) - { - case 0: - type[0] = 'a'; - return type; - case 3: - type[0] = 'A'; - return type; - case 4: - type[0] = 'B'; - return type; - case 5: - type[0] = 'H'; - return type; - case 6: - type[0] = 'G'; - return type; - default: - type[0] = 'I'; - return type; - }; - } + if (bitCount(I) == 2) { + Generator s = firstBit(I); + Generator t = firstBit(I & I - 1); + CoxEntry m = G.M(s, t); + + switch (m) { + case 0: + type[0] = 'a'; + return type; + case 3: + type[0] = 'A'; + return type; + case 4: + type[0] = 'B'; + return type; + case 5: + type[0] = 'H'; + return type; + case 6: + type[0] = 'G'; + return type; + default: + type[0] = 'I'; + return type; + }; + } /* from here on the rank is at least three */ - if (!isTree(G,I)) /* type must be a_n */ - { - if (!isLoop(G,I)) /* unknown type */ - return type; - if (!isSimplyLaced(G,I)) /* unknown type */ - return type; - type[0] = 'a'; + if (!isTree(G, I)) /* type must be a_n */ + { + if (!isLoop(G, I)) /* unknown type */ return type; - } + if (!isSimplyLaced(G, I)) /* unknown type */ + return type; + type[0] = 'a'; + return type; + } /* from here on the graph is a tree */ - CoxEntry m = maxCoefficient(G,I); + CoxEntry m = maxCoefficient(G, I); switch (m) { case 3: { /* simply laced : type is A, D, E, d, e if known */ LFlags fn = G.nodes(I); - switch (bitCount(fn)) - { - case 0: /* type A */ - type[0] = 'A'; - return type; - case 1: { /* type is D, E, e, or d5, if known */ - Generator n = firstBit(G.nodes(I)); - switch (bitCount(G.star(n))) - { - case 3: { /* type is D, E or e */ - LFlags f = G.extremities(I); - switch (bitCount(f & G.star(n))) /* short branches */ - { - case 3: /* type is D4 */ - type[0] = 'D'; - return type; - case 2: /* type is Dn, n >= 5 */ - type[0] = 'D'; - return type; - case 1: { /* type is E6, E7, E8, e8 or e9 */ - /* trim branches by one */ - LFlags J = I & ~f; - f = G.extremities(J); - switch (bitCount(f & G.star(n))) - { - case 0: /* two branches of length > 2 */ - if (bitCount(I) == 8) /* type e8 */ - type[0] = 'e'; - return type; - case 1: /* one branch of length 2 */ - switch (bitCount(I)) - { - case 7: /* type E7 */ - case 8: /* type E8 */ - type[0] = 'E'; - return type; - case 9: /* type e9 */ - type[0] = 'e'; - return type; - default: /* unknown type */ - return type; - }; - case 2: /* two branches of length 2 */ - if (bitCount(I) == 6) /* type E6 */ - type[0] = 'E'; - return type; - }; - } - case 0: /* type has to be e7 */ - if (bitCount(I) == 7) - type[0] = 'e'; - return type; - }; - } - case 4: /* type is d5 */ - if (bitCount(I) == 5) - type[0] = 'd'; - return type; - default: /* unknown type */ - return type; - }; - } - case 2: { - LFlags f = G.extremities(I); - if (bitCount(f) > 4) /* unknown type */ - return type; - /* from here on each node has three branches */ - LFlags J = I & ~f; - f = G.extremities(J); - if (f == fn) /* type d */ - type[0] = 'd'; - return type; + switch (bitCount(fn)) { + case 0: /* type A */ + type[0] = 'A'; + return type; + case 1: { /* type is D, E, e, or d5, if known */ + Generator n = firstBit(G.nodes(I)); + switch (bitCount(G.star(n))) { + case 3: { /* type is D, E or e */ + LFlags f = G.extremities(I); + switch (bitCount(f & G.star(n))) /* short branches */ + { + case 3: /* type is D4 */ + type[0] = 'D'; + return type; + case 2: /* type is Dn, n >= 5 */ + type[0] = 'D'; + return type; + case 1: { /* type is E6, E7, E8, e8 or e9 */ + /* trim branches by one */ + LFlags J = I & ~f; + f = G.extremities(J); + switch (bitCount(f & G.star(n))) { + case 0: /* two branches of length > 2 */ + if (bitCount(I) == 8) /* type e8 */ + type[0] = 'e'; + return type; + case 1: /* one branch of length 2 */ + switch (bitCount(I)) { + case 7: /* type E7 */ + case 8: /* type E8 */ + type[0] = 'E'; + return type; + case 9: /* type e9 */ + type[0] = 'e'; + return type; + default: /* unknown type */ + return type; + }; + case 2: /* two branches of length 2 */ + if (bitCount(I) == 6) /* type E6 */ + type[0] = 'E'; + return type; + }; + } + case 0: /* type has to be e7 */ + if (bitCount(I) == 7) + type[0] = 'e'; + return type; + }; } - default: /* unknown type */ - return type; + case 4: /* type is d5 */ + if (bitCount(I) == 5) + type[0] = 'd'; + return type; + default: /* unknown type */ + return type; }; + } + case 2: { + LFlags f = G.extremities(I); + if (bitCount(f) > 4) /* unknown type */ + return type; + /* from here on each node has three branches */ + LFlags J = I & ~f; + f = G.extremities(J); + if (f == fn) /* type d */ + type[0] = 'd'; + return type; + } + default: /* unknown type */ + return type; + }; } case 4: { /* type is B, F, b, c or f if known */ - switch (bitCount(G.nodes(I))) - { - case 0: { /* graph is a string : type is B, F, c or f */ - LFlags f = G.extremities(I); - LFlags J = I & ~f; - switch (maxCoefficient(G,J)) - { - case 1: - case 3: { /* type is B or c */ - type[0] = 'B'; - Generator s = firstBit(f); - Generator t = firstBit(G.star(s)); - CoxEntry m1 = G.M(s,t); - if (m1 == 3) - return type; - f &= f-1; - s = firstBit(f); - t = firstBit(G.star(s)); - m1 = G.M(s,t); - if (m1 == 4) - type[0] = 'c'; - return type; - } - case 4: /* type is F or f, if known */ - switch (bitCount(I)) - { - case 4: /* type F4 */ - type[0] = 'F'; - return type; - case 5: { - CoxEntry m1 = minCoefficient(G,J); - if (m1 == 3) /* type f5 */ - type[0] = 'f'; - return type; - } - default: /* unknown type */ - return type; - }; - default: /* unknown type */ - return type; - }; + switch (bitCount(G.nodes(I))) { + case 0: { /* graph is a string : type is B, F, c or f */ + LFlags f = G.extremities(I); + LFlags J = I & ~f; + switch (maxCoefficient(G, J)) { + case 1: + case 3: { /* type is B or c */ + type[0] = 'B'; + Generator s = firstBit(f); + Generator t = firstBit(G.star(s)); + CoxEntry m1 = G.M(s, t); + if (m1 == 3) + return type; + f &= f - 1; + s = firstBit(f); + t = firstBit(G.star(s)); + m1 = G.M(s, t); + if (m1 == 4) + type[0] = 'c'; + return type; } - case 1: { /* type is b if known */ - LFlags f = G.extremities(I); - if (bitCount(f) > 3) /* more than three branches */ - return type; - LFlags J = I & ~f; - if (!isSimplyLaced(G,J)) /* unknown type */ - return type; - Generator n = firstBit(G.nodes(I)); - f &= G.star(n); - switch (bitCount(f)) - { - case 2: /* exactly one long branch */ - J = f | lmask[n]; - if (isSimplyLaced(G,J)) /* type is b */ - type[0] = 'b'; - return type; - case 3: /* type is b4 */ - type[0] = 'b'; - return type; - default: /* more than one long branch */ - return type; - }; - } - default: /* unknown type */ - return type; + case 4: /* type is F or f, if known */ + switch (bitCount(I)) { + case 4: /* type F4 */ + type[0] = 'F'; + return type; + case 5: { + CoxEntry m1 = minCoefficient(G, J); + if (m1 == 3) /* type f5 */ + type[0] = 'f'; + return type; + } + default: /* unknown type */ + return type; + }; + default: /* unknown type */ + return type; }; + } + case 1: { /* type is b if known */ + LFlags f = G.extremities(I); + if (bitCount(f) > 3) /* more than three branches */ + return type; + LFlags J = I & ~f; + if (!isSimplyLaced(G, J)) /* unknown type */ + return type; + Generator n = firstBit(G.nodes(I)); + f &= G.star(n); + switch (bitCount(f)) { + case 2: /* exactly one long branch */ + J = f | lmask[n]; + if (isSimplyLaced(G, J)) /* type is b */ + type[0] = 'b'; + return type; + case 3: /* type is b4 */ + type[0] = 'b'; + return type; + default: /* more than one long branch */ + return type; + }; + } + default: /* unknown type */ + return type; + }; } case 5: { /* type must be H3 or H4 if known */ - switch (bitCount(I)) - { - case 3: { - CoxEntry m1 = minCoefficient(G,I); - if (m1 == 3) - type[0] = 'H'; - return type; - } - case 4: { - if (G.nodes(I)) /* graph is not a string */ - return type; - LFlags f = G.extremities(I); - LFlags J = I & ~f; - if (!isSimplyLaced(G,J)) /* unknown type */ - return type; - J = 0; - for (; f; f &= f-1) - { - Generator s = firstBit(f); - J |= G.star(s); - } - CoxEntry m1 = minCoefficient(G,J); - if (m1 == 3) - type[0] = 'H'; - return type; + switch (bitCount(I)) { + case 3: { + CoxEntry m1 = minCoefficient(G, I); + if (m1 == 3) + type[0] = 'H'; + return type; + } + case 4: { + if (G.nodes(I)) /* graph is not a string */ + return type; + LFlags f = G.extremities(I); + LFlags J = I & ~f; + if (!isSimplyLaced(G, J)) /* unknown type */ + return type; + J = 0; + for (; f; f &= f - 1) { + Generator s = firstBit(f); + J |= G.star(s); } - default: - return type; - }; + CoxEntry m1 = minCoefficient(G, J); + if (m1 == 3) + type[0] = 'H'; + return type; + } + default: + return type; + }; break; } case 6: { /* type must be g3 if known */ - switch(bitCount(I)) - { - case 3: { - CoxEntry m1 = minCoefficient(G,I); - if (m1 == 3) - type[0] = 'g'; - return type; - } - default: - return type; - }; + switch (bitCount(I)) { + case 3: { + CoxEntry m1 = minCoefficient(G, I); + if (m1 == 3) + type[0] = 'g'; + return type; + } + default: + return type; + }; } - default: /* unknown type */ + default: /* unknown type */ return type; }; return type; // unreachable } -}; +}; // namespace namespace graph { -const Type& type(CoxGraph& G, LFlags I) +const Type &type(CoxGraph &G, LFlags I) /* Returns the type of the group generated by I as a string containing one @@ -1204,7 +1154,7 @@ const Type& type(CoxGraph& G, LFlags I) string is the number of components of the group. Returns the empty string if I = 0. - The result is returned as buf.ptr(), which is a safe place until the next + The result is returned as buf.ptr(), which is a safe place until the next call to type */ @@ -1216,30 +1166,30 @@ const Type& type(CoxGraph& G, LFlags I) type.name().setLength(G.rank()); - for (Ulong j = 0; I; j++) /* run through connected components */ - { - s = firstBit(I); - f = G.component(I,s); - type[j] = (irrType(G,f))[0]; - I &= ~f; - } + for (Ulong j = 0; I; j++) /* run through connected components */ + { + s = firstBit(I); + f = G.component(I, s); + type[j] = (irrType(G, f))[0]; + I &= ~f; + } return type; } -}; +}; // namespace graph /**************************************************************************** Chapter IV -- Order computations. - This section regroups functions for computing the order of subgroups + This section regroups functions for computing the order of subgroups generated by subsets of S. The functions are : - - A_order(rank),B_order(rank),D_order(rank) : order functions for the + - A_order(rank),B_order(rank),D_order(rank) : order functions for the infinite families; - dihedralOrder(G,I) : returns the order for dihedral groups; - extrQuotOrder(G,I,s) : returns the order of the quotient of I by I\{s}, @@ -1267,13 +1217,12 @@ CoxSize A_order(Rank rank) { CoxSize a = 1; - - for (Rank j = 1; j <= rank; j++) - { - if (a > COXSIZE_MAX/(j+1)) - return 0; - a *= j+1; - } + + for (Rank j = 1; j <= rank; j++) { + if (a > COXSIZE_MAX / (j + 1)) + return 0; + a *= j + 1; + } return a; } @@ -1287,18 +1236,16 @@ CoxSize B_order(Rank rank) { CoxSize a = 2; - - for (Rank j = 2; j <= rank; j++) - { - if (a > COXSIZE_MAX/(2*j)) - return 0; - a *= 2*j; - } + + for (Rank j = 2; j <= rank; j++) { + if (a > COXSIZE_MAX / (2 * j)) + return 0; + a *= 2 * j; + } return a; } - CoxSize D_order(Rank rank) /* @@ -1308,18 +1255,17 @@ CoxSize D_order(Rank rank) { CoxSize a = 24; - - for (Rank j = 4; j <= rank; j++) - { - if (a > COXSIZE_MAX/(2*j)) - return 0; - a *= 2*j; - } + + for (Rank j = 4; j <= rank; j++) { + if (a > COXSIZE_MAX / (2 * j)) + return 0; + a *= 2 * j; + } return a; } -CoxSize dihedralOrder(CoxGraph& G, LFlags I) +CoxSize dihedralOrder(CoxGraph &G, LFlags I) /* Assuming that |I| = 2, returns the order of the subgroup generated @@ -1332,18 +1278,17 @@ CoxSize dihedralOrder(CoxGraph& G, LFlags I) Generator s, t; s = firstBit(I); - I &= I-1; + I &= I - 1; t = firstBit(I); - m = (CoxSize)(G.M(s,t)); + m = (CoxSize)(G.M(s, t)); - if (m > COXSIZE_MAX/2) + if (m > COXSIZE_MAX / 2) return 0; - return 2*m; + return 2 * m; } - -ParSize extrQuotOrder(CoxGraph& G, LFlags I, Generator s) +ParSize extrQuotOrder(CoxGraph &G, LFlags I, Generator s) /* Assuming I irreducible and s extremal, this function returns @@ -1358,113 +1303,102 @@ ParSize extrQuotOrder(CoxGraph& G, LFlags I, Generator s) Generator s1; CoxEntry m; - const Type& t = irrType(G,I); + const Type &t = irrType(G, I); l = bitCount(I); if (l == 1) return (ParSize)2; I1 = I & ~lmask[s]; - const Type& t1 = irrType(G,I1); + const Type &t1 = irrType(G, I1); - switch (t[0]) - { - case 'A': - return (ParSize)(l+1); + switch (t[0]) { + case 'A': + return (ParSize)(l + 1); + case 'B': + switch (t1[0]) { + case 'A': /* return 2^l */ + if (l == BITS(ParSize)) + return 0; + else + return (ParSize)1 << l; case 'B': - switch (t1[0]) - { - case 'A': /* return 2^l */ - if (l == BITS(ParSize)) - return 0; - else - return (ParSize)1 << l; - case 'B': - return (ParSize)(2*l); - }; + return (ParSize)(2 * l); + }; + case 'D': + switch (t1[0]) { + case 'A': /* return 2^(l-1) */ + return (ParSize)1 << (l - 1); case 'D': - switch (t1[0]) - { - case 'A': /* return 2^(l-1) */ - return (ParSize)1 << (l-1); - case 'D': - return (ParSize)(2*l); - }; - case 'E': - switch (l) - { - case 6: - switch (t1[0]) - { - case 'A': - return (ParSize)72; - case 'D': - return (ParSize)27; - }; - case 7: - switch (t1[0]) - { - case 'A': - return (ParSize)576; - case 'D': - return (ParSize)126; - case 'E': - return (ParSize)56; - }; - case 8: - switch (t1[0]) - { - case 'A': - return (ParSize)17280; - case 'D': - return (ParSize)2160; - case 'E': - return (ParSize)240; - }; - }; - case 'F': - return (ParSize)24; - case 'G': - return (ParSize)6; - case 'H': - switch (l) - { - case 2: - return (ParSize)5; - case 3: - switch (t1[0]) - { - case 'H': - return (ParSize)12; - case 'A': - return (ParSize)20; - }; - case 4: - switch (t1[0]) - { - case 'H': - return (ParSize)120; - case 'A': - return (ParSize)600; - }; - }; - case 'I': - I &= ~(lmask[s]); - s1 = firstBit(I); - m = G.M(s,s1); - return (ParSize)m; - default: /* group is not finite */ - return 0; + return (ParSize)(2 * l); + }; + case 'E': + switch (l) { + case 6: + switch (t1[0]) { + case 'A': + return (ParSize)72; + case 'D': + return (ParSize)27; + }; + case 7: + switch (t1[0]) { + case 'A': + return (ParSize)576; + case 'D': + return (ParSize)126; + case 'E': + return (ParSize)56; + }; + case 8: + switch (t1[0]) { + case 'A': + return (ParSize)17280; + case 'D': + return (ParSize)2160; + case 'E': + return (ParSize)240; + }; }; + case 'F': + return (ParSize)24; + case 'G': + return (ParSize)6; + case 'H': + switch (l) { + case 2: + return (ParSize)5; + case 3: + switch (t1[0]) { + case 'H': + return (ParSize)12; + case 'A': + return (ParSize)20; + }; + case 4: + switch (t1[0]) { + case 'H': + return (ParSize)120; + case 'A': + return (ParSize)600; + }; + }; + case 'I': + I &= ~(lmask[s]); + s1 = firstBit(I); + m = G.M(s, s1); + return (ParSize)m; + default: /* group is not finite */ + return 0; + }; } - -CoxSize finiteOrder(const Type& type, const Rank& rank) +CoxSize finiteOrder(const Type &type, const Rank &rank) /* This function returns the order of the group of the given type and rank, by dispatching it to the appropriate sub-function. - It is assumed that type[0] is one of A-H. Type I is handled + It is assumed that type[0] is one of A-H. Type I is handled separately. It is assumed that the rank has been scanned so that it is >= 1 in type A, >= 2 in type B, >= 4 in type D, 6,7,8 in type E, 4 in type F, 2 in type G, 2,3,4 in type H. @@ -1485,11 +1419,11 @@ CoxSize finiteOrder(const Type& type, const Rank& rank) case 'E': switch (rank) { case 6: - return static_cast(51840); + return static_cast(51840); case 7: - return static_cast(2903040); + return static_cast(2903040); case 8: - return static_cast(696729600); + return static_cast(696729600); }; case 'F': return static_cast(1152); @@ -1498,19 +1432,18 @@ CoxSize finiteOrder(const Type& type, const Rank& rank) case 'H': switch (rank) { case 2: - return static_cast(10); + return static_cast(10); case 3: - return static_cast(120); + return static_cast(120); case 4: - return static_cast(14400); + return static_cast(14400); }; default: // unreachable return 0; }; } - -ParSize lastQuotOrder(const Type& type, Rank rank) +ParSize lastQuotOrder(const Type &type, Rank rank) /* Returns the order of the privileged quotient in the given type and @@ -1521,11 +1454,11 @@ ParSize lastQuotOrder(const Type& type, Rank rank) { switch (type[0]) { case 'A': - return static_cast(rank+1); + return static_cast(rank + 1); case 'B': case 'C': case 'D': - return static_cast(2*rank); + return static_cast(2 * rank); case 'E': switch (rank) { case 6: @@ -1553,12 +1486,11 @@ ParSize lastQuotOrder(const Type& type, Rank rank) }; } -}; - +}; // namespace namespace graph { -CoxSize order(CoxGraph& G, LFlags I) +CoxSize order(CoxGraph &G, LFlags I) /* Returns the order of the subgroup generated by I, if this fits @@ -1570,28 +1502,27 @@ CoxSize order(CoxGraph& G, LFlags I) return 1; Generator s = firstBit(I); - LFlags J = G.component(I,s); + LFlags J = G.component(I, s); - if (J != I) /* group is not irreducible */ - { - CoxSize c1 = order(G,J); - CoxSize c2 = order(G,I&~J); - if (c1 & c2 & (c2 > COXSIZE_MAX/c1)) /* overflow */ - return 0; - return c1*c2; - } + if (J != I) /* group is not irreducible */ + { + CoxSize c1 = order(G, J); + CoxSize c2 = order(G, I & ~J); + if (c1 & c2 & (c2 > COXSIZE_MAX / c1)) /* overflow */ + return 0; + return c1 * c2; + } - const Type& t = irrType(G,I); + const Type &t = irrType(G, I); Rank l = bitCount(I); if (t[0] == 'I') - return dihedralOrder(G,I); + return dihedralOrder(G, I); else - return finiteOrder(t,l); + return finiteOrder(t, l); } - -ParSize quotOrder(CoxGraph& G, LFlags I, LFlags J) +ParSize quotOrder(CoxGraph &G, LFlags I, LFlags J) /* Returns the number of elements of W_I/W_J, assuming that J is contained @@ -1604,76 +1535,75 @@ ParSize quotOrder(CoxGraph& G, LFlags I, LFlags J) return 1; Generator s = firstBit(I); - LFlags I1 = G.component(I,s); + LFlags I1 = G.component(I, s); - if (I1 != I) /* argue by induction */ - { - LFlags J1 = J & I1; - LFlags I2 = I & ~I1; - LFlags J2 = J & ~J1; - ParSize c1 = quotOrder(G,I1,J1); - ParSize c2 = quotOrder(G,I2,J2); - if (c1 & c2 & (c2 > LPARNBR_MAX/c1)) /* overflow */ - return 0; - return c1*c2; - } + if (I1 != I) /* argue by induction */ + { + LFlags J1 = J & I1; + LFlags I2 = I & ~I1; + LFlags J2 = J & ~J1; + ParSize c1 = quotOrder(G, I1, J1); + ParSize c2 = quotOrder(G, I2, J2); + if (c1 & c2 & (c2 > LPARNBR_MAX / c1)) /* overflow */ + return 0; + return c1 * c2; + } /* now I is irreducible */ - const Type& type = irrType(G,I); - if (strchr("ABCDEFGHI",type[0]) == NULL) /* group is infinite */ + const Type &type = irrType(G, I); + if (strchr("ABCDEFGHI", type[0]) == NULL) /* group is infinite */ return 0; Rank l = bitCount(I); - if (l == 2) /* dihedral case */ - { - Generator s = firstBit(I); - Generator t = firstBit(G.star(I,s)); - CoxEntry m = G.M(s,t); - if (m == 0) /* group is infinite */ - return 0; - - switch(bitCount(J)) - { - case 0: - return static_cast(2*m); - case 1: - return static_cast(m); - }; - } + if (l == 2) /* dihedral case */ + { + Generator s = firstBit(I); + Generator t = firstBit(G.star(I, s)); + CoxEntry m = G.M(s, t); + if (m == 0) /* group is infinite */ + return 0; + + switch (bitCount(J)) { + case 0: + return static_cast(2 * m); + case 1: + return static_cast(m); + }; + } - s = lastGenerator(G,I); + s = lastGenerator(G, I); I1 = I & ~(lmask[s]); LFlags J1 = J & ~(lmask[s]); - ParSize c1 = lastQuotOrder(type,l); - ParSize c2 = quotOrder(G,I1,J1); + ParSize c1 = lastQuotOrder(type, l); + ParSize c2 = quotOrder(G, I1, J1); if (c2 == 0) return 0; - if ((J & lmask[s]) == 0) /* s is not in J */ + if ((J & lmask[s]) == 0) /* s is not in J */ goto exit; - J = G.component(J,s); + J = G.component(J, s); { - ParSize q = extrQuotOrder(G,J,s); - ParSize d = gcd((Ulong)c1,(Ulong)q); + ParSize q = extrQuotOrder(G, J, s); + ParSize d = gcd((Ulong)c1, (Ulong)q); c1 /= d; q /= d; - c2 /= q; /* now c2 must be divisible by q */ + c2 /= q; /* now c2 must be divisible by q */ } - exit: - if (c2 > LPARNBR_MAX/c1) /* overflow */ +exit: + if (c2 > LPARNBR_MAX / c1) /* overflow */ return 0; - - return c1*c2; + + return c1 * c2; } -}; +}; // namespace graph /**************************************************************************** @@ -1700,26 +1630,25 @@ Ulong gcd(Ulong a, Ulong b) */ { - if (a < b) /* exchange a and b */ - return gcd(b,a); + if (a < b) /* exchange a and b */ + return gcd(b, a); - Ulong r = a%b; + Ulong r = a % b; - while (r != 0) - { - a = b; - b = r; - r = a%b; - } + while (r != 0) { + a = b; + b = r; + r = a % b; + } return b; } -}; +}; // namespace namespace graph { -void getConjugacyClasses(List& cl, const CoxGraph& G) +void getConjugacyClasses(List &cl, const CoxGraph &G) /* This function returns in cl the conjugacy classes of generators in W (i.e. @@ -1732,11 +1661,11 @@ void getConjugacyClasses(List& cl, const CoxGraph& G) List odd_star(0); odd_star.setSize(G.rank()); - for(Generator s = 0; s < G.rank(); ++s) { + for (Generator s = 0; s < G.rank(); ++s) { odd_star[s] = 0; for (Generator t = 0; t < G.rank(); ++t) - if ((G.M(s,t)%2) && (G.M(s,t) > 1)) - odd_star[s] |= lmask[t]; + if ((G.M(s, t) % 2) && (G.M(s, t) > 1)) + odd_star[s] |= lmask[t]; } Ulong c = 0; @@ -1744,14 +1673,14 @@ void getConjugacyClasses(List& cl, const CoxGraph& G) for (LFlags fS = G.supp(); fS; ++c) { LFlags nf = lmask[firstBit(fS)]; LFlags f = 0; - while (nf) /* there are new elements to be considered */ - { - f |= nf; - for (LFlags f1 = nf; f1; f1 &= f1-1) - nf |= (odd_star[firstBit(f1)]); - nf &= ~f; - } - cl.setSize(c+1); + while (nf) /* there are new elements to be considered */ + { + f |= nf; + for (LFlags f1 = nf; f1; f1 &= f1 - 1) + nf |= (odd_star[firstBit(f1)]); + nf &= ~f; + } + cl.setSize(c + 1); cl[c] = f; fS &= ~f; } @@ -1759,11 +1688,11 @@ void getConjugacyClasses(List& cl, const CoxGraph& G) return; } -}; +}; // namespace graph namespace { -Generator lastGenerator(CoxGraph& G, LFlags I) +Generator lastGenerator(CoxGraph &G, LFlags I) /* Assuming that I is irreducible, this function returns an element @@ -1777,146 +1706,134 @@ Generator lastGenerator(CoxGraph& G, LFlags I) /* from now on the rank is at least three */ - const Type& x = irrType(G,I); + const Type &x = irrType(G, I); LFlags f = G.extremities(I); - switch (x[0]) - { - case 'A': + switch (x[0]) { + case 'A': + return firstBit(f); + case 'B': { + Generator s = firstBit(f); + Generator t = firstBit(G.star(I, s)); + CoxEntry m = G.M(s, t); + switch (m) { + case 3: + return s; + case 4: + f &= ~(lmask[s]); return firstBit(f); - case 'B': { - Generator s = firstBit(f); - Generator t = firstBit(G.star(I,s)); - CoxEntry m = G.M(s,t); - switch (m) - { - case 3: - return s; - case 4: - f &= ~(lmask[s]); - return firstBit(f); - }; + }; + } + case 'D': { + Generator s = firstBit(f); + Generator n = firstBit(G.nodes(I)); + f &= ~(G.star(n)); + if (f) + return firstBit(f); + else /* rank is 4 */ + return s; + } + case 'E': { + Generator n = firstBit(G.nodes(I)); + f &= ~(G.star(n)); + Generator s = firstBit(f); + switch (l) { + case 6: + return s; + case 7: + case 8: { + Generator t = firstBit(G.star(I, s)); + if (lmask[t] & G.star(n)) { + f &= ~(lmask[s]); + return firstBit(f); + } else + return s; } - case 'D': { - Generator s = firstBit(f); + }; + } + case 'F': + return firstBit(f); + case 'H': { + Generator s = firstBit(f); + Generator t = firstBit(G.star(I, s)); + CoxEntry m = G.M(s, t); + switch (m) { + case 3: + return s; + case 5: + f &= ~(lmask[s]); + return firstBit(f); + }; + } + case 'a': + return firstBit(I); + case 'b': { + Generator s = firstBit(f); + Generator t = firstBit(G.star(I, s)); + CoxEntry m = G.M(s, t); + switch (m) { + case 3: + return s; + case 4: + f &= ~(lmask[s]); + return firstBit(f); + }; + } + case 'c': + return firstBit(f); + case 'd': + return firstBit(f); + case 'e': { + switch (l) { + case 7: + return firstBit(f); + case 8: { Generator n = firstBit(G.nodes(I)); f &= ~(G.star(n)); - if (f) - return firstBit(f); - else /* rank is 4 */ - return s; + return firstBit(f); } - case 'E': { + case 9: { Generator n = firstBit(G.nodes(I)); f &= ~(G.star(n)); Generator s = firstBit(f); - switch (l) - { - case 6: - return s; - case 7: - case 8: { - Generator t = firstBit(G.star(I,s)); - if (lmask[t] & G.star(n)) { - f &= ~(lmask[s]); - return firstBit(f); - } - else - return s; - } - }; - } - case 'F': - return firstBit(f); - case 'H': { - Generator s = firstBit(f); - Generator t = firstBit(G.star(I,s)); - CoxEntry m = G.M(s,t); - switch (m) - { - case 3: - return s; - case 5: - f &= ~(lmask[s]); - return firstBit(f); - }; + Generator t = firstBit(G.star(I, s)); + if (lmask[t] & G.star(n)) { + f &= ~(lmask[s]); + return firstBit(f); + } else + return s; } - case 'a': - return firstBit(I); - case 'b': { - Generator s = firstBit(f); - Generator t = firstBit(G.star(I,s)); - CoxEntry m = G.M(s,t); - switch (m) - { - case 3: - return s; - case 4: - f &= ~(lmask[s]); - return firstBit(f); - }; - } - case 'c': + }; + } + case 'f': { + Generator s = firstBit(f); + LFlags I1 = I & ~(lmask[s]); + switch ((irrType(G, I1))[0]) { + case 'B': + f &= ~(lmask[s]); return firstBit(f); - case 'd': + case 'F': + return s; + }; + } + case 'g': { + Generator s = firstBit(f); + Generator t = firstBit(G.star(I, s)); + CoxEntry m = G.M(s, t); + switch (m) { + case 3: + return s; + case 6: + f &= ~(lmask[s]); return firstBit(f); - case 'e': { - switch (l) - { - case 7: - return firstBit(f); - case 8: { - Generator n = firstBit(G.nodes(I)); - f &= ~(G.star(n)); - return firstBit(f); - } - case 9: { - Generator n = firstBit(G.nodes(I)); - f &= ~(G.star(n)); - Generator s = firstBit(f); - Generator t = firstBit(G.star(I,s)); - if (lmask[t] & G.star(n)) - { - f &= ~(lmask[s]); - return firstBit(f); - } - else - return s; - } - }; - } - case 'f': { - Generator s = firstBit(f); - LFlags I1 = I & ~(lmask[s]); - switch ((irrType(G,I1))[0]) - { - case 'B': - f &= ~(lmask[s]); - return firstBit(f); - case 'F': - return s; - }; - } - case 'g': { - Generator s = firstBit(f); - Generator t = firstBit(G.star(I,s)); - CoxEntry m = G.M(s,t); - switch (m) - { - case 3: - return s; - case 6: - f &= ~(lmask[s]); - return firstBit(f); - }; - } - default: - return lastBit(I); }; + } + default: + return lastBit(I); + }; } - -CoxEntry maxCoefficient(CoxGraph& G, LFlags I) +CoxEntry maxCoefficient(CoxGraph &G, LFlags I) /* Returns the maximal coefficient in the Coxeter matrix restricted to @@ -1929,24 +1846,21 @@ CoxEntry maxCoefficient(CoxGraph& G, LFlags I) CoxEntry m = 2; - for (LFlags fs = I; fs; fs &= fs-1) - { - Generator s = firstBit(fs); - for (LFlags ft = fs&G.star(s); ft; ft &= ft-1) - { - Generator t = firstBit(ft); - if (G.M(s,t) == 0) - return 0; - if (G.M(s,t) > m) - m = G.M(s,t); - } + for (LFlags fs = I; fs; fs &= fs - 1) { + Generator s = firstBit(fs); + for (LFlags ft = fs & G.star(s); ft; ft &= ft - 1) { + Generator t = firstBit(ft); + if (G.M(s, t) == 0) + return 0; + if (G.M(s, t) > m) + m = G.M(s, t); } + } return m; } - -CoxEntry minCoefficient(CoxGraph& G, LFlags I) +CoxEntry minCoefficient(CoxGraph &G, LFlags I) /* Returns the minimal coefficient > 2 in the Coxeter matrix restricted @@ -1958,19 +1872,18 @@ CoxEntry minCoefficient(CoxGraph& G, LFlags I) if (bitCount(I) == 1) return 1; - CoxEntry m = maxCoefficient(G,I); + CoxEntry m = maxCoefficient(G, I); if (m == 2) return 2; for (Generator s = 0; s < G.rank(); s++) - for (LFlags f = I&G.star(s); f; f &= f-1) - { - Generator t = firstBit(f); - if ((G.M(s,t) != 0) && (G.M(s,t) < m)) - m = G.M(s,t); - } + for (LFlags f = I & G.star(s); f; f &= f - 1) { + Generator t = firstBit(f); + if ((G.M(s, t) != 0) && (G.M(s, t) < m)) + m = G.M(s, t); + } return m; } -}; +}; // namespace diff --git a/graph.h b/graph.h index 80c5603..d666a52 100644 --- a/graph.h +++ b/graph.h @@ -7,7 +7,7 @@ /* type definitions */ -#ifndef GRAPH_H /* guarantee single inclusion */ +#ifndef GRAPH_H /* guarantee single inclusion */ #define GRAPH_H #include "globals.h" @@ -18,84 +18,87 @@ #include "type.h" namespace graph { - using namespace coxeter; - using namespace list; - using namespace bits; - using namespace coxtypes; - using namespace memory; +using namespace coxeter; +using namespace list; +using namespace bits; +using namespace coxtypes; +using namespace memory; /* type declarations */ - class CoxGraph; - typedef unsigned short CoxEntry; - typedef List CoxMatrix; +class CoxGraph; +typedef unsigned short CoxEntry; +typedef List CoxMatrix; /* constants */ - const Ulong SBITMAP_MAX = RANK_MAX/CHAR_BIT + (bool)(RANK_MAX%CHAR_BIT); - /* a CoxNbr should hold at least 2 COXENTRY_MAX elements */ - static const CoxEntry COXENTRY_MAX = 32763; - static const CoxEntry undef_coxentry = USHRT_MAX; - static const CoxEntry infty = 0; +const Ulong SBITMAP_MAX = RANK_MAX / CHAR_BIT + (bool)(RANK_MAX % CHAR_BIT); +/* a CoxNbr should hold at least 2 COXENTRY_MAX elements */ +static const CoxEntry COXENTRY_MAX = 32763; +static const CoxEntry undef_coxentry = USHRT_MAX; +static const CoxEntry infty = 0; /******** function declarations **********************************************/ - void getConjugacyClasses(List& cl, const CoxGraph& G); - bool isAffine(CoxGraph& G, LFlags I); - bool isConnected(CoxGraph& G, LFlags I); - bool isCrystallographic(CoxGraph& G, LFlags I); - bool isFinite(CoxGraph& G, LFlags I); - bool isLoop(CoxGraph& G, LFlags I); - bool isSimplyLaced(CoxGraph& G, LFlags I); - bool isTree(CoxGraph& G, LFlags I); - CoxSize order(CoxGraph& G, LFlags I); - ParSize quotOrder(CoxGraph& G, LFlags I, LFlags J); - Generator *standardEnumeration(CoxGraph& G, LFlags I); - const Type& type(CoxGraph& G, LFlags I); +void getConjugacyClasses(List &cl, const CoxGraph &G); +bool isAffine(CoxGraph &G, LFlags I); +bool isConnected(CoxGraph &G, LFlags I); +bool isCrystallographic(CoxGraph &G, LFlags I); +bool isFinite(CoxGraph &G, LFlags I); +bool isLoop(CoxGraph &G, LFlags I); +bool isSimplyLaced(CoxGraph &G, LFlags I); +bool isTree(CoxGraph &G, LFlags I); +CoxSize order(CoxGraph &G, LFlags I); +ParSize quotOrder(CoxGraph &G, LFlags I, LFlags J); +Generator *standardEnumeration(CoxGraph &G, LFlags I); +const Type &type(CoxGraph &G, LFlags I); /* type definitions */ -class CoxGraph -{ - private: +class CoxGraph { +private: Type d_type; Rank d_rank; CoxMatrix d_matrix; LFlags d_S; List d_star; List d_starOps; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(CoxGraph));} - CoxGraph(const Type& x, const Rank& l); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(CoxGraph)); + } + CoxGraph(const Type &x, const Rank &l); ~CoxGraph(); -/* accessors */ - LFlags component(LFlags I,Generator s) const; + /* accessors */ + LFlags component(LFlags I, Generator s) const; LFlags extremities(LFlags I) const; - CoxEntry M(Generator s, Generator t) const; /* inlined */ + CoxEntry M(Generator s, Generator t) const; /* inlined */ LFlags nodes(LFlags I) const; - Rank rank() const; /* inlined */ - LFlags supp() const; /* inlined */ - LFlags star(Generator s) const; /* inlined */ - LFlags star(LFlags I, Generator s) const; /* inlined */ - const List& starOps() const; /* inlined */ - const Type& type() const; /* inlined */ + Rank rank() const; /* inlined */ + LFlags supp() const; /* inlined */ + LFlags star(Generator s) const; /* inlined */ + LFlags star(LFlags I, Generator s) const; /* inlined */ + const List &starOps() const; /* inlined */ + const Type &type() const; /* inlined */ }; /******** inline definitions **********************************************/ - inline CoxEntry CoxGraph::M(Generator s, Generator t) const - {return(d_matrix[s*d_rank + t]);} - inline Rank CoxGraph::rank() const {return d_rank;} - inline LFlags CoxGraph::supp() const {return d_S;} - inline LFlags CoxGraph::star(Generator s) const {return(d_star[s]);} - inline LFlags CoxGraph::star(LFlags I, Generator s) const - {return(d_star[s]&I);} - inline const List& CoxGraph::starOps() const {return d_starOps;} - inline const Type& CoxGraph::type() const {return d_type;} - -}; +inline CoxEntry CoxGraph::M(Generator s, Generator t) const { + return (d_matrix[s * d_rank + t]); +} +inline Rank CoxGraph::rank() const { return d_rank; } +inline LFlags CoxGraph::supp() const { return d_S; } +inline LFlags CoxGraph::star(Generator s) const { return (d_star[s]); } +inline LFlags CoxGraph::star(LFlags I, Generator s) const { + return (d_star[s] & I); +} +inline const List &CoxGraph::starOps() const { return d_starOps; } +inline const Type &CoxGraph::type() const { return d_type; } + +}; // namespace graph #endif diff --git a/hecke.h b/hecke.h index aa5dc43..e44b5d2 100644 --- a/hecke.h +++ b/hecke.h @@ -1,11 +1,11 @@ /* This is hecke.h - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ -#ifndef HECKE_H /* guard against multiple inclusions */ +#ifndef HECKE_H /* guard against multiple inclusions */ #define HECKE_H #include "globals.h" @@ -14,11 +14,11 @@ /******** type declarations *************************************************/ namespace hecke { - template class HeckeMonomial; - template struct NFCompare; - template class HeckeIterator; - template class ToCoxNbr; -}; +template class HeckeMonomial; +template struct NFCompare; +template class HeckeIterator; +template class ToCoxNbr; +}; // namespace hecke /******** function declarations *********************************************/ @@ -26,88 +26,95 @@ namespace hecke { #include "schubert.h" namespace hecke { - using namespace interface; - using namespace schubert; -}; +using namespace interface; +using namespace schubert; +}; // namespace hecke namespace hecke { - template - void append(String& str, const HeckeMonomial

& m, const SchubertContext& p, - const Interface& I); - template - void prettyPrint(FILE* file, const List >& h, - const Permutation& a, const SchubertContext& p, - const Interface& I, const Length& l, - const Ulong &ls = LINESIZE); - template - void printBasis(FILE* f, const List >& h, - const Interface& I); - template - void singularStratification(List >& hs, - const List >& h, - const SchubertContext& p); -}; +template +void append(String &str, const HeckeMonomial

&m, const SchubertContext &p, + const Interface &I); +template +void prettyPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, + const Ulong &ls = LINESIZE); +template +void printBasis(FILE *f, const List> &h, const Interface &I); +template +void singularStratification(List> &hs, + const List> &h, + const SchubertContext &p); +}; // namespace hecke /******** type definitions **************************************************/ namespace hecke { -template class HeckeMonomial { - private: +template class HeckeMonomial { +private: CoxNbr d_x; - const P* d_pol; - public: + const P *d_pol; + +public: typedef P PolType; -/* constructors and destructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(HeckeMonomial));} - HeckeMonomial() {}; - HeckeMonomial(const CoxNbr& x, const P* pol); + /* constructors and destructors */ + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(HeckeMonomial)); + } + HeckeMonomial(){}; + HeckeMonomial(const CoxNbr &x, const P *pol); ~HeckeMonomial(); -/* accessors */ - bool operator> (const HeckeMonomial& m); - const P& pol() const; /* inlined */ - CoxNbr x() const; /* inlined */ -/* manipulators */ - void setData(const CoxNbr& x, const P* pol); + /* accessors */ + bool operator>(const HeckeMonomial &m); + const P &pol() const; /* inlined */ + CoxNbr x() const; /* inlined */ + /* manipulators */ + void setData(const CoxNbr &x, const P *pol); }; -template class ToCoxNbr { - private: - const List >* d_h; - public: - ToCoxNbr(const List >* h):d_h(h) {}; - ~ToCoxNbr() {}; - CoxNbr operator() (const Ulong& j) {return (*d_h)[j].x();} -}; +template class ToCoxNbr { +private: + const List> *d_h; -template struct NFCompare { - const SchubertContext& p; - const Permutation& order; - NFCompare(const SchubertContext& q, const Permutation& generator_ordering) - :p(q),order(generator_ordering) {}; - ~NFCompare() {}; - bool operator()(const HeckeMonomial

& a, const HeckeMonomial

& b) const - {return shortLexOrder(p,a.x(),b.x(),order);} +public: + ToCoxNbr(const List> *h) : d_h(h){}; + ~ToCoxNbr(){}; + CoxNbr operator()(const Ulong &j) { return (*d_h)[j].x(); } }; +template struct NFCompare { + const SchubertContext &p; + const Permutation ℴ + NFCompare(const SchubertContext &q, const Permutation &generator_ordering) + : p(q), order(generator_ordering){}; + ~NFCompare(){}; + bool operator()(const HeckeMonomial

&a, const HeckeMonomial

&b) const { + return shortLexOrder(p, a.x(), b.x(), order); + } }; +}; // namespace hecke + /******** inline definitions ************************************************/ namespace hecke { -template -inline bool HeckeMonomial

::operator> (const HeckeMonomial

& m) - {return d_x > m.d_x;} -template inline const P& HeckeMonomial

::pol() const - {return *d_pol;} -template inline CoxNbr HeckeMonomial

::x() const {return d_x;} -template -inline void HeckeMonomial

::setData(const CoxNbr& x, const P* pol) - {d_x = x; d_pol = pol;} - -}; +template +inline bool HeckeMonomial

::operator>(const HeckeMonomial

&m) { + return d_x > m.d_x; +} +template inline const P &HeckeMonomial

::pol() const { + return *d_pol; +} +template inline CoxNbr HeckeMonomial

::x() const { return d_x; } +template +inline void HeckeMonomial

::setData(const CoxNbr &x, const P *pol) { + d_x = x; + d_pol = pol; +} + +}; // namespace hecke #include "hecke.hpp" diff --git a/hecke.hpp b/hecke.hpp index 425ebb0..15351f5 100644 --- a/hecke.hpp +++ b/hecke.hpp @@ -1,6 +1,6 @@ /* This is hecke.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -8,7 +8,7 @@ #include "polynomials.h" namespace hecke { - using namespace polynomials; +using namespace polynomials; }; /***************************************************************************** @@ -28,29 +28,29 @@ namespace hecke { ******************************************************************************/ namespace { - using namespace hecke; - - template struct PPtrF { - typedef const P* valueType; - valueType operator() (const HeckeMonomial

& m) {return &m.pol();} - }; - - template - void appendStar(String& str, const HeckeMonomial

& m, - const SchubertContext& p, const Length& l); - template - Ulong maxLength(const List >& h, const SchubertContext& p, - const Interface& I, const Length& l); - template - void oneColumnPrint(FILE* file, const List >& h, - const Permutation& a, const SchubertContext& p, - const Interface& I, const Length& l, const Ulong& ls); - template - void twoColumnPrint(FILE* file, const List >& h, - const Permutation&a, const SchubertContext& p, - const Interface& I, const Length& l, const Ulong& ls); +using namespace hecke; + +template struct PPtrF { + typedef const P *valueType; + valueType operator()(const HeckeMonomial

&m) { return &m.pol(); } }; +template +void appendStar(String &str, const HeckeMonomial

&m, + const SchubertContext &p, const Length &l); +template +Ulong maxLength(const List> &h, const SchubertContext &p, + const Interface &I, const Length &l); +template +void oneColumnPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, const Ulong &ls); +template +void twoColumnPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, const Ulong &ls); +}; // namespace + /***************************************************************************** Chapter II -- The HeckeMonomial class. @@ -76,12 +76,13 @@ namespace { namespace hecke { template -HeckeMonomial

::HeckeMonomial(const CoxNbr& x, const P* pol) - :d_x(x), d_pol(pol) +HeckeMonomial

::HeckeMonomial(const CoxNbr &x, const P *pol) + : d_x(x), d_pol(pol) {} -template HeckeMonomial

::~HeckeMonomial() +template +HeckeMonomial

::~HeckeMonomial() /* Automatic destruction is enough. @@ -89,7 +90,7 @@ template HeckeMonomial

::~HeckeMonomial() {} -}; +}; // namespace hecke /***************************************************************************** @@ -98,7 +99,7 @@ template HeckeMonomial

::~HeckeMonomial() This section defines some utility functions declared in hecke.h : - append(str,m,p,I) : appends m to str using I; - - appendStar(str,m,p,l) : appends a star to str if there is a + - appendStar(str,m,p,l) : appends a star to str if there is a mu-coefficient; - maxLength(h,p,I,l) : computes the maximal length of an output line; - oneColumnPrint(h,p,I,l,ls) : does one-column output; @@ -112,58 +113,58 @@ template HeckeMonomial

::~HeckeMonomial() namespace hecke { -template -void append(String& str, const HeckeMonomial

& m, const SchubertContext& p, - const Interface& I) +template +void append(String &str, const HeckeMonomial

&m, const SchubertContext &p, + const Interface &I) /* Outputs m to str. */ -{ - p.append(str,m.x(),I); - io::append(str," : "); - polynomials::append(str,m.pol(),"q"); +{ + p.append(str, m.x(), I); + io::append(str, " : "); + polynomials::append(str, m.pol(), "q"); return; } -}; +}; // namespace hecke namespace { -template -void appendStar(String& str, const HeckeMonomial

& m, - const SchubertContext& p, const Length& l) +template +void appendStar(String &str, const HeckeMonomial

&m, + const SchubertContext &p, const Length &l) { Length lx = p.length(m.x()); - - if (static_cast(2*m.pol().deg()) == static_cast(l-lx-1)) - append(str," *"); + + if (static_cast(2 * m.pol().deg()) == static_cast(l - lx - 1)) + append(str, " *"); return; } -template -Ulong maxLength(const List >& h, const SchubertContext& p, - const Interface& I, const Length& l) +template +Ulong maxLength(const List> &h, const SchubertContext &p, + const Interface &I, const Length &l) /* Returns the length of the longest line that would be printed out by oneColumnPrint(file,h,I,l). This is a preliminary to prettyprinting. */ -{ +{ static String buf(0); Ulong maxl = 0; for (Ulong j = 0; j < h.size(); ++j) { reset(buf); - const HeckeMonomial

& m = h[j]; - hecke::append(buf,m,p,I); - appendStar(buf,m,p,l); + const HeckeMonomial

&m = h[j]; + hecke::append(buf, m, p, I); + appendStar(buf, m, p, l); if (maxl < buf.length()) maxl = buf.length(); } @@ -171,14 +172,10 @@ Ulong maxLength(const List >& h, const SchubertContext& p, return maxl; } -template -void oneColumnPrint(FILE* file, - const List >& h, - const Permutation& a, - const SchubertContext& p, - const Interface& I, - const Length& l, - const Ulong& ls) +template +void oneColumnPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, const Ulong &ls) /* This function prints out the row in one-column format, trying to fold long @@ -190,25 +187,21 @@ void oneColumnPrint(FILE* file, for (Ulong j = 0; j < h.size(); ++j) { reset(buf); - hecke::append(buf,h[a[j]],p,I); - appendStar(buf,h[a[j]],p,l); - foldLine(file,buf,ls,4,"+"); - fprintf(file,"\n"); + hecke::append(buf, h[a[j]], p, I); + appendStar(buf, h[a[j]], p, l); + foldLine(file, buf, ls, 4, "+"); + fprintf(file, "\n"); } } -}; +}; // namespace namespace hecke { -template -void prettyPrint(FILE* file, - const List >& h, - const Permutation& a, - const SchubertContext& p, - const Interface& I, - const Length& l, - const Ulong& ls) +template +void prettyPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, const Ulong &ls) /* This function does the prettyprinting of h to the file. The formatting @@ -222,25 +215,25 @@ void prettyPrint(FILE* file, { static String buf(0); - Ulong maxl = maxLength(h,p,I,l); - Ulong hl = (ls-1)/2; + Ulong maxl = maxLength(h, p, I, l); + Ulong hl = (ls - 1) / 2; if (maxl > hl) - return oneColumnPrint(file,h,a,p,I,l,ls); + return oneColumnPrint(file, h, a, p, I, l, ls); else - return twoColumnPrint(file,h,a,p,I,l,ls); + return twoColumnPrint(file, h, a, p, I, l, ls); return; } -template -void singularStratification(List >& hs, - const List >& h, - const SchubertContext& p) +template +void singularStratification(List> &hs, + const List> &h, + const SchubertContext &p) /* - This function extracts the "rational singular stratification". By this we - mean that we sort by Kazhdan-Lusztig polynomials, and then consider maximal + This function extracts the "rational singular stratification". By this we + mean that we sort by Kazhdan-Lusztig polynomials, and then consider maximal elements (for the Bruhat ordering) in each class. Geometrically, when the Bruhat ordering comes from the stratification @@ -269,7 +262,7 @@ void singularStratification(List >& hs, /* sort row by kl-polynomial */ PPtrF

f; - Partition pi(h.begin(),h.end(),f); + Partition pi(h.begin(), h.end(), f); /* find maximal elements in each class */ @@ -280,30 +273,26 @@ void singularStratification(List >& hs, if (h[m].pol().deg() == 0) // polynomial is one continue; ToCoxNbr

f(&h); - List c(i().begin(),i().end(),f); + List c(i().begin(), i().end(), f); List a(0); - extractMaximals(p,c,a); - hs.setSize(count+a.size()); + extractMaximals(p, c, a); + hs.setSize(count + a.size()); for (Ulong j = 0; j < a.size(); ++j) - hs[count+j] = h[i()[a[j]]]; + hs[count + j] = h[i()[a[j]]]; count += a.size(); } return; } -}; +}; // namespace hecke namespace { -template -void twoColumnPrint(FILE* file, - const List >& h, - const Permutation& a, - const SchubertContext& p, - const Interface& I, - const Length& l, - const Ulong& ls) +template +void twoColumnPrint(FILE *file, const List> &h, + const Permutation &a, const SchubertContext &p, + const Interface &I, const Length &l, const Ulong &ls) /* This function prints out the row in two-column format, on lines of length @@ -316,39 +305,32 @@ void twoColumnPrint(FILE* file, { static String buf(0); - Ulong hl = (ls-1)/2; /* width of output column */ - Ulong fl = h.size()/2; /* number of full lines */ + Ulong hl = (ls - 1) / 2; /* width of output column */ + Ulong fl = h.size() / 2; /* number of full lines */ Ulong i = 0; for (Ulong j = 0; j < fl; ++j) { /* print out a full line */ reset(buf); - hecke::append(buf,h[a[i]],p,I); - appendStar(buf,h[a[i]],p,l); - pad(buf,ls-hl); + hecke::append(buf, h[a[i]], p, I); + appendStar(buf, h[a[i]], p, l); + pad(buf, ls - hl); i++; - hecke::append(buf,h[a[i]],p,I); - appendStar(buf,h[a[i]],p,l); + hecke::append(buf, h[a[i]], p, I); + appendStar(buf, h[a[i]], p, l); i++; - print(file,buf); - fprintf(file,"\n"); + print(file, buf); + fprintf(file, "\n"); } - if (h.size()%2) { /* print out a half line */ + if (h.size() % 2) { /* print out a half line */ reset(buf); - hecke::append(buf,h[a[i]],p,I); - appendStar(buf,h[a[i]],p,l); - print(file,buf); - fprintf(file,"\n"); + hecke::append(buf, h[a[i]], p, I); + appendStar(buf, h[a[i]], p, l); + print(file, buf); + fprintf(file, "\n"); } return; } -}; - - - - - - - +}; // namespace diff --git a/help.cpp b/help.cpp index 2758542..9ca392e 100644 --- a/help.cpp +++ b/help.cpp @@ -1,6 +1,6 @@ /* This is help.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -12,9 +12,9 @@ #include "io.h" namespace help { - using namespace directories; - using namespace io; -}; +using namespace directories; +using namespace io; +}; // namespace help /************************************************************************* @@ -36,12 +36,12 @@ namespace help { void main_help() -{ +{ using namespace commands; - printFile(stderr,"main.help1",MESSAGE_DIR); - printCommands(stderr,mainCommandTree()->helpMode()); - printFile(stderr,"main.help2",MESSAGE_DIR); + printFile(stderr, "main.help1", MESSAGE_DIR); + printCommands(stderr, mainCommandTree()->helpMode()); + printFile(stderr, "main.help2", MESSAGE_DIR); return; } @@ -51,9 +51,9 @@ void interface_help() { using namespace commands; - printFile(stderr,"interface_m.help1",MESSAGE_DIR); - printCommands(stderr,interfaceCommandTree()->helpMode()); - printFile(stderr,"interface_m.help2",MESSAGE_DIR); + printFile(stderr, "interface_m.help1", MESSAGE_DIR); + printCommands(stderr, interfaceCommandTree()->helpMode()); + printFile(stderr, "interface_m.help2", MESSAGE_DIR); return; } @@ -65,9 +65,9 @@ void in_help() { using namespace commands; - printFile(stderr,"interface/in_m.help1",MESSAGE_DIR); - printCommands(stderr,commands::interface::inCommandTree()->helpMode()); - printFile(stderr,"interface/in_m.help2",MESSAGE_DIR); + printFile(stderr, "interface/in_m.help1", MESSAGE_DIR); + printCommands(stderr, commands::interface::inCommandTree()->helpMode()); + printFile(stderr, "interface/in_m.help2", MESSAGE_DIR); return; } @@ -77,35 +77,34 @@ void out_help() { using namespace commands; - printFile(stderr,"interface/out_m.help1",MESSAGE_DIR); - printCommands(stderr,commands::interface::outCommandTree()->helpMode()); - printFile(stderr,"interface/out_m.help2",MESSAGE_DIR); + printFile(stderr, "interface/out_m.help1", MESSAGE_DIR); + printCommands(stderr, commands::interface::outCommandTree()->helpMode()); + printFile(stderr, "interface/out_m.help2", MESSAGE_DIR); return; } -}; +}; // namespace interface void uneq_help() -{ +{ using namespace commands; - printFile(stderr,"uneq.help1",MESSAGE_DIR); - printCommands(stderr,uneqCommandTree()->helpMode()); - printFile(stderr,"uneq.help2",MESSAGE_DIR); + printFile(stderr, "uneq.help1", MESSAGE_DIR); + printCommands(stderr, uneqCommandTree()->helpMode()); + printFile(stderr, "uneq.help2", MESSAGE_DIR); return; } -}; - +}; // namespace help /************************************************************************* Chapter II : help functions for the commands of the program - + These are the functions invoked upon typing various commands in help mode. @@ -195,91 +194,91 @@ namespace help { void betti_h() { - printFile(stderr,"betti.help",MESSAGE_DIR); + printFile(stderr, "betti.help", MESSAGE_DIR); return; } void coatoms_h() { - printFile(stderr,"compute.help",MESSAGE_DIR); + printFile(stderr, "compute.help", MESSAGE_DIR); return; } void compute_h() { - printFile(stderr,"coatoms.help",MESSAGE_DIR); + printFile(stderr, "coatoms.help", MESSAGE_DIR); return; } void cr_h() { - printFile(stderr,"cr.help",MESSAGE_DIR); + printFile(stderr, "cr.help", MESSAGE_DIR); return; } void default_h() { - printFile(stderr,"default.help",MESSAGE_DIR); + printFile(stderr, "default.help", MESSAGE_DIR); return; } void descent_h() { - printFile(stderr,"descent.help",MESSAGE_DIR); + printFile(stderr, "descent.help", MESSAGE_DIR); return; } void duflo_h() { - printFile(stderr,"duflo.help",MESSAGE_DIR); + printFile(stderr, "duflo.help", MESSAGE_DIR); return; } void extremals_h() { - printFile(stderr,"extremals.help",MESSAGE_DIR); + printFile(stderr, "extremals.help", MESSAGE_DIR); return; } void fullcontext_h() { - printFile(stderr,"fullcontext.help",MESSAGE_DIR); + printFile(stderr, "fullcontext.help", MESSAGE_DIR); return; } void help_h() { - printFile(stderr,"help.help",MESSAGE_DIR); + printFile(stderr, "help.help", MESSAGE_DIR); return; } void ihbetti_h() { - printFile(stderr,"ihbetti.help",MESSAGE_DIR); + printFile(stderr, "ihbetti.help", MESSAGE_DIR); return; } void inorder_h() { - printFile(stderr,"inorder.help",MESSAGE_DIR); + printFile(stderr, "inorder.help", MESSAGE_DIR); return; } void input_h() { - printFile(stderr,"input.help",MESSAGE_DIR); + printFile(stderr, "input.help", MESSAGE_DIR); return; } @@ -288,16 +287,16 @@ void interface_h() { using namespace commands; - printFile(stderr,"interface.help",MESSAGE_DIR); - printCommands(stderr,interfaceCommandTree()->helpMode()); - fprintf(stderr,"\n"); + printFile(stderr, "interface.help", MESSAGE_DIR); + printCommands(stderr, interfaceCommandTree()->helpMode()); + fprintf(stderr, "\n"); return; } void interval_h() { - printFile(stderr,"interval.help",MESSAGE_DIR); + printFile(stderr, "interval.help", MESSAGE_DIR); return; } @@ -306,9 +305,9 @@ void intro_h() { using namespace commands; - printFile(stderr,"empty_m.help1",MESSAGE_DIR); - printCommands(stderr,mainCommandTree()->helpMode()); - printFile(stderr,"empty_m.help2",MESSAGE_DIR); + printFile(stderr, "empty_m.help1", MESSAGE_DIR); + printCommands(stderr, mainCommandTree()->helpMode()); + printFile(stderr, "empty_m.help2", MESSAGE_DIR); return; } @@ -316,98 +315,98 @@ void intro_h() void invpol_h() { - printFile(stderr,"invpol.help",MESSAGE_DIR); + printFile(stderr, "invpol.help", MESSAGE_DIR); return; } void klbasis_h() { - printFile(stderr,"klbasis.help",MESSAGE_DIR); + printFile(stderr, "klbasis.help", MESSAGE_DIR); return; } void lcorder_h() { - printFile(stderr,"lcorder.help",MESSAGE_DIR); + printFile(stderr, "lcorder.help", MESSAGE_DIR); return; } void lcells_h() { - printFile(stderr,"lcells.help",MESSAGE_DIR); + printFile(stderr, "lcells.help", MESSAGE_DIR); return; } void lcwgraphs_h() { - printFile(stderr,"lcwgraphs.help",MESSAGE_DIR); + printFile(stderr, "lcwgraphs.help", MESSAGE_DIR); return; } void lrcorder_h() { - printFile(stderr,"lrcorder.help",MESSAGE_DIR); + printFile(stderr, "lrcorder.help", MESSAGE_DIR); return; } void lrcells_h() { - printFile(stderr,"lrcells.help",MESSAGE_DIR); + printFile(stderr, "lrcells.help", MESSAGE_DIR); return; } void lrcwgraphs_h() { - printFile(stderr,"lrcwgraphs.help",MESSAGE_DIR); + printFile(stderr, "lrcwgraphs.help", MESSAGE_DIR); return; } void lrwgraph_h() { - printFile(stderr,"lrwgraph.help",MESSAGE_DIR); + printFile(stderr, "lrwgraph.help", MESSAGE_DIR); return; } void lwgraph_h() { - printFile(stderr,"lwgraph.help",MESSAGE_DIR); + printFile(stderr, "lwgraph.help", MESSAGE_DIR); return; } void matrix_h() { - printFile(stderr,"matrix.help",MESSAGE_DIR); + printFile(stderr, "matrix.help", MESSAGE_DIR); return; } void mu_h() { - printFile(stderr,"mu.help",MESSAGE_DIR); + printFile(stderr, "mu.help", MESSAGE_DIR); return; } void pol_h() { - printFile(stderr,"pol.help",MESSAGE_DIR); + printFile(stderr, "pol.help", MESSAGE_DIR); return; } void rwgraph_h() { - printFile(stderr,"rwgraph.help",MESSAGE_DIR); + printFile(stderr, "rwgraph.help", MESSAGE_DIR); return; } @@ -419,91 +418,91 @@ void q_h() */ { - printFile(stderr,"q.help",MESSAGE_DIR); + printFile(stderr, "q.help", MESSAGE_DIR); return; } void qq_h() { - printFile(stderr,"qq.help",MESSAGE_DIR); + printFile(stderr, "qq.help", MESSAGE_DIR); return; } void rank_h() { - printFile(stderr,"rank.help",MESSAGE_DIR); + printFile(stderr, "rank.help", MESSAGE_DIR); return; } void rcorder_h() { - printFile(stderr,"rcorder.help",MESSAGE_DIR); + printFile(stderr, "rcorder.help", MESSAGE_DIR); return; } void rcells_h() { - printFile(stderr,"rcells.help",MESSAGE_DIR); + printFile(stderr, "rcells.help", MESSAGE_DIR); return; } void rcwgraphs_h() { - printFile(stderr,"rcwgraphs.help",MESSAGE_DIR); + printFile(stderr, "rcwgraphs.help", MESSAGE_DIR); return; } void schubert_h() { - printFile(stderr,"schubert.help",MESSAGE_DIR); + printFile(stderr, "schubert.help", MESSAGE_DIR); return; } void show_h() { - printFile(stderr,"show.help",MESSAGE_DIR); + printFile(stderr, "show.help", MESSAGE_DIR); return; } void showmu_h() { - printFile(stderr,"showmu.help",MESSAGE_DIR); + printFile(stderr, "showmu.help", MESSAGE_DIR); return; } void slocus_h() { - printFile(stderr,"slocus.help",MESSAGE_DIR); + printFile(stderr, "slocus.help", MESSAGE_DIR); return; } void sstratification_h() { - printFile(stderr,"sstratification.help",MESSAGE_DIR); + printFile(stderr, "sstratification.help", MESSAGE_DIR); return; } void type_h() { - printFile(stderr,"type.help",MESSAGE_DIR); + printFile(stderr, "type.help", MESSAGE_DIR); return; } void uneq_h() { - printFile(stderr,"uneq.help",MESSAGE_DIR); + printFile(stderr, "uneq.help", MESSAGE_DIR); return; } @@ -512,322 +511,322 @@ namespace uneq { void klbasis_h() { - printFile(stderr,"uneq/klbasis.help",MESSAGE_DIR); + printFile(stderr, "uneq/klbasis.help", MESSAGE_DIR); return; } void lcorder_h() { - printFile(stderr,"uneq/lcorder.help",MESSAGE_DIR); + printFile(stderr, "uneq/lcorder.help", MESSAGE_DIR); return; } void lcells_h() { - printFile(stderr,"uneq/lcells.help",MESSAGE_DIR); + printFile(stderr, "uneq/lcells.help", MESSAGE_DIR); return; } void lrcorder_h() { - printFile(stderr,"uneq/lrcorder.help",MESSAGE_DIR); + printFile(stderr, "uneq/lrcorder.help", MESSAGE_DIR); return; } void lrcells_h() { - printFile(stderr,"uneq/lrcells.help",MESSAGE_DIR); + printFile(stderr, "uneq/lrcells.help", MESSAGE_DIR); return; } void mu_h() { - printFile(stderr,"uneq/mu.help",MESSAGE_DIR); + printFile(stderr, "uneq/mu.help", MESSAGE_DIR); return; } void pol_h() { - printFile(stderr,"uneq/pol.help",MESSAGE_DIR); + printFile(stderr, "uneq/pol.help", MESSAGE_DIR); return; } void rcells_h() { - printFile(stderr,"uneq/rcells.help",MESSAGE_DIR); + printFile(stderr, "uneq/rcells.help", MESSAGE_DIR); return; } void rcorder_h() { - printFile(stderr,"uneq/rcorder.help",MESSAGE_DIR); + printFile(stderr, "uneq/rcorder.help", MESSAGE_DIR); return; } -}; +}; // namespace uneq namespace interface { void abort_h() { - printFile(stderr,"interface/abort.help",MESSAGE_DIR); + printFile(stderr, "interface/abort.help", MESSAGE_DIR); return; } void alphabetic_h() { - printFile(stderr,"interface/alphabetic.help",MESSAGE_DIR); + printFile(stderr, "interface/alphabetic.help", MESSAGE_DIR); return; } void bourbaki_h() { - printFile(stderr,"interface/bourbaki.help",MESSAGE_DIR); + printFile(stderr, "interface/bourbaki.help", MESSAGE_DIR); return; } void decimal_h() { - printFile(stderr,"interface/decimal.help",MESSAGE_DIR); + printFile(stderr, "interface/decimal.help", MESSAGE_DIR); return; } void gap_h() { - printFile(stderr,"interface/gap.help",MESSAGE_DIR); + printFile(stderr, "interface/gap.help", MESSAGE_DIR); return; } void default_h() { - printFile(stderr,"interface/default.help",MESSAGE_DIR); + printFile(stderr, "interface/default.help", MESSAGE_DIR); return; } void hexadecimal_h() { - printFile(stderr,"interface/hexadecimal.help",MESSAGE_DIR); + printFile(stderr, "interface/hexadecimal.help", MESSAGE_DIR); return; } -void in_h () +void in_h() { - printFile(stderr,"interface/in.help",MESSAGE_DIR); + printFile(stderr, "interface/in.help", MESSAGE_DIR); return; } void ordering_h() { - printFile(stderr,"interface/ordering.help",MESSAGE_DIR); + printFile(stderr, "interface/ordering.help", MESSAGE_DIR); return; } void out_h() { - printFile(stderr,"interface/out.help",MESSAGE_DIR); + printFile(stderr, "interface/out.help", MESSAGE_DIR); return; } void permutation_h() { - printFile(stderr,"interface/permutation.help",MESSAGE_DIR); + printFile(stderr, "interface/permutation.help", MESSAGE_DIR); return; } void terse_h() { - printFile(stderr,"interface/terse.help",MESSAGE_DIR); + printFile(stderr, "interface/terse.help", MESSAGE_DIR); return; } void in::alphabetic_h() { - printFile(stderr,"interface/in/alphabetic.help",MESSAGE_DIR); + printFile(stderr, "interface/in/alphabetic.help", MESSAGE_DIR); return; } void in::bourbaki_h() { - printFile(stderr,"interface/in/bourbaki.help",MESSAGE_DIR); + printFile(stderr, "interface/in/bourbaki.help", MESSAGE_DIR); return; } void in::decimal_h() { - printFile(stderr,"interface/in/decimal.help",MESSAGE_DIR); + printFile(stderr, "interface/in/decimal.help", MESSAGE_DIR); return; } void in::default_h() { - printFile(stderr,"interface/in/default.help",MESSAGE_DIR); + printFile(stderr, "interface/in/default.help", MESSAGE_DIR); return; } void in::gap_h() { - printFile(stderr,"interface/in/gap.help",MESSAGE_DIR); + printFile(stderr, "interface/in/gap.help", MESSAGE_DIR); return; } void in::hexadecimal_h() { - printFile(stderr,"interface/in/hexadecimal.help",MESSAGE_DIR); + printFile(stderr, "interface/in/hexadecimal.help", MESSAGE_DIR); return; } void in::permutation_h() { - printFile(stderr,"interface/in/permutation.help",MESSAGE_DIR); + printFile(stderr, "interface/in/permutation.help", MESSAGE_DIR); return; } void in::postfix_h() { - printFile(stderr,"interface/in/postfix.help",MESSAGE_DIR); + printFile(stderr, "interface/in/postfix.help", MESSAGE_DIR); return; } void in::prefix_h() { - printFile(stderr,"interface/in/prefix.help",MESSAGE_DIR); + printFile(stderr, "interface/in/prefix.help", MESSAGE_DIR); return; } void in::separator_h() { - printFile(stderr,"interface/in/separator.help",MESSAGE_DIR); + printFile(stderr, "interface/in/separator.help", MESSAGE_DIR); return; } void in::symbol_h() { - printFile(stderr,"interface/in/symbol.help",MESSAGE_DIR); + printFile(stderr, "interface/in/symbol.help", MESSAGE_DIR); return; } void in::terse_h() { - printFile(stderr,"interface/in/terse.help",MESSAGE_DIR); + printFile(stderr, "interface/in/terse.help", MESSAGE_DIR); return; } void out::alphabetic_h() { - printFile(stderr,"interface/out/alphabetic.help",MESSAGE_DIR); + printFile(stderr, "interface/out/alphabetic.help", MESSAGE_DIR); return; } void out::bourbaki_h() { - printFile(stderr,"interface/out/bourbaki.help",MESSAGE_DIR); + printFile(stderr, "interface/out/bourbaki.help", MESSAGE_DIR); return; } void out::decimal_h() { - printFile(stderr,"interface/out/decimal.help",MESSAGE_DIR); + printFile(stderr, "interface/out/decimal.help", MESSAGE_DIR); return; } void out::default_h() { - printFile(stderr,"interface/out/default.help",MESSAGE_DIR); + printFile(stderr, "interface/out/default.help", MESSAGE_DIR); return; } void out::gap_h() { - printFile(stderr,"interface/out/gap.help",MESSAGE_DIR); + printFile(stderr, "interface/out/gap.help", MESSAGE_DIR); return; } void out::hexadecimal_h() { - printFile(stderr,"interface/out/hexadecimal.help",MESSAGE_DIR); + printFile(stderr, "interface/out/hexadecimal.help", MESSAGE_DIR); return; } void out::permutation_h() { - printFile(stderr,"interface/out/permutation.help",MESSAGE_DIR); + printFile(stderr, "interface/out/permutation.help", MESSAGE_DIR); return; } void out::postfix_h() { - printFile(stderr,"interface/out/postfix.help",MESSAGE_DIR); + printFile(stderr, "interface/out/postfix.help", MESSAGE_DIR); return; } void out::prefix_h() { - printFile(stderr,"interface/out/prefix.help",MESSAGE_DIR); + printFile(stderr, "interface/out/prefix.help", MESSAGE_DIR); return; } void out::separator_h() { - printFile(stderr,"interface/out/separator.help",MESSAGE_DIR); + printFile(stderr, "interface/out/separator.help", MESSAGE_DIR); return; } void out::symbol_h() { - printFile(stderr,"interface/out/symbol.help",MESSAGE_DIR); + printFile(stderr, "interface/out/symbol.help", MESSAGE_DIR); return; } void out::terse_h() { - printFile(stderr,"interface/out/terse.help",MESSAGE_DIR); + printFile(stderr, "interface/out/terse.help", MESSAGE_DIR); return; } -}; +}; // namespace interface -}; +}; // namespace help diff --git a/help.h b/help.h index 27ec549..e51f4bc 100644 --- a/help.h +++ b/help.h @@ -5,119 +5,119 @@ See file main.cpp for full copyright notice */ -#ifndef HELP_H /* guard against multiple inclusions */ +#ifndef HELP_H /* guard against multiple inclusions */ #define HELP_H #include "globals.h" namespace help { - using namespace coxeter; +using namespace coxeter; /* modes */ - void main_help(); - void interface_help(); - void uneq_help(); +void main_help(); +void interface_help(); +void uneq_help(); /* commands */ - void betti_h(); - void coatoms_h(); - void compute_h(); - void cr_h(); - void default_h(); - void descent_h(); - void duflo_h(); - void extremals_h(); - void fullcontext_h(); - void help_h(); - void ihbetti_h(); - void inorder_h(); - void interface_h(); - void interval_h(); - void input_h(); - void intro_h(); - void invpol_h(); - void klbasis_h(); - void lcorder_h(); - void lcells_h(); - void lcwgraphs_h(); - void lrcorder_h(); - void lrcells_h(); - void lrcwgraphs_h(); - void lrwgraph_h(); - void lwgraph_h(); - void matrix_h(); - void mu_h(); - void ordering_h(); - void pol_h(); - void q_h(); - void qq_h(); - void rank_h(); - void rcorder_h(); - void rcells_h(); - void rcwgraphs_h(); - void rwgraph_h(); - void schubert_h(); - void show_h(); - void showmu_h(); - void slocus_h(); - void sstratification_h(); - void type_h(); - void uneq_h(); - namespace uneq{ - void klbasis_h(); - void lcorder_h(); - void lrcorder_h(); - void lcells_h(); - void lrcells_h(); - void mu_h(); - void pol_h(); - void rcells_h(); - void rcorder_h(); - }; -/* special modes */ - namespace interface { - void abort_h(); - void alphabetic_h(); - void bourbaki_h(); - void decimal_h(); - void default_h(); - void gap_h(); - void hexadecimal_h(); - void in_h (); - void ordering_h(); - void out_h (); - void permutation_h(); - void in_help (); - void out_help (); - void terse_h(); - namespace in { - void alphabetic_h(); - void bourbaki_h(); - void decimal_h(); - void default_h(); - void gap_h(); - void hexadecimal_h(); - void permutation_h(); - void postfix_h(); - void prefix_h(); - void separator_h(); - void symbol_h(); - void terse_h(); - }; - namespace out { - void alphabetic_h(); - void bourbaki_h(); - void decimal_h(); - void default_h(); - void gap_h(); - void hexadecimal_h(); - void permutation_h(); - void postfix_h(); - void prefix_h(); - void separator_h(); - void symbol_h(); - void terse_h(); - }; - } -}; +void betti_h(); +void coatoms_h(); +void compute_h(); +void cr_h(); +void default_h(); +void descent_h(); +void duflo_h(); +void extremals_h(); +void fullcontext_h(); +void help_h(); +void ihbetti_h(); +void inorder_h(); +void interface_h(); +void interval_h(); +void input_h(); +void intro_h(); +void invpol_h(); +void klbasis_h(); +void lcorder_h(); +void lcells_h(); +void lcwgraphs_h(); +void lrcorder_h(); +void lrcells_h(); +void lrcwgraphs_h(); +void lrwgraph_h(); +void lwgraph_h(); +void matrix_h(); +void mu_h(); +void ordering_h(); +void pol_h(); +void q_h(); +void qq_h(); +void rank_h(); +void rcorder_h(); +void rcells_h(); +void rcwgraphs_h(); +void rwgraph_h(); +void schubert_h(); +void show_h(); +void showmu_h(); +void slocus_h(); +void sstratification_h(); +void type_h(); +void uneq_h(); +namespace uneq { +void klbasis_h(); +void lcorder_h(); +void lrcorder_h(); +void lcells_h(); +void lrcells_h(); +void mu_h(); +void pol_h(); +void rcells_h(); +void rcorder_h(); +}; // namespace uneq + /* special modes */ +namespace interface { +void abort_h(); +void alphabetic_h(); +void bourbaki_h(); +void decimal_h(); +void default_h(); +void gap_h(); +void hexadecimal_h(); +void in_h(); +void ordering_h(); +void out_h(); +void permutation_h(); +void in_help(); +void out_help(); +void terse_h(); +namespace in { +void alphabetic_h(); +void bourbaki_h(); +void decimal_h(); +void default_h(); +void gap_h(); +void hexadecimal_h(); +void permutation_h(); +void postfix_h(); +void prefix_h(); +void separator_h(); +void symbol_h(); +void terse_h(); +}; // namespace in +namespace out { +void alphabetic_h(); +void bourbaki_h(); +void decimal_h(); +void default_h(); +void gap_h(); +void hexadecimal_h(); +void permutation_h(); +void postfix_h(); +void prefix_h(); +void separator_h(); +void symbol_h(); +void terse_h(); +}; // namespace out +} // namespace interface +}; // namespace help #endif diff --git a/interactive.cpp b/interactive.cpp index 4dddfb5..88987e8 100644 --- a/interactive.cpp +++ b/interactive.cpp @@ -21,14 +21,14 @@ #include "typeA.h" namespace interactive { - using namespace affine; - using namespace automata; - using namespace coxeter; - using namespace error; - using namespace fcoxgroup; - using namespace general; - using namespace io; -}; +using namespace affine; +using namespace automata; +using namespace coxeter; +using namespace error; +using namespace fcoxgroup; +using namespace general; +using namespace io; +}; // namespace interactive /**************************************************************************** @@ -43,32 +43,32 @@ namespace interactive { /* local variables */ namespace { - using namespace interactive; - const Letter generator_type = 0; -}; +using namespace interactive; +const Letter generator_type = 0; +}; // namespace /******** local declarations ************************************************/ namespace { - void checkCoxElement(CoxGroup *W, CoxWord g); - void checkCoxEntry(Rank i, Rank j, Ulong m); - void checkFilename(char *s); - void checkLength(const long& l); - void checkRank(const Rank& l, const Type& type); - void checkType(String& buf); - void getCoxFileName(String& buf); - Ulong parse(const Interface& I, Generator &s, const String& line); - Ulong parse(const Interface& I, Generator &s, const String& line, - const LFlags& f); - void printADiagram(FILE* file, const CoxGroup* W); - void printBDiagram(FILE* file, const CoxGroup* W); - void printDDiagram(FILE* file, const CoxGroup* W); - void printEDiagram(FILE* file, const CoxGroup* W); - void printFDiagram(FILE* file, const CoxGroup* W); - void printGDiagram(FILE* file, const CoxGroup* W); - void printHDiagram(FILE* file, const CoxGroup* W); - void printIDiagram(FILE* file, const CoxGroup* W); -}; +void checkCoxElement(CoxGroup *W, CoxWord g); +void checkCoxEntry(Rank i, Rank j, Ulong m); +void checkFilename(char *s); +void checkLength(const long &l); +void checkRank(const Rank &l, const Type &type); +void checkType(String &buf); +void getCoxFileName(String &buf); +Ulong parse(const Interface &I, Generator &s, const String &line); +Ulong parse(const Interface &I, Generator &s, const String &line, + const LFlags &f); +void printADiagram(FILE *file, const CoxGroup *W); +void printBDiagram(FILE *file, const CoxGroup *W); +void printDDiagram(FILE *file, const CoxGroup *W); +void printEDiagram(FILE *file, const CoxGroup *W); +void printFDiagram(FILE *file, const CoxGroup *W); +void printGDiagram(FILE *file, const CoxGroup *W); +void printHDiagram(FILE *file, const CoxGroup *W); +void printIDiagram(FILE *file, const CoxGroup *W); +}; // namespace /**************************************************************************** @@ -89,15 +89,14 @@ OutputFile::OutputFile() static String buf(0); printf("Name an output file (hit return for stdout):\n"); - interactive::getInput(stdin,buf); + interactive::getInput(stdin, buf); if (buf[0] == '\0') d_file = stdout; else - d_file = fopen(buf.ptr(),"w"); + d_file = fopen(buf.ptr(), "w"); } - OutputFile::~OutputFile() { @@ -129,7 +128,7 @@ OutputFile::~OutputFile() ****************************************************************************/ -CoxGroup* allocCoxGroup() +CoxGroup *allocCoxGroup() /* This function gets a type from the user, and allocates a CoxGroup @@ -138,7 +137,7 @@ CoxGroup* allocCoxGroup() */ { - const Type& x = getType(); + const Type &x = getType(); if (ERRNO) return 0; @@ -146,7 +145,7 @@ CoxGroup* allocCoxGroup() return allocCoxGroup(x); } -CoxGroup* allocCoxGroup(const Type& x) +CoxGroup *allocCoxGroup(const Type &x) /* This function gets a rank from the user, and allocates a CoxGroup @@ -160,10 +159,10 @@ CoxGroup* allocCoxGroup(const Type& x) if (ERRNO) return 0; - return coxeterGroup(x,l); + return coxeterGroup(x, l); } -CoxGroup* coxeterGroup(const Type& x, const Rank& l) +CoxGroup *coxeterGroup(const Type &x, const Rank &l) /* This function allocates a CoxGroup of the given type and rank. More @@ -180,38 +179,35 @@ CoxGroup* coxeterGroup(const Type& x, const Rank& l) return new GeneralTypeAMRCoxGroup(l); else if (l > maxSmallRank(x)) return new GeneralTypeASRCoxGroup(l); - else /* group is small */ + else /* group is small */ return new GeneralTypeASCoxGroup(l); - } - else if (isFiniteType(x)) { /* allocate a FiniteCoxGroup */ + } else if (isFiniteType(x)) { /* allocate a FiniteCoxGroup */ if (l > MEDRANK_MAX) - return new GeneralFBRCoxGroup(x,l); + return new GeneralFBRCoxGroup(x, l); else if (l > SMALLRANK_MAX) - return new GeneralFMRCoxGroup(x,l); + return new GeneralFMRCoxGroup(x, l); else if (l > maxSmallRank(x)) - return new GeneralFSRCoxGroup(x,l); - else /* group is small */ - return new GeneralSCoxGroup(x,l); - } - else if (isAffineType(x)) { /* allocate an AffineCoxGroup */ + return new GeneralFSRCoxGroup(x, l); + else /* group is small */ + return new GeneralSCoxGroup(x, l); + } else if (isAffineType(x)) { /* allocate an AffineCoxGroup */ if (l > MEDRANK_MAX) - return new GeneralABRCoxGroup(x,l); + return new GeneralABRCoxGroup(x, l); else if (l > SMALLRANK_MAX) - return new GeneralAMRCoxGroup(x,l); - else /* l <= SMALLRANK_MAX */ - return new GeneralASRCoxGroup(x,l); - } - else { /* allocate a GeneralCoxGroup */ + return new GeneralAMRCoxGroup(x, l); + else /* l <= SMALLRANK_MAX */ + return new GeneralASRCoxGroup(x, l); + } else { /* allocate a GeneralCoxGroup */ if (l > MEDRANK_MAX) - return new BigRankCoxGroup(x,l); + return new BigRankCoxGroup(x, l); else if (l > SMALLRANK_MAX) - return new MedRankCoxGroup(x,l); + return new MedRankCoxGroup(x, l); else - return new SmallRankCoxGroup(x,l); + return new SmallRankCoxGroup(x, l); } } -CoxEntry getCoxEntry(const Rank& i, const Rank& j) +CoxEntry getCoxEntry(const Rank &i, const Rank &j) /* This function gets a Coxeter matrix entry from the user. It prompts @@ -225,26 +221,25 @@ CoxEntry getCoxEntry(const Rank& i, const Rank& j) do { if (ERRNO) - Error(ERRNO,i,j,m); - printf("\nm[%d,%d] : ",i,j); - getInput(stdin,buf); + Error(ERRNO, i, j, m); + printf("\nm[%d,%d] : ", i, j); + getInput(stdin, buf); if (buf[0] == '\0') { /* abort */ ERRNO = BAD_COXENTRY; return undef_coxentry; } - m = strtol(buf.ptr(),NULL,0); - checkCoxEntry(i,j,m); - } - while (ERRNO); + m = strtol(buf.ptr(), NULL, 0); + checkCoxEntry(i, j, m); + } while (ERRNO); - return static_cast(m) ; + return static_cast(m); } -}; +}; // namespace interactive namespace { -void getCoxFileName(String& str) +void getCoxFileName(String &str) /* This function gets from the user the name of the file containing the @@ -259,40 +254,39 @@ void getCoxFileName(String& str) using directories::COXMATRIX_DIR; reset(buf); - append(buf,COXMATRIX_DIR); - append(buf,"/"); + append(buf, COXMATRIX_DIR); + append(buf, "/"); Ulong c = buf.length(); do { if (ERRNO) { - Error(ERRNO,buf.ptr()); + Error(ERRNO, buf.ptr()); reset(buf); - append(buf,COXMATRIX_DIR); - append(buf,"/"); + append(buf, COXMATRIX_DIR); + append(buf, "/"); } - printf("\nFile name : %s/",COXMATRIX_DIR); - getInput(stdin,buf,buf.length()); + printf("\nFile name : %s/", COXMATRIX_DIR); + getInput(stdin, buf, buf.length()); if (buf[c] == '\0') { /* abort */ ERRNO = ABORT; return; } checkFilename(buf.ptr()); - } - while (ERRNO); + } while (ERRNO); - str.setLength(buf.length()-c+1); + str.setLength(buf.length() - c + 1); str[0] = 'X'; - str.setData(buf.ptr()+c,1,buf.length()-c); + str.setData(buf.ptr() + c, 1, buf.length() - c); str[str.length()] = '\0'; return; } -}; +}; // namespace namespace interactive { -const CoxWord& getCoxWord(CoxGroup *W) +const CoxWord &getCoxWord(CoxGroup *W) /* This function gets a coxword from the user. If the input is not @@ -308,9 +302,9 @@ const CoxWord& getCoxWord(CoxGroup *W) do { if (ERRNO) { P.str[P.offset] = '\0'; - Error(ERRNO,P.str.ptr()); + Error(ERRNO, P.str.ptr()); } - getInput(stdin,P.str,P.offset); + getInput(stdin, P.str, P.offset); if (P.str[P.offset] == '?') { ERRNO = ABORT; return P.a[0]; @@ -318,14 +312,12 @@ const CoxWord& getCoxWord(CoxGroup *W) W->parse(P); if (P.offset != P.str.length()) ERRNO = PARSE_ERROR; - } - while (ERRNO); + } while (ERRNO); return P.a[0]; } - -Generator getGenerator(CoxGroup* W) +Generator getGenerator(CoxGroup *W) /* This function gets a generator from the user. The string should start @@ -338,7 +330,7 @@ Generator getGenerator(CoxGroup* W) { static String buf(0); - const Interface& I = W->interface(); + const Interface &I = W->interface(); Generator s = undef_generator; Ulong r = 0; @@ -347,21 +339,20 @@ Generator getGenerator(CoxGroup* W) do { if (ERRNO) { buf[r] = '\0'; - Error(ERRNO,buf.ptr()); + Error(ERRNO, buf.ptr()); } - getInput(stdin,buf,r); + getInput(stdin, buf, r); if (buf[r] == '?') { ERRNO = ABORT; return undef_generator; } - r = parse(I,s,buf); + r = parse(I, s, buf); } while (ERRNO); return s; } - -Generator getGenerator(CoxGroup* W, const LFlags& f) +Generator getGenerator(CoxGroup *W, const LFlags &f) /* Like getGenerator, but moreover checks if s is flagged by f. @@ -370,7 +361,7 @@ Generator getGenerator(CoxGroup* W, const LFlags& f) { static String buf(0); - const Interface& I = W->interface(); + const Interface &I = W->interface(); Generator s = undef_generator; Ulong r = 0; @@ -379,21 +370,20 @@ Generator getGenerator(CoxGroup* W, const LFlags& f) do { if (ERRNO) { buf[r] = '\0'; - Error(ERRNO,buf.ptr()); + Error(ERRNO, buf.ptr()); } - getInput(stdin,buf,r); + getInput(stdin, buf, r); if (buf[r] == '?') { ERRNO = ABORT; return undef_generator; } - r = parse(I,s,buf,f); + r = parse(I, s, buf, f); } while (ERRNO); return s; } - -void getLength(List& L, const CoxGraph& G, const Interface& I) +void getLength(List &L, const CoxGraph &G, const Interface &I) /* This function gets lengths of generators from the user, for computing @@ -410,9 +400,9 @@ void getLength(List& L, const CoxGraph& G, const Interface& I) List cl(0); static String buf(0); - getConjugacyClasses(cl,G); + getConjugacyClasses(cl, G); - printf("There are %lu conjugacy classes of generators.",cl.size()); + printf("There are %lu conjugacy classes of generators.", cl.size()); printf(" Enter weights (? to abort):\n\n"); for (Ulong j = 0; j < cl.size(); ++j) { @@ -424,37 +414,36 @@ void getLength(List& L, const CoxGraph& G, const Interface& I) do { if (trials >= 5) { - ERRNO = ABORT; - return; + ERRNO = ABORT; + return; } ++trials; if (ERRNO) { - Error(ERRNO,l); + Error(ERRNO, l); } - print(stdout,cl[j],I); + print(stdout, cl[j], I); printf(" : "); - getInput(stdin,buf); + getInput(stdin, buf); if (buf[0] == '?') { - ERRNO = ABORT; - return; + ERRNO = ABORT; + return; } - l = strtol(buf.ptr(),NULL,0); - checkLength(l); + l = strtol(buf.ptr(), NULL, 0); + checkLength(l); } while (ERRNO); /* set corresponding lengths */ - for (LFlags f = cl[j]; f; f &= f-1) { + for (LFlags f = cl[j]; f; f &= f - 1) { Generator s = firstBit(f); L[s] = l; - L[s+G.rank()] = l; // left multiplication + L[s + G.rank()] = l; // left multiplication } } return; } - -Rank getRank(const Type& type) +Rank getRank(const Type &type) /* This function gets a rank from the user, corresponding to the given @@ -468,38 +457,36 @@ Rank getRank(const Type& type) Rank l; int ignore_error; - if (strchr("GI",type[0])) /* rank is 2 */ - { - printf("\nsetting rank to 2\n"); - if (type[0] == 'G') - printf("\n"); - return 2; - } + if (strchr("GI", type[0])) /* rank is 2 */ + { + printf("\nsetting rank to 2\n"); + if (type[0] == 'G') + printf("\n"); + return 2; + } ignore_error = 0; reset(buf); do { if (ERRNO) - Error(ERRNO,&type,&l,&ignore_error); + Error(ERRNO, &type, &l, &ignore_error); if (ignore_error) break; printf("\nrank : "); - getInput(stdin,buf); + getInput(stdin, buf); if (buf[0] == '\0') { /* abort */ ERRNO = ERROR_WARNING; return 0; } - l = (Rank)strtol(buf.ptr(),NULL,0); - checkRank(l,type); - } - while (ERRNO); + l = (Rank)strtol(buf.ptr(), NULL, 0); + checkRank(l, type); + } while (ERRNO); return l; } - -const Type& getType() +const Type &getType() /* This function gets a type from the user. In case of invalid input, @@ -512,27 +499,25 @@ const Type& getType() { static Type buf(""); - String& name = buf.name(); + String &name = buf.name(); reset(name); do { if (ERRNO) Error(ERRNO); printf("\ntype : "); - getInput(stdin,name); + getInput(stdin, name); if (name[0] == '\0') { /* abort */ ERRNO = ABORT; return undef_type; } checkType(name); - } - while (ERRNO); /* give the user another chance */ + } while (ERRNO); /* give the user another chance */ return buf; } - -CoxEntry readCoxEntry(const Rank& i, const Rank& j, FILE *inputfile) +CoxEntry readCoxEntry(const Rank &i, const Rank &j, FILE *inputfile) /* Reads the entry i,j of a Coxeter matrix from the file inputfile. @@ -541,11 +526,11 @@ CoxEntry readCoxEntry(const Rank& i, const Rank& j, FILE *inputfile) { Ulong m; - fscanf(inputfile,"%lu",&m); + fscanf(inputfile, "%lu", &m); - checkCoxEntry(i,j,m); + checkCoxEntry(i, j, m); if (ERRNO) { - Error(ERRNO,i,j,m); + Error(ERRNO, i, j, m); ERRNO = ABORT; return 1; } @@ -566,29 +551,26 @@ CoxEntry readCoxEntry(const Rank& i, const Rank& j, FILE *inputfile) ******************************************************************************/ - /* This function allows the user to specify a new ordering of the generators. He should input the standard generators in the ordering that he wants them (this is perhaps easier than to work from the current ordering, which would have been another possibility.) */ -void changeOrdering(CoxGroup *W, Permutation& order) -{ +void changeOrdering(CoxGroup *W, Permutation &order) { static CoxWord g(0); - printRepresentation(stdout,W); + printRepresentation(stdout, W); printf("Current ordering of the generators:\n\n\t"); - printOrdering(stdout,W); + printOrdering(stdout, W); printf("\n\n"); - printf - ("To change the numbering of the generators, enter the Coxeter element\n"); - printf - ("for which the generators are written in their new ordering (use the\n"); - printf - ("current symbols, prefix, postfix and separator)\n\n"); + printf( + "To change the numbering of the generators, enter the Coxeter element\n"); + printf( + "for which the generators are written in their new ordering (use the\n"); + printf("current symbols, prefix, postfix and separator)\n\n"); printf("new ordering : "); do { @@ -597,21 +579,20 @@ void changeOrdering(CoxGroup *W, Permutation& order) g = getCoxWord(W); if (g.length() == 0) ERRNO = ABORT; - if (ERRNO) /* abort */ + if (ERRNO) /* abort */ return; - checkCoxElement(W,g); - } - while (ERRNO); + checkCoxElement(W, g); + } while (ERRNO); /* transfer ordering to the permutation */ for (Generator s = 0; s < W->rank(); s++) - order[s] = g[s]-1; + order[s] = g[s] - 1; return; } -} +} // namespace interactive /***************************************************************************** @@ -658,7 +639,6 @@ void checkCoxElement(CoxGroup *W, CoxWord g) return; } - void checkCoxEntry(Rank i, Rank j, Ulong m) /* @@ -689,7 +669,7 @@ void checkFilename(char *s) { FILE *f; - f = fopen(s,"r"); + f = fopen(s, "r"); if (f == NULL) { /* error */ ERRNO = FILE_NOT_FOUND; @@ -701,7 +681,7 @@ void checkFilename(char *s) return; } -void checkLength(const long& l) +void checkLength(const long &l) /* Checks if l is an acceptable length. Acceptable values are nonnegative @@ -718,7 +698,7 @@ void checkLength(const long& l) return; } -void checkRank(const Rank& l, const Type& type) +void checkRank(const Rank &l, const Type &type) /* It is assumed that W->type() has been succesfully filled in. This function @@ -730,83 +710,81 @@ void checkRank(const Rank& l, const Type& type) */ { - switch(type[0]) - { - case 'A': - if ((l < 1) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'B': - if ((l < 2) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'D': - if ((l < 2) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'E': - if ((l < 3) || (l > 8)) - ERRNO = WRONG_RANK; - break; - case 'F': - if ((l < 3) || (l > 4)) - ERRNO = WRONG_RANK; - break; - case 'G': - if (l != 2) - ERRNO = WRONG_RANK; - break; - case 'H': - if ((l < 2) || (l > 4)) - ERRNO = WRONG_RANK; - break; - case 'I': - if (l != 2) - ERRNO = WRONG_RANK; - break; - case 'a': - if ((l < 2) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'b': - if ((l < 3) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'c': - if ((l < 3) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'd': - if ((l < 5) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'e': - if ((l < 7) || (l > 9)) - ERRNO = WRONG_RANK; - break; - case 'f': - if (l != 5) - ERRNO = WRONG_RANK; - break; - case 'g': - if (l != 3) - ERRNO = WRONG_RANK; - break; - case 'X': - if ((l < 1) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - case 'Y': - if ((l < 1) || (l > RANK_MAX)) - ERRNO = WRONG_RANK; - break; - } + switch (type[0]) { + case 'A': + if ((l < 1) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'B': + if ((l < 2) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'D': + if ((l < 2) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'E': + if ((l < 3) || (l > 8)) + ERRNO = WRONG_RANK; + break; + case 'F': + if ((l < 3) || (l > 4)) + ERRNO = WRONG_RANK; + break; + case 'G': + if (l != 2) + ERRNO = WRONG_RANK; + break; + case 'H': + if ((l < 2) || (l > 4)) + ERRNO = WRONG_RANK; + break; + case 'I': + if (l != 2) + ERRNO = WRONG_RANK; + break; + case 'a': + if ((l < 2) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'b': + if ((l < 3) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'c': + if ((l < 3) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'd': + if ((l < 5) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'e': + if ((l < 7) || (l > 9)) + ERRNO = WRONG_RANK; + break; + case 'f': + if (l != 5) + ERRNO = WRONG_RANK; + break; + case 'g': + if (l != 3) + ERRNO = WRONG_RANK; + break; + case 'X': + if ((l < 1) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + case 'Y': + if ((l < 1) || (l > RANK_MAX)) + ERRNO = WRONG_RANK; + break; + } return; } - -void checkType(String& str) +void checkType(String &str) /* Checks if the string s is a valid type for a Coxeter group. Currently @@ -832,11 +810,10 @@ void checkType(String& str) } if ((str[0] >= 'A') && (str[0] <= 'I')) { - if (str[0] == 'C') - { - printf("\nwarning: type was changed to B\n"); - str[0] = 'B'; - } + if (str[0] == 'C') { + printf("\nwarning: type was changed to B\n"); + str[0] = 'B'; + } return; } @@ -858,7 +835,7 @@ void checkType(String& str) return; } -}; +}; // namespace /***************************************************************************** @@ -877,57 +854,57 @@ void checkType(String& str) namespace interactive { -void printInterface(FILE* file, const GroupEltInterface& GI, - const Permutation& a) +void printInterface(FILE *file, const GroupEltInterface &GI, + const Permutation &a) { - fprintf(file,"prefix: "); - print(file,GI.prefix); - fprintf(file,"\n"); - fprintf(file,"separator: "); - print(file,GI.separator); - fprintf(file,"\n"); - fprintf(file,"postfix: "); - print(file,GI.postfix); - fprintf(file,"\n"); + fprintf(file, "prefix: "); + print(file, GI.prefix); + fprintf(file, "\n"); + fprintf(file, "separator: "); + print(file, GI.separator); + fprintf(file, "\n"); + fprintf(file, "postfix: "); + print(file, GI.postfix); + fprintf(file, "\n"); for (Ulong j = 0; j < a.size(); ++j) { - fprintf(file,"generator "); + fprintf(file, "generator "); Generator s = a[j]; - print(file,GI.symbol[s]); - fprintf(file,"\n"); + print(file, GI.symbol[s]); + fprintf(file, "\n"); } return; } -void printInterface(FILE* file, const GroupEltInterface& GI, - const GroupEltInterface& WI, const Permutation& a) +void printInterface(FILE *file, const GroupEltInterface &GI, + const GroupEltInterface &WI, const Permutation &a) { - fprintf(file,"prefix: "); - print(file,GI.prefix); - fprintf(file,"\n"); - fprintf(file,"separator: "); - print(file,GI.separator); - fprintf(file,"\n"); - fprintf(file,"postfix: "); - print(file,GI.postfix); - fprintf(file,"\n"); + fprintf(file, "prefix: "); + print(file, GI.prefix); + fprintf(file, "\n"); + fprintf(file, "separator: "); + print(file, GI.separator); + fprintf(file, "\n"); + fprintf(file, "postfix: "); + print(file, GI.postfix); + fprintf(file, "\n"); for (Ulong j = 0; j < a.size(); ++j) { - fprintf(file,"generator "); + fprintf(file, "generator "); Generator s = a[j]; - print(file,WI.symbol[s]); - fprintf(file,": "); - print(file,GI.symbol[s]); - fprintf(file,"\n"); + print(file, WI.symbol[s]); + fprintf(file, ": "); + print(file, GI.symbol[s]); + fprintf(file, "\n"); } return; } -void printMatrix(FILE* file, const CoxGroup* W) +void printMatrix(FILE *file, const CoxGroup *W) /* Prints the Coxeter matrix on file. @@ -939,15 +916,15 @@ void printMatrix(FILE* file, const CoxGroup* W) for (Ulong i = 0; i < W->rank(); ++i) { for (Ulong j = 0; j < W->rank(); j++) { - fprintf(file,"%4d",W->M(a[i],a[j])); + fprintf(file, "%4d", W->M(a[i], a[j])); } - fprintf(file,"\n"); + fprintf(file, "\n"); } return; } -void printOrdering(FILE* file, const CoxGroup* W) +void printOrdering(FILE *file, const CoxGroup *W) /* Prints the current ordering of the generators. @@ -959,15 +936,15 @@ void printOrdering(FILE* file, const CoxGroup* W) for (Ulong j = 0; j < a.size(); ++j) { Generator s = a[j]; - print(file,W->interface().inSymbol(s)); - if (j+1 < a.size()) /* there is more to come */ - fprintf(file," < "); + print(file, W->interface().inSymbol(s)); + if (j + 1 < a.size()) /* there is more to come */ + fprintf(file, " < "); } return; } -void printRepresentation(FILE* file, const CoxGroup* W) +void printRepresentation(FILE *file, const CoxGroup *W) /* Prints the numbering of the generators on the file, for @@ -975,270 +952,265 @@ void printRepresentation(FILE* file, const CoxGroup* W) */ { - switch (W->type()[0]) - { - case 'A': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printADiagram(file,W); - fprintf(file,"\n"); - return; - case 'B': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printBDiagram(file,W); - fprintf(file,"\n"); - return; - case 'D': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printDDiagram(file,W); - fprintf(file,"\n"); - return; - case 'E': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printEDiagram(file,W); - fprintf(file,"\n"); - return; - case 'F': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printFDiagram(file,W); - fprintf(file,"\n"); - return; - case 'G': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printGDiagram(file,W); - fprintf(file,"\n"); - return; - case 'H': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printHDiagram(file,W); - fprintf(file,"\n"); - return; - case 'I': - fprintf(file,"The labelling of the generators is as follows :\n\n"); - printIDiagram(file,W); - fprintf(file,"\n"); - return; - default: - fprintf(file,"The current Coxeter matrix is as follows :\n\n"); - printMatrix(file,W); - fprintf(file,"\n"); - return; - }; + switch (W->type()[0]) { + case 'A': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printADiagram(file, W); + fprintf(file, "\n"); + return; + case 'B': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printBDiagram(file, W); + fprintf(file, "\n"); + return; + case 'D': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printDDiagram(file, W); + fprintf(file, "\n"); + return; + case 'E': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printEDiagram(file, W); + fprintf(file, "\n"); + return; + case 'F': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printFDiagram(file, W); + fprintf(file, "\n"); + return; + case 'G': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printGDiagram(file, W); + fprintf(file, "\n"); + return; + case 'H': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printHDiagram(file, W); + fprintf(file, "\n"); + return; + case 'I': + fprintf(file, "The labelling of the generators is as follows :\n\n"); + printIDiagram(file, W); + fprintf(file, "\n"); + return; + default: + fprintf(file, "The current Coxeter matrix is as follows :\n\n"); + printMatrix(file, W); + fprintf(file, "\n"); + return; + }; } -}; +}; // namespace interactive namespace { -void printADiagram(FILE* file, const CoxGroup* W) +void printADiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); if (W->rank() <= 8) { /* rank is at least 4 */ - print(file,I.inSymbol(0)); + print(file, I.inSymbol(0)); for (Generator s = 1; s < W->rank(); ++s) { - fprintf(file," - "); - print(file,I.inSymbol(s)); + fprintf(file, " - "); + print(file, I.inSymbol(s)); } - } - else { - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(1)); - fprintf(file," - ... - "); - print(file,I.inSymbol(W->rank()-1)); + } else { + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(1)); + fprintf(file, " - ... - "); + print(file, I.inSymbol(W->rank() - 1)); } - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -void printBDiagram(FILE* file, const CoxGroup* W) +void printBDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); if (W->rank() <= 8) { /* rank is at least 4 */ - print(file,I.inSymbol(0)); - fprintf(file," = "); - print(file,I.inSymbol(1)); + print(file, I.inSymbol(0)); + fprintf(file, " = "); + print(file, I.inSymbol(1)); for (Generator s = 2; s < W->rank(); ++s) { - fprintf(file," - "); - print(file,I.inSymbol(s)); + fprintf(file, " - "); + print(file, I.inSymbol(s)); } - } - else { - print(file,I.inSymbol(0)); - fprintf(file," = "); - print(file,I.inSymbol(1)); - fprintf(file," - ... - "); - print(file,I.inSymbol(W->rank()-1)); + } else { + print(file, I.inSymbol(0)); + fprintf(file, " = "); + print(file, I.inSymbol(1)); + fprintf(file, " - ... - "); + print(file, I.inSymbol(W->rank() - 1)); } - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -void printDDiagram(FILE* file, const CoxGroup* W) +void printDDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); if (W->rank() <= 8) { - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(2)); + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(2)); for (Generator s = 3; s < W->rank(); ++s) { - fprintf(file," - "); - print(file,I.inSymbol(s)); + fprintf(file, " - "); + print(file, I.inSymbol(s)); } int c = I.inSymbol(0).length() + 3; - c += I.inSymbol(2).length()/2; - printf("\n\t%*s|",c,""); - c -= I.inSymbol(1).length()/2; + c += I.inSymbol(2).length() / 2; + printf("\n\t%*s|", c, ""); + c -= I.inSymbol(1).length() / 2; if (c < 0) c = 0; - printf("\n\t%*s",c,""); - print(file,I.inSymbol(1)); - } - else { - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(2)); - fprintf(file," - ... - "); - print(file,I.inSymbol(W->rank()-1)); + printf("\n\t%*s", c, ""); + print(file, I.inSymbol(1)); + } else { + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(2)); + fprintf(file, " - ... - "); + print(file, I.inSymbol(W->rank() - 1)); int c = I.inSymbol(0).length() + 3; - c += I.inSymbol(2).length()/2; - printf("\n\t%*s|",c,""); - c -= I.inSymbol(1).length()/2; + c += I.inSymbol(2).length() / 2; + printf("\n\t%*s|", c, ""); + c -= I.inSymbol(1).length() / 2; if (c < 0) c = 0; - printf("\n\t%*s",c,""); - print(file,I.inSymbol(1)); + printf("\n\t%*s", c, ""); + print(file, I.inSymbol(1)); } - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -void printEDiagram(FILE* file, const CoxGroup* W) +void printEDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(2)); - fprintf(file," - "); - print(file,I.inSymbol(3)); + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(2)); + fprintf(file, " - "); + print(file, I.inSymbol(3)); for (Generator s = 4; s < W->rank(); ++s) { - fprintf(file," - "); - print(file,I.inSymbol(s)); + fprintf(file, " - "); + print(file, I.inSymbol(s)); } int c = I.inSymbol(0).length() + I.inSymbol(2).length() + 6; - c += I.inSymbol(3).length()/2; - printf("\n\t%*s|",c,""); - c -= I.inSymbol(1).length()/2; + c += I.inSymbol(3).length() / 2; + printf("\n\t%*s|", c, ""); + c -= I.inSymbol(1).length() / 2; if (c < 0) c = 0; - printf("\n\t%*s",c,""); - print(file,I.inSymbol(1)); + printf("\n\t%*s", c, ""); + print(file, I.inSymbol(1)); - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -void printFDiagram(FILE* file, const CoxGroup* W) +void printFDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(1)); - fprintf(file," = "); - print(file,I.inSymbol(2)); - fprintf(file," - "); - print(file,I.inSymbol(3)); + fprintf(file, "\t"); + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(1)); + fprintf(file, " = "); + print(file, I.inSymbol(2)); + fprintf(file, " - "); + print(file, I.inSymbol(3)); return; } -void printGDiagram(FILE* file, const CoxGroup* W) +void printGDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); int c = I.inSymbol(0).length() + 1; - fprintf(file,"%*s6\n",c,""); - fprintf(file,"\t"); - print(file,I.inSymbol(0)); - fprintf(file," - "); - print(file,I.inSymbol(1)); + fprintf(file, "%*s6\n", c, ""); + fprintf(file, "\t"); + print(file, I.inSymbol(0)); + fprintf(file, " - "); + print(file, I.inSymbol(1)); return; } -void printHDiagram(FILE* file, const CoxGroup* W) +void printHDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); - fprintf(file,"\t"); + fprintf(file, "\t"); int c = I.inSymbol(0).length() + 1; - fprintf(file,"%*s5\n",c,""); - fprintf(file,"\t"); - print(file,I.inSymbol(0)); + fprintf(file, "%*s5\n", c, ""); + fprintf(file, "\t"); + print(file, I.inSymbol(0)); for (Generator s = 1; s < W->rank(); ++s) { - fprintf(file," - "); - print(file,I.inSymbol(s)); + fprintf(file, " - "); + print(file, I.inSymbol(s)); } return; } -void printIDiagram(FILE* file, const CoxGroup* W) +void printIDiagram(FILE *file, const CoxGroup *W) { - const Interface& I = W->interface(); + const Interface &I = W->interface(); /* print the tag */ - CoxEntry m = W->M(0,1); - fprintf(file,"\t"); + CoxEntry m = W->M(0, 1); + fprintf(file, "\t"); int c = I.inSymbol(0).length() + 1; - fprintf(file,"%*s%d\n",c,"",m); + fprintf(file, "%*s%d\n", c, "", m); /* print the symbols */ - int d = digits(m,10); - fprintf(file,"\t"); - print(file,I.inSymbol(0)); - fprintf(file," "); + int d = digits(m, 10); + fprintf(file, "\t"); + print(file, I.inSymbol(0)); + fprintf(file, " "); for (int j = 0; j < d; ++j) - fprintf(file,"-"); - fprintf(file," "); - print(file,I.inSymbol(1)); + fprintf(file, "-"); + fprintf(file, " "); + print(file, I.inSymbol(1)); return; } -}; - +}; // namespace /***************************************************************************** @@ -1265,13 +1237,13 @@ int interactive::endOfLine(FILE *f) { int c; - while((c = getc(f)) != EOF) { + while ((c = getc(f)) != EOF) { if (!isspace(c)) { - ungetc(c,f); + ungetc(c, f); return 0; } if (c == '\n') { - ungetc(c,f); + ungetc(c, f); return 1; } } @@ -1283,7 +1255,7 @@ int interactive::endOfLine(FILE *f) namespace { -Ulong parse(const Interface& I, Generator &s, const String& line) +Ulong parse(const Interface &I, Generator &s, const String &line) /* This function parses a generator from the line. @@ -1296,10 +1268,10 @@ Ulong parse(const Interface& I, Generator &s, const String& line) { Token tok; - Ulong q = io::skipSpaces(line,0); + Ulong q = io::skipSpaces(line, 0); - const char* str = line.ptr()+q; - Ulong strsize = line.length()-q; + const char *str = line.ptr() + q; + Ulong strsize = line.length() - q; if (strsize == 0) { /* default generator */ s = undef_generator; @@ -1322,23 +1294,23 @@ Ulong parse(const Interface& I, Generator &s, const String& line) strsize--; q++; - q += io::skipSpaces(line,q); + q += io::skipSpaces(line, q); - str = line.ptr()+q; - Ulong p = I.symbolTree().find(str,0,tok); + str = line.ptr() + q; + Ulong p = I.symbolTree().find(str, 0, tok); if (tokenType(tok) != interface::generator_type) { /* error */ ERRNO = PARSE_ERROR; return q; } - s += tok-1; + s += tok - 1; q += p; return q; } -Ulong parse(const Interface& I, Generator &s, const String& line, - const LFlags& f) +Ulong parse(const Interface &I, Generator &s, const String &line, + const LFlags &f) /* This function parses a generator from the line, checking if the @@ -1352,10 +1324,10 @@ Ulong parse(const Interface& I, Generator &s, const String& line, { Token tok; - Ulong q = io::skipSpaces(line,0); + Ulong q = io::skipSpaces(line, 0); - const char* str = line.ptr()+q; - Ulong strsize = line.length()-q; + const char *str = line.ptr() + q; + Ulong strsize = line.length() - q; if (strsize == 0) { /* default generator */ s = undef_generator; @@ -1378,28 +1350,28 @@ Ulong parse(const Interface& I, Generator &s, const String& line, strsize--; q++; - q += io::skipSpaces(line,q); + q += io::skipSpaces(line, q); - str = line.ptr()+q; - strsize = line.length()-q; + str = line.ptr() + q; + strsize = line.length() - q; - Ulong p = I.symbolTree().find(str,0,tok); + Ulong p = I.symbolTree().find(str, 0, tok); if (tokenType(tok) != interface::generator_type) { /* error */ ERRNO = PARSE_ERROR; return q; } - if (!(f & lmask[s+tok-1])) { /* error */ + if (!(f & lmask[s + tok - 1])) { /* error */ ERRNO = NOT_DESCENT; return q; } - s += tok-1; + s += tok - 1; q += p; return q; } -}; +}; // namespace namespace interactive { @@ -1414,10 +1386,10 @@ bool yesNo() do { if (ERRNO) { - fprintf(stderr,"please answer yes or no\n"); + fprintf(stderr, "please answer yes or no\n"); ERRNO = 0; } - getInput(stdin,buf); + getInput(stdin, buf); char c = buf[0]; if (c == 'y') return true; @@ -1429,4 +1401,4 @@ bool yesNo() return true; // should be unreachable } -}; +}; // namespace interactive diff --git a/interactive.h b/interactive.h index 84cf9dc..bb183b8 100644 --- a/interactive.h +++ b/interactive.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERACTIVE_H /* guard against multiple inclusions */ +#ifndef INTERACTIVE_H /* guard against multiple inclusions */ #define INTERACTIVE_H #include "globals.h" @@ -21,52 +21,53 @@ namespace interactive { /******** type declarations *************************************************/ - class OutputFile; +class OutputFile; - using namespace bits; - using namespace coxeter; - using namespace coxtypes; - using namespace graph; - using namespace interface; - using namespace transducer; +using namespace bits; +using namespace coxeter; +using namespace coxtypes; +using namespace graph; +using namespace interface; +using namespace transducer; /******** function declarations **********************************************/ - CoxGroup* allocCoxGroup(); - CoxGroup* allocCoxGroup(const Type& x); - void changeOrdering(CoxGroup *W, Permutation& order); - CoxGroup* coxeterGroup(const Type& x, const Rank& l); - int endOfLine(FILE *f); - const Type& getType(); - CoxEntry getCoxEntry(const Rank& i, const Rank& j); - CoxArr& getCoxArr(Transducer& T) /* not implemented */; - CoxNbr& getCoxNbr(Transducer& T) /* not implemented */; - const CoxWord& getCoxWord(CoxGroup *W); - Generator getGenerator(CoxGroup *W); - Generator getGenerator(CoxGroup *W, const LFlags& f); - void getLength(List& L, const CoxGraph& G, const Interface& I); - Rank getRank(const Type& type); - void printInterface(FILE* file, const GroupEltInterface& GI, - const Permutation& a); - void printInterface(FILE* file, const GroupEltInterface& GI, - const GroupEltInterface& WI, const Permutation& a); - void printMatrix(FILE *file, const CoxGroup* W); - void printOrdering(FILE* file, const CoxGroup* W); - void printRepresentation(FILE *file, const CoxGroup* W); - CoxEntry readCoxEntry(const Rank& i, const Rank& j, FILE *inputfile); - bool yesNo(); +CoxGroup *allocCoxGroup(); +CoxGroup *allocCoxGroup(const Type &x); +void changeOrdering(CoxGroup *W, Permutation &order); +CoxGroup *coxeterGroup(const Type &x, const Rank &l); +int endOfLine(FILE *f); +const Type &getType(); +CoxEntry getCoxEntry(const Rank &i, const Rank &j); +CoxArr &getCoxArr(Transducer &T) /* not implemented */; +CoxNbr &getCoxNbr(Transducer &T) /* not implemented */; +const CoxWord &getCoxWord(CoxGroup *W); +Generator getGenerator(CoxGroup *W); +Generator getGenerator(CoxGroup *W, const LFlags &f); +void getLength(List &L, const CoxGraph &G, const Interface &I); +Rank getRank(const Type &type); +void printInterface(FILE *file, const GroupEltInterface &GI, + const Permutation &a); +void printInterface(FILE *file, const GroupEltInterface &GI, + const GroupEltInterface &WI, const Permutation &a); +void printMatrix(FILE *file, const CoxGroup *W); +void printOrdering(FILE *file, const CoxGroup *W); +void printRepresentation(FILE *file, const CoxGroup *W); +CoxEntry readCoxEntry(const Rank &i, const Rank &j, FILE *inputfile); +bool yesNo(); /* type definitions */ class OutputFile { - private: - FILE* d_file; - public: +private: + FILE *d_file; + +public: OutputFile(); ~OutputFile(); - FILE* f() {return d_file;} + FILE *f() { return d_file; } }; -}; +}; // namespace interactive #endif diff --git a/interface.cpp b/interface.cpp index ab6d820..f30f0a6 100644 --- a/interface.cpp +++ b/interface.cpp @@ -1,6 +1,6 @@ /* This is interface.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -13,50 +13,50 @@ #include "error.h" namespace interface { - using namespace error; +using namespace error; }; /******** local declarations *************************************************/ namespace { - using namespace interface; - - const char *alphabet = "abcdefghijklmnopqrstuvwxyz"; - const char *affine = "abcdefg"; - - const Token not_token = RANK_MAX+1; - const Token prefix_token = RANK_MAX+2; - const Token postfix_token = RANK_MAX+3; - const Token separator_token = RANK_MAX+4; - const Token begingroup_token = RANK_MAX+5; - const Token endgroup_token = RANK_MAX+6; - const Token longest_token = RANK_MAX+7; - const Token inverse_token = RANK_MAX+8; - const Token power_token = RANK_MAX+9; - const Token contextnbr_token = RANK_MAX+10; - const Token densearray_token = RANK_MAX+11; - - const unsigned prefix_bit = 0; - const unsigned postfix_bit = 1; - const unsigned separator_bit = 2; -}; +using namespace interface; + +const char *alphabet = "abcdefghijklmnopqrstuvwxyz"; +const char *affine = "abcdefg"; + +const Token not_token = RANK_MAX + 1; +const Token prefix_token = RANK_MAX + 2; +const Token postfix_token = RANK_MAX + 3; +const Token separator_token = RANK_MAX + 4; +const Token begingroup_token = RANK_MAX + 5; +const Token endgroup_token = RANK_MAX + 6; +const Token longest_token = RANK_MAX + 7; +const Token inverse_token = RANK_MAX + 8; +const Token power_token = RANK_MAX + 9; +const Token contextnbr_token = RANK_MAX + 10; +const Token densearray_token = RANK_MAX + 11; + +const unsigned prefix_bit = 0; +const unsigned postfix_bit = 1; +const unsigned separator_bit = 2; +}; // namespace namespace { - using namespace interface; - - void makeSymbols(List& list, const String* const symbol, Ulong n); - CoxNbr toCoxNbr(char c); - Automaton *tokenAutomaton(LFlags f); - Automaton *tokenAut0(); - Automaton *tokenAut1(); - Automaton *tokenAut2(); - Automaton *tokenAut3(); - Automaton *tokenAut4(); - Automaton *tokenAut5(); - Automaton *tokenAut6(); - Automaton *tokenAut7(); - -}; +using namespace interface; + +void makeSymbols(List &list, const String *const symbol, Ulong n); +CoxNbr toCoxNbr(char c); +Automaton *tokenAutomaton(LFlags f); +Automaton *tokenAut0(); +Automaton *tokenAut1(); +Automaton *tokenAut2(); +Automaton *tokenAut3(); +Automaton *tokenAut4(); +Automaton *tokenAut5(); +Automaton *tokenAut6(); +Automaton *tokenAut7(); + +}; // namespace /**************************************************************************** @@ -73,9 +73,9 @@ namespace { integer in {1,...,n}, where n is the rank, there is associated a symbol (in fact two symbols, an input symbol --- some non-empty string --- and an output symbol, an arbitrary string). The default is input = output = - the decimal representation of the number. Furthermore, there are three + the decimal representation of the number. Furthermore, there are three arbitrary strings : prefix, postfix and separator, also with - an input and an output version. Default is prefix and postfix empty, + an input and an output version. Default is prefix and postfix empty, separator empty if the rank is <= 9, "." otherwise. The second level is the possibility to define an arbitrary ordering on @@ -86,8 +86,8 @@ namespace { This setup is easy to implement, and gives more than enough flexibility to read from and write to programs like Gap, Magma or Maple, or even TeX, - and to perform some other nifty output tricks (outputting a k-l basis - element in Gap format, say, is a breeze.) Also the program can read from + and to perform some other nifty output tricks (outputting a k-l basis + element in Gap format, say, is a breeze.) Also the program can read from one program and write to another, functioning as a pipe. ****************************************************************************/ @@ -102,7 +102,7 @@ namespace { The following functions are defined : constructors : - + - Interface(x,l) : constructs the standard interface in type x and rank l; - ~Interface() : (not implemented yet); @@ -140,18 +140,10 @@ namespace { namespace interface { -Interface::Interface(const Type& x, const Rank& l) - :d_order(l), - d_beginGroup("("), - d_endGroup(")"), - d_longest("*"), - d_inverse("!"), - d_power("^"), - d_contextNbr("%"), - d_denseArray("#"), - d_parseEscape("?"), - d_reserved(0), - d_rank(l) +Interface::Interface(const Type &x, const Rank &l) + : d_order(l), d_beginGroup("("), d_endGroup(")"), d_longest("*"), + d_inverse("!"), d_power("^"), d_contextNbr("%"), d_denseArray("#"), + d_parseEscape("?"), d_reserved(0), d_rank(l) /* Constructs the default interface (see the introduction.) @@ -165,14 +157,14 @@ Interface::Interface(const Type& x, const Rank& l) d_descent = new DescentSetInterface; - insert(d_reserved,d_beginGroup); - insert(d_reserved,d_endGroup); - insert(d_reserved,d_longest); - insert(d_reserved,d_inverse); - insert(d_reserved,d_power); - insert(d_reserved,d_contextNbr); - insert(d_reserved,d_denseArray); - insert(d_reserved,d_parseEscape); + insert(d_reserved, d_beginGroup); + insert(d_reserved, d_endGroup); + insert(d_reserved, d_longest); + insert(d_reserved, d_inverse); + insert(d_reserved, d_power); + insert(d_reserved, d_contextNbr); + insert(d_reserved, d_denseArray); + insert(d_reserved, d_parseEscape); readSymbols(); setAutomaton(); @@ -205,35 +197,35 @@ void Interface::readSymbols() { d_symbolTree.~TokenTree(); - new(&d_symbolTree) TokenTree; + new (&d_symbolTree) TokenTree; if (inPrefix().length()) - d_symbolTree.insert(inPrefix(),prefix_token); + d_symbolTree.insert(inPrefix(), prefix_token); if (inSeparator().length()) - d_symbolTree.insert(inSeparator(),separator_token); + d_symbolTree.insert(inSeparator(), separator_token); if (inPostfix().length()) - d_symbolTree.insert(inPostfix(),postfix_token); + d_symbolTree.insert(inPostfix(), postfix_token); for (Generator s = 0; s < rank(); ++s) { - d_symbolTree.insert(inSymbol(s),s+1); + d_symbolTree.insert(inSymbol(s), s + 1); } - d_symbolTree.insert(d_beginGroup,begingroup_token); - d_symbolTree.insert(d_endGroup,endgroup_token); - d_symbolTree.insert(d_longest,longest_token); - d_symbolTree.insert(d_inverse,inverse_token); - d_symbolTree.insert(d_power,power_token); - d_symbolTree.insert(d_contextNbr,contextnbr_token); - d_symbolTree.insert(d_denseArray,densearray_token); + d_symbolTree.insert(d_beginGroup, begingroup_token); + d_symbolTree.insert(d_endGroup, endgroup_token); + d_symbolTree.insert(d_longest, longest_token); + d_symbolTree.insert(d_inverse, inverse_token); + d_symbolTree.insert(d_power, power_token); + d_symbolTree.insert(d_contextNbr, contextnbr_token); + d_symbolTree.insert(d_denseArray, densearray_token); return; } void Interface::setAutomaton() -{ +{ LFlags f = 0; using constants::lmask; @@ -257,7 +249,7 @@ void Interface::setDescent(Default) */ { - new(d_descent) DescentSetInterface(); + new (d_descent) DescentSetInterface(); return; } @@ -268,14 +260,14 @@ void Interface::setDescent(GAP) */ { - new(d_descent) DescentSetInterface(GAP()); + new (d_descent) DescentSetInterface(GAP()); return; } -void Interface::setIn(const GroupEltInterface& i) +void Interface::setIn(const GroupEltInterface &i) /* - Resets d_in to i. + Resets d_in to i. */ { @@ -287,7 +279,7 @@ void Interface::setIn(const GroupEltInterface& i) return; } -void Interface::setOrder(const Permutation& order) +void Interface::setOrder(const Permutation &order) /* Resets the numbering of the generators. The given ordering is the @@ -304,7 +296,7 @@ void Interface::setOrder(const Permutation& order) return; } -void Interface::setOut(const GroupEltInterface& i) +void Interface::setOut(const GroupEltInterface &i) /* Resets d_out to i */ @@ -316,11 +308,11 @@ void Interface::setOut(const GroupEltInterface& i) /******** input-output *******************************************************/ -bool Interface::parseCoxWord(ParseInterface& P, const MinTable& T) const - +bool Interface::parseCoxWord(ParseInterface &P, const MinTable &T) const + /* This function parses a CoxWord from the line, starting at position r, and - increments the CoxWord g with it. The syntax for a group element is as + increments the CoxWord g with it. The syntax for a group element is as follows : prefix [generator [separator generator]*] postfix @@ -350,17 +342,17 @@ bool Interface::parseCoxWord(ParseInterface& P, const MinTable& T) const { Token tok = 0; - while (Ulong p = getToken(P,tok)) { + while (Ulong p = getToken(P, tok)) { Letter tok_type = tokenType(tok); if (tok_type > separator_type) /* end of coxword */ break; - State y = d_tokenAut->act(P.x,tok_type); + State y = d_tokenAut->act(P.x, tok_type); if (d_tokenAut->isFailure(y)) /* end of coxword */ break; P.x = y; if (tok_type == generator_type) { - Generator s = tok-1; - T.prod(P.c,s); + Generator s = tok - 1; + T.prod(P.c, s); } P.offset += p; } @@ -373,8 +365,8 @@ bool Interface::parseCoxWord(ParseInterface& P, const MinTable& T) const return true; } -bool Interface::readCoxElt(ParseInterface& P) const - +bool Interface::readCoxElt(ParseInterface &P) const + /* This function attempts to read a Coxeter element from P. It does not have to worry about word reduction because all the generators read have @@ -391,43 +383,42 @@ bool Interface::readCoxElt(ParseInterface& P) const // f hold the part already read for (Ulong j = 0; j < P.c.length(); ++j) - f |= lmask[P.c[j]-1]; + f |= lmask[P.c[j] - 1]; // read new part - while (Ulong p = getToken(P,tok)) { + while (Ulong p = getToken(P, tok)) { Letter tok_type = tokenType(tok); if (tok_type > separator_type) /* end of coxword */ break; - State y = d_tokenAut->act(P.x,tok_type); + State y = d_tokenAut->act(P.x, tok_type); if (d_tokenAut->isFailure(y)) /* end of coxword */ break; P.x = y; if (tok_type == generator_type) { - if (f & lmask[tok-1]) { // generator already appeared - ERRNO = NOT_COXELT; - return true; + if (f & lmask[tok - 1]) { // generator already appeared + ERRNO = NOT_COXELT; + return true; } - f |= lmask[tok-1]; + f |= lmask[tok - 1]; P.c.append(tok); } P.offset += p; } if (d_tokenAut->isAccept(P.x)) { /* input is subword of coxelt */ - if ((f != 0) && (f != leqmask[rank()-1])) + if ((f != 0) && (f != leqmask[rank() - 1])) ERRNO = NOT_COXELT; else P.x = 0; - } - else { /* incomplete input */ + } else { /* incomplete input */ ERRNO = PARSE_ERROR; } return true; } -}; +}; // namespace interface /**************************************************************************** @@ -467,8 +458,8 @@ bool Interface::readCoxElt(ParseInterface& P) const namespace interface { DescentSetInterface::DescentSetInterface() - :prefix("{"),postfix("}"),separator(","),twosidedPrefix("{"), - twosidedPostfix("}"),twosidedSeparator(";") + : prefix("{"), postfix("}"), separator(","), twosidedPrefix("{"), + twosidedPostfix("}"), twosidedSeparator(";") /* Sets the default values for the interface. @@ -477,8 +468,8 @@ DescentSetInterface::DescentSetInterface() {} DescentSetInterface::DescentSetInterface(GAP) - :prefix("["),postfix("]"),separator(","),twosidedPrefix("[["), - twosidedPostfix("]]"),twosidedSeparator("],[") + : prefix("["), postfix("]"), separator(","), twosidedPrefix("[["), + twosidedPostfix("]]"), twosidedSeparator("],[") {} @@ -486,49 +477,49 @@ DescentSetInterface::~DescentSetInterface() {} -void DescentSetInterface::setPrefix(const String& str) +void DescentSetInterface::setPrefix(const String &str) { prefix = str; return; } -void DescentSetInterface::setPostfix(const String& str) +void DescentSetInterface::setPostfix(const String &str) { postfix = str; return; } -void DescentSetInterface::setSeparator(const String& str) +void DescentSetInterface::setSeparator(const String &str) { separator = str; return; } -void DescentSetInterface::setTwosidedPrefix(const String& str) +void DescentSetInterface::setTwosidedPrefix(const String &str) { twosidedPrefix = str; return; } -void DescentSetInterface::setTwosidedPostfix(const String& str) +void DescentSetInterface::setTwosidedPostfix(const String &str) { twosidedPostfix = str; return; } -void DescentSetInterface::setTwosidedSeparator(const String& str) +void DescentSetInterface::setTwosidedSeparator(const String &str) { twosidedSeparator = str; return; } -}; +}; // namespace interface /**************************************************************************** @@ -554,14 +545,14 @@ void DescentSetInterface::setTwosidedSeparator(const String& str) - setPrefix(a) : sets the prefix to a; - setSeparator(a) : sets the separator to a; - setSymbol(s,a) : sets symbol # s to a; - + ****************************************************************************/ namespace interface { GroupEltInterface::GroupEltInterface() - :symbol(0),prefix(String::undefined()),postfix(String::undefined()), - separator(String::undefined()) + : symbol(0), prefix(String::undefined()), postfix(String::undefined()), + separator(String::undefined()) /* We use the default constructor to construct an interface where the symbol @@ -573,8 +564,8 @@ GroupEltInterface::GroupEltInterface() {} -GroupEltInterface::GroupEltInterface(const Rank& l) - :symbol(l),prefix(0),postfix(0),separator(0) +GroupEltInterface::GroupEltInterface(const Rank &l) + : symbol(l), prefix(0), postfix(0), separator(0) /* Constructs the default interface in rank l. */ @@ -582,15 +573,15 @@ GroupEltInterface::GroupEltInterface(const Rank& l) { symbol.setSize(l); - makeSymbols(symbol,decimalSymbols(l),l); + makeSymbols(symbol, decimalSymbols(l), l); if (l > 9) { /* need separators */ - new(&separator) String("."); + new (&separator) String("."); } } -GroupEltInterface::GroupEltInterface(const Rank& l, Alphabetic) - :symbol(l),prefix(""),postfix(""),separator("") +GroupEltInterface::GroupEltInterface(const Rank &l, Alphabetic) + : symbol(l), prefix(""), postfix(""), separator("") /* Constructs the GAP interface in rank l. This represents Coxeter words as lists, with decimal symbols : for instance, the element 12321 in @@ -599,14 +590,14 @@ GroupEltInterface::GroupEltInterface(const Rank& l, Alphabetic) { symbol.setSize(l); - makeSymbols(symbol,alphabeticSymbols(l),l); + makeSymbols(symbol, alphabeticSymbols(l), l); if (l > 26) separator = "."; } -GroupEltInterface::GroupEltInterface(const Rank& l, Decimal) - :symbol(l),prefix(""),postfix(""),separator("") +GroupEltInterface::GroupEltInterface(const Rank &l, Decimal) + : symbol(l), prefix(""), postfix(""), separator("") /* Constructs the GAP interface in rank l. This represents Coxeter words as lists, with decimal symbols : for instance, the element 12321 in @@ -615,14 +606,14 @@ GroupEltInterface::GroupEltInterface(const Rank& l, Decimal) { symbol.setSize(l); - makeSymbols(symbol,decimalSymbols(l),l); + makeSymbols(symbol, decimalSymbols(l), l); if (l > 9) separator = "."; } -GroupEltInterface::GroupEltInterface(const Rank& l, GAP) - :symbol(l),prefix("["),postfix("]"),separator(",") +GroupEltInterface::GroupEltInterface(const Rank &l, GAP) + : symbol(l), prefix("["), postfix("]"), separator(",") /* Constructs the GAP interface in rank l. This represents Coxeter words as lists, with decimal symbols : for instance, the element 12321 in @@ -631,11 +622,11 @@ GroupEltInterface::GroupEltInterface(const Rank& l, GAP) { symbol.setSize(l); - makeSymbols(symbol,decimalSymbols(l),l); + makeSymbols(symbol, decimalSymbols(l), l); } -GroupEltInterface::GroupEltInterface(const Rank& l, Hexadecimal) - :symbol(l),prefix(""),postfix(""),separator("") +GroupEltInterface::GroupEltInterface(const Rank &l, Hexadecimal) + : symbol(l), prefix(""), postfix(""), separator("") /* Constructs the hexadecimal interface in rank l. This represents Coxeter words as strings of hex digits if the rank is <= 15, dot-separated hex @@ -644,14 +635,14 @@ GroupEltInterface::GroupEltInterface(const Rank& l, Hexadecimal) { symbol.setSize(l); - makeSymbols(symbol,hexSymbols(l),l); + makeSymbols(symbol, hexSymbols(l), l); if (l > 15) separator = "."; } -GroupEltInterface::GroupEltInterface(const Rank& l, HexadecimalFromZero) - :symbol(l),prefix(""),postfix(""),separator("") +GroupEltInterface::GroupEltInterface(const Rank &l, HexadecimalFromZero) + : symbol(l), prefix(""), postfix(""), separator("") /* Constructs the hexadecimal interface in rank l. This represents Coxeter @@ -661,7 +652,7 @@ GroupEltInterface::GroupEltInterface(const Rank& l, HexadecimalFromZero) { symbol.setSize(l); - makeSymbols(symbol,hexSymbolsFromZero(l),l); + makeSymbols(symbol, hexSymbolsFromZero(l), l); if (l > 16) separator = "."; @@ -677,23 +668,23 @@ GroupEltInterface::~GroupEltInterface() /******** accessors *********************************************************/ -void GroupEltInterface::print(FILE* file) const +void GroupEltInterface::print(FILE *file) const { - fprintf(file,"prefix: "); - io::print(file,prefix); - fprintf(file,"\n"); - fprintf(file,"separator: "); - io::print(file,separator); - fprintf(file,"\n"); - fprintf(file,"postfix: "); - io::print(file,postfix); - fprintf(file,"\n"); + fprintf(file, "prefix: "); + io::print(file, prefix); + fprintf(file, "\n"); + fprintf(file, "separator: "); + io::print(file, separator); + fprintf(file, "\n"); + fprintf(file, "postfix: "); + io::print(file, postfix); + fprintf(file, "\n"); for (Generator s = 0; s < symbol.size(); ++s) { - fprintf(file,"symbol #%d: ",s+1); - io::print(file,symbol[s]); - fprintf(file,"\n"); + fprintf(file, "symbol #%d: ", s + 1); + io::print(file, symbol[s]); + fprintf(file, "\n"); } return; @@ -701,34 +692,34 @@ void GroupEltInterface::print(FILE* file) const /******** manipulators ******************************************************/ -void GroupEltInterface::setPostfix(const String& a) +void GroupEltInterface::setPostfix(const String &a) { postfix = a; return; } -void GroupEltInterface::setPrefix(const String& a) +void GroupEltInterface::setPrefix(const String &a) { prefix = a; return; } -void GroupEltInterface::setSeparator(const String& a) +void GroupEltInterface::setSeparator(const String &a) { separator = a; return; } -void GroupEltInterface::setSymbol(const Generator& s, const String& a) +void GroupEltInterface::setSymbol(const Generator &s, const String &a) /* - Sets the symbol for generator s to a. Remember that the relation between - symbols and numbers is not affected by the ordering of the generators; if - the user changes the ordering, so that a generator previously numbered i is - now numbered j, that generator will be represented by symbol j instead of + Sets the symbol for generator s to a. Remember that the relation between + symbols and numbers is not affected by the ordering of the generators; if + the user changes the ordering, so that a generator previously numbered i is + now numbered j, that generator will be represented by symbol j instead of symbol i; this is the expected behaviour, I think. */ @@ -737,7 +728,7 @@ void GroupEltInterface::setSymbol(const Generator& s, const String& a) return; } -}; +}; // namespace interface /**************************************************************************** @@ -756,14 +747,14 @@ void GroupEltInterface::setSymbol(const Generator& s, const String& a) namespace interface { ReservedSymbols::ReservedSymbols() - :beginGroup(0),endGroup(0),longest(0),inverse(0),power(0),contextnbr(0), - densearray(0) + : beginGroup(0), endGroup(0), longest(0), inverse(0), power(0), + contextnbr(0), densearray(0) {} ReservedSymbols::ReservedSymbols(Default) - :beginGroup("("),endGroup(")"),longest("*"),inverse("!"),power("^"), - contextnbr("%"),densearray("#") + : beginGroup("("), endGroup(")"), longest("*"), inverse("!"), power("^"), + contextnbr("%"), densearray("#") {} @@ -771,7 +762,7 @@ ReservedSymbols::~ReservedSymbols() {} -}; +}; // namespace interface /**************************************************************************** @@ -787,7 +778,7 @@ ReservedSymbols::~ReservedSymbols() - decimalSymbols() : returns a pointer to the list of decimal integers; - hexSymbols() : returns a pointer to the list of hexadecimal integers; - - hexSymbolsFromZero() : returns a pointer to the list of hexadecimal + - hexSymbolsFromZero() : returns a pointer to the list of hexadecimal integers, starting from zero; - twohexSymbols() : returns a pointer to the list of two-digit hex symbols; - alphabeticSymbols() : returns a pointer to the list of alphabetic symbols; @@ -796,7 +787,7 @@ ReservedSymbols::~ReservedSymbols() namespace interface { -const String* alphabeticSymbols(Ulong n) +const String *alphabeticSymbols(Ulong n) /* Produces an alphabetic representation of the numbers in {1,...,n}. @@ -815,22 +806,22 @@ const String* alphabeticSymbols(Ulong n) if (first) { first = false; list.setSize(1); - new(list.ptr()) String(""); + new (list.ptr()) String(""); } - if (n+1 > list.size()) { /* enlarge the list */ - Ulong prev = list.size()-1; - list.setSize(n+1); - for (Ulong j = prev; j < n; ++j) { /* write symbol */ - list[j+1].assign(list[j/26]); - append(list[j+1],alphabet[j%26]); + if (n + 1 > list.size()) { /* enlarge the list */ + Ulong prev = list.size() - 1; + list.setSize(n + 1); + for (Ulong j = prev; j < n; ++j) { /* write symbol */ + list[j + 1].assign(list[j / 26]); + append(list[j + 1], alphabet[j % 26]); } } - return list.ptr()+1; + return list.ptr() + 1; } -const String* decimalSymbols(Ulong n) +const String *decimalSymbols(Ulong n) /* Returns a pointer to a list of strings, the first n of which contain @@ -843,16 +834,16 @@ const String* decimalSymbols(Ulong n) if (n > list.size()) { /* enlarge the list */ Ulong prev_size = list.size(); list.setSize(n); - for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ - list[j].setLength(io::digits(j+1,10)); - sprintf(list[j].ptr(),"%lu",j+1); + for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ + list[j].setLength(io::digits(j + 1, 10)); + sprintf(list[j].ptr(), "%lu", j + 1); } } return list.ptr(); } -const String* hexSymbolsFromZero(Ulong n) +const String *hexSymbolsFromZero(Ulong n) /* Returns a pointer to a list of strings, the first n of which contain @@ -866,16 +857,16 @@ const String* hexSymbolsFromZero(Ulong n) if (n > list.size()) { /* enlarge the list */ Ulong prev_size = list.size(); list.setSize(n); - for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ - list[j].setLength(io::digits(j,16)); - sprintf(list[j].ptr(),"%lx",j); + for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ + list[j].setLength(io::digits(j, 16)); + sprintf(list[j].ptr(), "%lx", j); } } return list.ptr(); } -const String* hexSymbols(Ulong n) +const String *hexSymbols(Ulong n) /* Returns a pointer to a list of strings, the first n of which contain @@ -888,16 +879,16 @@ const String* hexSymbols(Ulong n) if (n > list.size()) { /* enlarge the list */ Ulong prev_size = list.size(); list.setSize(n); - for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ - list[j].setLength(io::digits(j+1,16)); - sprintf(list[j].ptr(),"%lx",j+1); + for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ + list[j].setLength(io::digits(j + 1, 16)); + sprintf(list[j].ptr(), "%lx", j + 1); } } return list.ptr(); } -const String* twohexSymbols(Ulong n) +const String *twohexSymbols(Ulong n) /* Returns a pointer to a list of strings, the first n of which contain @@ -913,16 +904,16 @@ const String* twohexSymbols(Ulong n) if (n > list.size()) { /* enlarge the list */ Ulong prev_size = list.size(); list.setSize(n); - for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ - list[j].setLength(2*io::digits(j+1,256)); - sprintf(list[j].ptr(),"%0*lx",2*io::digits(j+1,256),j+1); + for (Ulong j = prev_size; j < n; ++j) { /* write symbol */ + list[j].setLength(2 * io::digits(j + 1, 256)); + sprintf(list[j].ptr(), "%0*lx", 2 * io::digits(j + 1, 256), j + 1); } } return list.ptr(); } -const Permutation& identityOrder(Ulong n) +const Permutation &identityOrder(Ulong n) { static Permutation list(0); @@ -940,7 +931,7 @@ const Permutation& identityOrder(Ulong n) return list; } -}; +}; // namespace interface /**************************************************************************** @@ -962,7 +953,7 @@ const Permutation& identityOrder(Ulong n) namespace interface { ParseInterface::ParseInterface() - :str(0),nestlevel(0),a(1),c(0),x(0) + : str(0), nestlevel(0), a(1), c(0), x(0) { a.setSize(1); @@ -989,7 +980,7 @@ void ParseInterface::reset() offset = 0; } -}; +}; // namespace interface /**************************************************************************** @@ -1003,8 +994,7 @@ void ParseInterface::reset() namespace interface { -TokenCell::~TokenCell() -{ +TokenCell::~TokenCell() { delete left; delete right; } @@ -1021,13 +1011,12 @@ TokenTree::~TokenTree() delete d_root; } - -Ulong TokenTree::find(const String& str, const Ulong& n, Token& val) const +Ulong TokenTree::find(const String &str, const Ulong &n, Token &val) const /* - Finds the longest initial substring in str from position n which is a valid - token, and puts the value of the token in val. Returns the length of the - token string (i.e., the number of characters read.) It is assumed that the + Finds the longest initial substring in str from position n which is a valid + token, and puts the value of the token in val. Returns the length of the + token string (i.e., the number of characters read.) It is assumed that the empty string is always a valid token, with value 0, and that this value is characteristic of the empty token. @@ -1037,34 +1026,33 @@ Ulong TokenTree::find(const String& str, const Ulong& n, Token& val) const { TokenCell *lastfound = d_root; TokenCell *cell = d_root; - Ulong q = skipSpaces(str,n); + Ulong q = skipSpaces(str, n); Ulong p = 0; - for (Ulong j = 0; j < str.length()-q-n; ++j) { - if (cell->left == 0) /* no tokens of bigger length */ + for (Ulong j = 0; j < str.length() - q - n; ++j) { + if (cell->left == 0) /* no tokens of bigger length */ goto done; cell = cell->left; - char c = str[n+q+j]; + char c = str[n + q + j]; while ((cell->right) && (c > cell->letter)) cell = cell->right; if (c == cell->letter) { if (cell->val) { /* longer token found */ - lastfound = cell; - p = j+1; + lastfound = cell; + p = j + 1; } - } - else + } else goto done; } - done: +done: val = lastfound->val; q += p; return q; } -void TokenTree::insert(const String& str, const Token& val) +void TokenTree::insert(const String &str, const Token &val) /* Insert a new string in the tree, corresponding to the token val. @@ -1090,7 +1078,7 @@ void TokenTree::insert(const String& str, const Token& val) for (; j < str.length(); ++j) { cell = new TokenCell; - cell->right = icell[0]; /* is zero except maybe the first time */ + cell->right = icell[0]; /* is zero except maybe the first time */ cell->letter = str[j]; icell[0] = cell; icell = &cell->left; @@ -1100,7 +1088,7 @@ void TokenTree::insert(const String& str, const Token& val) return; } -}; +}; // namespace interface /**************************************************************************** @@ -1117,28 +1105,28 @@ void TokenTree::insert(const String& str, const Token& val) namespace interface { -String& append(String& str, const CoxWord& g, const GroupEltInterface& GI) +String &append(String &str, const CoxWord &g, const GroupEltInterface &GI) /* Appends the string g to the string str in the output format defined by I. */ { - io::append(str,GI.prefix); + io::append(str, GI.prefix); for (Ulong j = 0; j < g.length(); ++j) { - Generator s = g[j]-1; - io::append(str,GI.symbol[s]); - if (j+1 < g.length()) /* more to come */ - io::append(str,GI.separator); + Generator s = g[j] - 1; + io::append(str, GI.symbol[s]); + if (j + 1 < g.length()) /* more to come */ + io::append(str, GI.separator); } - io::append(str,GI.postfix); + io::append(str, GI.postfix); return str; } -String& append(String& str, const LFlags& f, const Interface& I) +String &append(String &str, const LFlags &f, const Interface &I) /* Appends to str the representation of f as a one-sided descent set, @@ -1146,25 +1134,24 @@ String& append(String& str, const LFlags& f, const Interface& I) */ { - const DescentSetInterface& d = I.descentInterface(); + const DescentSetInterface &d = I.descentInterface(); - io::append(str,d.prefix); + io::append(str, d.prefix); - for (LFlags f1 = f; f1;) - { - Generator s = bits::firstBit(f1); - appendSymbol(str,s,I); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::append(str,d.separator); - } + for (LFlags f1 = f; f1;) { + Generator s = bits::firstBit(f1); + appendSymbol(str, s, I); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::append(str, d.separator); + } - io::append(str,d.postfix); + io::append(str, d.postfix); return str; } -String& appendTwosided(String& str, const LFlags& f, const Interface& I) +String &appendTwosided(String &str, const LFlags &f, const Interface &I) /* Appends to str the representation of f as a two-sided descent set, @@ -1172,56 +1159,56 @@ String& appendTwosided(String& str, const LFlags& f, const Interface& I) */ { - const DescentSetInterface& d = I.descentInterface(); + const DescentSetInterface &d = I.descentInterface(); - io::append(str,d.twosidedPrefix); + io::append(str, d.twosidedPrefix); - for (LFlags f1 = f>>I.rank(); f1;) // left descents - { - Generator s = bits::firstBit(f1); - appendSymbol(str,s,I); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::append(str,d.separator); - } + for (LFlags f1 = f >> I.rank(); f1;) // left descents + { + Generator s = bits::firstBit(f1); + appendSymbol(str, s, I); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::append(str, d.separator); + } - io::append(str,d.twosidedSeparator); + io::append(str, d.twosidedSeparator); - for (LFlags f1 = f&leqmask[I.rank()-1]; f1;) // right descents - { - Generator s = bits::firstBit(f1); - appendSymbol(str,s,I); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::append(str,d.separator); - } + for (LFlags f1 = f & leqmask[I.rank() - 1]; f1;) // right descents + { + Generator s = bits::firstBit(f1); + appendSymbol(str, s, I); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::append(str, d.separator); + } - io::append(str,d.twosidedPostfix); + io::append(str, d.twosidedPostfix); return str; } -void print(FILE *file, const CoxWord& g, const GroupEltInterface& GI) +void print(FILE *file, const CoxWord &g, const GroupEltInterface &GI) /* Prints the CoxWord g to the file in GI's format. */ { - io::print(file,GI.prefix); + io::print(file, GI.prefix); for (Ulong j = 0; j < g.length(); ++j) { - Generator s = g[j]-1; - io::print(file,GI.symbol[s]); - if (j+1 < g.length()) /* more to come */ - io::print(file,GI.separator); + Generator s = g[j] - 1; + io::print(file, GI.symbol[s]); + if (j + 1 < g.length()) /* more to come */ + io::print(file, GI.separator); } - io::print(file,GI.postfix); + io::print(file, GI.postfix); } -void print(FILE *file, const LFlags& f, const DescentSetInterface& DI, - const GroupEltInterface& GI) +void print(FILE *file, const LFlags &f, const DescentSetInterface &DI, + const GroupEltInterface &GI) /* Prints f as a one-sided descent set, according to the current @@ -1229,24 +1216,23 @@ void print(FILE *file, const LFlags& f, const DescentSetInterface& DI, */ { - io::print(file,DI.prefix); + io::print(file, DI.prefix); - for (LFlags f1 = f; f1;) - { - Generator s = bits::firstBit(f1); - io::print(file,GI.symbol[s]); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::print(file,DI.separator); - } + for (LFlags f1 = f; f1;) { + Generator s = bits::firstBit(f1); + io::print(file, GI.symbol[s]); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::print(file, DI.separator); + } - io::print(file,DI.postfix); + io::print(file, DI.postfix); return; } -void printTwosided(FILE *file, const LFlags& f, const DescentSetInterface& DI, - const GroupEltInterface& GI, const Rank& l) +void printTwosided(FILE *file, const LFlags &f, const DescentSetInterface &DI, + const GroupEltInterface &GI, const Rank &l) /* Prints f as a two-sided descent set, according to the current @@ -1254,34 +1240,34 @@ void printTwosided(FILE *file, const LFlags& f, const DescentSetInterface& DI, */ { - io::print(file,DI.twosidedPrefix); + io::print(file, DI.twosidedPrefix); - for (LFlags f1 = f>>l; f1;) // left descents - { - Generator s = bits::firstBit(f1); - io::print(file,GI.symbol[s]); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::print(file,DI.separator); - } + for (LFlags f1 = f >> l; f1;) // left descents + { + Generator s = bits::firstBit(f1); + io::print(file, GI.symbol[s]); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::print(file, DI.separator); + } - io::print(file,DI.twosidedSeparator); + io::print(file, DI.twosidedSeparator); - for (LFlags f1 = f&leqmask[l-1]; f1;) // right descents - { - Generator s = bits::firstBit(f1); - io::print(file,GI.symbol[s]); - f1 &= f1-1; - if (f1) /* there is more to come */ - io::print(file,DI.separator); - } + for (LFlags f1 = f & leqmask[l - 1]; f1;) // right descents + { + Generator s = bits::firstBit(f1); + io::print(file, GI.symbol[s]); + f1 &= f1 - 1; + if (f1) /* there is more to come */ + io::print(file, DI.separator); + } - io::print(file,DI.twosidedPostfix); + io::print(file, DI.twosidedPostfix); return; } -}; +}; // namespace interface /**************************************************************************** @@ -1312,11 +1298,11 @@ void printTwosided(FILE *file, const LFlags& f, const DescentSetInterface& DI, namespace interface { -const String* checkLeadingWhite(const GroupEltInterface& GI) +const String *checkLeadingWhite(const GroupEltInterface &GI) /* Checks if GI constains a string starting with whitespace, as defined by - isspace(). If so, returns a pointer to the first such string; otherwise, + isspace(). If so, returns a pointer to the first such string; otherwise, returns the null-pointer. */ @@ -1335,7 +1321,7 @@ const String* checkLeadingWhite(const GroupEltInterface& GI) return 0; } -bool checkRepeated(const GroupEltInterface& GI) +bool checkRepeated(const GroupEltInterface &GI) /* Checks if G has repeated non-empty symbols. @@ -1348,36 +1334,36 @@ bool checkRepeated(const GroupEltInterface& GI) { List l(0); - + if (GI.prefix.length()) - insert(l,GI.prefix); - if (find(l,GI.separator) != not_found) + insert(l, GI.prefix); + if (find(l, GI.separator) != not_found) return false; if (GI.separator.length()) - insert(l,GI.separator); - if (find(l,GI.postfix) != not_found) + insert(l, GI.separator); + if (find(l, GI.postfix) != not_found) return false; if (GI.separator.length()) - insert(l,GI.postfix); - + insert(l, GI.postfix); + for (Generator s = 0; s < GI.symbol.size(); ++s) { - if (find(l,GI.symbol[s]) != not_found) + if (find(l, GI.symbol[s]) != not_found) return false; if (GI.symbol[s].length()) - insert(l,GI.symbol[s]); + insert(l, GI.symbol[s]); } return true; } -const String* checkReserved(const GroupEltInterface& GI, const Interface& I) +const String *checkReserved(const GroupEltInterface &GI, const Interface &I) /* Checks if GI constains a string that was reserved by I. If so, returns a pointer to the first such string; otherwise, returns the null-pointer. */ -{ +{ if (I.isReserved(GI.prefix)) return &GI.prefix; if (I.isReserved(GI.separator)) @@ -1392,7 +1378,7 @@ const String* checkReserved(const GroupEltInterface& GI, const Interface& I) return 0; } -Ulong descentWidth(const LFlags& f, const Interface& I) +Ulong descentWidth(const LFlags &f, const Interface &I) /* Returns the width of the printout of the descent set. We assume that @@ -1402,76 +1388,75 @@ Ulong descentWidth(const LFlags& f, const Interface& I) { String str(0); - if (f == leqmask[2*I.rank()-1]) { // two-sided descents - interface::appendTwosided(str,f,I); - } - else { // one-sided descents - interface::append(str,leqmask[I.rank()-1],I); + if (f == leqmask[2 * I.rank() - 1]) { // two-sided descents + interface::appendTwosided(str, f, I); + } else { // one-sided descents + interface::append(str, leqmask[I.rank() - 1], I); } - return(str.length()); + return (str.length()); } -bool isBeginGroup(const Token& tok) +bool isBeginGroup(const Token &tok) { return (tok == begingroup_token); } -bool isContextNbr(const Token& tok) +bool isContextNbr(const Token &tok) { return (tok == contextnbr_token); } -bool isDenseArray(const Token& tok) +bool isDenseArray(const Token &tok) { return (tok == densearray_token); } -bool isEndGroup(const Token& tok) +bool isEndGroup(const Token &tok) { return (tok == endgroup_token); } -bool isInverse(const Token& tok) +bool isInverse(const Token &tok) { return (tok == inverse_token); } -bool isLongest(const Token& tok) +bool isLongest(const Token &tok) { return (tok == longest_token); } -bool isModifier(const Token& tok) +bool isModifier(const Token &tok) { return (tokenType(tok) == modifier_type); } -bool isPower(const Token& tok) +bool isPower(const Token &tok) { return (tok == power_token); } -}; +}; // namespace interface namespace { -void makeSymbols(List& list, const String* const symbol, Ulong n) +void makeSymbols(List &list, const String *const symbol, Ulong n) /* - This function deep-copies the n first entries of symbol onto the + This function deep-copies the n first entries of symbol onto the corresponding entries of list. */ -{ +{ list.setSize(n); for (Ulong j = 0; j < n; ++j) { @@ -1481,11 +1466,11 @@ void makeSymbols(List& list, const String* const symbol, Ulong n) return; } -}; +}; // namespace namespace interface { -CoxNbr readCoxNbr(ParseInterface& P, Ulong size) +CoxNbr readCoxNbr(ParseInterface &P, Ulong size) /* This function reads a CoxNbr off P.str, at position P.offset. It returns @@ -1498,48 +1483,47 @@ CoxNbr readCoxNbr(ParseInterface& P, Ulong size) */ { - String& str = P.str; - P.offset += skipSpaces(str,P.offset); + String &str = P.str; + P.offset += skipSpaces(str, P.offset); Ulong c = 0; Ulong p = 0; Ulong q = P.offset; - if ((str[q] == '0') && (str[q+1] == 'x')) { /* process hex number */ + if ((str[q] == '0') && (str[q + 1] == 'x')) { /* process hex number */ p += 2; - while (isxdigit(str[q+p])) { - CoxNbr x = toCoxNbr(str[q+p]); + while (isxdigit(str[q + p])) { + CoxNbr x = toCoxNbr(str[q + p]); if (size <= x) /* overflow */ - return undef_coxnbr; - if (size/16 < c) /* overflow */ - return undef_coxnbr; + return undef_coxnbr; + if (size / 16 < c) /* overflow */ + return undef_coxnbr; c *= 16; - if ((size-x) < c) /* overflow */ - return undef_coxnbr; + if ((size - x) < c) /* overflow */ + return undef_coxnbr; c += x; p++; } - } - else { /* process decimal number */ - while (isdigit(str[q+p])) { - CoxNbr x = toCoxNbr(str[q+p]); + } else { /* process decimal number */ + while (isdigit(str[q + p])) { + CoxNbr x = toCoxNbr(str[q + p]); if (size <= x) /* overflow */ - return undef_coxnbr; - if (size/10 < c) /* overflow */ - return undef_coxnbr; + return undef_coxnbr; + if (size / 10 < c) /* overflow */ + return undef_coxnbr; c *= 10; - if ((size-x) <= c) /* overflow */ - return undef_coxnbr; + if ((size - x) <= c) /* overflow */ + return undef_coxnbr; c += x; p++; } } - P.offset+= p; + P.offset += p; return c; } -}; +}; // namespace interface namespace { @@ -1552,13 +1536,13 @@ CoxNbr toCoxNbr(char c) { if (('0' <= c) && (c <= '9')) { - return c-'0'; + return c - '0'; } if (('a' <= c) && (c <= 'f')) { - return c-'a'+10; + return c - 'a' + 10; } if (('A' <= c) && (c <= 'F')) { - return c-'A'+10; + return c - 'A' + 10; } return 0; } @@ -1566,7 +1550,7 @@ CoxNbr toCoxNbr(char c) Automaton *tokenAutomaton(LFlags f) { - switch(f) { + switch (f) { case 0: return tokenAut0(); case 1: @@ -1594,286 +1578,286 @@ Automaton *tokenAut0() Word recognizer for the case where prefix, postfix and separator are all empty. There should never be tokens of postfix, prefix or generator type. */ - + { - static ExplicitAutomaton aut(2,5); + static ExplicitAutomaton aut(2, 5); aut.setInitial(0); aut.setFailure(1); aut.setAccept(0); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,0); - aut.setTable(0,prefix_type,1); - aut.setTable(0,postfix_type,1); - aut.setTable(0,separator_type,1); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 0); + aut.setTable(0, prefix_type, 1); + aut.setTable(0, postfix_type, 1); + aut.setTable(0, separator_type, 1); - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,1); - aut.setTable(1,prefix_type,1); - aut.setTable(1,postfix_type,1); - aut.setTable(1,separator_type,1); + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 1); + aut.setTable(1, prefix_type, 1); + aut.setTable(1, postfix_type, 1); + aut.setTable(1, separator_type, 1); return &aut; } Automaton *tokenAut1() - + /* Word recognizer for the case where postfix and separator are empty, but prefix is non-empty. */ - + { - static ExplicitAutomaton aut(3,5); + static ExplicitAutomaton aut(3, 5); aut.setInitial(0); aut.setFailure(2); aut.setAccept(1); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,2); - aut.setTable(0,prefix_type,1); - aut.setTable(0,postfix_type,2); - aut.setTable(0,separator_type,2); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 2); + aut.setTable(0, prefix_type, 1); + aut.setTable(0, postfix_type, 2); + aut.setTable(0, separator_type, 2); - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,1); - aut.setTable(1,prefix_type,2); // should be 1 ?? - aut.setTable(1,postfix_type,2); - aut.setTable(1,separator_type,2); + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 1); + aut.setTable(1, prefix_type, 2); // should be 1 ?? + aut.setTable(1, postfix_type, 2); + aut.setTable(1, separator_type, 2); - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,2); - aut.setTable(2,prefix_type,2); - aut.setTable(2,postfix_type,2); - aut.setTable(2,separator_type,2); + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 2); + aut.setTable(2, prefix_type, 2); + aut.setTable(2, postfix_type, 2); + aut.setTable(2, separator_type, 2); return &aut; } Automaton *tokenAut2() - + /* Word recognizer for the case where prefix and separator are empty, but postfix is non-empty. */ - + { - static ExplicitAutomaton aut(3,5); + static ExplicitAutomaton aut(3, 5); aut.setInitial(0); aut.setFailure(2); aut.setAccept(1); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,0); - aut.setTable(0,prefix_type,2); - aut.setTable(0,postfix_type,1); - aut.setTable(0,separator_type,2); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 0); + aut.setTable(0, prefix_type, 2); + aut.setTable(0, postfix_type, 1); + aut.setTable(0, separator_type, 2); - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,2); - aut.setTable(1,prefix_type,2); - aut.setTable(1,postfix_type,2); - aut.setTable(1,separator_type,2); + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 2); + aut.setTable(1, prefix_type, 2); + aut.setTable(1, postfix_type, 2); + aut.setTable(1, separator_type, 2); - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,2); - aut.setTable(2,prefix_type,2); - aut.setTable(2,postfix_type,2); - aut.setTable(2,separator_type,2); + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 2); + aut.setTable(2, prefix_type, 2); + aut.setTable(2, postfix_type, 2); + aut.setTable(2, separator_type, 2); return &aut; } Automaton *tokenAut3() - + /* Word recognizer for the case where prefix and postfix are non-empty, but separator is empty. */ - + { - static ExplicitAutomaton aut(4,5); + static ExplicitAutomaton aut(4, 5); aut.setInitial(0); aut.setFailure(3); aut.setAccept(2); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,3); - aut.setTable(0,prefix_type,1); - aut.setTable(0,postfix_type,3); - aut.setTable(0,separator_type,3); - - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,1); - aut.setTable(1,prefix_type,3); - aut.setTable(1,postfix_type,2); - aut.setTable(1,separator_type,3); - - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,3); - aut.setTable(2,prefix_type,3); - aut.setTable(2,postfix_type,3); - aut.setTable(2,separator_type,3); - - aut.setTable(3,empty_type,3); - aut.setTable(3,generator_type,3); - aut.setTable(3,prefix_type,3); - aut.setTable(3,postfix_type,3); - aut.setTable(3,separator_type,3); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 3); + aut.setTable(0, prefix_type, 1); + aut.setTable(0, postfix_type, 3); + aut.setTable(0, separator_type, 3); + + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 1); + aut.setTable(1, prefix_type, 3); + aut.setTable(1, postfix_type, 2); + aut.setTable(1, separator_type, 3); + + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 3); + aut.setTable(2, prefix_type, 3); + aut.setTable(2, postfix_type, 3); + aut.setTable(2, separator_type, 3); + + aut.setTable(3, empty_type, 3); + aut.setTable(3, generator_type, 3); + aut.setTable(3, prefix_type, 3); + aut.setTable(3, postfix_type, 3); + aut.setTable(3, separator_type, 3); return &aut; } Automaton *tokenAut4() - + /* Word recognizer for the case where prefix and postfix are empty, but postfix is non-empty. */ - + { - static ExplicitAutomaton aut(4,5); + static ExplicitAutomaton aut(4, 5); aut.setInitial(0); aut.setFailure(3); aut.setAccept(0); aut.setAccept(1); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,1); - aut.setTable(0,prefix_type,3); - aut.setTable(0,postfix_type,3); - aut.setTable(0,separator_type,3); - - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,3); - aut.setTable(1,prefix_type,3); - aut.setTable(1,postfix_type,3); - aut.setTable(1,separator_type,2); - - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,1); - aut.setTable(2,prefix_type,3); - aut.setTable(2,postfix_type,3); - aut.setTable(2,separator_type,3); - - aut.setTable(3,empty_type,3); - aut.setTable(3,generator_type,3); - aut.setTable(3,prefix_type,3); - aut.setTable(3,postfix_type,3); - aut.setTable(3,separator_type,3); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 1); + aut.setTable(0, prefix_type, 3); + aut.setTable(0, postfix_type, 3); + aut.setTable(0, separator_type, 3); + + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 3); + aut.setTable(1, prefix_type, 3); + aut.setTable(1, postfix_type, 3); + aut.setTable(1, separator_type, 2); + + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 1); + aut.setTable(2, prefix_type, 3); + aut.setTable(2, postfix_type, 3); + aut.setTable(2, separator_type, 3); + + aut.setTable(3, empty_type, 3); + aut.setTable(3, generator_type, 3); + aut.setTable(3, prefix_type, 3); + aut.setTable(3, postfix_type, 3); + aut.setTable(3, separator_type, 3); return &aut; } Automaton *tokenAut5() - + /* Word recognizer for the case where prefix and separator are non-empty, but postfix is empty. */ - + { - static ExplicitAutomaton aut(5,5); + static ExplicitAutomaton aut(5, 5); aut.setInitial(0); aut.setFailure(4); aut.setAccept(1); aut.setAccept(2); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,4); - aut.setTable(0,prefix_type,1); - aut.setTable(0,postfix_type,4); - aut.setTable(0,separator_type,4); - - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,2); - aut.setTable(1,prefix_type,4); - aut.setTable(1,postfix_type,4); - aut.setTable(1,separator_type,4); - - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,4); - aut.setTable(2,prefix_type,4); - aut.setTable(2,postfix_type,4); - aut.setTable(2,separator_type,3); - - aut.setTable(3,empty_type,3); - aut.setTable(3,generator_type,2); - aut.setTable(3,prefix_type,4); - aut.setTable(3,postfix_type,4); - aut.setTable(3,separator_type,4); - - aut.setTable(4,empty_type,4); - aut.setTable(4,generator_type,4); - aut.setTable(4,prefix_type,4); - aut.setTable(4,postfix_type,4); - aut.setTable(4,separator_type,4); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 4); + aut.setTable(0, prefix_type, 1); + aut.setTable(0, postfix_type, 4); + aut.setTable(0, separator_type, 4); + + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 2); + aut.setTable(1, prefix_type, 4); + aut.setTable(1, postfix_type, 4); + aut.setTable(1, separator_type, 4); + + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 4); + aut.setTable(2, prefix_type, 4); + aut.setTable(2, postfix_type, 4); + aut.setTable(2, separator_type, 3); + + aut.setTable(3, empty_type, 3); + aut.setTable(3, generator_type, 2); + aut.setTable(3, prefix_type, 4); + aut.setTable(3, postfix_type, 4); + aut.setTable(3, separator_type, 4); + + aut.setTable(4, empty_type, 4); + aut.setTable(4, generator_type, 4); + aut.setTable(4, prefix_type, 4); + aut.setTable(4, postfix_type, 4); + aut.setTable(4, separator_type, 4); return &aut; } Automaton *tokenAut6() - + /* Word recognizer for the case where postfix and separator are non-empty, but prefix is empty. */ - + { - static ExplicitAutomaton aut(5,5); + static ExplicitAutomaton aut(5, 5); aut.setInitial(0); aut.setFailure(4); aut.setAccept(3); - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,1); - aut.setTable(0,prefix_type,4); - aut.setTable(0,postfix_type,3); - aut.setTable(0,separator_type,4); - - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,4); - aut.setTable(1,prefix_type,4); - aut.setTable(1,postfix_type,3); - aut.setTable(1,separator_type,2); - - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,1); - aut.setTable(2,prefix_type,4); - aut.setTable(2,postfix_type,4); - aut.setTable(2,separator_type,4); - - aut.setTable(3,empty_type,3); - aut.setTable(3,generator_type,4); - aut.setTable(3,prefix_type,4); - aut.setTable(3,postfix_type,4); - aut.setTable(3,separator_type,4); - - aut.setTable(4,empty_type,4); - aut.setTable(4,generator_type,4); - aut.setTable(4,prefix_type,4); - aut.setTable(4,postfix_type,4); - aut.setTable(4,separator_type,4); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 1); + aut.setTable(0, prefix_type, 4); + aut.setTable(0, postfix_type, 3); + aut.setTable(0, separator_type, 4); + + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 4); + aut.setTable(1, prefix_type, 4); + aut.setTable(1, postfix_type, 3); + aut.setTable(1, separator_type, 2); + + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 1); + aut.setTable(2, prefix_type, 4); + aut.setTable(2, postfix_type, 4); + aut.setTable(2, separator_type, 4); + + aut.setTable(3, empty_type, 3); + aut.setTable(3, generator_type, 4); + aut.setTable(3, prefix_type, 4); + aut.setTable(3, postfix_type, 4); + aut.setTable(3, separator_type, 4); + + aut.setTable(4, empty_type, 4); + aut.setTable(4, generator_type, 4); + aut.setTable(4, prefix_type, 4); + aut.setTable(4, postfix_type, 4); + aut.setTable(4, separator_type, 4); return &aut; } Automaton *tokenAut7() - + /* Word recognizer for the case where prefix, postfix and separator are all non-empty. */ - + { - static ExplicitAutomaton aut(6,5); + static ExplicitAutomaton aut(6, 5); aut.setInitial(0); aut.setFailure(5); @@ -1881,60 +1865,60 @@ Automaton *tokenAut7() // initial state; accepts only the prefix - aut.setTable(0,empty_type,0); - aut.setTable(0,generator_type,5); - aut.setTable(0,prefix_type,1); - aut.setTable(0,postfix_type,5); - aut.setTable(0,separator_type,5); + aut.setTable(0, empty_type, 0); + aut.setTable(0, generator_type, 5); + aut.setTable(0, prefix_type, 1); + aut.setTable(0, postfix_type, 5); + aut.setTable(0, separator_type, 5); // prefix-read; accepts postfix or generator - aut.setTable(1,empty_type,1); - aut.setTable(1,generator_type,2); - aut.setTable(1,prefix_type,5); - aut.setTable(1,postfix_type,4); - aut.setTable(1,separator_type,5); + aut.setTable(1, empty_type, 1); + aut.setTable(1, generator_type, 2); + aut.setTable(1, prefix_type, 5); + aut.setTable(1, postfix_type, 4); + aut.setTable(1, separator_type, 5); // generator-read; accepts postfix or separator - aut.setTable(2,empty_type,2); - aut.setTable(2,generator_type,5); - aut.setTable(2,prefix_type,5); - aut.setTable(2,postfix_type,4); - aut.setTable(2,separator_type,3); + aut.setTable(2, empty_type, 2); + aut.setTable(2, generator_type, 5); + aut.setTable(2, prefix_type, 5); + aut.setTable(2, postfix_type, 4); + aut.setTable(2, separator_type, 3); // separator-read; accepts only a generator - aut.setTable(3,empty_type,3); - aut.setTable(3,generator_type,2); - aut.setTable(3,prefix_type,5); - aut.setTable(3,postfix_type,5); - aut.setTable(3,separator_type,5); + aut.setTable(3, empty_type, 3); + aut.setTable(3, generator_type, 2); + aut.setTable(3, prefix_type, 5); + aut.setTable(3, postfix_type, 5); + aut.setTable(3, separator_type, 5); // postfix-read; doesn't accept anything - aut.setTable(4,empty_type,4); - aut.setTable(4,generator_type,5); - aut.setTable(4,prefix_type,5); - aut.setTable(4,postfix_type,5); - aut.setTable(4,separator_type,5); + aut.setTable(4, empty_type, 4); + aut.setTable(4, generator_type, 5); + aut.setTable(4, prefix_type, 5); + aut.setTable(4, postfix_type, 5); + aut.setTable(4, separator_type, 5); // failure state - aut.setTable(5,empty_type,5); - aut.setTable(5,generator_type,5); - aut.setTable(5,prefix_type,5); - aut.setTable(5,postfix_type,5); - aut.setTable(5,separator_type,5); + aut.setTable(5, empty_type, 5); + aut.setTable(5, generator_type, 5); + aut.setTable(5, prefix_type, 5); + aut.setTable(5, postfix_type, 5); + aut.setTable(5, separator_type, 5); return &aut; } -}; +}; // namespace namespace interface { -Letter tokenType(const Token& tok) +Letter tokenType(const Token &tok) /* Returns the type of the token : one of generator_type, separator_type, @@ -1966,4 +1950,4 @@ Letter tokenType(const Token& tok) }; } -}; +}; // namespace interface diff --git a/interface.h b/interface.h index 3d37ec0..8f6bee4 100644 --- a/interface.h +++ b/interface.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERFACE_H /* guard against multiple inclusions */ +#ifndef INTERFACE_H /* guard against multiple inclusions */ #define INTERFACE_H #include "globals.h" @@ -18,84 +18,83 @@ #include "transducer.h" namespace interface { - using namespace coxeter; - using namespace automata; - using namespace coxtypes; - using namespace list; - using namespace minroots; - using namespace transducer; +using namespace coxeter; +using namespace automata; +using namespace coxtypes; +using namespace list; +using namespace minroots; +using namespace transducer; /******** type declarations *************************************************/ - struct DescentSetInterface; - struct GroupEltInterface; - struct ReservedSymbols; - class PolynomialInterface; - class Interface; - class EmptyInterface; - class MinRootInterface; - class TokenTree; - class TransducerInterface; +struct DescentSetInterface; +struct GroupEltInterface; +struct ReservedSymbols; +class PolynomialInterface; +class Interface; +class EmptyInterface; +class MinRootInterface; +class TokenTree; +class TransducerInterface; - struct TokenCell; - struct ParseInterface; +struct TokenCell; +struct ParseInterface; - typedef unsigned int Token; +typedef unsigned int Token; - // tags +// tags - struct Hexadecimal {}; - struct HexadecimalFromZero {}; - struct Decimal {}; - struct Alphabetic {}; +struct Hexadecimal {}; +struct HexadecimalFromZero {}; +struct Decimal {}; +struct Alphabetic {}; /******** constants **********************************************************/ - const Letter empty_type = 0; - const Letter generator_type = 1; - const Letter prefix_type = 2; - const Letter postfix_type = 3; - const Letter separator_type = 4; - const Letter modifier_type = 5; - const Letter grouping_type = 6; - const Letter number_type = 7; +const Letter empty_type = 0; +const Letter generator_type = 1; +const Letter prefix_type = 2; +const Letter postfix_type = 3; +const Letter separator_type = 4; +const Letter modifier_type = 5; +const Letter grouping_type = 6; +const Letter number_type = 7; /******** function declarations **********************************************/ - const String* alphabeticSymbols(Ulong n); - String& append(String& str, const CoxWord& g, const GroupEltInterface& GI); - String& append(String& buf, const LFlags& f, const Interface& I); - String& appendSymbol(String& str, const Generator& s, const Interface& I); - String& appendTwosided(String& buf, const LFlags& f, const Interface& I); - const String* checkLeadingWhite(const GroupEltInterface& GI); - bool checkRepeated(const GroupEltInterface& GI); - const String* checkReserved(const GroupEltInterface& GI, const Interface& I); - const String* decimalSymbols(Ulong n); - Ulong descentWidth(const LFlags& f, const Interface& I); - const String* hexSymbols(Ulong n); - const String* hexSymbolsFromZero(Ulong n); - const Permutation& identityOrder(Ulong n); - bool isBeginGroup(const Token& tok); - bool isContextNbr(const Token& tok); - bool isDenseArray(const Token& tok); - bool isEndGroup(const Token& tok); - bool isInverse(const Token& tok); - bool isLongest(const Token& tok); - bool isModifier(const Token& tok); - bool isPower(const Token& tok); - void print(FILE *file, const CoxWord& g, const GroupEltInterface& I); - void print(FILE *file, const LFlags& f, const Interface& I); - void print(FILE *file, const LFlags& f, const DescentSetInterface& DI, - const GroupEltInterface& GI); - void printSymbol(FILE *file, const Generator& s, const Interface& I); - void printTwosided(FILE *file, const LFlags& f, - const DescentSetInterface& DI, - const GroupEltInterface& GI, const Rank& l); - void printTwosided(FILE *file, const LFlags& f, const Interface& I); - /* inlined */ - CoxNbr readCoxNbr(ParseInterface& P, Ulong size); - Letter tokenType(const Token& tok); - const String* twohexSymbols(Ulong n); +const String *alphabeticSymbols(Ulong n); +String &append(String &str, const CoxWord &g, const GroupEltInterface &GI); +String &append(String &buf, const LFlags &f, const Interface &I); +String &appendSymbol(String &str, const Generator &s, const Interface &I); +String &appendTwosided(String &buf, const LFlags &f, const Interface &I); +const String *checkLeadingWhite(const GroupEltInterface &GI); +bool checkRepeated(const GroupEltInterface &GI); +const String *checkReserved(const GroupEltInterface &GI, const Interface &I); +const String *decimalSymbols(Ulong n); +Ulong descentWidth(const LFlags &f, const Interface &I); +const String *hexSymbols(Ulong n); +const String *hexSymbolsFromZero(Ulong n); +const Permutation &identityOrder(Ulong n); +bool isBeginGroup(const Token &tok); +bool isContextNbr(const Token &tok); +bool isDenseArray(const Token &tok); +bool isEndGroup(const Token &tok); +bool isInverse(const Token &tok); +bool isLongest(const Token &tok); +bool isModifier(const Token &tok); +bool isPower(const Token &tok); +void print(FILE *file, const CoxWord &g, const GroupEltInterface &I); +void print(FILE *file, const LFlags &f, const Interface &I); +void print(FILE *file, const LFlags &f, const DescentSetInterface &DI, + const GroupEltInterface &GI); +void printSymbol(FILE *file, const Generator &s, const Interface &I); +void printTwosided(FILE *file, const LFlags &f, const DescentSetInterface &DI, + const GroupEltInterface &GI, const Rank &l); +void printTwosided(FILE *file, const LFlags &f, const Interface &I); +/* inlined */ +CoxNbr readCoxNbr(ParseInterface &P, Ulong size); +Letter tokenType(const Token &tok); +const String *twohexSymbols(Ulong n); /******** type definitions ***************************************************/ @@ -106,7 +105,7 @@ struct ParseInterface { CoxWord c; State x; Ulong offset; -/* constructors and destructors */ + /* constructors and destructors */ ParseInterface(); ~ParseInterface(); void reset(); @@ -117,28 +116,30 @@ struct TokenCell { char letter; TokenCell *left; TokenCell *right; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TokenCell));} - TokenCell() {}; + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TokenCell)); + } + TokenCell(){}; ~TokenCell(); }; class TokenTree { - private: +private: TokenCell *d_root; - public: -/* constructors and destructors */ + +public: + /* constructors and destructors */ TokenTree(); - TokenTree(TokenCell *cell):d_root(cell) {}; + TokenTree(TokenCell *cell) : d_root(cell){}; ~TokenTree(); -/* manipulators */ - void insert(const String& str, const Token& val); -/* accessors */ - Ulong find(String& str, Token& val) const; - Ulong find(const String& str, const Ulong& n, Token& val) const; - TokenCell *root() {return d_root;} + /* manipulators */ + void insert(const String &str, const Token &val); + /* accessors */ + Ulong find(String &str, Token &val) const; + Ulong find(const String &str, const Ulong &n, Token &val) const; + TokenCell *root() { return d_root; } }; struct DescentSetInterface { @@ -148,20 +149,21 @@ struct DescentSetInterface { String twosidedPrefix; String twosidedPostfix; String twosidedSeparator; - void* operator new(size_t size) {return arena().alloc(size);} - void* operator new(size_t size, void* ptr) {return ptr;} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(DescentSetInterface));} - void operator delete(void* p1, void* p2) {}; + void *operator new(size_t size) { return arena().alloc(size); } + void *operator new(size_t size, void *ptr) { return ptr; } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(DescentSetInterface)); + } + void operator delete(void *p1, void *p2){}; DescentSetInterface(); DescentSetInterface(GAP); ~DescentSetInterface(); - void setPostfix(const String& str); - void setPrefix(const String& str); - void setSeparator(const String& str); - void setTwosidedPrefix(const String& str); - void setTwosidedPostfix(const String& str); - void setTwosidedSeparator(const String& str); + void setPostfix(const String &str); + void setPrefix(const String &str); + void setSeparator(const String &str); + void setTwosidedPrefix(const String &str); + void setTwosidedPostfix(const String &str); + void setTwosidedSeparator(const String &str); }; struct GroupEltInterface { @@ -169,26 +171,27 @@ struct GroupEltInterface { String prefix; String postfix; String separator; - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GroupEltInterface));} + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GroupEltInterface)); + } #if 0 void* operator new(size_t size, void* ptr) {return ptr;} void operator delete(void* p1, void* p2) {}; #endif GroupEltInterface(); - GroupEltInterface(const Rank& l); - GroupEltInterface(const Rank& l, Alphabetic); - GroupEltInterface(const Rank& l, Decimal); - GroupEltInterface(const Rank& l, GAP); - GroupEltInterface(const Rank& l, Hexadecimal); - GroupEltInterface(const Rank& l, HexadecimalFromZero); + GroupEltInterface(const Rank &l); + GroupEltInterface(const Rank &l, Alphabetic); + GroupEltInterface(const Rank &l, Decimal); + GroupEltInterface(const Rank &l, GAP); + GroupEltInterface(const Rank &l, Hexadecimal); + GroupEltInterface(const Rank &l, HexadecimalFromZero); ~GroupEltInterface(); - void setPostfix(const String& a); - void setPrefix(const String& a); - void setSeparator(const String& a); - void setSymbol(const Generator& s, const String& a); - void print(FILE* file) const; + void setPostfix(const String &a); + void setPrefix(const String &a); + void setSeparator(const String &a); + void setSymbol(const Generator &s, const String &a); + void print(FILE *file) const; }; struct ReservedSymbols { @@ -204,13 +207,13 @@ struct ReservedSymbols { ~ReservedSymbols(); }; class Interface { - protected: +protected: Permutation d_order; TokenTree d_symbolTree; - Automaton const* d_tokenAut; - GroupEltInterface* d_in; - GroupEltInterface* d_out; - DescentSetInterface* d_descent; + Automaton const *d_tokenAut; + GroupEltInterface *d_in; + GroupEltInterface *d_out; + DescentSetInterface *d_descent; String d_beginGroup; String d_endGroup; String d_longest; @@ -221,114 +224,136 @@ class Interface { String d_parseEscape; List d_reserved; Rank d_rank; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Interface));} - Interface(const Type& x, const Rank& l); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(Interface)); + } + Interface(const Type &x, const Rank &l); virtual ~Interface(); -/* manipulators */ + /* manipulators */ void readSymbols(); void setAutomaton(); void setDescent(Default); void setDescent(GAP); - virtual void setIn(const GroupEltInterface& i); /* inlined */ - void setInPostfix(const String& a); /* inlined */ - void setInPrefix(const String& a); /* inlined */ - void setInSeparator(const String& a); /* inlined */ - void setInSymbol(const Generator& s, const String& a); /* inlined */ - void setOrder(const Permutation& gen_order); - virtual void setOut(const GroupEltInterface& i); /* inlined */ - void setOutPostfix(const String& a); /* inlined */ - void setOutPrefix(const String& a); /* inlined */ - void setOutSeparator(const String& a); /* inlined */ - void setOutSymbol(const Generator& s, const String& a); /* inlined */ -/* accessors */ - const DescentSetInterface& descentInterface() const; /* inlined */ - Ulong getToken(ParseInterface& P, Token& tok) const; /* inlined */ - Ulong in(const Ulong& j) const; /* inlined */ - const GroupEltInterface& inInterface() const; /* inlined */ - const String& inPostfix() const; /* inlined */ - const String& inPrefix() const; /* inlined */ - const String& inSeparator() const; /* inlined */ - const String& inSymbol(const Generator& s) const; /* inlined */ - bool isReserved(const String& str) const; /* inlined */ - const Permutation& order() const; /* inlined */ - Ulong out(const Ulong& j) const; /* inlined */ - const GroupEltInterface& outInterface() const; /* inlined */ - const String& outPostfix() const; /* inlined */ - const String& outPrefix() const; /* inlined */ - const String& outSeparator() const; /* inlined */ - const String& outSymbol(const Generator& s) const; /* inlined */ - bool parseCoxWord(ParseInterface& P, const MinTable& T) const; - Rank rank() const; /* inlined */ - bool readCoxElt(ParseInterface& P) const; - const TokenTree& symbolTree() const; -// i/o - virtual String& append(String& str, const CoxWord& g) const; - virtual void print(FILE* file, const CoxWord& g) const; + virtual void setIn(const GroupEltInterface &i); /* inlined */ + void setInPostfix(const String &a); /* inlined */ + void setInPrefix(const String &a); /* inlined */ + void setInSeparator(const String &a); /* inlined */ + void setInSymbol(const Generator &s, const String &a); /* inlined */ + void setOrder(const Permutation &gen_order); + virtual void setOut(const GroupEltInterface &i); /* inlined */ + void setOutPostfix(const String &a); /* inlined */ + void setOutPrefix(const String &a); /* inlined */ + void setOutSeparator(const String &a); /* inlined */ + void setOutSymbol(const Generator &s, const String &a); /* inlined */ + /* accessors */ + const DescentSetInterface &descentInterface() const; /* inlined */ + Ulong getToken(ParseInterface &P, Token &tok) const; /* inlined */ + Ulong in(const Ulong &j) const; /* inlined */ + const GroupEltInterface &inInterface() const; /* inlined */ + const String &inPostfix() const; /* inlined */ + const String &inPrefix() const; /* inlined */ + const String &inSeparator() const; /* inlined */ + const String &inSymbol(const Generator &s) const; /* inlined */ + bool isReserved(const String &str) const; /* inlined */ + const Permutation &order() const; /* inlined */ + Ulong out(const Ulong &j) const; /* inlined */ + const GroupEltInterface &outInterface() const; /* inlined */ + const String &outPostfix() const; /* inlined */ + const String &outPrefix() const; /* inlined */ + const String &outSeparator() const; /* inlined */ + const String &outSymbol(const Generator &s) const; /* inlined */ + bool parseCoxWord(ParseInterface &P, const MinTable &T) const; + Rank rank() const; /* inlined */ + bool readCoxElt(ParseInterface &P) const; + const TokenTree &symbolTree() const; + // i/o + virtual String &append(String &str, const CoxWord &g) const; + virtual void print(FILE *file, const CoxWord &g) const; }; /******** inline implementations *******************************************/ -inline String& append(String& str, const CoxWord& g, const Interface& I) - {return append(str,g,I.outInterface());} -inline String& appendSymbol(String& str, const Generator& s, - const Interface& I) - {return io::append(str,I.outSymbol(s));} -inline void print(FILE *file, const LFlags& f, const Interface& I) - {return print(file,f,I.descentInterface(),I.outInterface());} -inline void printSymbol(FILE *file, const Generator& s, const Interface& I) - {io::print(file,I.outSymbol(s));} -inline void printTwosided(FILE *file, const LFlags& f, const Interface& I) - {return printTwosided(file,f,I.descentInterface(),I.outInterface(), - I.rank());} - -inline Ulong TokenTree::find(String& str, Token& val) const - {return find(str.ptr(),str.length(),val);} +inline String &append(String &str, const CoxWord &g, const Interface &I) { + return append(str, g, I.outInterface()); +} +inline String &appendSymbol(String &str, const Generator &s, + const Interface &I) { + return io::append(str, I.outSymbol(s)); +} +inline void print(FILE *file, const LFlags &f, const Interface &I) { + return print(file, f, I.descentInterface(), I.outInterface()); +} +inline void printSymbol(FILE *file, const Generator &s, const Interface &I) { + io::print(file, I.outSymbol(s)); +} +inline void printTwosided(FILE *file, const LFlags &f, const Interface &I) { + return printTwosided(file, f, I.descentInterface(), I.outInterface(), + I.rank()); +} -inline const DescentSetInterface& Interface::descentInterface() const - {return *d_descent;} -inline Ulong Interface::getToken(ParseInterface& P, Token& tok) const - {return d_symbolTree.find(P.str,P.offset,tok);} -inline const GroupEltInterface& Interface::inInterface() const - {return *d_in;} -inline const String& Interface::inPostfix() const {return d_in->postfix;} -inline const String& Interface::inPrefix() const {return d_in->prefix;} -inline const String& Interface::inSeparator() const {return d_in->separator;} -inline const String& Interface::inSymbol(const Generator& s) const - {return d_in->symbol[s];} -inline bool Interface::isReserved(const String& str) const - {return find(d_reserved,str) != ~static_cast(0);} -inline const GroupEltInterface& Interface::outInterface() const - {return *d_out;} -inline const Permutation& Interface::order() const {return d_order;} -inline const String& Interface::outPostfix() const {return d_out->postfix;} -inline const String& Interface::outPrefix() const {return d_out->prefix;} -inline const String& Interface::outSeparator() const {return d_out->separator;} -inline const String& Interface::outSymbol(const Generator& s) const - {return d_out->symbol[s];} -inline Rank Interface::rank() const {return d_rank;} -inline const TokenTree& Interface::symbolTree() const {return d_symbolTree;} +inline Ulong TokenTree::find(String &str, Token &val) const { + return find(str.ptr(), str.length(), val); +} -inline void Interface::setInPostfix(const String& a) {d_in->setPostfix(a);} -inline void Interface::setInPrefix(const String& a) {d_in->setPrefix(a);} -inline void Interface::setInSeparator(const String& a) {d_in->setSeparator(a);} -inline void Interface::setInSymbol(const Generator& s, const String& a) - {return d_in->setSymbol(s,a);} -inline void Interface::setOutPostfix(const String& a) {d_out->setPostfix(a);} -inline void Interface::setOutPrefix(const String& a) {d_out->setPrefix(a);} -inline void Interface::setOutSeparator(const String& a) - {d_out->setSeparator(a);} -inline void Interface::setOutSymbol(const Generator& s, const String& a) - {return d_out->setSymbol(s,a);} +inline const DescentSetInterface &Interface::descentInterface() const { + return *d_descent; +} +inline Ulong Interface::getToken(ParseInterface &P, Token &tok) const { + return d_symbolTree.find(P.str, P.offset, tok); +} +inline const GroupEltInterface &Interface::inInterface() const { return *d_in; } +inline const String &Interface::inPostfix() const { return d_in->postfix; } +inline const String &Interface::inPrefix() const { return d_in->prefix; } +inline const String &Interface::inSeparator() const { return d_in->separator; } +inline const String &Interface::inSymbol(const Generator &s) const { + return d_in->symbol[s]; +} +inline bool Interface::isReserved(const String &str) const { + return find(d_reserved, str) != ~static_cast(0); +} +inline const GroupEltInterface &Interface::outInterface() const { + return *d_out; +} +inline const Permutation &Interface::order() const { return d_order; } +inline const String &Interface::outPostfix() const { return d_out->postfix; } +inline const String &Interface::outPrefix() const { return d_out->prefix; } +inline const String &Interface::outSeparator() const { + return d_out->separator; +} +inline const String &Interface::outSymbol(const Generator &s) const { + return d_out->symbol[s]; +} +inline Rank Interface::rank() const { return d_rank; } +inline const TokenTree &Interface::symbolTree() const { return d_symbolTree; } -inline String& Interface::append(String& str, const CoxWord& g) const - {return interface::append(str,g,*d_out);} -inline void Interface::print(FILE* file, const CoxWord& g) const - {interface::print(file,g,*d_out);} +inline void Interface::setInPostfix(const String &a) { d_in->setPostfix(a); } +inline void Interface::setInPrefix(const String &a) { d_in->setPrefix(a); } +inline void Interface::setInSeparator(const String &a) { + d_in->setSeparator(a); +} +inline void Interface::setInSymbol(const Generator &s, const String &a) { + return d_in->setSymbol(s, a); +} +inline void Interface::setOutPostfix(const String &a) { d_out->setPostfix(a); } +inline void Interface::setOutPrefix(const String &a) { d_out->setPrefix(a); } +inline void Interface::setOutSeparator(const String &a) { + d_out->setSeparator(a); +} +inline void Interface::setOutSymbol(const Generator &s, const String &a) { + return d_out->setSymbol(s, a); +} +inline String &Interface::append(String &str, const CoxWord &g) const { + return interface::append(str, g, *d_out); +} +inline void Interface::print(FILE *file, const CoxWord &g) const { + interface::print(file, g, *d_out); } +} // namespace interface + #endif diff --git a/invkl.cpp b/invkl.cpp index cec994d..47c3c50 100644 --- a/invkl.cpp +++ b/invkl.cpp @@ -1,6 +1,6 @@ /* This is invkl.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -27,7 +27,7 @@ - then, we apply recursion : let s be s.t. ys < y, so that also xs < x; then we have : - Q_{xs,ys} = Q_{x,y} + qQ_{x,ys} - + Q_{xs,ys} = Q_{x,y} + qQ_{x,ys} - \sum_z Q_{ys,z}mu(x,z)q^{1/2(l_z-l_xs)} where z runs through the elements in [x,ys] s.t. the length difference @@ -43,64 +43,67 @@ namespace invkl { - struct KLContext::KLHelper { -/* data */ - KLContext* d_kl; -/* constructors and destructors */ - KLHelper(KLContext* kl):d_kl(kl) {}; - ~KLHelper() {}; - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLHelper));} -/* member functions */ - void addCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, - KLPol& pol); - void allocExtrRow(const CoxNbr& y) {klsupport().allocExtrRow(y);} - void allocKLRow(const CoxNbr& y); - void allocMuRow(const CoxNbr& y); - void allocRowComputation(const CoxNbr& y); - bool checkKLRow(const CoxNbr& y); - bool checkMuRow(const CoxNbr& y); - void coatomCorrection(const CoxNbr& y, List& pol); - KLCoeff computeMu(const CoxNbr& x, const CoxNbr& y); - const ExtrRow& extrList(const CoxNbr& y) {return klsupport().extrList(y);} - const KLPol* fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - void fillKLRow(const CoxNbr& y); - void initWorkspace(const CoxNbr& y, List& pol); - CoxNbr inverse(const CoxNbr& y) {return klsupport().inverse(y);} - void inverseMuRow(const CoxNbr& y); - bool isExtrAllocated(const CoxNbr& y) - {return klsupport().isExtrAllocated(y);} - bool isKLAllocated(const CoxNbr& y) {return d_kl->isKLAllocated(y);} - bool isMuAllocated(const CoxNbr& y) {return d_kl->isMuAllocated(y);} - KLRow& klList(const CoxNbr& y) {return *d_kl->d_klList[y];} - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y) - {return d_kl->klPol(x,y);} - KLSupport& klsupport() {return d_kl->d_klsupport[0];} - search::BinaryTree& klTree() {return d_kl->d_klTree;} - Generator last(const CoxNbr& x) {return klsupport().last(x);} - void lastTerm(const CoxNbr& y, List& pol); - void makeKLRow(const CoxNbr& y); - void muCorrection(const CoxNbr& y, List& pol); - MuRow& muList(const CoxNbr& y) {return *d_kl->d_muList[y];} - Rank rank() {return d_kl->rank();} - void readMuRow(const CoxNbr& y); - KLCoeff recursiveMu(const CoxNbr& x, const CoxNbr& y, const Generator& s); - const SchubertContext& schubert() {return klsupport().schubert();} - KLStatus& status() {return *d_kl->d_status;} - void writeKLRow(const CoxNbr& y, List& pol); - }; - +struct KLContext::KLHelper { + /* data */ + KLContext *d_kl; + /* constructors and destructors */ + KLHelper(KLContext *kl) : d_kl(kl){}; + ~KLHelper(){}; + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLHelper)); + } + /* member functions */ + void addCorrection(const CoxNbr &x, const CoxNbr &y, const Generator &s, + KLPol &pol); + void allocExtrRow(const CoxNbr &y) { klsupport().allocExtrRow(y); } + void allocKLRow(const CoxNbr &y); + void allocMuRow(const CoxNbr &y); + void allocRowComputation(const CoxNbr &y); + bool checkKLRow(const CoxNbr &y); + bool checkMuRow(const CoxNbr &y); + void coatomCorrection(const CoxNbr &y, List &pol); + KLCoeff computeMu(const CoxNbr &x, const CoxNbr &y); + const ExtrRow &extrList(const CoxNbr &y) { return klsupport().extrList(y); } + const KLPol *fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + void fillKLRow(const CoxNbr &y); + void initWorkspace(const CoxNbr &y, List &pol); + CoxNbr inverse(const CoxNbr &y) { return klsupport().inverse(y); } + void inverseMuRow(const CoxNbr &y); + bool isExtrAllocated(const CoxNbr &y) { + return klsupport().isExtrAllocated(y); + } + bool isKLAllocated(const CoxNbr &y) { return d_kl->isKLAllocated(y); } + bool isMuAllocated(const CoxNbr &y) { return d_kl->isMuAllocated(y); } + KLRow &klList(const CoxNbr &y) { return *d_kl->d_klList[y]; } + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y) { + return d_kl->klPol(x, y); + } + KLSupport &klsupport() { return d_kl->d_klsupport[0]; } + search::BinaryTree &klTree() { return d_kl->d_klTree; } + Generator last(const CoxNbr &x) { return klsupport().last(x); } + void lastTerm(const CoxNbr &y, List &pol); + void makeKLRow(const CoxNbr &y); + void muCorrection(const CoxNbr &y, List &pol); + MuRow &muList(const CoxNbr &y) { return *d_kl->d_muList[y]; } + Rank rank() { return d_kl->rank(); } + void readMuRow(const CoxNbr &y); + KLCoeff recursiveMu(const CoxNbr &x, const CoxNbr &y, const Generator &s); + const SchubertContext &schubert() { return klsupport().schubert(); } + KLStatus &status() { return *d_kl->d_status; } + void writeKLRow(const CoxNbr &y, List &pol); }; +}; // namespace invkl + namespace { - using namespace invkl; +using namespace invkl; - MuData* find(MuRow& row, const CoxNbr& x); - const KLPol& zeroPol(); -}; +MuData *find(MuRow &row, const CoxNbr &x); +const KLPol &zeroPol(); +}; // namespace /***************************************************************************** @@ -136,8 +139,8 @@ namespace { namespace invkl { -KLContext::KLContext(KLSupport* kls) - :d_klsupport(kls), d_klList(kls->size()), d_muList(kls->size()) +KLContext::KLContext(KLSupport *kls) + : d_klsupport(kls), d_klList(kls->size()), d_muList(kls->size()) { d_status = new KLStatus; @@ -179,7 +182,7 @@ KLContext::~KLContext() /******** manipulators *******************************************************/ -void KLContext::applyInverse(const CoxNbr& x) +void KLContext::applyInverse(const CoxNbr &x) /* Exchanges rows for x and x_inverse in klList. It is assumed that the row @@ -239,8 +242,8 @@ void KLContext::fillMu() {} -const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, - const Generator& s) +const KLPol &KLContext::klPol(const CoxNbr &d_x, const CoxNbr &d_y, + const Generator &s) /* This function returns the Kazhdan-Lusztig polynomial P_{x,y}. It is @@ -251,11 +254,11 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, { CoxNbr x = d_x; CoxNbr y = d_y; - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); /* put y in extremal position w.r.t. x */ - y = p.minimize(y,p.ascent(x)); + y = p.minimize(y, p.ascent(x)); /* check for trivial cases */ @@ -280,11 +283,11 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, /* find x in extrList[y] */ - Ulong m = find(extrList(y),x); - const KLPol*& pol = d_help->klList(y)[m]; + Ulong m = find(extrList(y), x); + const KLPol *&pol = d_help->klList(y)[m]; if (pol == 0) { /* we have to compute the polynomial */ - pol = d_help->fillKLPol(x,y,s); + pol = d_help->fillKLPol(x, y, s); if (ERRNO) return zeroPol(); } @@ -292,7 +295,7 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, return *pol; } -KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y, const Generator& s) +KLCoeff KLContext::mu(const CoxNbr &x, const CoxNbr &y, const Generator &s) /* This function returns the mu-coefficient mu(x,y). It is assumed that @@ -305,12 +308,12 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y, const Generator& s) value undef_klcoeff for mu. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); Length d = p.length(y) - p.length(x); - if (d%2 == 0) + if (d % 2 == 0) return 0; if (d == 1) /* x is a coatom of y */ @@ -318,7 +321,7 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y, const Generator& s) /* check if x is in extremal position w.r.t. y */ - if (y != p.minimize(y,p.ascent(x))) + if (y != p.minimize(y, p.ascent(x))) return 0; /* allocate *d_muList[y] if necessary */ @@ -331,13 +334,13 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y, const Generator& s) /* find x in muList(y) */ - MuRow& m = d_help->muList(y); - MuData* md = find(m,x); + MuRow &m = d_help->muList(y); + MuData *md = find(m, x); if (md == 0) return 0; if (md->mu == undef_klcoeff) { /* we need to compute the coefficient */ - md->mu = d_help->computeMu(x,y); + md->mu = d_help->computeMu(x, y); if (ERRNO) return undef_klcoeff; } @@ -345,7 +348,7 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y, const Generator& s) return md->mu; } -void KLContext::permute(const Permutation& a) +void KLContext::permute(const Permutation &a) /* Permutes the context according to the permutation a. See the permute function @@ -359,7 +362,7 @@ void KLContext::permute(const Permutation& a) for (CoxNbr y = 0; y < size(); ++y) { if (!isMuAllocated(y)) continue; - MuRow& row = *d_muList[y]; + MuRow &row = *d_muList[y]; for (Ulong j = 0; j < row.size(); ++j) row[j].x = a[row[j].x]; row.sort(); @@ -379,8 +382,8 @@ void KLContext::permute(const Permutation& a) for (CoxNbr y = a[x]; y != x; y = a[y]) { /* back up values for y */ - KLRow* kl_buf = d_klList[y]; - MuRow* mu_buf = d_muList[y]; + KLRow *kl_buf = d_klList[y]; + MuRow *mu_buf = d_muList[y]; /* put values for x in y */ d_klList[y] = d_klList[x]; d_muList[y] = d_muList[x]; @@ -397,7 +400,7 @@ void KLContext::permute(const Permutation& a) return; } -void KLContext::revertSize(const Ulong& n) +void KLContext::revertSize(const Ulong &n) /* Reverts the sizes of the lists to size n. This is meant to be used @@ -406,26 +409,25 @@ void KLContext::revertSize(const Ulong& n) miserably if a premutation has taken place in-between. */ -{ +{ d_klList.setSize(n); d_muList.setSize(n); return; } -void KLContext::row(HeckeElt& h, const CoxNbr& y) - +void KLContext::row(HeckeElt &h, const CoxNbr &y) /* This function returns in h the data for the full row of y in the k-l table, sorted in the context number order. NOTE : this is probably not the natural concept of row in the context of - inverse k-l polynomials, but it's the only one that's reasonably + inverse k-l polynomials, but it's the only one that's reasonably implementable, so we'll keep it anyway. */ -{ +{ if (!d_help->checkKLRow(y)) { d_help->makeKLRow(y); } @@ -436,20 +438,19 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) } if (y <= inverse(y)) { - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); h.setSize(e.size()); - const KLRow& klr = klList(y); + const KLRow &klr = klList(y); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(e[j],klr[j]); + h[j].setData(e[j], klr[j]); } - } - else { /* go over to inverses */ + } else { /* go over to inverses */ CoxNbr yi = inverse(y); - const ExtrRow& e = extrList(yi); + const ExtrRow &e = extrList(yi); h.setSize(e.size()); - const KLRow& klr = klList(yi); + const KLRow &klr = klList(yi); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(inverse(e[j]),klr[j]); + h[j].setData(inverse(e[j]), klr[j]); } h.sort(); /* make sure list is ordered */ } @@ -457,7 +458,7 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) return; } -void KLContext::setSize(const Ulong& n) +void KLContext::setSize(const Ulong &n) { CoxNbr prev_size = size(); @@ -478,13 +479,13 @@ void KLContext::setSize(const Ulong& n) return; - revert: +revert: CATCH_MEMORY_OVERFLOW = false; revertSize(prev_size); return; } -}; +}; // namespace invkl /**************************************************************************** @@ -496,16 +497,16 @@ void KLContext::setSize(const Ulong& n) The following functions are defined : - - addCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, - KLPol& pol) : ads the corrections for mu and coatoms; + - addCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, + KLPol& pol) : ads the corrections for mu and coatoms; - allocKLRow(const CoxNbr& y) : allocates a row in the k-l list; - - allocRowComputation(const CoxNbr& y) : initial allocation for a + - allocRowComputation(const CoxNbr& y) : initial allocation for a row-computation - checkKLRow(const CoxNbr& y) : checks if a k-l row is fully computed; - coatomCorrection(const CoxNbr& y, List& pol) : subtracts the terms ofr coatoms in the mu-correction, for a full row; - computeMu(const CoxNbr& x, const CoxNbr& y) : computes a mu-coefficient; - - fillKLPol(const CoxNbr& x, const CoxNbr& y, const Generator& s = + - fillKLPol(const CoxNbr& x, const CoxNbr& y, const Generator& s = undef_generator) : fills in one polynomial, using s as descent; - fillKLRow(const CoxNbr& y) : fills in one row in the k-l table; CoxNbr inverse(const CoxNbr& y) : returns the inverse of y; @@ -518,15 +519,15 @@ void KLContext::setSize(const Ulong& n) - muCorrection(const CoxNbr& y, List& pol) : subtracts the non-coatom mu-part in the computation of a row; - readMuRow(const CoxNbr& y) : fills in the mu-row from the k-l row; - - writeKLRow(const CoxNbr& y, List& pol) : transfers the + - writeKLRow(const CoxNbr& y, List& pol) : transfers the polynomials from pol to klList; ****************************************************************************/ namespace invkl { -void KLContext::KLHelper::addCorrection(const CoxNbr& x, const CoxNbr& y, - const Generator& s, KLPol& pol) +void KLContext::KLHelper::addCorrection(const CoxNbr &x, const CoxNbr &y, + const Generator &s, KLPol &pol) /* This function adds the correcting terms both for atoms of x and for the @@ -538,51 +539,51 @@ void KLContext::KLHelper::addCorrection(const CoxNbr& x, const CoxNbr& y, */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); - CoxNbr ys = p.shift(y,s); + CoxNbr ys = p.shift(y, s); BitMap b(0); - p.extractClosure(b,ys); + p.extractClosure(b, ys); b.andnot(p.downset(s)); // extract z s.t. zs > z - b.andnot(p.parity(x)); // extract elements with opposite length parity from x + b.andnot(p.parity(x)); // extract elements with opposite length parity from x BitMap::Iterator b_end = b.end(); for (BitMap::Iterator i = b.begin(); i != b_end; ++i) { CoxNbr z = *i; - if (!p.inOrder(x,z)) + if (!p.inOrder(x, z)) continue; - if (p.length(z)-p.length(x) == 1) { // x is a coatom of z - const KLPol& p_zys = klPol(z,ys); + if (p.length(z) - p.length(x) == 1) { // x is a coatom of z + const KLPol &p_zys = klPol(z, ys); if (ERRNO) - goto abort; - pol.add(p_zys,1,1); + goto abort; + pol.add(p_zys, 1, 1); continue; } // if we get here l(z)-l(x) >= 3 - KLCoeff mu_xz = d_kl->mu(x,z); + KLCoeff mu_xz = d_kl->mu(x, z); if (ERRNO) goto abort; if (mu_xz == 0) continue; - const KLPol& p_zys = klPol(z,ys); + const KLPol &p_zys = klPol(z, ys); if (ERRNO) goto abort; - Ulong h = (p.length(z)-p.length(x)+1)/2; - pol.add(p_zys,mu_xz,h); + Ulong h = (p.length(z) - p.length(x) + 1) / 2; + pol.add(p_zys, mu_xz, h); continue; } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::allocKLRow(const CoxNbr& y) +void KLContext::KLHelper::allocKLRow(const CoxNbr &y) /* This function allocates one row of the kl_list. The row contains one @@ -613,7 +614,7 @@ void KLContext::KLHelper::allocKLRow(const CoxNbr& y) return; } -void KLContext::KLHelper::allocMuRow(const CoxNbr& y) +void KLContext::KLHelper::allocMuRow(const CoxNbr &y) /* This function allocates one row in the muList. There is one entry for @@ -623,15 +624,15 @@ void KLContext::KLHelper::allocMuRow(const CoxNbr& y) differently. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); BitMap b(0); - p.extractClosure(b,y); - maximize(p,b,p.descent(y)); + p.extractClosure(b, y); + maximize(p, b, p.descent(y)); b.andnot(p.parity(y)); // extract elements with opposite parity from y - const CoatomList& c = p.hasse(y); + const CoatomList &c = p.hasse(y); for (Ulong j = 0; j < c.size(); ++j) { // remove coatoms b.clearBit(c[j]); @@ -644,15 +645,15 @@ void KLContext::KLHelper::allocMuRow(const CoxNbr& y) for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { CoxNbr x = *k; - Length h = (ly-p.length(x)-1)/2; - MuData md(x,undef_klcoeff,h); + Length h = (ly - p.length(x) - 1) / 2; + MuData md(x, undef_klcoeff, h); muList(y).append(md); } return; } -void KLContext::KLHelper::allocRowComputation(const CoxNbr& y) +void KLContext::KLHelper::allocRowComputation(const CoxNbr &y) /* This function does the memory allocation for the computation of a full row @@ -663,9 +664,9 @@ void KLContext::KLHelper::allocRowComputation(const CoxNbr& y) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); BitMap::Iterator b_end = b.end(); @@ -676,21 +677,21 @@ void KLContext::KLHelper::allocRowComputation(const CoxNbr& y) if (!isExtrAllocated(z)) { klsupport().allocExtrRow(z); if (ERRNO) - return; + return; } if (!isKLAllocated(z)) { - const ExtrRow& e = extrList(z); + const ExtrRow &e = extrList(z); d_kl->d_klList[z] = new KLRow(0); klList(z).setSize(e.size()); if (ERRNO) - return; + return; } } return; } -bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) +bool KLContext::KLHelper::checkKLRow(const CoxNbr &d_y) /* This function checks if the row for y (or for inverse(y) if appropriate) @@ -706,7 +707,7 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) if (!isKLAllocated(y)) /* row is not allocated */ return false; - KLRow& kl_row = klList(y); + KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j] == 0) @@ -716,17 +717,17 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) return true; } -bool KLContext::KLHelper::checkMuRow(const CoxNbr& y) +bool KLContext::KLHelper::checkMuRow(const CoxNbr &y) /* This function checks if the row for y in muList has been filled. */ -{ +{ if (!isMuAllocated(y)) /* row is not allocated */ return false; - const MuRow& mu_row = muList(y); + const MuRow &mu_row = muList(y); for (Ulong j = 0; j < mu_row.size(); ++j) { if (mu_row[j].mu == undef_klcoeff) @@ -736,7 +737,7 @@ bool KLContext::KLHelper::checkMuRow(const CoxNbr& y) return true; } -void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) +void KLContext::KLHelper::coatomCorrection(const CoxNbr &y, List &pol) /* This function adds the correction terms corresponding to the atoms of x in @@ -748,46 +749,46 @@ void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); BitMap b(0); Generator s = last(y); - CoxNbr ys = p.shift(y,s); - p.extractClosure(b,ys); + CoxNbr ys = p.shift(y, s); + p.extractClosure(b, ys); b.andnot(p.downset(s)); LFlags fy = p.descent(y); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); BitMap::Iterator b_end = b.end(); for (BitMap::Iterator i = b.begin(); i != b_end; ++i) { CoxNbr z = *i; - const CoatomList& c = p.hasse(z); + const CoatomList &c = p.hasse(z); for (Ulong j = 0; j < c.size(); ++j) { CoxNbr x = c[j]; LFlags fx = p.descent(x); if ((fx & fy) != fy) // x is not extremal w.r.t. y - continue; + continue; /* find x in the extremal list */ - Ulong k = find(e,x); + Ulong k = find(e, x); /* add q*P_{z,ys} to pol[k] */ - pol[k].add(klPol(z,ys),1,1); + pol[k].add(klPol(z, ys), 1, 1); if (ERRNO) { - Error(ERRNO,x,y); - goto abort; + Error(ERRNO, x, y); + goto abort; } } } return; - abort: +abort: ERRNO = ERROR_WARNING; return; } -KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) +KLCoeff KLContext::KLHelper::computeMu(const CoxNbr &x, const CoxNbr &y) /* This function gets a previously uncomputed entry in the muList. It @@ -802,51 +803,51 @@ KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) exactly as in the proof of thm. 4.2. in the original k-l paper, one sees that at most four terms survive in the recursion formula : we have - mu(x,y) = mu(xs,ys) - mu(x,yst) + mu(xt,ys)(if xts > xt) + mu(x,y) = mu(xs,ys) - mu(x,yst) + mu(xt,ys)(if xts > xt) + mu(x,yst)(if ysts > yst) So in all these cases we get an elementary recursion. - Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of + Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of failure (this can be due to memory overflow, or to coefficient over- or underflow.) */ { if (inverse(y) < y) - return computeMu(inverse(x),inverse(y)); + return computeMu(inverse(x), inverse(y)); - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); LFlags f = p.twoDescent(y); - if ((p.descent(x)&f) == f) { /* x is super-extremal w.r.t. y */ - return recursiveMu(x,y,last(y)); + if ((p.descent(x) & f) == f) { /* x is super-extremal w.r.t. y */ + return recursiveMu(x, y, last(y)); } Generator s, t; /* choose s s.t. LR(ys) not contained in LR(x) */ - for (LFlags f1 = p.descent(y); f1; f1 &= f1-1) { + for (LFlags f1 = p.descent(y); f1; f1 &= f1 - 1) { Generator u = firstBit(f1); - CoxNbr yu = p.shift(y,u); + CoxNbr yu = p.shift(y, u); LFlags fu = p.descent(yu); - if ((p.descent(x)&fu) != fu) { + if ((p.descent(x) & fu) != fu) { s = u; t = firstBit(fu & ~p.descent(x)); break; } } - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); - KLCoeff r1 = d_kl->mu(xs,ys); + KLCoeff r1 = d_kl->mu(xs, ys); if (ERRNO) goto abort; - if (!p.inOrder(x,ys)) { /* value is found */ + if (!p.inOrder(x, ys)) { /* value is found */ status().mucomputed++; if (r1 == 0) status().muzero++; @@ -854,53 +855,53 @@ KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) } { - CoxNbr xt = p.shift(x,t); - CoxNbr yst = p.shift(ys,t); - - if (!p.isDescent(xt,s)) { // add mu(xt,ys) - KLCoeff r = d_kl->mu(xt,ys); + CoxNbr xt = p.shift(x, t); + CoxNbr yst = p.shift(ys, t); + + if (!p.isDescent(xt, s)) { // add mu(xt,ys) + KLCoeff r = d_kl->mu(xt, ys); if (ERRNO) - goto abort; - safeAdd(r1,r); + goto abort; + safeAdd(r1, r); if (ERRNO) - goto abort; + goto abort; } - if (!p.isDescent(yst,s)) { // add mu(x,yst) - KLCoeff r = d_kl->mu(x,yst); + if (!p.isDescent(yst, s)) { // add mu(x,yst) + KLCoeff r = d_kl->mu(x, yst); if (ERRNO) - goto abort; - safeAdd(r1,r); + goto abort; + safeAdd(r1, r); if (ERRNO) - goto abort; + goto abort; } { - KLCoeff r = d_kl->mu(x,yst); + KLCoeff r = d_kl->mu(x, yst); if (ERRNO) - goto abort; - safeSubtract(r1,r); + goto abort; + safeSubtract(r1, r); if (ERRNO) - goto abort; + goto abort; } return r1; } - abort: +abort: if (ERRNO != MEMORY_WARNING) ERRNO = MU_FAIL; return undef_klcoeff; } -const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& d_s) +const KLPol *KLContext::KLHelper::fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &d_s) /* This function fills in a single k-l polynomial. In this function our goal is not speed, but rather computing as few things as possible. So only the terms that actually do come up in the recursion are computed. On the other hand, - when a row in the klList or in the muList is allocated, it has to be + when a row in the klList or in the muList is allocated, it has to be allocated in full, so there is some amount of waste there. It is assumed that x <= y has already been checked, that inverse(y) >= y, @@ -909,8 +910,8 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, Returns 0 in case of error, and sets the error KL_FAIL. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); /* check easy cases */ @@ -923,65 +924,64 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, Generator s = d_s; - /* If d_s is undef_generator, we compute the polynomial using descent by + /* If d_s is undef_generator, we compute the polynomial using descent by last term in normal form */ if (s == undef_generator) s = last(y); - CoxNbr ys = p.shift(y,s); - CoxNbr xs = p.shift(x,s); + CoxNbr ys = p.shift(y, s); + CoxNbr xs = p.shift(x, s); /* check if x is comparable to ys */ - if (!p.inOrder(x,ys)) { /* return the answer recursively */ + if (!p.inOrder(x, ys)) { /* return the answer recursively */ status().klcomputed++; - return &klPol(xs,ys); + return &klPol(xs, ys); } CATCH_MEMORY_OVERFLOW = true; /* initialize the workspace to P_{xs,ys} */ - KLPol pol = klPol(xs,ys); + KLPol pol = klPol(xs, ys); if (ERRNO) goto abort; /* add correction terms */ - addCorrection(x,y,s,pol); + addCorrection(x, y, s, pol); if (ERRNO) goto abort; /* subtract q.P_{x,ys} */ { - const KLPol& p_xys = klPol(x,ys); + const KLPol &p_xys = klPol(x, ys); if (ERRNO) goto abort; - pol.subtract(p_xys,1); + pol.subtract(p_xys, 1); } /* find address of polynomial */ { - const KLPol* p_xy = klTree().find(pol); + const KLPol *p_xy = klTree().find(pol); if (ERRNO) goto abort; return p_xy; } - - abort: /* an error occurred */ + +abort: /* an error occurred */ CATCH_MEMORY_OVERFLOW = false; // something should be done here about the error! especially in case // MEMORY_WARNING. ERRNO = KL_FAIL; return 0; - } -void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) +void KLContext::KLHelper::fillKLRow(const CoxNbr &d_y) /* This function fills in the row for d_y in d_klList. It assumes that all @@ -998,41 +998,41 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) if (inverse(y) < y) /* nothing to do */ return; - /* prepare workspace; pol holds the row of polynomials; + /* prepare workspace; pol holds the row of polynomials; initialize workspace with P_{xs,ys} */ - initWorkspace(y,pol); + initWorkspace(y, pol); /* add correcting terms */ - muCorrection(y,pol); + muCorrection(y, pol); if (ERRNO) goto abort; - coatomCorrection(y,pol); + coatomCorrection(y, pol); if (ERRNO) goto abort; /* subtract q.P_{xs,y} when appropriate */ - lastTerm(y,pol); + lastTerm(y, pol); if (ERRNO) goto abort; /* write down result */ - writeKLRow(y,pol); + writeKLRow(y, pol); if (ERRNO) goto abort; return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) +void KLContext::KLHelper::initWorkspace(const CoxNbr &y, List &pol) /* This function sets pol to a row of one polynomial for each x in klList(y), @@ -1040,8 +1040,8 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); - const ExtrRow& e = extrList(y); + const SchubertContext &p = schubert(); + const ExtrRow &e = extrList(y); pol.setSize(e.size()); if (ERRNO) goto abort; @@ -1050,26 +1050,25 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) { Generator s = last(y); - CoxNbr ys = p.rshift(y,s); - + CoxNbr ys = p.rshift(y, s); + for (Ulong j = 0; j < e.size(); ++j) { - CoxNbr xs = p.shift(e[j],s); - pol[j] = klPol(xs,ys); + CoxNbr xs = p.shift(e[j], s); + pol[j] = klPol(xs, ys); if (ERRNO) - goto abort; + goto abort; } - } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) +void KLContext::KLHelper::inverseMuRow(const CoxNbr &y) /* This function constructs the mu-row for the inverse of y from that of y. @@ -1083,20 +1082,20 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) CoxNbr yi = inverse(y); if (isMuAllocated(yi)) { /* deallocate; update status */ - MuRow& m = muList(yi); + MuRow &m = muList(yi); for (Ulong j = 0; j < m.size(); ++j) { KLCoeff mu = m[j].mu; if (mu != undef_klcoeff) - status().mucomputed--; + status().mucomputed--; if (mu == 0) - status().muzero--; + status().muzero--; } status().munodes -= m.size(); delete &m; } d_kl->d_muList[yi] = new MuRow(muList(y)); - MuRow& m = muList(yi); + MuRow &m = muList(yi); for (Ulong j = 0; j < m.size(); ++j) { m[j].x = inverse(m[j].x); @@ -1107,11 +1106,11 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) /* update status */ for (Ulong j = 0; j < m.size(); ++j) { - KLCoeff mu = m[j].mu; - if (mu != undef_klcoeff) - status().mucomputed++; - if (mu == 0) - status().muzero++; + KLCoeff mu = m[j].mu; + if (mu != undef_klcoeff) + status().mucomputed++; + if (mu == 0) + status().muzero++; } status().munodes += m.size(); @@ -1119,25 +1118,25 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) return; } -void KLContext::KLHelper::lastTerm(const CoxNbr& y, List& pol) +void KLContext::KLHelper::lastTerm(const CoxNbr &y, List &pol) /* - This function subtracts the term .qP_{x,ys} from the term pol[j] - corresponding to x. We do this last, so that an alert can be given for + This function subtracts the term .qP_{x,ys} from the term pol[j] + corresponding to x. We do this last, so that an alert can be given for negative coefficients. */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); Generator s = last(y); - CoxNbr ys = schubert().shift(y,s); + CoxNbr ys = schubert().shift(y, s); BitMap b(0); - p.extractClosure(b,ys); - maximize(p,b,p.descent(y)); + p.extractClosure(b, ys); + maximize(p, b, p.descent(y)); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); BitMap::Iterator b_end = b.end(); Ulong j = 0; @@ -1145,9 +1144,9 @@ void KLContext::KLHelper::lastTerm(const CoxNbr& y, List& pol) CoxNbr x = *i; while (e[j] < x) // move e[j] up to x ++j; - pol[j].subtract(klPol(x,ys),1); + pol[j].subtract(klPol(x, ys), 1); if (ERRNO) { - Error(ERRNO,x,y); + Error(ERRNO, x, y); ERRNO = ERROR_WARNING; return; } @@ -1157,7 +1156,7 @@ void KLContext::KLHelper::lastTerm(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::makeKLRow(const CoxNbr& y) +void KLContext::KLHelper::makeKLRow(const CoxNbr &y) /* This function makes sure that the row for y in d_klList is filled, i.e. @@ -1170,9 +1169,9 @@ void KLContext::KLHelper::makeKLRow(const CoxNbr& y) if (ERRNO) return; - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); BitMap::Iterator b_end = b.end(); @@ -1183,24 +1182,24 @@ void KLContext::KLHelper::makeKLRow(const CoxNbr& y) if (!checkKLRow(z)) { fillKLRow(z); if (ERRNO) - return; + return; } if (!checkMuRow(z)) { readMuRow(z); if (ERRNO) - return; + return; } if (!checkMuRow(inverse(z))) { inverseMuRow(z); if (ERRNO) - return; + return; } } return; } -void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) +void KLContext::KLHelper::muCorrection(const CoxNbr &y, List &pol) /* This function adds the correction terms corresponding to the mu(x,z) @@ -1214,35 +1213,35 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); BitMap b(0); Generator s = last(y); - CoxNbr ys = p.shift(y,s); - p.extractClosure(b,ys); + CoxNbr ys = p.shift(y, s); + p.extractClosure(b, ys); b.andnot(p.downset(s)); LFlags fy = p.descent(y); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); BitMap::Iterator b_end = b.end(); for (BitMap::Iterator i = b.begin(); i != b_end; ++i) { CoxNbr z = *i; - const MuRow& muR = muList(z); + const MuRow &muR = muList(z); for (Ulong j = 0; j < muR.size(); ++j) { CoxNbr x = muR[j].x; LFlags fx = p.descent(x); if ((fx & fy) != fy) // x is not extremal w.r.t. y - continue; - Ulong k = find(e,x); + continue; + Ulong k = find(e, x); KLCoeff mu = muR[j].mu; - Length h = (p.length(z)-p.length(x)+1)/2; - pol[k].add(klPol(z,ys),mu,h); + Length h = (p.length(z) - p.length(x) + 1) / 2; + pol[k].add(klPol(z, ys), mu, h); if (ERRNO) { - Error(ERRNO,x,y); - ERRNO = ERROR_WARNING; - return; + Error(ERRNO, x, y); + ERRNO = ERROR_WARNING; + return; } } } @@ -1250,7 +1249,7 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::readMuRow(const CoxNbr& y) +void KLContext::KLHelper::readMuRow(const CoxNbr &y) /* This function fills the mu-row from the corresponding kl-row. If the @@ -1260,78 +1259,77 @@ void KLContext::KLHelper::readMuRow(const CoxNbr& y) Handles a possible memory error, and returns ERROR_WARNING. */ -{ - const SchubertContext& p = schubert(); - const KLRow& kl_row = klList(y); - const ExtrRow& e_row = extrList(y); +{ + const SchubertContext &p = schubert(); + const KLRow &kl_row = klList(y); + const ExtrRow &e_row = extrList(y); if (!isMuAllocated(y)) { /* make row from scratch */ MuRow mu_buf(0); mu_buf.setSizeValue(0); Length ly = p.length(y); - + for (Ulong j = 0; j < kl_row.size(); ++j) { - + CoxNbr x = e_row[j]; Length lx = p.length(x); - - if ((ly-lx)%2 == 0) - continue; - - if ((ly-lx) == 1) - continue; - - const KLPol& pol = *kl_row[j]; - - Degree d = (ly-lx-1)/2; + + if ((ly - lx) % 2 == 0) + continue; + + if ((ly - lx) == 1) + continue; + + const KLPol &pol = *kl_row[j]; + + Degree d = (ly - lx - 1) / 2; if (pol.deg() < d) - continue; - - MuData m(x,pol[d],d); + continue; + + MuData m(x, pol[d], d); mu_buf.append(m); if (ERRNO) - goto abort; + goto abort; } - + d_kl->d_muList[y] = new MuRow(mu_buf); if (ERRNO) goto abort; - + status().munodes += mu_buf.size(); status().mucomputed += mu_buf.size(); status().murows++; - } - else { + } else { Ulong i = 0; - MuRow& mu_row = muList(y); + MuRow &mu_row = muList(y); for (Ulong j = 0; j < muList(y).size(); ++j) { - MuData& mu = mu_row[j]; + MuData &mu = mu_row[j]; CoxNbr x = mu.x; - while(e_row[i] < x) - ++i; - const KLPol& pol = *kl_row[i]; + while (e_row[i] < x) + ++i; + const KLPol &pol = *kl_row[i]; Length d = mu.height; if (pol.deg() == d) - mu.mu = pol[d]; + mu.mu = pol[d]; else - mu.mu = 0; + mu.mu = 0; status().mucomputed++; if (mu.mu == 0) - status().muzero++; + status().muzero++; } } - + return; - abort: +abort: Error(ERRNO); ERRNO = MEMORY_WARNING; return; } -KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& x, const CoxNbr& y, - const Generator& s) +KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr &x, const CoxNbr &y, + const Generator &s) /* This function computes mu(x,y) using the general recursive formula for @@ -1339,95 +1337,95 @@ KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& x, const CoxNbr& y, of x contains the _second_ descent set of y. It is assumed that x < y x extremal w.r.t. y, and l(y)-l(x) odd > 1. - Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of + Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of failure (this can be due to memory overflow, or to coefficient over- or underflow.) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); Length l = p.length(y) - p.length(x); /* l is odd > 1 */ - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); - KLCoeff mu_xy = d_kl->mu(xs,ys); + KLCoeff mu_xy = d_kl->mu(xs, ys); if (ERRNO) goto abort; - if (!p.inOrder(x,ys)) { /* value is found */ + if (!p.inOrder(x, ys)) { /* value is found */ status().mucomputed++; if (mu_xy == 0) status().muzero++; return mu_xy; } - + /* add correction terms */ { BitMap b(0); - p.extractClosure(b,ys); + p.extractClosure(b, ys); b.andnot(p.downset(s)); // extract z s.t. zs > z - b.andnot(p.parity(x)); // extract elements with opposite length parity + b.andnot(p.parity(x)); // extract elements with opposite length parity // from x BitMap::Iterator b_end = b.end(); for (BitMap::Iterator i = b.begin(); i != b_end; ++i) { CoxNbr z = *i; - if (!p.inOrder(x,z)) - continue; - if (p.length(z)-p.length(x) == 1) { // x is a coatom of z - KLCoeff mu_zys = d_kl->mu(z,ys); - if (ERRNO) - goto abort; - if (mu_zys == 0) - continue; - safeAdd(mu_xy,mu_zys); - if (ERRNO) - goto abort; - continue; + if (!p.inOrder(x, z)) + continue; + if (p.length(z) - p.length(x) == 1) { // x is a coatom of z + KLCoeff mu_zys = d_kl->mu(z, ys); + if (ERRNO) + goto abort; + if (mu_zys == 0) + continue; + safeAdd(mu_xy, mu_zys); + if (ERRNO) + goto abort; + continue; } // if we get here l(z)-l(x) >= 3 - KLCoeff a = d_kl->mu(x,z); + KLCoeff a = d_kl->mu(x, z); if (ERRNO) - goto abort; + goto abort; if (a == 0) - continue; - KLCoeff mu_zys = d_kl->mu(z,ys); + continue; + KLCoeff mu_zys = d_kl->mu(z, ys); if (ERRNO) - goto abort; + goto abort; if (mu_zys == 0) - continue; - safeMultiply(a,mu_zys); - safeAdd(mu_xy,a); + continue; + safeMultiply(a, mu_zys); + safeAdd(mu_xy, a); } } /* subtract term from P_{x,ys} */ { - const KLPol& pol = klPol(x,ys); - Length d = (l-1)/2 - 1; + const KLPol &pol = klPol(x, ys); + Length d = (l - 1) / 2 - 1; if (pol.deg() == d) { - safeSubtract(mu_xy,pol[d]); + safeSubtract(mu_xy, pol[d]); if (ERRNO) { // overflow; highly unlikely! - Error(MU_OVERFLOW,this,x,y); - goto abort; + Error(MU_OVERFLOW, this, x, y); + goto abort; } } } return mu_xy; - abort: +abort: if (ERRNO != MEMORY_WARNING) ERRNO = MU_FAIL; return undef_klcoeff; } -void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) +void KLContext::KLHelper::writeKLRow(const CoxNbr &y, List &pol) /* This function writes the polynomials from the list pol to klList(y); @@ -1442,7 +1440,7 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) */ { - KLRow& kl_row = klList(y); + KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j]) @@ -1451,10 +1449,10 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) Degree d = pol[j].deg(); for (; d; --d) { if (pol[j][d]) - break; + break; } pol[j].setDeg(d); - const KLPol* q = klTree().find(pol[j]); + const KLPol *q = klTree().find(pol[j]); if (q == 0) { /* an error occurred */ Error(ERRNO); ERRNO = ERROR_WARNING; @@ -1467,7 +1465,7 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) return; } -}; +}; // namespace invkl /**************************************************************************** Chapter III -- KLStatus @@ -1482,8 +1480,8 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) namespace invkl { KLStatus::KLStatus() - :klrows(0), klnodes(0), klcomputed(0), murows(0), munodes(0), mucomputed(0), - muzero(0) + : klrows(0), klnodes(0), klcomputed(0), murows(0), munodes(0), + mucomputed(0), muzero(0) {} @@ -1491,7 +1489,7 @@ KLStatus::~KLStatus() {} -}; +}; // namespace invkl /***************************************************************************** @@ -1504,7 +1502,7 @@ KLStatus::~KLStatus() The following functions are defined : - - add(p,mu,n) : adds to the current polynomial the product of p and mu, + - add(p,mu,n) : adds to the current polynomial the product of p and mu, shifted by n; - subtract(p,n) : subtracts p shifted by n from the current polynomial; @@ -1512,7 +1510,7 @@ KLStatus::~KLStatus() namespace invkl { -KLPol& KLPol::add(const KLPol& p, const KLCoeff& mu, const Ulong& n) +KLPol &KLPol::add(const KLPol &p, const KLCoeff &mu, const Ulong &n) /* Adds the polynomial p*mu.X^n to the current polynomial. We don't test for @@ -1524,11 +1522,11 @@ KLPol& KLPol::add(const KLPol& p, const KLCoeff& mu, const Ulong& n) */ { - if (deg() < p.deg()+n) - setDeg(p.deg()+n); + if (deg() < p.deg() + n) + setDeg(p.deg() + n); for (Ulong j = 0; j <= p.deg(); ++j) { - safeAdd(v[j+n],p[j]*mu); + safeAdd(v[j + n], p[j] * mu); if (ERRNO) return *this; } @@ -1536,7 +1534,7 @@ KLPol& KLPol::add(const KLPol& p, const KLCoeff& mu, const Ulong& n) return *this; } -KLPol& KLPol::subtract(const KLPol& p, const Ulong& n) +KLPol &KLPol::subtract(const KLPol &p, const Ulong &n) /* This function subtracts q^n.p from the current polynomial, checking for @@ -1548,13 +1546,13 @@ KLPol& KLPol::subtract(const KLPol& p, const Ulong& n) { /* make sure the degree will hold the computation */ - if (deg() < p.deg()+n) - setDeg(p.deg()+n); + if (deg() < p.deg() + n) + setDeg(p.deg() + n); /* subtract */ for (Degree j = 0; j <= p.deg(); ++j) { - safeSubtract((*this)[j+n],p[j]); + safeSubtract((*this)[j + n], p[j]); if (ERRNO) return *this; } @@ -1564,7 +1562,7 @@ KLPol& KLPol::subtract(const KLPol& p, const Ulong& n) return *this; } -}; +}; // namespace invkl /**************************************************************************** @@ -1578,7 +1576,7 @@ KLPol& KLPol::subtract(const KLPol& p, const Ulong& n) namespace { -MuData* find(MuRow& row, const CoxNbr& x) +MuData *find(MuRow &row, const CoxNbr &x) /* Finds x in the row and returns the address of the corresponding row. @@ -1588,10 +1586,10 @@ MuData* find(MuRow& row, const CoxNbr& x) { Ulong j0 = (Ulong)(-1); - for (Ulong j1 = row.size(); j1-j0 > 1;) { - Ulong j = j0 + (j1-j0)/2; + for (Ulong j1 = row.size(); j1 - j0 > 1;) { + Ulong j = j0 + (j1 - j0) / 2; if (row[j].x == x) // m was found - return row.ptr()+j; + return row.ptr() + j; if (row[j].x < x) j0 = j; else @@ -1601,22 +1599,22 @@ MuData* find(MuRow& row, const CoxNbr& x) return 0; } -}; +}; // namespace namespace invkl { -const KLPol& one() +const KLPol &one() { - static KLPol p(1,KLPol::const_tag()); + static KLPol p(1, KLPol::const_tag()); return p; } -}; +}; // namespace invkl namespace { -const KLPol& zeroPol() +const KLPol &zeroPol() /* Returns the zero polynomial (usually this indicates an error condition.) @@ -1627,4 +1625,4 @@ const KLPol& zeroPol() return z; } -}; +}; // namespace diff --git a/invkl.h b/invkl.h index c09a8c8..28949fb 100644 --- a/invkl.h +++ b/invkl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INVKL_H /* guard against multiple inclusions */ +#ifndef INVKL_H /* guard against multiple inclusions */ #define INVKL_H #include "globals.h" @@ -19,55 +19,54 @@ #include "search.h" namespace invkl { - using namespace coxeter; - using namespace coxtypes; - using namespace klsupport; - using namespace list; - using namespace polynomials; - using namespace bits; - using namespace memory; - +using namespace coxeter; +using namespace coxtypes; +using namespace klsupport; +using namespace list; +using namespace polynomials; +using namespace bits; +using namespace memory; /******** type declarations *************************************************/ - class KLContext; - class KLPol; - struct KLStatus; - struct MuData; - class MuFilter; +class KLContext; +class KLPol; +struct KLStatus; +struct MuData; +class MuFilter; - typedef List KLRow; - typedef List MuRow; - typedef List > HeckeElt; +typedef List KLRow; +typedef List MuRow; +typedef List> HeckeElt; /******** function declarations *********************************************/ - const KLPol& one(); +const KLPol &one(); /******** type definitions **************************************************/ -class KLPol:public Polynomial { +class KLPol : public Polynomial { public: - static PolynomialType polType() {return INV_KLPOL;} - KLPol() {}; - KLPol(const Ulong& n):Polynomial(n) {}; - KLPol(const KLCoeff& c, const_tag):Polynomial(c,const_tag()) {}; - ~KLPol() {}; - KLPol& add(const KLPol& p, const KLCoeff& mu, const Ulong& n); - KLPol& subtract(const KLPol& p, const Ulong& n); + static PolynomialType polType() { return INV_KLPOL; } + KLPol(){}; + KLPol(const Ulong &n) : Polynomial(n){}; + KLPol(const KLCoeff &c, const_tag) : Polynomial(c, const_tag()){}; + ~KLPol(){}; + KLPol &add(const KLPol &p, const KLCoeff &mu, const Ulong &n); + KLPol &subtract(const KLPol &p, const Ulong &n); }; struct MuData { CoxNbr x; KLCoeff mu; Length height; -/* constructors */ - MuData() {}; - MuData(const CoxNbr& d_x, const KLCoeff& d_mu, const Length& d_h) - :x(d_x), mu(d_mu), height(d_h) {}; - ~MuData() {}; -/* comparison */ - bool operator> (const MuData& m) const; /* inlined */ + /* constructors */ + MuData(){}; + MuData(const CoxNbr &d_x, const KLCoeff &d_mu, const Length &d_h) + : x(d_x), mu(d_mu), height(d_h){}; + ~MuData(){}; + /* comparison */ + bool operator>(const MuData &m) const; /* inlined */ }; struct KLStatus { @@ -81,108 +80,125 @@ struct KLStatus { Ulong munodes; Ulong mucomputed; Ulong muzero; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLStatus));} + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLStatus)); + } KLStatus(); ~KLStatus(); }; class KLContext { - KLSupport* d_klsupport; - List d_klList; - List d_muList; + KLSupport *d_klsupport; + List d_klList; + List d_muList; search::BinaryTree d_klTree; - KLStatus* d_status; + KLStatus *d_status; struct KLHelper; /* provides helper functions */ - KLHelper* d_help; + KLHelper *d_help; friend struct KLHelper; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLContext));} - KLContext(KLSupport* kls); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLContext)); + } + KLContext(KLSupport *kls); ~KLContext(); -/* accessors */ - const ExtrRow& extrList(const CoxNbr& y) const; /* inlined */ - CoxNbr inverse(const CoxNbr& x) const; /* inlined */ - const BitMap& involution() const; /* inlined */ - bool isExtrAllocated(const CoxNbr& x) const; /* inlined */ - bool isFullKL() const; /* inlined */ - bool isFullMu() const; /* inlined */ - bool isKLAllocated(const CoxNbr& x) const; /* inlined */ - bool isMuAllocated(const CoxNbr& x) const; /* inlined */ - const KLRow& klList(const CoxNbr& y) const; /* inlined */ - const KLSupport& klsupport() const; /* inlined */ - Generator last(const CoxNbr& y) const; /* inlined */ - const MuRow& muList(const CoxNbr& y) const; /* inlined */ - Rank rank() const; /* inlined */ - const SchubertContext& schubert() const; /* inlined */ - Ulong size() const; /* inlined */ - const search::BinaryTree& tree() const; /* inlined */ -/* manipulators */ - void applyInverse(const CoxNbr& y); - void applyIPermutation(const CoxNbr& y, const Permutation& a); /* inlined */ + /* accessors */ + const ExtrRow &extrList(const CoxNbr &y) const; /* inlined */ + CoxNbr inverse(const CoxNbr &x) const; /* inlined */ + const BitMap &involution() const; /* inlined */ + bool isExtrAllocated(const CoxNbr &x) const; /* inlined */ + bool isFullKL() const; /* inlined */ + bool isFullMu() const; /* inlined */ + bool isKLAllocated(const CoxNbr &x) const; /* inlined */ + bool isMuAllocated(const CoxNbr &x) const; /* inlined */ + const KLRow &klList(const CoxNbr &y) const; /* inlined */ + const KLSupport &klsupport() const; /* inlined */ + Generator last(const CoxNbr &y) const; /* inlined */ + const MuRow &muList(const CoxNbr &y) const; /* inlined */ + Rank rank() const; /* inlined */ + const SchubertContext &schubert() const; /* inlined */ + Ulong size() const; /* inlined */ + const search::BinaryTree &tree() const; /* inlined */ + /* manipulators */ + void applyInverse(const CoxNbr &y); + void applyIPermutation(const CoxNbr &y, const Permutation &a); /* inlined */ void clearFullKL(); /* inlined */ void clearFullMu(); /* inlined */ void fillKL(); void fillMu(); - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - KLCoeff mu(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - void permute(const Permutation& a); - void row(HeckeElt& h, const CoxNbr& y); - void revertSize(const Ulong& n); - void setFullKL(); /* inlined */ - void setFullMu(); /* inlined */ - void setSize(const Ulong& n); + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + KLCoeff mu(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + void permute(const Permutation &a); + void row(HeckeElt &h, const CoxNbr &y); + void revertSize(const Ulong &n); + void setFullKL(); /* inlined */ + void setFullMu(); /* inlined */ + void setSize(const Ulong &n); }; /******** inline definitions ************************************************/ -inline bool MuData::operator> (const MuData& m) const {return x > m.x;} - -inline const ExtrRow& KLContext::extrList(const CoxNbr& y) const - {return klsupport().extrList(y);} -inline CoxNbr KLContext::inverse(const CoxNbr& x) const - {return d_klsupport->inverse(x);} -inline const BitMap& KLContext::involution() const - {return d_klsupport->involution();} -inline bool KLContext::isExtrAllocated(const CoxNbr& x) const - {return d_klsupport->isExtrAllocated(x);} -inline bool KLContext::isFullKL() const - {return d_status->flags&KLStatus::kl_done;} -inline bool KLContext::isFullMu() const - {return d_status->flags&KLStatus::mu_done;} -inline bool KLContext::isKLAllocated(const CoxNbr& x) const - {return d_klList[x] != 0;} -inline bool KLContext::isMuAllocated(const CoxNbr& x) const - {return d_muList[x] != 0;} -inline const KLRow& KLContext::klList(const CoxNbr& y) const - {return *d_klList[y];} -inline const KLSupport& KLContext::klsupport() const {return *d_klsupport;} -inline Generator KLContext::last(const CoxNbr& y) const - {return d_klsupport->last(y);} -inline const MuRow& KLContext::muList(const CoxNbr& y) const - {return *d_muList[y];} -inline Rank KLContext::rank() const {return d_klsupport->rank();} -inline const SchubertContext& KLContext::schubert() const - {return d_klsupport->schubert();} -inline Ulong KLContext::size() const {return d_klList.size();} -inline const search::BinaryTree& KLContext::tree() const - {return d_klTree;} - -inline void KLContext::applyIPermutation(const CoxNbr& y, - const Permutation& a) - {return rightRangePermute(*d_klList[y],a);} -inline void KLContext::clearFullKL() {d_status->flags &= ~KLStatus::kl_done;} -inline void KLContext::clearFullMu() {d_status->flags &= ~KLStatus::mu_done;} -inline void KLContext::setFullKL() {d_status->flags |= KLStatus::kl_done;} -inline void KLContext::setFullMu() {d_status->flags |= KLStatus::mu_done;} +inline bool MuData::operator>(const MuData &m) const { return x > m.x; } + +inline const ExtrRow &KLContext::extrList(const CoxNbr &y) const { + return klsupport().extrList(y); +} +inline CoxNbr KLContext::inverse(const CoxNbr &x) const { + return d_klsupport->inverse(x); +} +inline const BitMap &KLContext::involution() const { + return d_klsupport->involution(); +} +inline bool KLContext::isExtrAllocated(const CoxNbr &x) const { + return d_klsupport->isExtrAllocated(x); +} +inline bool KLContext::isFullKL() const { + return d_status->flags & KLStatus::kl_done; +} +inline bool KLContext::isFullMu() const { + return d_status->flags & KLStatus::mu_done; +} +inline bool KLContext::isKLAllocated(const CoxNbr &x) const { + return d_klList[x] != 0; +} +inline bool KLContext::isMuAllocated(const CoxNbr &x) const { + return d_muList[x] != 0; +} +inline const KLRow &KLContext::klList(const CoxNbr &y) const { + return *d_klList[y]; +} +inline const KLSupport &KLContext::klsupport() const { return *d_klsupport; } +inline Generator KLContext::last(const CoxNbr &y) const { + return d_klsupport->last(y); +} +inline const MuRow &KLContext::muList(const CoxNbr &y) const { + return *d_muList[y]; +} +inline Rank KLContext::rank() const { return d_klsupport->rank(); } +inline const SchubertContext &KLContext::schubert() const { + return d_klsupport->schubert(); +} +inline Ulong KLContext::size() const { return d_klList.size(); } +inline const search::BinaryTree &KLContext::tree() const { + return d_klTree; +} +inline void KLContext::applyIPermutation(const CoxNbr &y, + const Permutation &a) { + return rightRangePermute(*d_klList[y], a); } +inline void KLContext::clearFullKL() { d_status->flags &= ~KLStatus::kl_done; } +inline void KLContext::clearFullMu() { d_status->flags &= ~KLStatus::mu_done; } +inline void KLContext::setFullKL() { d_status->flags |= KLStatus::kl_done; } +inline void KLContext::setFullMu() { d_status->flags |= KLStatus::mu_done; } + +} // namespace invkl #endif diff --git a/io.cpp b/io.cpp index de5be3d..95bcc97 100644 --- a/io.cpp +++ b/io.cpp @@ -1,6 +1,6 @@ /* This is io.cpp - + Coxeter version 3.0_demo Copyright (C) 2001 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -42,7 +42,7 @@ String::~String() {} -}; +}; // namespace io /***************************************************************************** @@ -71,7 +71,7 @@ String::~String() namespace io { -String& append(String& l, const char c) +String &append(String &l, const char c) /* Appends c to the varstring l, resizing l as necessary. @@ -79,64 +79,59 @@ String& append(String& l, const char c) { l[l.length()] = c; - l.setLength(l.length()+1); + l.setLength(l.length() + 1); l[l.length()] = 0; return l; } - -String& append(String& l, const char *s) +String &append(String &l, const char *s) /* Appends s to the varstring l, resizing l as necessary. */ { - l.setLength(l.length()+strlen(s)); - strcat(l.ptr(),s); + l.setLength(l.length() + strlen(s)); + strcat(l.ptr(), s); return l; } - -String& append(String& l1, const String& l2) +String &append(String &l1, const String &l2) /* Appends l2 to the varstring l1, resizing l1 as necessary. */ -{ - l1.setLength(l1.length()+l2.length()); - strcat(l1.ptr(),l2.ptr()); +{ + l1.setLength(l1.length() + l2.length()); + strcat(l1.ptr(), l2.ptr()); return l1; } - -String& append(String& str, const Ulong& n) +String &append(String &str, const Ulong &n) { - static String cs(digits(ULONG_MAX,10)); + static String cs(digits(ULONG_MAX, 10)); - cs.setLength(sprintf(cs.ptr(),"%lu",n)); - append(str,cs); + cs.setLength(sprintf(cs.ptr(), "%lu", n)); + append(str, cs); return str; } - -String& append(String& str, const long& m) +String &append(String &str, const long &m) { - static String cs(digits(LONG_MAX,10)+1); + static String cs(digits(LONG_MAX, 10) + 1); - cs.setLength(sprintf(cs.ptr(),"%ld",m)); - append(str,cs); + cs.setLength(sprintf(cs.ptr(), "%ld", m)); + append(str, cs); return str; } - -String& append(String& l, const int *v, const Ulong& n) +String &append(String &l, const int *v, const Ulong &n) /* Appends to l the string representation of the n first elements pointed @@ -148,45 +143,42 @@ String& append(String& l, const int *v, const Ulong& n) reset(buf); - append(buf,"["); + append(buf, "["); for (Ulong j = 0; j < n; j++) { - append(buf,v[j]); - if (j+1 < n) /* more to come */ - append(buf,","); + append(buf, v[j]); + if (j + 1 < n) /* more to come */ + append(buf, ","); } - append(buf,"]"); + append(buf, "]"); return l; } - -String& append(String& str, const int& n) +String &append(String &str, const int &n) { - static String cs(digits(INT_MAX,10)+1); + static String cs(digits(INT_MAX, 10) + 1); - cs.setLength(sprintf(cs.ptr(),"%d",n)); - append(str,cs); + cs.setLength(sprintf(cs.ptr(), "%d", n)); + append(str, cs); return str; } - -String& append(String& str, const unsigned& n) +String &append(String &str, const unsigned &n) { - static String cs(digits(UINT_MAX,10)+1); + static String cs(digits(UINT_MAX, 10) + 1); - cs.setLength(sprintf(cs.ptr(),"%u",n)); - append(str,cs); + cs.setLength(sprintf(cs.ptr(), "%u", n)); + append(str, cs); return str; } - -String& erase(String&l, const Ulong& n) +String &erase(String &l, const Ulong &n) /* Erases the last n letters from the string l (everything if n >= length) @@ -196,14 +188,13 @@ String& erase(String&l, const Ulong& n) if (n >= l.length()) /* erase everything */ return reset(l); - l[l.length()-n] = '\0'; - l.setLength(l.length()-n); + l[l.length() - n] = '\0'; + l.setLength(l.length() - n); return l; } - -String& pad(String& l, const Ulong& n) +String &pad(String &l, const Ulong &n) /* Pads the string with white spaces to length n. @@ -217,13 +208,12 @@ String& pad(String& l, const Ulong& n) int a = l.length(); l.setLength(n); - sprintf(l.ptr()+a,"%*s",static_cast(n-a),""); + sprintf(l.ptr() + a, "%*s", static_cast(n - a), ""); return l; } - -String& reset(String& l) +String &reset(String &l) /* Resets l to the empty string. @@ -236,8 +226,8 @@ String& reset(String& l) return l; } -String& setString(String& l, const String& s, const Ulong& first, - const Ulong& r) +String &setString(String &l, const String &s, const Ulong &first, + const Ulong &r) /* Sets the string l to the subword of s starting at first, with length r. @@ -245,13 +235,13 @@ String& setString(String& l, const String& s, const Ulong& first, { l.setLength(r); - l.setData(s.ptr()+first,0,r); + l.setData(s.ptr() + first, 0, r); l[r] = '\0'; return l; } -const String& String::undefined() +const String &String::undefined() /* This function returns an impossible string, namely the one corresponding @@ -263,8 +253,7 @@ const String& String::undefined() return str; } -}; - +}; // namespace io /***************************************************************************** @@ -279,15 +268,15 @@ const String& String::undefined() - print(file,str) : prints the (var)string to the file; - print(file,v,n) : prints a list of integers; - printFile(file,name) : prints the contents of the file name; - - printFile(file,name,dir_name) : prints the contents of the file + - printFile(file,name,dir_name) : prints the contents of the file dir_name/name; ******************************************************************************/ namespace io { -void foldLine(FILE* file, const String& str, const Ulong& ls, - const Ulong& h, const char* hyphens) +void foldLine(FILE *file, const String &str, const Ulong &ls, const Ulong &h, + const char *hyphens) /* This function breaks up the string str into lines of at most ls characters @@ -301,7 +290,7 @@ void foldLine(FILE* file, const String& str, const Ulong& ls, String buf(0); if (str.length() <= ls) { /* str fits on one line */ - print(file,str); + print(file, str); return; } @@ -309,7 +298,7 @@ void foldLine(FILE* file, const String& str, const Ulong& ls, Ulong bp = 0; - for (Ulong j = 0; j < ls; j += strcspn(str.ptr()+j,hyphens)) { + for (Ulong j = 0; j < ls; j += strcspn(str.ptr() + j, hyphens)) { bp = j; j++; } @@ -317,37 +306,36 @@ void foldLine(FILE* file, const String& str, const Ulong& ls, if (bp == 0) /* break brutally */ bp = ls; - setString(buf,str,0,bp); - print(file,buf); + setString(buf, str, 0, bp); + print(file, buf); /* print continuation lines */ Ulong p = bp; - for (; p < str.length()-ls+h; p += bp) { + for (; p < str.length() - ls + h; p += bp) { bp = 0; - for (Ulong j = 0; j < ls-h; j += strcspn(str.ptr()+p+j,hyphens)) { + for (Ulong j = 0; j < ls - h; j += strcspn(str.ptr() + p + j, hyphens)) { bp = j; j++; } if (bp == 0) - bp = ls-h; - setString(buf,str,p,bp); - fprintf(file,"\n%*s",static_cast(h),""); - print(file,buf); + bp = ls - h; + setString(buf, str, p, bp); + fprintf(file, "\n%*s", static_cast(h), ""); + print(file, buf); } /* print last line */ - setString(buf,str,p,str.length()-p); - fprintf(file,"\n%*s",static_cast(h),""); - print(file,buf); + setString(buf, str, p, str.length() - p); + fprintf(file, "\n%*s", static_cast(h), ""); + print(file, buf); return; } - -void print(FILE *file, const int* const& v, const Ulong& n) +void print(FILE *file, const int *const &v, const Ulong &n) /* Appends to l the string representation of the n first elements pointed @@ -355,21 +343,20 @@ void print(FILE *file, const int* const& v, const Ulong& n) */ { - fprintf(file,"["); + fprintf(file, "["); - for (Ulong j = 0; j < n; j++) - { - fprintf(file,"%d",v[j]); - if (j+1 < n) /* more to come */ - fprintf(file,","); - } + for (Ulong j = 0; j < n; j++) { + fprintf(file, "%d", v[j]); + if (j + 1 < n) /* more to come */ + fprintf(file, ","); + } - fprintf(file,"]"); + fprintf(file, "]"); return; } -void printFile(FILE* file, const char *name, const char *dir_name) +void printFile(FILE *file, const char *name, const char *dir_name) /* Prints the contents of the file with the name dir_name/name on the file. @@ -379,55 +366,54 @@ void printFile(FILE* file, const char *name, const char *dir_name) static String buf(0); reset(buf); - append(buf,dir_name); - append(buf,"/"); - append(buf,name); + append(buf, dir_name); + append(buf, "/"); + append(buf, name); - FILE* inputfile; + FILE *inputfile; char c; - inputfile = fopen(buf.ptr(),"r"); + inputfile = fopen(buf.ptr(), "r"); if (inputfile == 0) { - Error(FILE_NOT_FOUND,buf.ptr()); + Error(FILE_NOT_FOUND, buf.ptr()); return; } - while((c = getc(inputfile)) != EOF) - putc(c,file); + while ((c = getc(inputfile)) != EOF) + putc(c, file); fclose(inputfile); return; } -void printFile(FILE* file, const char *name) +void printFile(FILE *file, const char *name) /* Prints the contents of the file with the given name, onto file. */ { - FILE* inputfile; + FILE *inputfile; char c; - inputfile = fopen(name,"r"); + inputfile = fopen(name, "r"); if (inputfile == 0) { - Error(FILE_NOT_FOUND,name); + Error(FILE_NOT_FOUND, name); return; } - while((c = getc(inputfile)) != EOF) - putc(c,file); + while ((c = getc(inputfile)) != EOF) + putc(c, file); fclose(inputfile); return; } -}; - +}; // namespace io /***************************************************************************** @@ -443,7 +429,7 @@ void printFile(FILE* file, const char *name) namespace io { -char* getInput(FILE *inputfile, String& buf, Ulong len) +char *getInput(FILE *inputfile, String &buf, Ulong len) /* Reads from the inputfile until either EOF or a newline is reached; @@ -454,7 +440,7 @@ char* getInput(FILE *inputfile, String& buf, Ulong len) { for (Ulong a = len;; a++) { - int c = getc(inputfile); + int c = getc(inputfile); buf.setLength(a); if ((c == EOF) || (c == '\n')) { buf[a] = '\0'; @@ -466,8 +452,7 @@ char* getInput(FILE *inputfile, String& buf, Ulong len) return buf.ptr(); } -}; - +}; // namespace io /***************************************************************************** @@ -498,13 +483,12 @@ int alphabeticDigits(Ulong c, Ulong b) { Ulong j = 0; - for(; c; c = (c-1)/b) + for (; c; c = (c - 1) / b) ++j; return j; } - int digits(Ulong c, Ulong b) /* @@ -520,7 +504,7 @@ int digits(Ulong c, Ulong b) return j; } -Ulong skipSpaces(const String& l, Ulong p) +Ulong skipSpaces(const String &l, Ulong p) /* Skips from character position p over white space (characters recognized @@ -530,10 +514,10 @@ Ulong skipSpaces(const String& l, Ulong p) { Ulong j = 0; - for (; isspace(l[p+j]); ++j) + for (; isspace(l[p + j]); ++j) ; return j; } -}; +}; // namespace io diff --git a/io.h b/io.h index eefd485..8b41cca 100644 --- a/io.h +++ b/io.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef IO_H /* guarantee single inclusion */ +#ifndef IO_H /* guarantee single inclusion */ #define IO_H #include "globals.h" @@ -13,87 +13,88 @@ #include "memory.h" namespace io { - using namespace coxeter; - using namespace list; - using namespace memory; +using namespace coxeter; +using namespace list; +using namespace memory; /******** type definitions **************************************************/ - class String; +class String; - /* style tags for i/o */ +/* style tags for i/o */ - struct Default{}; - struct GAP {}; - struct LaTeX {}; - struct Pretty {}; - struct Terse {}; - struct TeX {}; +struct Default {}; +struct GAP {}; +struct LaTeX {}; +struct Pretty {}; +struct Terse {}; +struct TeX {}; /******** constants **********************************************************/ - const Ulong LINESIZE = 79; - const Ulong HALFLINESIZE = 39; +const Ulong LINESIZE = 79; +const Ulong HALFLINESIZE = 39; /******** function declarations **********************************************/ - int alphabeticDigits(Ulong c, Ulong b); - String& append(String& l, const char c); - String& append(String& l, const char *s); - String& append(String& l1, const String& l2); - String& append(String& l, const Ulong& n); - String& append(String& l, const long& m); - String& append(String& l, const int& n); - String& append(String& l, const unsigned& n); - String& append(String& l, const int *v, const Ulong& n); - int digits(Ulong c, Ulong b); - String& erase(String& l, const Ulong& n); - void foldLine(FILE* file, const String& str, const Ulong& ls, - const Ulong& h, const char* hyphens); - char* getInput(FILE *inputfile, String& buf, Ulong len = 0); - String& pad(String& l, const Ulong& n); - void print(FILE* file, const char * str); /* inlined */ - void print(FILE* file, const String& str); /* inlined */ - void print(FILE* file, const int *const& v, const Ulong& n); - void printFile(FILE* file, const char *name); - void printFile(FILE* file, const char *name, const char *dir_name); - String& reset(String& l); - String& setString(String& l, const String& s, const Ulong &first, - const Ulong& r); - Ulong skipSpaces(const String& l, Ulong p); +int alphabeticDigits(Ulong c, Ulong b); +String &append(String &l, const char c); +String &append(String &l, const char *s); +String &append(String &l1, const String &l2); +String &append(String &l, const Ulong &n); +String &append(String &l, const long &m); +String &append(String &l, const int &n); +String &append(String &l, const unsigned &n); +String &append(String &l, const int *v, const Ulong &n); +int digits(Ulong c, Ulong b); +String &erase(String &l, const Ulong &n); +void foldLine(FILE *file, const String &str, const Ulong &ls, const Ulong &h, + const char *hyphens); +char *getInput(FILE *inputfile, String &buf, Ulong len = 0); +String &pad(String &l, const Ulong &n); +void print(FILE *file, const char *str); /* inlined */ +void print(FILE *file, const String &str); /* inlined */ +void print(FILE *file, const int *const &v, const Ulong &n); +void printFile(FILE *file, const char *name); +void printFile(FILE *file, const char *name, const char *dir_name); +String &reset(String &l); +String &setString(String &l, const String &s, const Ulong &first, + const Ulong &r); +Ulong skipSpaces(const String &l, Ulong p); /******** type definitions **************************************************/ -class String:public List -{ - private: - public: -/* constructors and destructors */ - String():List() {}; - String(const Ulong& n):List(n+1) {setSizeValue(1);} - String(const int& n):List(n+1) {setSizeValue(1);} - String(const char* const str):List(strlen(str)+1) - {setData(str,strlen(str)+1);} - ~String(); -/* modifiers */ - void setLength(const Ulong& n); /* inlined */ -/* accessors */ - bool isDefined() const; /* inlined */ - Ulong length() const; /* inlined */ -/* static member function */ - static const String& undefined(); - }; +class String : public List { +private: +public: + /* constructors and destructors */ + String() : List(){}; + String(const Ulong &n) : List(n + 1) { setSizeValue(1); } + String(const int &n) : List(n + 1) { setSizeValue(1); } + String(const char *const str) : List(strlen(str) + 1) { + setData(str, strlen(str) + 1); + } + ~String(); + /* modifiers */ + void setLength(const Ulong &n); /* inlined */ + /* accessors */ + bool isDefined() const; /* inlined */ + Ulong length() const; /* inlined */ + /* static member function */ + static const String &undefined(); +}; /******** Inline definitions ***********************************************/ -inline void print(FILE *file, const char* str) {fprintf(file,"%s",str);} -inline void print(FILE *file, const String& str) - {fprintf(file,"%s",str.ptr());} +inline void print(FILE *file, const char *str) { fprintf(file, "%s", str); } +inline void print(FILE *file, const String &str) { + fprintf(file, "%s", str.ptr()); +} -inline void String::setLength(const Ulong& n) {setSize(n+1);} -inline bool String::isDefined() const {return size();} -inline Ulong String::length() const {return size()-1;} +inline void String::setLength(const Ulong &n) { setSize(n + 1); } +inline bool String::isDefined() const { return size(); } +inline Ulong String::length() const { return size() - 1; } -} +} // namespace io #endif diff --git a/iterator.h b/iterator.h index 35fcbbd..5211318 100644 --- a/iterator.h +++ b/iterator.h @@ -5,18 +5,18 @@ See file main.cpp for full copyright notice */ -#ifndef ITERATOR_H /* guard against multiple inclusions */ +#ifndef ITERATOR_H /* guard against multiple inclusions */ #define ITERATOR_H #include "globals.h" namespace iterator { - using namespace coxeter; +using namespace coxeter; /******** type declarations **************************************************/ - template class FilteredIterator; - template class ComposedIterator; +template class FilteredIterator; +template class ComposedIterator; /******** type definitions ***************************************************/ @@ -27,32 +27,32 @@ namespace iterator { values of the old one for which the function object returns true. T is the value-type of I. */ -template -class FilteredIterator { - private: +template class FilteredIterator { +private: I d_i; I d_max; - const F& d_f; - public: - FilteredIterator(I i, I max, const F& f):d_i(i),d_max(max),d_f(f) { + const F &d_f; + +public: + FilteredIterator(I i, I max, const F &f) : d_i(i), d_max(max), d_f(f) { for (; d_i != d_max; ++d_i) { if (d_f(*d_i)) - break; + break; } } - ~FilteredIterator() {}; - T operator* () {return *d_i;} - FilteredIterator& operator++ () { + ~FilteredIterator(){}; + T operator*() { return *d_i; } + FilteredIterator &operator++() { for (++d_i; d_i != d_max; ++d_i) { if (d_f(*d_i)) - break; + break; } return *this; } - bool operator== (const FilteredIterator& i) const {return d_i == i.d_i;} - bool operator!= (const FilteredIterator& i) const {return d_i != i.d_i;} + bool operator==(const FilteredIterator &i) const { return d_i == i.d_i; } + bool operator!=(const FilteredIterator &i) const { return d_i != i.d_i; } }; -} +} // namespace iterator #endif diff --git a/kl.cpp b/kl.cpp index d47d6be..7dd6ab4 100644 --- a/kl.cpp +++ b/kl.cpp @@ -1,6 +1,6 @@ /* This is kl.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -11,9 +11,9 @@ #include "iterator.h" namespace kl { - using namespace error; - using namespace iterator; -} +using namespace error; +using namespace iterator; +} // namespace kl /**************************************************************************** @@ -64,7 +64,7 @@ namespace kl { - compute the full file of k-l polynomials (mu coefficients); It turns out that the dominant factor in the computation is the Bruhat order - comparison. That is why computing a whole row can be done much more + comparison. That is why computing a whole row can be done much more efficently than computing each entry in the row separately : using our closure function from the schubert context, we can basically factor out most of the Bruhat things for a whole row. In any case, the row computation @@ -74,95 +74,98 @@ namespace kl { namespace kl { - struct KLContext::KLHelper { -/* data */ - KLContext* d_kl; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLHelper));} - KLHelper(KLContext* kl):d_kl(kl) {}; - ~KLHelper() {}; -/* member functions */ - void allocExtrRow(const CoxNbr& y) {klsupport().allocExtrRow(y);} - void allocKLRow(const CoxNbr& y); - void allocMuRow(const CoxNbr& y); - void allocMuRow(MuRow& row, const CoxNbr& y); - void allocMuTable(); - void allocRowComputation(const CoxNbr& y); - bool checkKLRow(const CoxNbr& y); - bool checkMuRow(const CoxNbr& y); - void coatomCorrection(const CoxNbr& y, List& pol); - void coatomCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, - List& pol, const Ulong& a); - KLCoeff computeMu(const CoxNbr& x, const CoxNbr& y); - const ExtrRow& extrList(const CoxNbr& y) {return klsupport().extrList(y);} - void fillMuRow(MuRow& row, const CoxNbr& y); - const KLPol* fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - void fillKLRow(const CoxNbr& y); - void initWorkspace(const CoxNbr& y, List& pol); - CoxNbr inverse(const CoxNbr& y) {return klsupport().inverse(y);} - void inverseMuRow(const CoxNbr& y); - bool isExtrAllocated(const CoxNbr& y) - {return klsupport().isExtrAllocated(y);} - bool isKLAllocated(const CoxNbr& y) {return d_kl->isKLAllocated(y);} - bool isMuAllocated(const CoxNbr& y) {return d_kl->isMuAllocated(y);} - KLRow& klList(const CoxNbr& y) {return *d_kl->d_klList[y];} - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y) - {return d_kl->klPol(x,y);} - KLSupport& klsupport() {return d_kl->d_klsupport[0];} - BinaryTree& klTree() {return d_kl->d_klTree;} - Generator last(const CoxNbr& x) {return klsupport().last(x);} - void makeMuRow(const CoxNbr& y); - KLCoeff mu(const CoxNbr& x, const CoxNbr& y) {return d_kl->mu(x,y);} - void muCorrection(const CoxNbr& y, List& pol); - void muCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, - List& pol, const Ulong& a); - MuRow& muList(const CoxNbr& y) {return *d_kl->d_muList[y];} - void prepareRow(const CoxNbr& y, const Generator& s); - Rank rank() {return d_kl->rank();} - void readMuRow(const CoxNbr& y); - KLCoeff recursiveMu(const CoxNbr& x, const CoxNbr& y, const Generator& s); - const SchubertContext& schubert() {return klsupport().schubert();} - void secondTerm(const CoxNbr& y, List& pol); - Ulong size() {return d_kl->size();} - KLStatus& status() {return *d_kl->d_status;} - void writeKLRow(const CoxNbr& y, List& pol); - void writeMuRow(const MuRow& row, const CoxNbr& y); - }; - +struct KLContext::KLHelper { + /* data */ + KLContext *d_kl; + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLHelper)); + } + KLHelper(KLContext *kl) : d_kl(kl){}; + ~KLHelper(){}; + /* member functions */ + void allocExtrRow(const CoxNbr &y) { klsupport().allocExtrRow(y); } + void allocKLRow(const CoxNbr &y); + void allocMuRow(const CoxNbr &y); + void allocMuRow(MuRow &row, const CoxNbr &y); + void allocMuTable(); + void allocRowComputation(const CoxNbr &y); + bool checkKLRow(const CoxNbr &y); + bool checkMuRow(const CoxNbr &y); + void coatomCorrection(const CoxNbr &y, List &pol); + void coatomCorrection(const CoxNbr &x, const CoxNbr &y, const Generator &s, + List &pol, const Ulong &a); + KLCoeff computeMu(const CoxNbr &x, const CoxNbr &y); + const ExtrRow &extrList(const CoxNbr &y) { return klsupport().extrList(y); } + void fillMuRow(MuRow &row, const CoxNbr &y); + const KLPol *fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + void fillKLRow(const CoxNbr &y); + void initWorkspace(const CoxNbr &y, List &pol); + CoxNbr inverse(const CoxNbr &y) { return klsupport().inverse(y); } + void inverseMuRow(const CoxNbr &y); + bool isExtrAllocated(const CoxNbr &y) { + return klsupport().isExtrAllocated(y); + } + bool isKLAllocated(const CoxNbr &y) { return d_kl->isKLAllocated(y); } + bool isMuAllocated(const CoxNbr &y) { return d_kl->isMuAllocated(y); } + KLRow &klList(const CoxNbr &y) { return *d_kl->d_klList[y]; } + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y) { + return d_kl->klPol(x, y); + } + KLSupport &klsupport() { return d_kl->d_klsupport[0]; } + BinaryTree &klTree() { return d_kl->d_klTree; } + Generator last(const CoxNbr &x) { return klsupport().last(x); } + void makeMuRow(const CoxNbr &y); + KLCoeff mu(const CoxNbr &x, const CoxNbr &y) { return d_kl->mu(x, y); } + void muCorrection(const CoxNbr &y, List &pol); + void muCorrection(const CoxNbr &x, const CoxNbr &y, const Generator &s, + List &pol, const Ulong &a); + MuRow &muList(const CoxNbr &y) { return *d_kl->d_muList[y]; } + void prepareRow(const CoxNbr &y, const Generator &s); + Rank rank() { return d_kl->rank(); } + void readMuRow(const CoxNbr &y); + KLCoeff recursiveMu(const CoxNbr &x, const CoxNbr &y, const Generator &s); + const SchubertContext &schubert() { return klsupport().schubert(); } + void secondTerm(const CoxNbr &y, List &pol); + Ulong size() { return d_kl->size(); } + KLStatus &status() { return *d_kl->d_status; } + void writeKLRow(const CoxNbr &y, List &pol); + void writeMuRow(const MuRow &row, const CoxNbr &y); }; +}; // namespace kl + namespace { - using namespace kl; - - struct PolPtrF { - typedef const KLPol* valueType; - const KLPol* operator()(const KLPol* pol) {return pol;} - }; - - void allocExtrRow(KLContext& kl, ExtrRow& row, const CoxNbr& y); - void appendStar(String& str, const KLContext& kl, const CoxNbr& x, - const KLPol& pol, const Length& l); - MuData* find(MuRow& row, const CoxNbr& x); - void printStar(FILE* file, const KLContext& kl, const CoxNbr& x, - const KLPol& pol, const Length& l); - KLPol& safeAdd(KLPol& p, const KLPol& q, const Degree& n); - KLPol& safeSubtract(KLPol& p, const KLPol& q, const KLCoeff& mu, - const Length& h); - void showSimpleMu(FILE* file, KLContext& kl, const CoxNbr& x, - const CoxNbr& y, const KLCoeff& r, const Interface& I); - void showRecursiveMu(FILE* file, KLContext& kl, const CoxNbr& x, - const CoxNbr& y, const KLCoeff& r, const Interface& I); - KLPol& zeroPol(); +using namespace kl; + +struct PolPtrF { + typedef const KLPol *valueType; + const KLPol *operator()(const KLPol *pol) { return pol; } }; +void allocExtrRow(KLContext &kl, ExtrRow &row, const CoxNbr &y); +void appendStar(String &str, const KLContext &kl, const CoxNbr &x, + const KLPol &pol, const Length &l); +MuData *find(MuRow &row, const CoxNbr &x); +void printStar(FILE *file, const KLContext &kl, const CoxNbr &x, + const KLPol &pol, const Length &l); +KLPol &safeAdd(KLPol &p, const KLPol &q, const Degree &n); +KLPol &safeSubtract(KLPol &p, const KLPol &q, const KLCoeff &mu, + const Length &h); +void showSimpleMu(FILE *file, KLContext &kl, const CoxNbr &x, const CoxNbr &y, + const KLCoeff &r, const Interface &I); +void showRecursiveMu(FILE *file, KLContext &kl, const CoxNbr &x, + const CoxNbr &y, const KLCoeff &r, const Interface &I); +KLPol &zeroPol(); +}; // namespace + /**************************************************************************** Chapter I --- The KLContext class - This section defines the functions for the KLContext class. The following + This section defines the functions for the KLContext class. The following functions are defined : constructors and destructors : @@ -196,8 +199,8 @@ namespace { namespace kl { -KLContext::KLContext(KLSupport* kls) - :d_klsupport(kls), d_klList(kls->size()), d_muList(kls->size()) +KLContext::KLContext(KLSupport *kls) + : d_klsupport(kls), d_klList(kls->size()), d_muList(kls->size()) { d_status = new KLStatus; @@ -237,7 +240,7 @@ KLContext::~KLContext() /******** manipulators *******************************************************/ -void KLContext::applyInverse(const CoxNbr& x) +void KLContext::applyInverse(const CoxNbr &x) /* Exchanges rows for x and x_inverse in klList. It is assumed that the row @@ -296,7 +299,7 @@ void KLContext::fillMu() for (CoxNbr y = 0; y < size(); ++y) { if (inverse(y) < y) d_help->inverseMuRow(inverse(y)); - d_help->fillMuRow(*d_muList[y],y); + d_help->fillMuRow(*d_muList[y], y); if (ERRNO) goto abort; } @@ -304,14 +307,14 @@ void KLContext::fillMu() setFullMu(); return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, - const Generator& s) +const KLPol &KLContext::klPol(const CoxNbr &d_x, const CoxNbr &d_y, + const Generator &s) /* This function returns the Kazhdan-Lusztig polynomial P_{x,y}. It is @@ -322,11 +325,11 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, { CoxNbr x = d_x; CoxNbr y = d_y; - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); /* put x in extremal position w.r.t. y */ - x = p.maximize(x,p.descent(y)); + x = p.maximize(x, p.descent(y)); /* check for trivial cases */ @@ -351,11 +354,11 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, /* find x in extrList[y] */ - Ulong m = find(extrList(y),x); - const KLPol*& pol = d_help->klList(y)[m]; + Ulong m = find(extrList(y), x); + const KLPol *&pol = d_help->klList(y)[m]; if (pol == 0) { /* we have to compute the polynomial */ - pol = d_help->fillKLPol(x,y,s); + pol = d_help->fillKLPol(x, y, s); if (ERRNO) return zeroPol(); } @@ -363,7 +366,7 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y, return *pol; } -KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y) +KLCoeff KLContext::mu(const CoxNbr &x, const CoxNbr &y) /* This function returns the mu-coefficient mu(x,y). It is assumed that @@ -377,11 +380,11 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); Length d = p.length(y) - p.length(x); - if (d%2 == 0) + if (d % 2 == 0) return 0; if (d == 1) /* x is a coatom of y */ @@ -389,7 +392,7 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y) /* check if x is in extremal position w.r.t. y */ - if (x != p.maximize(x,p.descent(y))) + if (x != p.maximize(x, p.descent(y))) return 0; /* allocate *d_muList[y] if necessary */ @@ -402,13 +405,13 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y) /* find x in *d_muList[y] */ - MuRow& m = *d_muList[y]; - MuData* md = find(m,x); + MuRow &m = *d_muList[y]; + MuData *md = find(m, x); if (md == 0) return 0; if (md->mu == undef_klcoeff) { /* we need to compute the coefficient */ - md->mu = d_help->computeMu(x,y); + md->mu = d_help->computeMu(x, y); if (ERRNO) return undef_klcoeff; } @@ -416,7 +419,7 @@ KLCoeff KLContext::mu(const CoxNbr& x, const CoxNbr& y) return md->mu; } -void KLContext::permute(const Permutation& a) +void KLContext::permute(const Permutation &a) /* This function permutes the context according to the permutation a. The @@ -431,7 +434,7 @@ void KLContext::permute(const Permutation& a) Applying a permutation to something goes as follows. The permutation a is the table of the function which assigns to each x in the context its - number in the new enumeration. Applying this to the context means the + number in the new enumeration. Applying this to the context means the following : (a) for tables with _values_ in the context, we need to replace t[j] with @@ -444,10 +447,10 @@ void KLContext::permute(const Permutation& a) The replacements in (a) are straightforward. The permutations in (b) are more delicate, and would seem to require additional memory for each list to - be transformed. In fact, things can be done in place. The thing is to use - the cycle decomposition of the permutation : put t[x] at position a[x], - t[a[x]] at position a^2[x], ... t[a^{k-1}[x]] at position x, if a^k[x] = x. - This requires only the use of the bitmap of a to mark off the entries that + be transformed. In fact, things can be done in place. The thing is to use + the cycle decomposition of the permutation : put t[x] at position a[x], + t[a[x]] at position a^2[x], ... t[a^{k-1}[x]] at position x, if a^k[x] = x. + This requires only the use of the bitmap of a to mark off the entries that have been handled, and skip to the next entry. */ @@ -458,7 +461,7 @@ void KLContext::permute(const Permutation& a) for (CoxNbr y = 0; y < size(); ++y) { if (!isMuAllocated(y)) continue; - MuRow& row = *d_muList[y]; + MuRow &row = *d_muList[y]; for (Ulong j = 0; j < row.size(); ++j) row[j].x = a[row[j].x]; row.sort(); @@ -478,8 +481,8 @@ void KLContext::permute(const Permutation& a) for (CoxNbr y = a[x]; y != x; y = a[y]) { /* back up values for y */ - KLRow* kl_buf = d_klList[y]; - MuRow* mu_buf = d_muList[y]; + KLRow *kl_buf = d_klList[y]; + MuRow *mu_buf = d_muList[y]; /* put values for x in y */ d_klList[y] = d_klList[x]; d_muList[y] = d_muList[x]; @@ -496,7 +499,7 @@ void KLContext::permute(const Permutation& a) return; } -void KLContext::revertSize(const Ulong& n) +void KLContext::revertSize(const Ulong &n) /* Reverts the sizes of the lists to size n. This is meant to be used @@ -505,14 +508,14 @@ void KLContext::revertSize(const Ulong& n) miserably if a premutation has taken place in-between. */ -{ +{ d_klList.setSize(n); d_muList.setSize(n); return; } -void KLContext::row(HeckeElt& h, const CoxNbr& y) +void KLContext::row(HeckeElt &h, const CoxNbr &y) /* This function returns in h the data for the full row of y in the k-l table, @@ -531,20 +534,19 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) } if (y <= inverse(y)) { - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); h.setSize(e.size()); - const KLRow& klr = klList(y); + const KLRow &klr = klList(y); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(e[j],klr[j]); + h[j].setData(e[j], klr[j]); } - } - else { /* go over to inverses */ + } else { /* go over to inverses */ CoxNbr yi = inverse(y); - const ExtrRow& e = extrList(yi); + const ExtrRow &e = extrList(yi); h.setSize(e.size()); - const KLRow& klr = klList(yi); + const KLRow &klr = klList(yi); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(inverse(e[j]),klr[j]); + h[j].setData(inverse(e[j]), klr[j]); } h.sort(); /* make sure list is ordered */ } @@ -552,7 +554,7 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) return; } -void KLContext::setSize(const Ulong& n) +void KLContext::setSize(const Ulong &n) /* This function extends the context so that it can accomodate n elements. @@ -578,7 +580,7 @@ void KLContext::setSize(const Ulong& n) return; - revert: +revert: CATCH_MEMORY_OVERFLOW = false; revertSize(prev_size); return; @@ -586,7 +588,7 @@ void KLContext::setSize(const Ulong& n) /******** input/output ******************************************************/ -void KLContext::printStatus(FILE* file) const +void KLContext::printStatus(FILE *file) const /* This function prints the status of the context. This is a data structure @@ -595,13 +597,13 @@ void KLContext::printStatus(FILE* file) const */ { - fprintf(file,"klrows = %lu\n",d_status->klrows); - fprintf(file,"klnodes = %lu\n",d_status->klnodes); - fprintf(file,"klcomputed = %lu\n",d_status->klcomputed); - fprintf(file,"murows = %lu\n",d_status->murows); - fprintf(file,"munodes = %lu\n",d_status->munodes); - fprintf(file,"mucomputed = %lu\n",d_status->mucomputed); - fprintf(file,"muzero = %lu\n",d_status->muzero); + fprintf(file, "klrows = %lu\n", d_status->klrows); + fprintf(file, "klnodes = %lu\n", d_status->klnodes); + fprintf(file, "klcomputed = %lu\n", d_status->klcomputed); + fprintf(file, "murows = %lu\n", d_status->murows); + fprintf(file, "munodes = %lu\n", d_status->munodes); + fprintf(file, "mucomputed = %lu\n", d_status->mucomputed); + fprintf(file, "muzero = %lu\n", d_status->muzero); return; } @@ -627,31 +629,30 @@ void KLContext::compareMu() if (!isKLAllocated(y)) d_help->allocKLRow(y); d_help->fillKLRow(y); - const MuRow& mu_row = muList(y); - const ExtrRow& e = extrList(y); - const KLRow& kl_row = klList(y); + const MuRow &mu_row = muList(y); + const ExtrRow &e = extrList(y); + const KLRow &kl_row = klList(y); Ulong i = 0; for (Ulong j = 0; j < mu_row.size(); ++j) { CoxNbr x = mu_row[j].x; - while(e[i] < x) - ++i; - const KLPol& pol = *kl_row[i]; + while (e[i] < x) + ++i; + const KLPol &pol = *kl_row[i]; Length d = mu_row[j].height; if (pol.deg() == d) { - if (mu_row[j].mu != pol[d]) - printf("error! x = %lu, y = %lu\n",static_cast(x), - static_cast(y)); - } - else { - if(mu_row[j].mu != 0) - printf("error! x = %lu, y = %lu\n",static_cast(x), - static_cast(y)); + if (mu_row[j].mu != pol[d]) + printf("error! x = %lu, y = %lu\n", static_cast(x), + static_cast(y)); + } else { + if (mu_row[j].mu != 0) + printf("error! x = %lu, y = %lu\n", static_cast(x), + static_cast(y)); } } } } -}; +}; // namespace kl /**************************************************************************** @@ -668,7 +669,7 @@ void KLContext::compareMu() - allocMuRow(const CoxNbr& y) : allocates a row in the mu list; - allocMuRow(MuRow& row, const CoxNbr& y) : same, for an external mu-row; - allocMuTable() : allocates the full mu-table; - - allocRowComputation(const CoxNbr& y) : initial allocation for a + - allocRowComputation(const CoxNbr& y) : initial allocation for a row-computation - checkKLRow(const CoxNbr& y) : checks if a k-l row is fully computed; - coatomCorrection(const CoxNbr& y, List& pol) : subtracts the @@ -677,7 +678,7 @@ void KLContext::compareMu() List& pol, const Ulong& a) : same, for a single polynomial - computeMu(const CoxNbr& x, const CoxNbr& y) : computes a mu-coefficient; - fillMuRow(MuRow& row, const CoxNbr& y) : fills a row in the mu-table; - - fillKLPol(const CoxNbr& x, const CoxNbr& y, const Generator& s = + - fillKLPol(const CoxNbr& x, const CoxNbr& y, const Generator& s = undef_generator) : fills in one polynomial, using s as descent; - fillKLRow(const CoxNbr& y) : fills in one row in the k-l table; CoxNbr inverse(const CoxNbr& y) : returns the inverse of y; @@ -689,7 +690,7 @@ void KLContext::compareMu() - muCorrection(const CoxNbr& y, List& pol) : subtracts the non-coatom mu-part in the computation of a row; - muCorrection(const CoxNbr& x, const CoxNbr& y, const Generator& s, - List& pol, const Ulong& a) : subtracts the non-coatom mu-part, + List& pol, const Ulong& a) : subtracts the non-coatom mu-part, for the computation of a single polynomial; - muList(const CoxNbr& y) : returns the row for y in muList; - prepareRow(const CoxNbr& y, const Generator& s) : a preliminary to the @@ -699,16 +700,16 @@ void KLContext::compareMu() computes mu(x,y) using the general recursive formula; - secondTerm(const CoxNbr& y, List& pol) : takes care of the second term P_{x,ys} in the computation of a full row; - - writeKLRow(const CoxNbr& y, List& pol) : transfers the + - writeKLRow(const CoxNbr& y, List& pol) : transfers the polynomials from pol to klList; - - writeMuRow(const MuRow& row, const CoxNbr& y) transfers the + - writeMuRow(const MuRow& row, const CoxNbr& y) transfers the mu-coefficients from row to muList; ****************************************************************************/ namespace kl { -void KLContext::KLHelper::allocKLRow(const CoxNbr& y) +void KLContext::KLHelper::allocKLRow(const CoxNbr &y) /* This function allocates one row of the kl_list. The row contains one @@ -737,10 +738,9 @@ void KLContext::KLHelper::allocKLRow(const CoxNbr& y) status().klrows++; return; - } -void KLContext::KLHelper::allocMuRow(const CoxNbr& y) +void KLContext::KLHelper::allocMuRow(const CoxNbr &y) /* This function allocates one row in the muList. There is one entry for @@ -751,27 +751,26 @@ void KLContext::KLHelper::allocMuRow(const CoxNbr& y) */ { - typedef FilteredIterator EI; - typedef FilteredIterator BI; + typedef FilteredIterator EI; + typedef FilteredIterator BI; - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); ExtrRow e(0); - MuFilter f(p,y); + MuFilter f(p, y); if (isExtrAllocated(y)) { - EI first(extrList(y).begin(),extrList(y).end(),f); - EI last(extrList(y).end(),extrList(y).end(),f); - new(&e) ExtrRow(first,last); - } - else { + EI first(extrList(y).begin(), extrList(y).end(), f); + EI last(extrList(y).end(), extrList(y).end(), f); + new (&e) ExtrRow(first, last); + } else { BitMap b(size()); - p.extractClosure(b,y); + p.extractClosure(b, y); if (ERRNO) return; - maximize(p,b,p.descent(y)); - BI first(b.begin(),b.end(),f); - BI last(b.end(),b.end(),f); - new(&e) ExtrRow(first,last); + maximize(p, b, p.descent(y)); + BI first(b.begin(), b.end(), f); + BI last(b.end(), b.end(), f); + new (&e) ExtrRow(first, last); } Length ly = p.length(y); @@ -784,7 +783,7 @@ void KLContext::KLHelper::allocMuRow(const CoxNbr& y) for (Ulong j = 0; j < e.size(); ++j) { CoxNbr x = e[j]; Length lx = p.length(x); - new(muList(y).ptr()+j) MuData(x,undef_klcoeff,(ly-lx-1)/2); + new (muList(y).ptr() + j) MuData(x, undef_klcoeff, (ly - lx - 1) / 2); } status().munodes += e.size(); @@ -792,13 +791,13 @@ void KLContext::KLHelper::allocMuRow(const CoxNbr& y) return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::allocMuRow(MuRow& row, const CoxNbr& y) +void KLContext::KLHelper::allocMuRow(MuRow &row, const CoxNbr &y) /* Like allocMuRow(const CoxNbr& y), but does the allocation in row. @@ -809,17 +808,16 @@ void KLContext::KLHelper::allocMuRow(MuRow& row, const CoxNbr& y) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); ExtrRow e(0); if (isExtrAllocated(y)) { /* extremal row is already available */ e = extrList(y); - } - else { /* make it from scratch */ + } else { /* make it from scratch */ BitMap b(size()); - p.extractClosure(b,y); - maximize(p,b,p.descent(y)); - readBitMap(e,b); + p.extractClosure(b, y); + maximize(p, b, p.descent(y)); + readBitMap(e, b); } /* extract elements with odd length difference > 1 */ @@ -830,9 +828,9 @@ void KLContext::KLHelper::allocMuRow(MuRow& row, const CoxNbr& y) for (Ulong j = 0; j < e.size(); ++j) { CoxNbr x = e[j]; Length lx = p.length(x); - if ((ly-lx)%2 == 0) + if ((ly - lx) % 2 == 0) continue; - if (ly-lx == 1) + if (ly - lx == 1) continue; e[mu_count] = x; mu_count++; @@ -843,7 +841,7 @@ void KLContext::KLHelper::allocMuRow(MuRow& row, const CoxNbr& y) for (Ulong j = 0; j < mu_count; ++j) { CoxNbr x = e[j]; Length lx = p.length(x); - new(row.ptr()+j) MuData(x,undef_klcoeff,(ly-lx-1)/2); + new (row.ptr() + j) MuData(x, undef_klcoeff, (ly - lx - 1) / 2); } return; @@ -864,9 +862,9 @@ void KLContext::KLHelper::allocMuTable() */ { - typedef FilteredIterator I; + typedef FilteredIterator I; - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); for (ClosureIterator cl(p); cl; ++cl) { @@ -880,17 +878,17 @@ void KLContext::KLHelper::allocMuTable() BitMap b = cl().bitMap(); if (ERRNO) { - printf("error! y = %lu\n",static_cast(y)); + printf("error! y = %lu\n", static_cast(y)); goto abort; } - maximize(p,b,p.descent(y)); + maximize(p, b, p.descent(y)); - MuFilter f(p,y); - I first(b.begin(),b.end(),f); - I last(b.end(),b.end(),f); + MuFilter f(p, y); + I first(b.begin(), b.end(), f); + I last(b.end(), b.end(), f); - ExtrRow e(first,last); + ExtrRow e(first, last); if (ERRNO) { goto abort; } @@ -904,10 +902,10 @@ void KLContext::KLHelper::allocMuTable() for (Ulong j = 0; j < e.size(); ++j) { CoxNbr x = e[j]; Length lx = p.length(x); - MuData mu_data(x,undef_klcoeff,(ly-lx-1)/2); + MuData mu_data(x, undef_klcoeff, (ly - lx - 1) / 2); muList(y).append(mu_data); if (ERRNO) { - goto abort; + goto abort; } } @@ -917,13 +915,13 @@ void KLContext::KLHelper::allocMuTable() return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::allocRowComputation(const CoxNbr& y) +void KLContext::KLHelper::allocRowComputation(const CoxNbr &y) /* This function does the primary memory allocation for the computation @@ -945,40 +943,39 @@ void KLContext::KLHelper::allocRowComputation(const CoxNbr& y) of error. */ -{ +{ klsupport().allocRowComputation(y); List g(0); - klsupport().standardPath(g,y); + klsupport().standardPath(g, y); CoxNbr y1 = 0; for (Ulong j = 0; j < g.size(); ++j) { Generator s = g[j]; - y1 = schubert().shift(y1,s); + y1 = schubert().shift(y1, s); CoxNbr y2 = klsupport().inverseMin(y1); - const ExtrRow& e = extrList(y2); + const ExtrRow &e = extrList(y2); if (!isKLAllocated(y2)) { d_kl->d_klList[y2] = new KLRow(e.size()); if (ERRNO) - goto abort; + goto abort; klList(y2).setSizeValue(extrList(y2).size()); status().klnodes += extrList(y2).size(); status().klrows++; } - } - return; - abort: + return; +abort: Error(ERRNO); ERRNO = ERROR_WARNING; - return; + return; } -bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) +bool KLContext::KLHelper::checkKLRow(const CoxNbr &d_y) /* This function checks if the row for y (or for inverse(y) if appropriate) @@ -994,7 +991,7 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) if (!isKLAllocated(y)) /* row is not allocated */ return false; - KLRow& kl_row = klList(y); + KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j] == 0) @@ -1004,17 +1001,17 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) return true; } -bool KLContext::KLHelper::checkMuRow(const CoxNbr& y) +bool KLContext::KLHelper::checkMuRow(const CoxNbr &y) /* This function checks if the row for y in muList has been filled. */ -{ +{ if (!isMuAllocated(y)) /* row is not allocated */ return false; - const MuRow& mu_row = muList(y); + const MuRow &mu_row = muList(y); for (Ulong j = 0; j < mu_row.size(); ++j) { if (mu_row[j].mu == undef_klcoeff) @@ -1024,7 +1021,7 @@ bool KLContext::KLHelper::checkMuRow(const CoxNbr& y) return true; } -void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) +void KLContext::KLHelper::coatomCorrection(const CoxNbr &y, List &pol) /* This function subtracts the coatom correction from the list of polynomials. @@ -1032,21 +1029,21 @@ void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) muCorrection. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); BitMap b(size()); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); Generator s = last(y); - CoxNbr ys = p.rshift(y,s); - const CoatomList& c = p.hasse(ys); - + CoxNbr ys = p.rshift(y, s); + const CoatomList &c = p.hasse(ys); + for (Ulong j = 0; j < c.size(); ++j) { CoxNbr z = c[j]; - if (p.shift(z,s) > z) + if (p.shift(z, s) > z) continue; - p.extractClosure(b,z); - maximize(p,b,p.descent(y)); + p.extractClosure(b, z); + maximize(p, b, p.descent(y)); Ulong i = 0; BitMap::Iterator b_end = b.end(); @@ -1054,12 +1051,12 @@ void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { CoxNbr x = *k; while (e[i] < x) - ++i; - safeSubtract(pol[i],klPol(x,z),1,1); + ++i; + safeSubtract(pol[i], klPol(x, z), 1, 1); if (ERRNO) { - Error(ERRNO,this,x,y); - ERRNO = ERROR_WARNING; - return; + Error(ERRNO, this, x, y); + ERRNO = ERROR_WARNING; + return; } } } @@ -1067,9 +1064,9 @@ void KLContext::KLHelper::coatomCorrection(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::coatomCorrection(const CoxNbr& x, const CoxNbr& y, - const Generator& s, List& pol, - const Ulong& a) +void KLContext::KLHelper::coatomCorrection(const CoxNbr &x, const CoxNbr &y, + const Generator &s, List &pol, + const Ulong &a) /* This function subtracts the coatom correction from pol, which at this @@ -1081,37 +1078,38 @@ void KLContext::KLHelper::coatomCorrection(const CoxNbr& x, const CoxNbr& y, */ -{ - const SchubertContext& p = schubert(); - CoxNbr ys = p.shift(y,s); const CoatomList& c = p.hasse(ys); +{ + const SchubertContext &p = schubert(); + CoxNbr ys = p.shift(y, s); + const CoatomList &c = p.hasse(ys); for (Ulong j = 0; j < c.size(); ++j) { CoxNbr z = c[j]; - if (p.shift(z,s) > z) /* z is not considered */ + if (p.shift(z, s) > z) /* z is not considered */ continue; - if (!p.inOrder(x,z)) /* z is not in [x,ys] */ + if (!p.inOrder(x, z)) /* z is not in [x,ys] */ continue; /* at this point we have to do an actual subtraction */ - const KLPol& p_xz = klPol(x,z); + const KLPol &p_xz = klPol(x, z); if (ERRNO) return; - safeSubtract(pol[a],p_xz,1,1); + safeSubtract(pol[a], p_xz, 1, 1); if (ERRNO) { - Error(ERRNO,this,x,y); + Error(ERRNO, this, x, y); ERRNO = ERROR_WARNING; return; } } - + return; } -KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) +KLCoeff KLContext::KLHelper::computeMu(const CoxNbr &x, const CoxNbr &y) /* This function gets a previously uncomputed entry in the muList. It @@ -1126,53 +1124,53 @@ KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) exactly as in the proof of thm. 4.2. in the original k-l paper, one sees that at most four terms survive in the recursion formula : we have - mu(x,y) = mu(xs,ys) + mu(xt,ys) - mu(x,yst)(if ysts < yst) + mu(x,y) = mu(xs,ys) + mu(xt,ys) - mu(x,yst)(if ysts < yst) - mu(xt,ys)(if xts < xt) So in all these cases we get an elementary recursion. - Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of + Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of failure (this can be due to memory overflow, or to coefficient over- or underflow.) */ { if (inverse(y) < y) - return computeMu(inverse(x),inverse(y)); + return computeMu(inverse(x), inverse(y)); - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); LFlags f = p.twoDescent(y); - if ((p.descent(x)&f) == f) { /* x is super-extremal w.r.t. y */ - return recursiveMu(x,y,last(y)); + if ((p.descent(x) & f) == f) { /* x is super-extremal w.r.t. y */ + return recursiveMu(x, y, last(y)); } Generator s, t; /* choose s s.t. LR(ys) not contained in LR(x) */ - for (LFlags f1 = p.descent(y); f1; f1 &= f1-1) { + for (LFlags f1 = p.descent(y); f1; f1 &= f1 - 1) { Generator u = firstBit(f1); - CoxNbr yu = p.shift(y,u); + CoxNbr yu = p.shift(y, u); LFlags fu = p.descent(yu); - if ((p.descent(x)&fu) != fu) { + if ((p.descent(x) & fu) != fu) { s = u; t = firstBit(fu & ~p.descent(x)); break; } } - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); - KLCoeff r1 = mu(xs,ys); + KLCoeff r1 = mu(xs, ys); if (ERRNO) goto abort; /* check if x <= ys */ - if (!p.inOrder(x,ys)) { /* value is found */ + if (!p.inOrder(x, ys)) { /* value is found */ status().mucomputed++; if (r1 == 0) status().muzero++; @@ -1180,69 +1178,66 @@ KLCoeff KLContext::KLHelper::computeMu(const CoxNbr& x, const CoxNbr& y) } { - CoxNbr xt = p.shift(x,t); - CoxNbr yst = p.shift(ys,t); - + CoxNbr xt = p.shift(x, t); + CoxNbr yst = p.shift(ys, t); + /* consider four cases */ - - if (p.isDescent(xt,s)) { /* xts < xt */ - if (p.isDescent(yst,s)) { /* ysts < yst */ - KLCoeff r3 = mu(x,yst); - if (ERRNO) - goto abort; - if (r1 < r3) { /* negative mu-coefficient */ - ERRNO = MU_NEGATIVE; - goto abort; - } - status().mucomputed++; - if (r1 == r3) - status().muzero++; - return r1-r3; - } - else { /* ysts > yst */ - status().mucomputed++; - if (r1 == 0) - status().muzero++; - return r1; - } - } - else { /* xts > xt */ - if (p.isDescent(yst,s)) { /* ysts < yst */ - KLCoeff r2 = mu(xt,ys); - if (ERRNO) - goto abort; - KLCoeff r3 = mu(x,yst); - if (ERRNO) - goto abort; - if ((r1+r2) < r3) { /* negative mu-coefficient */ - ERRNO = MU_NEGATIVE; - goto abort; - } - status().mucomputed++; - if (r1+r2 == r3) - status().muzero++; - return r1+r2-r3; + + if (p.isDescent(xt, s)) { /* xts < xt */ + if (p.isDescent(yst, s)) { /* ysts < yst */ + KLCoeff r3 = mu(x, yst); + if (ERRNO) + goto abort; + if (r1 < r3) { /* negative mu-coefficient */ + ERRNO = MU_NEGATIVE; + goto abort; + } + status().mucomputed++; + if (r1 == r3) + status().muzero++; + return r1 - r3; + } else { /* ysts > yst */ + status().mucomputed++; + if (r1 == 0) + status().muzero++; + return r1; } - else { /* ysts > yst */ - KLCoeff r2 = mu(xt,ys); - if (ERRNO) - goto abort; - status().mucomputed++; - if (r1+r2 == 0) - status().muzero++; - return r1+r2; + } else { /* xts > xt */ + if (p.isDescent(yst, s)) { /* ysts < yst */ + KLCoeff r2 = mu(xt, ys); + if (ERRNO) + goto abort; + KLCoeff r3 = mu(x, yst); + if (ERRNO) + goto abort; + if ((r1 + r2) < r3) { /* negative mu-coefficient */ + ERRNO = MU_NEGATIVE; + goto abort; + } + status().mucomputed++; + if (r1 + r2 == r3) + status().muzero++; + return r1 + r2 - r3; + } else { /* ysts > yst */ + KLCoeff r2 = mu(xt, ys); + if (ERRNO) + goto abort; + status().mucomputed++; + if (r1 + r2 == 0) + status().muzero++; + return r1 + r2; } } } - abort: +abort: if (ERRNO != MEMORY_WARNING) ERRNO = MU_FAIL; return undef_klcoeff; } -const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& d_s) +const KLPol *KLContext::KLHelper::fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &d_s) /* This function performs one of the main tasks in the program, namely @@ -1266,7 +1261,7 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, { static List pol(0); - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); /* check easy cases */ @@ -1279,20 +1274,20 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, Generator s = d_s; - /* If d_s is undef_generator, we compute the polynomial using descent by + /* If d_s is undef_generator, we compute the polynomial using descent by last term in normal form */ if (s == undef_generator) s = last(y); - CoxNbr ys = p.shift(y,s); - CoxNbr xs = p.shift(x,s); + CoxNbr ys = p.shift(y, s); + CoxNbr xs = p.shift(x, s); /* check if x is comparable to ys */ - if (!p.inOrder(x,ys)) { /* return the answer recursively */ + if (!p.inOrder(x, ys)) { /* return the answer recursively */ status().klcomputed++; - return &klPol(xs,ys); + return &klPol(xs, ys); } /* get workspace */ @@ -1300,62 +1295,61 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, CATCH_MEMORY_OVERFLOW = true; Ulong a = pol.size(); - pol.setSize(a+1); + pol.setSize(a + 1); /* initialize the workspace to P_{xs,ys} */ - const KLPol& p_xsys = klPol(xs,ys); + const KLPol &p_xsys = klPol(xs, ys); if (ERRNO) goto abort; pol[a] = p_xsys; /* add q.P_{x,ys} */ - { - const KLPol& p_xys = klPol(x,ys); + { + const KLPol &p_xys = klPol(x, ys); if (ERRNO) goto abort; - safeAdd(pol[a],p_xys,1); + safeAdd(pol[a], p_xys, 1); if (ERRNO) goto abort; } /* subtract correction terms */ - coatomCorrection(x,y,s,pol,a); + coatomCorrection(x, y, s, pol, a); if (ERRNO) goto abort; - muCorrection(x,y,s,pol,a); + muCorrection(x, y, s, pol, a); if (ERRNO) goto abort; /* find address of polynomial */ { - const KLPol& p_xy = *klTree().find(pol[a]); + const KLPol &p_xy = *klTree().find(pol[a]); if (ERRNO) goto abort; - + /* return workspace and exit */ - + CATCH_MEMORY_OVERFLOW = false; - pol.setSize(a); + pol.setSize(a); status().klcomputed++; return &p_xy; } - abort: /* an error occurred */ +abort: /* an error occurred */ CATCH_MEMORY_OVERFLOW = false; if (ERRNO != MEMORY_WARNING) ERRNO = KL_FAIL; return 0; - } -void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) +void KLContext::KLHelper::fillKLRow(const CoxNbr &d_y) /* This function fills the rows for y in klList and muList. It is to be called @@ -1374,7 +1368,7 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) - it is assumed that the rows in klList and muList corresponding to the descent path that comes from our descent strategy (and the fact that sometimes we move over to inverses) have been allocated; this - can be assomplished by calling allocRowComputation. This condition will + can be assomplished by calling allocRowComputation. This condition will then also hold for the elements in the descent path. - then, we fill the corresponding rows, starting from the identity; @@ -1409,7 +1403,7 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) { static List pol(0); - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); CoxNbr y = d_y; if (y == 0) @@ -1421,7 +1415,7 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) /* recursively fill in rows in the descent path */ Generator s = last(y); - CoxNbr ys = p.rshift(y,s); + CoxNbr ys = p.rshift(y, s); if (!checkKLRow(ys)) { fillKLRow(ys); @@ -1431,45 +1425,45 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y) /* make sure the correcting terms are available */ - prepareRow(y,s); + prepareRow(y, s); if (ERRNO) goto abort; - /* prepare workspace; pol holds the row of polynomials; + /* prepare workspace; pol holds the row of polynomials; initialize workspace with P_{xs,ys} */ - initWorkspace(y,pol); + initWorkspace(y, pol); /* add q.P_{x,ys} when appropriate */ - secondTerm(y,pol); + secondTerm(y, pol); if (ERRNO) goto abort; /* subtract correcting terms */ - muCorrection(y,pol); + muCorrection(y, pol); if (ERRNO) goto abort; - coatomCorrection(y,pol); + coatomCorrection(y, pol); if (ERRNO) goto abort; /* copy results to row */ - writeKLRow(y,pol); + writeKLRow(y, pol); if (ERRNO) goto abort; return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::fillMuRow(MuRow& row, const CoxNbr& y) +void KLContext::KLHelper::fillMuRow(MuRow &row, const CoxNbr &y) /* Fills row with the values for the mu(x,y). It is assumed that the row @@ -1482,16 +1476,16 @@ void KLContext::KLHelper::fillMuRow(MuRow& row, const CoxNbr& y) for (Ulong j = 0; j < row.size(); ++j) { if (row[j].mu == undef_klcoeff) { CoxNbr x = row[j].x; - row[j].mu = computeMu(x,y); + row[j].mu = computeMu(x, y); if (ERRNO) - return; + return; } } return; } -void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) +void KLContext::KLHelper::initWorkspace(const CoxNbr &y, List &pol) /* This function sets pol to a row of one polynomial for each x in klList(y), @@ -1499,8 +1493,8 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); - const ExtrRow& e = extrList(y); + const SchubertContext &p = schubert(); + const ExtrRow &e = extrList(y); pol.setSize(e.size()); if (ERRNO) goto abort; @@ -1509,26 +1503,25 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol) { Generator s = last(y); - CoxNbr ys = p.rshift(y,s); - + CoxNbr ys = p.rshift(y, s); + for (Ulong j = 0; j < e.size(); ++j) { - CoxNbr xs = p.shift(e[j],s); - pol[j] = klPol(xs,ys); + CoxNbr xs = p.shift(e[j], s); + pol[j] = klPol(xs, ys); if (ERRNO) - goto abort; + goto abort; } - } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) +void KLContext::KLHelper::inverseMuRow(const CoxNbr &y) /* This function constructs the mu-row for the inverse of y from that of y. @@ -1542,20 +1535,20 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) CoxNbr yi = inverse(y); if (isMuAllocated(yi)) { /* deallocate; update status */ - MuRow& m = muList(yi); + MuRow &m = muList(yi); for (Ulong j = 0; j < m.size(); ++j) { KLCoeff mu = m[j].mu; if (mu != undef_klcoeff) - status().mucomputed--; + status().mucomputed--; if (mu == 0) - status().muzero--; + status().muzero--; } status().munodes -= m.size(); delete &m; } d_kl->d_muList[yi] = new MuRow(muList(y)); - MuRow& m = muList(yi); + MuRow &m = muList(yi); for (Ulong j = 0; j < m.size(); ++j) { m[j].x = inverse(m[j].x); @@ -1566,11 +1559,11 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) /* update status */ for (Ulong j = 0; j < m.size(); ++j) { - KLCoeff mu = m[j].mu; - if (mu != undef_klcoeff) - status().mucomputed++; - if (mu == 0) - status().muzero++; + KLCoeff mu = m[j].mu; + if (mu != undef_klcoeff) + status().mucomputed++; + if (mu == 0) + status().muzero++; } status().munodes += m.size(); @@ -1578,11 +1571,11 @@ void KLContext::KLHelper::inverseMuRow(const CoxNbr& y) return; } -void KLContext::KLHelper::makeMuRow(const CoxNbr& y) +void KLContext::KLHelper::makeMuRow(const CoxNbr &y) /* This function makes a row in the mu-table from scratch (i.e., it is assumed - that isMuAllocated(y) = false). The idea is to do the minimal allocation + that isMuAllocated(y) = false). The idea is to do the minimal allocation (i.e., write down non-zero mu's only), and to compute as much as possible within the mu-table itself. @@ -1602,7 +1595,7 @@ void KLContext::KLHelper::makeMuRow(const CoxNbr& y) {} -void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) +void KLContext::KLHelper::muCorrection(const CoxNbr &y, List &pol) /* This function subtracts the term P_{x,z}mu(z,ys) from the appropriate @@ -1611,25 +1604,25 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); - const ExtrRow& e = extrList(y); + const SchubertContext &p = schubert(); + const ExtrRow &e = extrList(y); Generator s = last(y); - CoxNbr ys = p.rshift(y,s); + CoxNbr ys = p.rshift(y, s); + + const MuRow &mu_row = muList(ys); - const MuRow& mu_row = muList(ys); - for (Ulong j = 0; j < mu_row.size(); ++j) { if (mu_row[j].mu == 0) continue; CoxNbr z = mu_row[j].x; Length h = mu_row[j].height; KLCoeff mu_value = mu_row[j].mu; - if (p.shift(z,s) > z) + if (p.shift(z, s) > z) continue; BitMap b(size()); - p.extractClosure(b,z); - maximize(p,b,p.descent(y)); + p.extractClosure(b, z); + maximize(p, b, p.descent(y)); Ulong i = 0; BitMap::Iterator b_end = b.end(); @@ -1637,12 +1630,12 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { CoxNbr x = *k; while (e[i] < x) - ++i; - safeSubtract(pol[i],klPol(x,z),mu_value,h+1); + ++i; + safeSubtract(pol[i], klPol(x, z), mu_value, h + 1); if (ERRNO) { - Error(ERRNO,this,x,y); - ERRNO = ERROR_WARNING; - return; + Error(ERRNO, this, x, y); + ERRNO = ERROR_WARNING; + return; } } } @@ -1650,12 +1643,12 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::muCorrection(const CoxNbr& d_x, const CoxNbr& y, - const Generator& d_s, List& pol, - const Ulong& a) +void KLContext::KLHelper::muCorrection(const CoxNbr &d_x, const CoxNbr &y, + const Generator &d_s, List &pol, + const Ulong &a) /* - This function subtracts from pol the correction terms + This function subtracts from pol the correction terms P_{x,z}.mu(z,ys)q^{(l(y)-l(z))/2} @@ -1671,11 +1664,11 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& d_x, const CoxNbr& y, */ { - const SchubertContext& p = schubert(); - + const SchubertContext &p = schubert(); + CoxNbr x = d_x; Generator s = d_s; - CoxNbr ys = p.shift(y,s); + CoxNbr ys = p.shift(y, s); if (!isMuAllocated(ys)) { /* allocate row */ allocMuRow(ys); @@ -1684,54 +1677,54 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& d_x, const CoxNbr& y, } { - MuRow& m = muList(ys); + MuRow &m = muList(ys); { Length ly = p.length(y); for (Ulong j = 0; j < m.size(); ++j) { - - CoxNbr z = m[j].x; - - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; - - /* compute the mu-coefficient if it was not already computed */ - - if (m[j].mu == undef_klcoeff) { - m[j].mu = computeMu(z,ys); - if (ERRNO) - goto abort; - } - - /* subtract the correction if mu(z,ys) != 0 */ - - if (m[j].mu) { - Length h = (ly - p.length(m[j].x))/2; - - const KLPol& p_xz = klPol(x,z); - if (ERRNO) - goto abort; - - safeSubtract(pol[a],p_xz,m[j].mu,h); - if (ERRNO) - goto abort; - } + + CoxNbr z = m[j].x; + + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; + + /* compute the mu-coefficient if it was not already computed */ + + if (m[j].mu == undef_klcoeff) { + m[j].mu = computeMu(z, ys); + if (ERRNO) + goto abort; + } + + /* subtract the correction if mu(z,ys) != 0 */ + + if (m[j].mu) { + Length h = (ly - p.length(m[j].x)) / 2; + + const KLPol &p_xz = klPol(x, z); + if (ERRNO) + goto abort; + + safeSubtract(pol[a], p_xz, m[j].mu, h); + if (ERRNO) + goto abort; + } } } } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::prepareRow(const CoxNbr& y, const Generator& d_s) +void KLContext::KLHelper::prepareRow(const CoxNbr &y, const Generator &d_s) /* This function prepares for the filling of row y in klList and @@ -1741,66 +1734,65 @@ void KLContext::KLHelper::prepareRow(const CoxNbr& y, const Generator& d_s) Deals with the error if it occurs, and sets the error ERROR_WARNING; */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); Generator s = d_s; - CoxNbr ys = p.shift(y,s); + CoxNbr ys = p.shift(y, s); if (!checkMuRow(ys)) { if (inverse(ys) < ys) { readMuRow(inverse(ys)); inverseMuRow(inverse(ys)); - } - else + } else readMuRow(ys); } - const MuRow& mu_row = muList(ys); - + const MuRow &mu_row = muList(ys); + for (Ulong j = 0; j < mu_row.size(); ++j) { if (mu_row[j].mu == 0) continue; CoxNbr z = mu_row[j].x; - if (p.shift(z,s) > z) + if (p.shift(z, s) > z) continue; if (!checkKLRow(z)) { allocRowComputation(z); if (ERRNO) - goto abort; + goto abort; fillKLRow(z); if (ERRNO) - goto abort; + goto abort; } } - + { - const CoatomList& c = p.hasse(ys); - + const CoatomList &c = p.hasse(ys); + for (Ulong j = 0; j < c.size(); ++j) { CoxNbr z = c[j]; - if (p.shift(z,s) > z) - continue; + if (p.shift(z, s) > z) + continue; if (!checkKLRow(z)) { - allocRowComputation(z); - if (ERRNO) - goto abort; - fillKLRow(z); - if (ERRNO) - goto abort; + allocRowComputation(z); + if (ERRNO) + goto abort; + fillKLRow(z); + if (ERRNO) + goto abort; } } } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::readMuRow(const CoxNbr& y) +void KLContext::KLHelper::readMuRow(const CoxNbr &y) /* This function fills the mu-row from the corresponding kl-row. If the @@ -1808,64 +1800,63 @@ void KLContext::KLHelper::readMuRow(const CoxNbr& y) allocations are made. */ -{ - const SchubertContext& p = schubert(); - const KLRow& kl_row = klList(y); - const ExtrRow& e_row = extrList(y); +{ + const SchubertContext &p = schubert(); + const KLRow &kl_row = klList(y); + const ExtrRow &e_row = extrList(y); if (!isMuAllocated(y)) { /* make row from scratch */ MuRow mu_buf(0); mu_buf.setSizeValue(0); Length ly = p.length(y); - + for (Ulong j = 0; j < kl_row.size(); ++j) { - + CoxNbr x = e_row[j]; Length lx = p.length(x); - - if ((ly-lx)%2 == 0) - continue; - - if ((ly-lx) == 1) - continue; - - const KLPol& pol = *kl_row[j]; - - Degree d = (ly-lx-1)/2; + + if ((ly - lx) % 2 == 0) + continue; + + if ((ly - lx) == 1) + continue; + + const KLPol &pol = *kl_row[j]; + + Degree d = (ly - lx - 1) / 2; if (pol.deg() < d) - continue; - - MuData m(x,pol[d],d); + continue; + + MuData m(x, pol[d], d); mu_buf.append(m); if (ERRNO) - goto abort; + goto abort; } - + d_kl->d_muList[y] = new MuRow(mu_buf); if (ERRNO) goto abort; - + status().munodes += mu_buf.size(); status().mucomputed += mu_buf.size(); status().murows++; - } - else { + } else { Ulong i = 0; - MuRow& mu_row = muList(y); + MuRow &mu_row = muList(y); for (Ulong j = 0; j < muList(y).size(); ++j) { - MuData& mu = mu_row[j]; + MuData &mu = mu_row[j]; CoxNbr x = mu.x; - while(e_row[i] < x) - ++i; - const KLPol& pol = *kl_row[i]; + while (e_row[i] < x) + ++i; + const KLPol &pol = *kl_row[i]; Length d = mu.height; if (pol.deg() == d) - mu.mu = pol[d]; + mu.mu = pol[d]; else { - mu.mu = 0; - status().muzero++; + mu.mu = 0; + status().muzero++; } status().mucomputed++; } @@ -1873,14 +1864,14 @@ void KLContext::KLHelper::readMuRow(const CoxNbr& y) return; - abort: +abort: Error(ERRNO); ERRNO = MEMORY_WARNING; return; } -KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& d_x, const CoxNbr& y, - const Generator& d_s) +KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr &d_x, const CoxNbr &y, + const Generator &d_s) /* This function computes mu(x,y) using the general recursive formula for @@ -1888,39 +1879,39 @@ KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& d_x, const CoxNbr& y, of x contains the _second_ descent set of y. It is assumed that x < y x extremal w.r.t. y, and l(y)-l(x) odd > 1. - Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of + Sets the error MU_FAIL, and returns the value undef_klcoeff, in case of failure (this can be due to memory overflow, or to coefficient over- or underflow.) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); CoxNbr x = d_x; Generator s = d_s; Length l = p.length(y) - p.length(x); /* l is odd > 1 */ - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); - KLCoeff r = mu(xs,ys); + KLCoeff r = mu(xs, ys); if (ERRNO) goto abort; - if (!p.inOrder(x,ys)) { /* value is found */ + if (!p.inOrder(x, ys)) { /* value is found */ status().mucomputed++; if (r == 0) status().muzero++; return r; } - + /* special case when the length difference is three */ if (l == 3) { /* P_{x,ys} = 1 */ - safeAdd(r,1); + safeAdd(r, 1); if (ERRNO) { /* overflow; highly unlikely! */ - Error(MU_OVERFLOW,this,x,y); + Error(MU_OVERFLOW, this, x, y); goto abort; } goto coatom_correction; @@ -1929,24 +1920,23 @@ KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& d_x, const CoxNbr& y, /* get the term from q.P_{x,ys} */ { - CoxNbr x1 = p.maximize(x,p.descent(ys)); + CoxNbr x1 = p.maximize(x, p.descent(ys)); if (x != x1) { // no polynomial is needed; does not happen in double // extremal case if (p.length(x1) == p.length(x) + 1) // no correction otherwise - r += mu(x1,ys); - } - else { /* we need a polynomial */ - const KLPol& pol = klPol(x,ys); + r += mu(x1, ys); + } else { /* we need a polynomial */ + const KLPol &pol = klPol(x, ys); if (ERRNO) - goto abort; - Degree d = (l-1)/2 - 1; + goto abort; + Degree d = (l - 1) / 2 - 1; if (pol.deg() == d) { - safeAdd(r,pol[d]); - if (ERRNO) { /* overflow; highly unlikely! */ - Error(MU_OVERFLOW,this,x,y); - goto abort; - } + safeAdd(r, pol[d]); + if (ERRNO) { /* overflow; highly unlikely! */ + Error(MU_OVERFLOW, this, x, y); + goto abort; + } } } } @@ -1957,71 +1947,71 @@ KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& d_x, const CoxNbr& y, if (!isMuAllocated(ys)) { /* allocate row */ allocMuRow(ys); if (ERRNO) - goto abort; + goto abort; } - MuRow& m = muList(ys); + MuRow &m = muList(ys); for (Ulong j = 0; j < m.size(); ++j) { CoxNbr z = m[j].x; if (z == x) - continue; - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; + continue; + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; /* fill in the mu-coefficient if it was not already computed */ if (m[j].mu == undef_klcoeff) { - m[j].mu = computeMu(z,ys); - if (ERRNO) - goto abort; + m[j].mu = computeMu(z, ys); + if (ERRNO) + goto abort; } - + /* subtract the correction if mu(z,ys) != 0 */ if (m[j].mu) { - KLCoeff r1 = mu(x,z); - if (ERRNO) - goto abort; - safeMultiply(r1,m[j].mu); - if (ERRNO) { /* overflow; highly unlikely! */ - Error(MU_OVERFLOW,this,x,y); - goto abort; - } - klsupport::safeSubtract(r,r1); - if (ERRNO) { /* negative coefficient */ - Error(MU_NEGATIVE,this,x,y); - goto abort; - } + KLCoeff r1 = mu(x, z); + if (ERRNO) + goto abort; + safeMultiply(r1, m[j].mu); + if (ERRNO) { /* overflow; highly unlikely! */ + Error(MU_OVERFLOW, this, x, y); + goto abort; + } + klsupport::safeSubtract(r, r1); + if (ERRNO) { /* negative coefficient */ + Error(MU_NEGATIVE, this, x, y); + goto abort; + } } } } - coatom_correction: +coatom_correction: /* subtract the coatom correction */ { - const CoatomList& c = p.hasse(ys); + const CoatomList &c = p.hasse(ys); for (Ulong j = 0; j < c.size(); ++j) { CoxNbr z = c[j]; - CoxNbr zs = p.shift(z,s); + CoxNbr zs = p.shift(z, s); if (zs > z) - continue; - if (!p.inOrder(x,z)) - continue; - KLCoeff r1 = mu(x,z); + continue; + if (!p.inOrder(x, z)) + continue; + KLCoeff r1 = mu(x, z); if (ERRNO) - goto abort; - klsupport::safeSubtract(r,r1); + goto abort; + klsupport::safeSubtract(r, r1); if (ERRNO) { /* negative coefficient */ - Error(MU_NEGATIVE,this,x,y); - goto abort; + Error(MU_NEGATIVE, this, x, y); + goto abort; } } } @@ -2032,13 +2022,13 @@ KLCoeff KLContext::KLHelper::recursiveMu(const CoxNbr& d_x, const CoxNbr& y, return r; - abort: +abort: if (ERRNO != MEMORY_WARNING) ERRNO = MU_FAIL; return undef_klcoeff; } -void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol) +void KLContext::KLHelper::secondTerm(const CoxNbr &y, List &pol) /* This function takes care of the "second term" q.P_{x,ys} in the @@ -2055,32 +2045,32 @@ void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); BitMap b(0); Generator s = last(y); - CoxNbr ys = p.rshift(y,s); + CoxNbr ys = p.rshift(y, s); /* extract [e,ys] */ - p.extractClosure(b,ys); + p.extractClosure(b, ys); /* extremalize w.r.t. y */ - maximize(p,b,p.descent(y)); + maximize(p, b, p.descent(y)); /* add to appropriate terms */ Ulong i = 0; BitMap::Iterator b_end = b.end(); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); for (BitMap::Iterator j = b.begin(); j != b_end; ++j) { CoxNbr x = *j; - while(e[i] < x) + while (e[i] < x) ++i; - safeAdd(pol[i],klPol(x,ys),1); + safeAdd(pol[i], klPol(x, ys), 1); if (ERRNO) { - Error(ERRNO,this,x,y); + Error(ERRNO, this, x, y); ERRNO = ERROR_WARNING; return; } @@ -2089,7 +2079,7 @@ void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) +void KLContext::KLHelper::writeKLRow(const CoxNbr &y, List &pol) /* This function writes the polynomials from the list pol to klList(y); @@ -2104,7 +2094,7 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) */ { - KLRow& kl_row = klList(y); + KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j]) @@ -2113,10 +2103,10 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) Degree d = pol[j].deg(); for (; d; --d) { if (pol[j][d]) - break; + break; } pol[j].setDeg(d); - const KLPol* q = klTree().find(pol[j]); + const KLPol *q = klTree().find(pol[j]); if (q == 0) { /* an error occurred */ Error(ERRNO); ERRNO = ERROR_WARNING; @@ -2129,7 +2119,7 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::writeMuRow(const MuRow& row, const CoxNbr& y) +void KLContext::KLHelper::writeMuRow(const MuRow &row, const CoxNbr &y) /* This function copies row to the corresponding row in the mu-list. The idea @@ -2146,7 +2136,7 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const CoxNbr& y) count++; } - MuRow& y_row = muList(y); + MuRow &y_row = muList(y); y_row.setSize(count); if (ERRNO) { Error(ERRNO); @@ -2158,7 +2148,7 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const CoxNbr& y) for (Ulong j = 0; j < row.size(); ++j) { if (row[j].mu != 0) { - new(y_row.ptr()+count) MuData(row[j].x,row[j].mu,row[j].height); + new (y_row.ptr() + count) MuData(row[j].x, row[j].mu, row[j].height); count++; } } @@ -2169,7 +2159,7 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const CoxNbr& y) return; } -}; +}; // namespace kl /**************************************************************************** @@ -2184,13 +2174,13 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const CoxNbr& y) namespace kl { -MuFilter::MuFilter(const SchubertContext& p, const Length& l) - :d_p(p), d_l(l) +MuFilter::MuFilter(const SchubertContext &p, const Length &l) + : d_p(p), d_l(l) {} -MuFilter::MuFilter(const SchubertContext& p, const CoxNbr& y) - :d_p(p) +MuFilter::MuFilter(const SchubertContext &p, const CoxNbr &y) + : d_p(p) { d_l = d_p.length(y); @@ -2200,7 +2190,7 @@ MuFilter::~MuFilter() {} -}; +}; // namespace kl /**************************************************************************** @@ -2216,8 +2206,8 @@ MuFilter::~MuFilter() namespace kl { KLStatus::KLStatus() - :klrows(0), klnodes(0), klcomputed(0), murows(0), munodes(0), mucomputed(0), - muzero(0) + : klrows(0), klnodes(0), klcomputed(0), murows(0), munodes(0), + mucomputed(0), muzero(0) {} @@ -2225,7 +2215,7 @@ KLStatus::~KLStatus() {} -}; +}; // namespace kl /**************************************************************************** @@ -2244,7 +2234,7 @@ KLStatus::~KLStatus() namespace kl { -void print(FILE* file, const Homology& h) +void print(FILE *file, const Homology &h) /* Prints the homology vector as a single long line. @@ -2252,16 +2242,16 @@ void print(FILE* file, const Homology& h) { if (h.size()) /* print first term */ - fprintf(file," h[0] = %lu",h[0]); + fprintf(file, " h[0] = %lu", h[0]); for (Ulong j = 1; j < h.size(); ++j) { - fprintf(file," h[%lu] = %lu",j,h[j]); + fprintf(file, " h[%lu] = %lu", j, h[j]); } return; } -void printMuTable(FILE* file, const KLContext& kl, const Interface& I) +void printMuTable(FILE *file, const KLContext &kl, const Interface &I) /* This function prints ou the contents of the mu-table. It prints only the @@ -2270,35 +2260,35 @@ void printMuTable(FILE* file, const KLContext& kl, const Interface& I) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); for (CoxNbr y = 0; y < p.size(); ++y) { - kl.print(file,y,I); - fprintf(file," : "); - const MuRow& row = kl.muList(y); + kl.print(file, y, I); + fprintf(file, " : "); + const MuRow &row = kl.muList(y); Ulong count = 0; for (Ulong j = 0; j < row.size(); ++j) { - const MuData& mu = row[j]; + const MuData &mu = row[j]; if (mu.mu == 0) - continue; + continue; if (count) - fprintf(file,","); + fprintf(file, ","); count++; - fprintf(file,"{"); - fprintf(file,"x = "); - kl.print(file,mu.x,I); - fprintf(file,", mu = %lu, height = %lu",static_cast(mu.mu), - static_cast(mu.height)); - fprintf(file,"}"); + fprintf(file, "{"); + fprintf(file, "x = "); + kl.print(file, mu.x, I); + fprintf(file, ", mu = %lu, height = %lu", static_cast(mu.mu), + static_cast(mu.height)); + fprintf(file, "}"); } - fprintf(file,"\n"); + fprintf(file, "\n"); } return; } -void showKLPol(FILE* file, KLContext& kl, const CoxNbr& d_x, const CoxNbr& d_y, - const Interface& I, const Generator& d_s) +void showKLPol(FILE *file, KLContext &kl, const CoxNbr &d_x, const CoxNbr &d_y, + const Interface &I, const Generator &d_s) /* This function prints out the various terms appearing in the computation @@ -2312,15 +2302,15 @@ void showKLPol(FILE* file, KLContext& kl, const CoxNbr& d_x, const CoxNbr& d_y, { static String buf(0); - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); CoxNbr x = d_x; CoxNbr y = d_y; Generator s = d_s; - const KLPol& pol = kl.klPol(x,y,s); + const KLPol &pol = kl.klPol(x, y, s); if (ERRNO) { - Error (ERRNO); + Error(ERRNO); return; } @@ -2328,96 +2318,94 @@ void showKLPol(FILE* file, KLContext& kl, const CoxNbr& d_x, const CoxNbr& d_y, reset(buf); - append(buf,"x = "); - p.append(buf,x,I); - append(buf,"; y = "); - p.append(buf,y,I); - append(buf," L:"); - append(buf,p.ldescent(y),I); - append(buf," R:"); - append(buf,p.rdescent(y),I); - foldLine(file,buf,ls,0,"yL"); - fprintf(file,"\n\n"); + append(buf, "x = "); + p.append(buf, x, I); + append(buf, "; y = "); + p.append(buf, y, I); + append(buf, " L:"); + append(buf, p.ldescent(y), I); + append(buf, " R:"); + append(buf, p.rdescent(y), I); + foldLine(file, buf, ls, 0, "yL"); + fprintf(file, "\n\n"); if (kl.inverse(y) < y) { // go over to inverses x = kl.inverse(x); y = kl.inverse(y); - fprintf(file,"inverse(y) < y\n"); - fprintf(file,"new x : "); - p.print(file,x,I); - fprintf(file,"\nnew y : "); - p.print(file,y,I); - fprintf(file,"\n\n"); + fprintf(file, "inverse(y) < y\n"); + fprintf(file, "new x : "); + p.print(file, x, I); + fprintf(file, "\nnew y : "); + p.print(file, y, I); + fprintf(file, "\n\n"); } LFlags f = p.descent(y); - x = p.maximize(x,f); + x = p.maximize(x, f); if (x > d_x) { - fprintf(file,"x is not extremal w.r.t. y\nnew x: "); - p.print(file,x,I); - fprintf(file,"\n\n"); + fprintf(file, "x is not extremal w.r.t. y\nnew x: "); + p.print(file, x, I); + fprintf(file, "\n\n"); } Length d = p.length(y) - p.length(x); if (d < 3) { /* trivial case */ - fprintf(file,"l(y)-l(x) < 3\n\n"); + fprintf(file, "l(y)-l(x) < 3\n\n"); goto end; } { if (s == undef_generator) s = kl.last(y); - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); - - if (!p.inOrder(x,ys)) { /* easy case */ - if (s < kl.rank()) { /* action is on the right */ - fprintf(file,"x not comparable to ys for s = %d\n",s+1); - reset(buf); - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf,"; ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"y"); - fprintf(file,"\n\n"); - goto end; - } - else { /* action is on the left */ - fprintf(file,"x not comparable to sy for s = %d\n",s+1-kl.rank()); - reset(buf); - append(buf,"sx = "); - p.append(buf,xs,I); - append(buf,"; sy = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"s"); - fprintf(file,"\n\n"); - goto end; + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); + + if (!p.inOrder(x, ys)) { /* easy case */ + if (s < kl.rank()) { /* action is on the right */ + fprintf(file, "x not comparable to ys for s = %d\n", s + 1); + reset(buf); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, "; ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "y"); + fprintf(file, "\n\n"); + goto end; + } else { /* action is on the left */ + fprintf(file, "x not comparable to sy for s = %d\n", s + 1 - kl.rank()); + reset(buf); + append(buf, "sx = "); + p.append(buf, xs, I); + append(buf, "; sy = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "s"); + fprintf(file, "\n\n"); + goto end; } } - /* apply recursion formula */ + /* apply recursion formula */ if (s < kl.rank()) { - fprintf(file,"applying recursion formula with s = %d on the right\n\n", - s+1); + fprintf(file, "applying recursion formula with s = %d on the right\n\n", + s + 1); reset(buf); - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf,"; ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"y"); - fprintf(file,"\n\n"); - } - else { - fprintf(file,"applying recursion formula with s = %d on the left\n\n", - s+1-kl.rank()); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, "; ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "y"); + fprintf(file, "\n\n"); + } else { + fprintf(file, "applying recursion formula with s = %d on the left\n\n", + s + 1 - kl.rank()); reset(buf); - append(buf,"sx = "); - p.append(buf,xs,I); - append(buf,"; sy = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"s"); - fprintf(file,"\n\n"); + append(buf, "sx = "); + p.append(buf, xs, I); + append(buf, "; sy = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "s"); + fprintf(file, "\n\n"); } /* first term */ @@ -2425,186 +2413,182 @@ void showKLPol(FILE* file, KLContext& kl, const CoxNbr& d_x, const CoxNbr& d_y, reset(buf); if (s < kl.rank()) { - append(buf,"P_{xs,ys} = "); - append(buf,kl.klPol(xs,ys),"q"); - } - else { - append(buf,"P_{sx,sy} = "); - append(buf,kl.klPol(xs,ys),"q"); + append(buf, "P_{xs,ys} = "); + append(buf, kl.klPol(xs, ys), "q"); + } else { + append(buf, "P_{sx,sy} = "); + append(buf, kl.klPol(xs, ys), "q"); } - foldLine(file,buf,ls,4,"+"); - fprintf(file,"\n"); + foldLine(file, buf, ls, 4, "+"); + fprintf(file, "\n"); /* second term */ reset(buf); if (s < kl.rank()) { - append(buf,"P_{x,ys} = "); - append(buf,kl.klPol(x,ys),"q"); - } - else { - append(buf,"P_{x,sy} = "); - append(buf,kl.klPol(x,ys),"q"); + append(buf, "P_{x,ys} = "); + append(buf, kl.klPol(x, ys), "q"); + } else { + append(buf, "P_{x,sy} = "); + append(buf, kl.klPol(x, ys), "q"); } - foldLine(file,buf,ls,4,"+"); - fprintf(file,"\n\n"); + foldLine(file, buf, ls, 4, "+"); + fprintf(file, "\n\n"); /* coatom correction */ - const CoatomList& c = p.hasse(ys); + const CoatomList &c = p.hasse(ys); bool coatomcorrection = false; for (Ulong j = 0; j < c.size(); ++j) { CoxNbr z = c[j]; - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; coatomcorrection = true; reset(buf); - io::append(buf,"z = "); - p.append(buf,z,I); - io::append(buf," P_{x,z} = "); - polynomials::append(buf,kl.klPol(x,z),"q"); - foldLine(file,buf,ls,4,"P+"); - fprintf(file,"\n"); + io::append(buf, "z = "); + p.append(buf, z, I); + io::append(buf, " P_{x,z} = "); + polynomials::append(buf, kl.klPol(x, z), "q"); + foldLine(file, buf, ls, 4, "P+"); + fprintf(file, "\n"); } if (coatomcorrection) - fprintf(file,"\n"); + fprintf(file, "\n"); /* mu correction */ - const MuRow& m = kl.muList(ys); + const MuRow &m = kl.muList(ys); Length l_ys = p.length(ys); bool mucorrection = false; for (Ulong j = 0; j < m.size(); ++j) { CoxNbr z = m[j].x; - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; if (m[j].mu) { - mucorrection = true; - reset(buf); - io::append(buf,"z = "); - p.append(buf,z,I); - pad(buf,l_ys+1); /* remember the four characters "z = " */ - io::append(buf," mu = "); - append(buf,m[j].mu); - io::append(buf," height = "); - append(buf,m[j].height); - io::append(buf," P_{x,z} = "); - append(buf,kl.klPol(x,z),"q"); - foldLine(file,buf,ls,4,"Pmh+"); - fprintf(file,"\n"); + mucorrection = true; + reset(buf); + io::append(buf, "z = "); + p.append(buf, z, I); + pad(buf, l_ys + 1); /* remember the four characters "z = " */ + io::append(buf, " mu = "); + append(buf, m[j].mu); + io::append(buf, " height = "); + append(buf, m[j].height); + io::append(buf, " P_{x,z} = "); + append(buf, kl.klPol(x, z), "q"); + foldLine(file, buf, ls, 4, "Pmh+"); + fprintf(file, "\n"); } } if (mucorrection) - fprintf(file,"\n"); + fprintf(file, "\n"); } - end: +end: reset(buf); - io::append(buf,"result : "); - append(buf,pol,"q"); - if (2*pol.deg()+1 == d) - io::append(buf," *"); - foldLine(file,buf,ls,4,"+"); - fprintf(file,"\n\n"); + io::append(buf, "result : "); + append(buf, pol, "q"); + if (2 * pol.deg() + 1 == d) + io::append(buf, " *"); + foldLine(file, buf, ls, 4, "+"); + fprintf(file, "\n\n"); return; } -void showMu(FILE* file, KLContext& kl, const CoxNbr& d_x, const CoxNbr& y, - const Interface& I) +void showMu(FILE *file, KLContext &kl, const CoxNbr &d_x, const CoxNbr &y, + const Interface &I) /* - Maps out the computation of a mu-coefficient. See + Maps out the computation of a mu-coefficient. See KLContext::KLHelper::computeMu for the algorithm. */ { static String buf(0); - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); CoxNbr x = d_x; - - KLCoeff r = kl.mu(x,y); + + KLCoeff r = kl.mu(x, y); if (ERRNO) goto abort; { unsigned long ls = LINESIZE; - + reset(buf); - - append(buf,"x = "); - p.append(buf,x,I); - append(buf," y = "); - p.append(buf,y,I); - append(buf," L:"); - append(buf,p.ldescent(y),I); - append(buf," R:"); - append(buf,p.rdescent(y),I); - foldLine(file,buf,ls,0,"yL"); - fprintf(file,"\n\n"); + + append(buf, "x = "); + p.append(buf, x, I); + append(buf, " y = "); + p.append(buf, y, I); + append(buf, " L:"); + append(buf, p.ldescent(y), I); + append(buf, " R:"); + append(buf, p.rdescent(y), I); + foldLine(file, buf, ls, 0, "yL"); + fprintf(file, "\n\n"); LFlags fy = p.descent(y); - x = p.maximize(x,fy); + x = p.maximize(x, fy); if (x > d_x) { - fprintf(file,"x is not extremal w.r.t. y\n\nresult: 0\n\n"); + fprintf(file, "x is not extremal w.r.t. y\n\nresult: 0\n\n"); return; } Length d = p.length(y) - p.length(x); - if ((d%2) == 0) { - fprintf(file,"even length difference\n\nresult: 0\n\n"); + if ((d % 2) == 0) { + fprintf(file, "even length difference\n\nresult: 0\n\n"); return; } if (d == 1) { /* trivial case */ - fprintf(file,"x is coatom of y\n\nresult: 1\n\n"); + fprintf(file, "x is coatom of y\n\nresult: 1\n\n"); return; } - + LFlags f2 = p.twoDescent(y); LFlags fx = p.descent(x); - - if ((fx&f2) != f2) { /* recursion case */ - - fprintf(file,"x is not doubly extremal w.r.t. y\n\n"); - showSimpleMu(file,kl,x,y,r,I); - + + if ((fx & f2) != f2) { /* recursion case */ + + fprintf(file, "x is not doubly extremal w.r.t. y\n\n"); + showSimpleMu(file, kl, x, y, r, I); + return; } - - fprintf(file,"x is doubly extremal w.r.t. y\n\n"); - showRecursiveMu(file,kl,x,y,r,I); - return; + fprintf(file, "x is doubly extremal w.r.t. y\n\n"); + showRecursiveMu(file, kl, x, y, r, I); + return; } - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; - } -}; +}; // namespace kl namespace { -void showRecursiveMu(FILE* file, KLContext& kl, const CoxNbr& d_x, - const CoxNbr& y, const KLCoeff& r, const Interface& I) +void showRecursiveMu(FILE *file, KLContext &kl, const CoxNbr &d_x, + const CoxNbr &y, const KLCoeff &r, const Interface &I) /* Maps out the computation in the case where the recursion formula has to @@ -2614,291 +2598,278 @@ void showRecursiveMu(FILE* file, KLContext& kl, const CoxNbr& d_x, { static String buf(0); - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); unsigned long ls = LINESIZE; CoxNbr x = d_x; Generator s = kl.last(y); Length l = p.length(y) - p.length(x); /* l is odd > 1 */ - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); - if (!p.inOrder(x,ys)) { // mu(x,y) = mu(xs,ys) - if (s < kl.rank()) { // action is on the right - fprintf(file,"x not comparable to ys for s = %d\n",s+1); + if (!p.inOrder(x, ys)) { // mu(x,y) = mu(xs,ys) + if (s < kl.rank()) { // action is on the right + fprintf(file, "x not comparable to ys for s = %d\n", s + 1); reset(buf); - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf,"; ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"y"); - fprintf(file,"\n\nresult : %lu\n\n",static_cast(r)); - } - else { // action is on the left - fprintf(file,"x not comparable to sy for s = %d\n",s-kl.rank()+1); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, "; ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "y"); + fprintf(file, "\n\nresult : %lu\n\n", static_cast(r)); + } else { // action is on the left + fprintf(file, "x not comparable to sy for s = %d\n", s - kl.rank() + 1); reset(buf); - append(buf,"sx = "); - p.append(buf,xs,I); - append(buf,"; sy = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"s"); - fprintf(file,"\n\n"); - fprintf(file,"\n\nresult : %lu\n\n",static_cast(r)); + append(buf, "sx = "); + p.append(buf, xs, I); + append(buf, "; sy = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "s"); + fprintf(file, "\n\n"); + fprintf(file, "\n\nresult : %lu\n\n", static_cast(r)); } return; } - + // if we get to this point, w need to apply the full recursion formula - if (s < kl.rank()) { - fprintf(file,"applying recursion formula with s = %d on the right\n\n", - s+1); - reset(buf); - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf,"; ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"y"); - fprintf(file,"\n\n"); - } - else { - fprintf(file,"applying recursion formula with s = %d on the left\n\n", - s+1-kl.rank()); - reset(buf); - append(buf,"sx = "); - p.append(buf,xs,I); - append(buf,"; sy = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"s"); - fprintf(file,"\n\n"); - } + if (s < kl.rank()) { + fprintf(file, "applying recursion formula with s = %d on the right\n\n", + s + 1); + reset(buf); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, "; ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "y"); + fprintf(file, "\n\n"); + } else { + fprintf(file, "applying recursion formula with s = %d on the left\n\n", + s + 1 - kl.rank()); + reset(buf); + append(buf, "sx = "); + p.append(buf, xs, I); + append(buf, "; sy = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "s"); + fprintf(file, "\n\n"); + } // first term - reset(buf); + reset(buf); - if (s < kl.rank()) { - fprintf(file,"mu(xs,ys) = %lu\n",static_cast(kl.mu(xs,ys))); - } - else { - fprintf(file,"mu(sx,sy) = %lu\n",static_cast(kl.mu(xs,ys))); - } + if (s < kl.rank()) { + fprintf(file, "mu(xs,ys) = %lu\n", static_cast(kl.mu(xs, ys))); + } else { + fprintf(file, "mu(sx,sy) = %lu\n", static_cast(kl.mu(xs, ys))); + } // second term - reset(buf); + reset(buf); - const KLPol& pol = kl.klPol(x,ys); - KLCoeff r1 = 0; - Degree d = (l-1)/2 - 1; - if (pol.deg() == d) { - r1 = pol[d]; - } + const KLPol &pol = kl.klPol(x, ys); + KLCoeff r1 = 0; + Degree d = (l - 1) / 2 - 1; + if (pol.deg() == d) { + r1 = pol[d]; + } - if (s < kl.rank()) { - fprintf(file,"second term is %lu\n",static_cast(r1)); - } - else { - fprintf(file,"second term is %lu\n",static_cast(r1)); - } + if (s < kl.rank()) { + fprintf(file, "second term is %lu\n", static_cast(r1)); + } else { + fprintf(file, "second term is %lu\n", static_cast(r1)); + } - fprintf(file,"\n"); + fprintf(file, "\n"); // coatom correction - const CoatomList& c = p.hasse(ys); - bool coatomcorrection = false; + const CoatomList &c = p.hasse(ys); + bool coatomcorrection = false; - for (Ulong j = 0; j < c.size(); ++j) { - CoxNbr z = c[j]; - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; - coatomcorrection = true; + for (Ulong j = 0; j < c.size(); ++j) { + CoxNbr z = c[j]; + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; + coatomcorrection = true; + reset(buf); + io::append(buf, "z = "); + p.append(buf, z, I); + io::append(buf, " mu(x,z) = "); + io::append(buf, kl.mu(x, z)); + foldLine(file, buf, ls, 4, " "); + fprintf(file, "\n"); + } + + if (coatomcorrection) + fprintf(file, "\n"); + + // mu-correction + + const MuRow &m = kl.muList(ys); + Length l_ys = p.length(ys); + bool mucorrection = false; + + for (Ulong j = 0; j < m.size(); ++j) { + + CoxNbr z = m[j].x; + if (p.shift(z, s) > z) + continue; + if (!p.inOrder(x, z)) + continue; + + // fill in the mu-coefficient if it was not already computed + + if (m[j].mu == undef_klcoeff) { + kl.mu(z, ys); // this will fill m[j].mu + if (ERRNO) { + Error(ERRNO); + return; + } + } + + if (m[j].mu) { + mucorrection = true; reset(buf); - io::append(buf,"z = "); - p.append(buf,z,I); - io::append(buf," mu(x,z) = "); - io::append(buf,kl.mu(x,z)); - foldLine(file,buf,ls,4," "); - fprintf(file,"\n"); + io::append(buf, "z = "); + p.append(buf, z, I); + pad(buf, l_ys + 1); // remember the four characters "z = " + io::append(buf, " mu = "); + append(buf, m[j].mu); + io::append(buf, " height = "); + append(buf, m[j].height); + io::append(buf, " mu(x,z) = "); + append(buf, kl.mu(x, z)); + foldLine(file, buf, ls, 4, " "); + fprintf(file, "\n"); } + } - if (coatomcorrection) - fprintf(file,"\n"); + if (mucorrection) + fprintf(file, "\n"); - // mu-correction + // print result : + + fprintf(file, "result : %lu\n\n", static_cast(r)); - const MuRow& m = kl.muList(ys); - Length l_ys = p.length(ys); - bool mucorrection = false; - - for (Ulong j = 0; j < m.size(); ++j) { - - CoxNbr z = m[j].x; - if (p.shift(z,s) > z) - continue; - if (!p.inOrder(x,z)) - continue; - - // fill in the mu-coefficient if it was not already computed - - if (m[j].mu == undef_klcoeff) { - kl.mu(z,ys); // this will fill m[j].mu - if (ERRNO) { - Error(ERRNO); - return; - } - } - - if (m[j].mu) { - mucorrection = true; - reset(buf); - io::append(buf,"z = "); - p.append(buf,z,I); - pad(buf,l_ys+1); // remember the four characters "z = " - io::append(buf," mu = "); - append(buf,m[j].mu); - io::append(buf," height = "); - append(buf,m[j].height); - io::append(buf," mu(x,z) = "); - append(buf,kl.mu(x,z)); - foldLine(file,buf,ls,4," "); - fprintf(file,"\n"); - } - - } - - if (mucorrection) - fprintf(file,"\n"); - - // print result : - - fprintf(file,"result : %lu\n\n",static_cast(r)); - - return; + return; } -void showSimpleMu(FILE* file, KLContext& kl, const CoxNbr& x, - const CoxNbr& y, const KLCoeff& r, const Interface& I) +void showSimpleMu(FILE *file, KLContext &kl, const CoxNbr &x, const CoxNbr &y, + const KLCoeff &r, const Interface &I) /* - Auxiliary to ShowMu. Maps out the computation of a mu-coefficient in the + Auxiliary to ShowMu. Maps out the computation of a mu-coefficient in the case where there is a direct recursion. It is assumed that the computation proper has already been tried with success. */ -{ +{ static String buf(0); - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); unsigned long ls = LINESIZE; - Generator s,t; - for (LFlags f1 = p.descent(y); f1; f1 &= f1-1) { + Generator s, t; + for (LFlags f1 = p.descent(y); f1; f1 &= f1 - 1) { Generator u = firstBit(f1); - CoxNbr yu = p.shift(y,u); + CoxNbr yu = p.shift(y, u); LFlags fu = p.descent(yu); - if ((p.descent(x)&fu) != fu) { + if ((p.descent(x) & fu) != fu) { s = u; t = firstBit(fu & ~p.descent(x)); break; } } - - fprintf(file,"using descent s = %lu and ascent t = %lu\n\n", - static_cast(s+1),static_cast(t+1)); - - CoxNbr xs = p.shift(x,s); - CoxNbr ys = p.shift(y,s); - CoxNbr xt = p.shift(x,t); - CoxNbr yst = p.shift(ys,t); - + + fprintf(file, "using descent s = %lu and ascent t = %lu\n\n", + static_cast(s + 1), static_cast(t + 1)); + + CoxNbr xs = p.shift(x, s); + CoxNbr ys = p.shift(y, s); + CoxNbr xt = p.shift(x, t); + CoxNbr yst = p.shift(ys, t); + /* consider four cases */ - + reset(buf); if (p.descent(xt) & lmask[s]) { /* xts < xt */ - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf," ys = "); - p.append(buf,ys,I); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, " ys = "); + p.append(buf, ys, I); if (p.descent(yst) & lmask[s]) { /* ysts < yst */ - append(buf," yst = "); - p.append(buf,yst,I); - foldLine(file,buf,ls,0,"xy"); - fprintf(file,"\n\n"); - fprintf(file, - "result is mu(xs,ys)-mu(x,yst) = %lu - %lu = %lu\n\n", - static_cast(kl.mu(xs,ys)), - static_cast(kl.mu(x,yst)), - static_cast(r)); + append(buf, " yst = "); + p.append(buf, yst, I); + foldLine(file, buf, ls, 0, "xy"); + fprintf(file, "\n\n"); + fprintf(file, "result is mu(xs,ys)-mu(x,yst) = %lu - %lu = %lu\n\n", + static_cast(kl.mu(xs, ys)), + static_cast(kl.mu(x, yst)), static_cast(r)); return; - } - else { /* ysts > yst */ - foldLine(file,buf,ls,0,"xy"); - fprintf(file,"\n\n"); - fprintf(file,"result is mu(xs,ys) = %lu\n\n",static_cast(r)); + } else { /* ysts > yst */ + foldLine(file, buf, ls, 0, "xy"); + fprintf(file, "\n\n"); + fprintf(file, "result is mu(xs,ys) = %lu\n\n", static_cast(r)); return; } - } - else { /* xts > xt */ + } else { /* xts > xt */ if (p.descent(yst) & lmask[s]) { /* ysts < yst */ - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf," xt = "); - p.append(buf,xt,I); - append(buf," ys = "); - p.append(buf,ys,I); - append(buf," yst = "); - p.append(buf,yst,I); - foldLine(file,buf,ls,0,"xy"); - fprintf(file,"\n\n"); - fprintf(file, - "result is mu(xs,ys)+mu(xt,ys)-mu(x,yst) = %lu + %lu - %lu = %lu\n\n", - static_cast(kl.mu(xs,ys)), - static_cast(kl.mu(xt,ys)), - static_cast(kl.mu(x,yst)), - static_cast(r)); + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, " xt = "); + p.append(buf, xt, I); + append(buf, " ys = "); + p.append(buf, ys, I); + append(buf, " yst = "); + p.append(buf, yst, I); + foldLine(file, buf, ls, 0, "xy"); + fprintf(file, "\n\n"); + fprintf( + file, + "result is mu(xs,ys)+mu(xt,ys)-mu(x,yst) = %lu + %lu - %lu = %lu\n\n", + static_cast(kl.mu(xs, ys)), static_cast(kl.mu(xt, ys)), + static_cast(kl.mu(x, yst)), static_cast(r)); return; - } - else { /* ysts > yst */ + } else { /* ysts > yst */ if (p.descent(xs) & lmask[t]) { - append(buf,"xs = "); - p.append(buf,xs,I); - append(buf," xt = "); - p.append(buf,xt,I); - append(buf," ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"xy"); - fprintf(file,"\n\n"); - fprintf(file,"result is mu(xs,ys)+mu(xt,ys) = %lu + %lu = %lu\n\n", - static_cast(kl.mu(xs,ys)), - static_cast(kl.mu(xt,ys)), - static_cast(r)); - return; - } - else { /* mu(xs,ys) = 0 */ - append(buf,"xt = "); - p.append(buf,xt,I); - append(buf," ys = "); - p.append(buf,ys,I); - foldLine(file,buf,ls,0,"xy"); - fprintf(file,"\n\n"); - fprintf(file,"result is mu(xt,ys) = %lu\n\n", static_cast(r)); - return; + append(buf, "xs = "); + p.append(buf, xs, I); + append(buf, " xt = "); + p.append(buf, xt, I); + append(buf, " ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "xy"); + fprintf(file, "\n\n"); + fprintf(file, "result is mu(xs,ys)+mu(xt,ys) = %lu + %lu = %lu\n\n", + static_cast(kl.mu(xs, ys)), + static_cast(kl.mu(xt, ys)), static_cast(r)); + return; + } else { /* mu(xs,ys) = 0 */ + append(buf, "xt = "); + p.append(buf, xt, I); + append(buf, " ys = "); + p.append(buf, ys, I); + foldLine(file, buf, ls, 0, "xy"); + fprintf(file, "\n\n"); + fprintf(file, "result is mu(xt,ys) = %lu\n\n", static_cast(r)); + return; } } } - + return; } -}; +}; // namespace /**************************************************************************** @@ -2921,32 +2892,32 @@ void showSimpleMu(FILE* file, KLContext& kl, const CoxNbr& x, namespace kl { -void genericSingularities(HeckeElt& h, const CoxNbr& y, KLContext& kl) +void genericSingularities(HeckeElt &h, const CoxNbr &y, KLContext &kl) /* - This function returns in h the singular locus of cl(X_y). The point is to + This function returns in h the singular locus of cl(X_y). The point is to do this while computing as few k-l polynomials as possible. */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); BitMap b(p.size()); BitMap bs(p.size()); - p.extractClosure(b,y); - maximize(p,b,p.descent(y)); + p.extractClosure(b, y); + maximize(p, b, p.descent(y)); h.setSize(0); for (BitMap::ReverseIterator x = b.rbegin(); x != b.rend(); ++x) { - const KLPol& pol = kl.klPol(*x,y); + const KLPol &pol = kl.klPol(*x, y); if (ERRNO) return; if (pol.deg() > 0) { /* remove [e,x[ */ - HeckeMonomial m(*x,&pol); + HeckeMonomial m(*x, &pol); h.append(m); - p.extractClosure(bs,*x); + p.extractClosure(bs, *x); CoxNbr x1 = *x; /* *x will not be correct anymore after modification */ b.andnot(bs); b.setBit(x1); /* needed to make the decrement correct */ @@ -2958,7 +2929,7 @@ void genericSingularities(HeckeElt& h, const CoxNbr& y, KLContext& kl) return; } -bool isSingular(const HeckeElt& h) +bool isSingular(const HeckeElt &h) /* This function answers yes if one of the polynomials in the row is distinct @@ -2966,21 +2937,21 @@ bool isSingular(const HeckeElt& h) Schubert variety, when such a geometric context is defined, and the row is the extremal row for an element y. - NOTE : conjecturally, annulation of the term corresponding to the + NOTE : conjecturally, annulation of the term corresponding to the extremalization of the origin ensures annulation of all the others. */ { for (Ulong j = 0; j < h.size(); ++j) { - const KLPol& pol = h[j].pol(); + const KLPol &pol = h[j].pol(); if (pol.deg() != 0) return true; } - + return false; } -bool isSingular(const KLRow& row) +bool isSingular(const KLRow &row) /* This function answers yes if one of the polynomials in the row is distinct @@ -2991,15 +2962,15 @@ bool isSingular(const KLRow& row) { for (Ulong j = 0; j < row.size(); ++j) { - const KLPol* pol = row[j]; + const KLPol *pol = row[j]; if (pol->deg() != 0) return true; } - + return false; } -}; +}; // namespace kl /**************************************************************************** @@ -3019,7 +2990,7 @@ bool isSingular(const KLRow& row) namespace kl { -void ihBetti(Homology& h, const CoxNbr& y, KLContext& kl) +void ihBetti(Homology &h, const CoxNbr &y, KLContext &kl) /* This function puts the IH betti numbers of the row in h, in a @@ -3030,30 +3001,30 @@ void ihBetti(Homology& h, const CoxNbr& y, KLContext& kl) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); - h.setSize(p.length(y)+1); + h.setSize(p.length(y) + 1); h.setZero(); BitMap::Iterator b_end = b.end(); for (BitMap::Iterator x = b.begin(); x != b_end; ++x) { - const KLPol& pol = kl.klPol(*x,y); + const KLPol &pol = kl.klPol(*x, y); Length d = p.length(*x); for (Ulong i = 0; i <= pol.deg(); ++i) { - if (h[d+i] > COXSIZE_MAX - pol[i]) - h[d+i] = undef_coxnbr; + if (h[d + i] > COXSIZE_MAX - pol[i]) + h[d + i] = undef_coxnbr; else - h[d+i] += pol[i]; + h[d + i] += pol[i]; } } return; } -}; +}; // namespace kl /**************************************************************************** @@ -3074,7 +3045,7 @@ void ihBetti(Homology& h, const CoxNbr& y, KLContext& kl) namespace kl { -void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) +void cBasis(HeckeElt &h, const CoxNbr &y, KLContext &kl) /* This is what in the original Kazhdan-Lusztig paper is called the C'-basis, @@ -3083,24 +3054,24 @@ void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); BitMap::Iterator b_end = b.end(); h.setSize(0); for (BitMap::Iterator x = b.begin(); x != b_end; ++x) { - const KLPol& pol = kl.klPol(*x,y); - HeckeMonomial m(*x,&pol); + const KLPol &pol = kl.klPol(*x, y); + HeckeMonomial m(*x, &pol); h.append(m); } return; } -}; +}; // namespace kl /**************************************************************************** @@ -3114,7 +3085,7 @@ void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) - permuteValues(kl,q) : permutes the values of tables in kl; - permuteRanges(kl,q) : permutes the ranges of tables in kl; - safeAdd(p,q,n) : adds x^n.q to p, checking for overflow; - - safeSubtract(p,q,mu,h) : subtracts x^h.mu.q from p, checking for + - safeSubtract(p,q,mu,h) : subtracts x^h.mu.q from p, checking for underflow; - zeroPol() : returns the zero-polynomial; @@ -3122,7 +3093,7 @@ void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) namespace { -void allocExtrRow(KLContext& kl, ExtrRow& row, const CoxNbr& y) +void allocExtrRow(KLContext &kl, ExtrRow &row, const CoxNbr &y) /* This function does the allocation of the extremal row for y, but in row @@ -3130,25 +3101,24 @@ void allocExtrRow(KLContext& kl, ExtrRow& row, const CoxNbr& y) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); BitMap b(kl.size()); - p.extractClosure(b,y); + p.extractClosure(b, y); if (ERRNO) return; - maximize(p,b,p.descent(y)); + maximize(p, b, p.descent(y)); - readBitMap(row,b); + readBitMap(row, b); if (ERRNO) return; return; - } -void appendStar(String& str, const KLContext& kl, const CoxNbr& x, - const KLPol& pol, const Length& l) +void appendStar(String &str, const KLContext &kl, const CoxNbr &x, + const KLPol &pol, const Length &l) /* Appends a star to the string if mu != 0. @@ -3156,16 +3126,16 @@ void appendStar(String& str, const KLContext& kl, const CoxNbr& x, { if (l != undef_length) { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); Length l_x = p.length(x); - if (2*pol.deg()+1+l_x == l) - io::append(str," *"); + if (2 * pol.deg() + 1 + l_x == l) + io::append(str, " *"); } return; } -MuData* find(MuRow& row, const CoxNbr& x) +MuData *find(MuRow &row, const CoxNbr &x) /* Finds x in the row and returns the address of the corresponding row. @@ -3175,10 +3145,10 @@ MuData* find(MuRow& row, const CoxNbr& x) { Ulong j0 = (Ulong)(-1); - for (Ulong j1 = row.size(); j1-j0 > 1;) { - Ulong j = j0 + (j1-j0)/2; + for (Ulong j1 = row.size(); j1 - j0 > 1;) { + Ulong j = j0 + (j1 - j0) / 2; if (row[j].x == x) // m was found - return row.ptr()+j; + return row.ptr() + j; if (row[j].x < x) j0 = j; else @@ -3188,23 +3158,23 @@ MuData* find(MuRow& row, const CoxNbr& x) return 0; } -}; +}; // namespace namespace kl { -const KLPol& one() +const KLPol &one() { - static KLPol p(1,KLPol::const_tag()); + static KLPol p(1, KLPol::const_tag()); return p; } -}; +}; // namespace kl namespace { -void printStar(FILE* file, const KLContext& kl, const CoxNbr& x, - const KLPol& pol, const Length& l) +void printStar(FILE *file, const KLContext &kl, const CoxNbr &x, + const KLPol &pol, const Length &l) /* Like appendStar, but with output to a file. @@ -3212,16 +3182,16 @@ void printStar(FILE* file, const KLContext& kl, const CoxNbr& x, { if (l != undef_length) { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); Length l_x = p.length(x); - if (2*pol.deg()+1+l_x == l) - fprintf(file," *"); + if (2 * pol.deg() + 1 + l_x == l) + fprintf(file, " *"); } return; } -KLPol& safeAdd(KLPol& p, const KLPol& q, const Degree& n) +KLPol &safeAdd(KLPol &p, const KLPol &q, const Degree &n) /* This function increments p by q, shifted by x^n, checking for overflow. @@ -3231,11 +3201,11 @@ KLPol& safeAdd(KLPol& p, const KLPol& q, const Degree& n) */ { - if (p.deg() < (q.deg()+n)) + if (p.deg() < (q.deg() + n)) p.setDeg(q.deg() + n); for (Degree j = 0; j <= q.deg(); ++j) { - klsupport::safeAdd(p[j+n],q[j]); + klsupport::safeAdd(p[j + n], q[j]); if (ERRNO) return p; } @@ -3243,11 +3213,11 @@ KLPol& safeAdd(KLPol& p, const KLPol& q, const Degree& n) return p; } -KLPol& safeSubtract(KLPol& p, const KLPol& q, const KLCoeff& mu, - const Length& h) +KLPol &safeSubtract(KLPol &p, const KLPol &q, const KLCoeff &mu, + const Length &h) /* - This function subtracts mu times q shifted by x^h from p, checking for + This function subtracts mu times q shifted by x^h from p, checking for underflow. Sets the error KLCOEFF_NEGATIVE in case of problem. */ @@ -3255,12 +3225,12 @@ KLPol& safeSubtract(KLPol& p, const KLPol& q, const KLCoeff& mu, { for (Degree j = 0; j <= q.deg(); ++j) { KLCoeff a = mu; - safeMultiply(a,q[j]); + safeMultiply(a, q[j]); if (ERRNO) { /* overflow; this will cause an underflow */ ERRNO = KLCOEFF_NEGATIVE; return p; } - klsupport::safeSubtract(p[j+h],a); + klsupport::safeSubtract(p[j + h], a); if (ERRNO) return p; } @@ -3270,7 +3240,7 @@ KLPol& safeSubtract(KLPol& p, const KLPol& q, const KLCoeff& mu, return p; } -KLPol& zeroPol() +KLPol &zeroPol() /* Returns the zero polynomial (usually this indicates an error condition.) @@ -3281,5 +3251,4 @@ KLPol& zeroPol() return z; } -}; - +}; // namespace diff --git a/kl.h b/kl.h index 95c8803..84efd97 100644 --- a/kl.h +++ b/kl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KL_H /* guard against multiple inclusions */ +#ifndef KL_H /* guard against multiple inclusions */ #define KL_H #include @@ -23,58 +23,58 @@ #include "search.h" namespace kl { - using namespace coxeter; - using namespace coxtypes; - using namespace hecke; - using namespace klsupport; - using namespace list; - using namespace polynomials; - using namespace bits; - using namespace io; - using namespace list; - using namespace coxtypes; - using namespace interface; - using namespace search; +using namespace coxeter; +using namespace coxtypes; +using namespace hecke; +using namespace klsupport; +using namespace list; +using namespace polynomials; +using namespace bits; +using namespace io; +using namespace list; +using namespace coxtypes; +using namespace interface; +using namespace search; /******** type declarations *************************************************/ - class KLContext; - struct KLStatus; - struct MuData; - class MuFilter; +class KLContext; +struct KLStatus; +struct MuData; +class MuFilter; - class KLPol; - typedef List KLRow; - typedef List MuRow; - typedef List > HeckeElt; +class KLPol; +typedef List KLRow; +typedef List MuRow; +typedef List> HeckeElt; /******** function declarations *********************************************/ - void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl); - void extractDufloInvolutions(const KLContext& kl, const Partition& pi, - BitMap& b); - void genericSingularities(HeckeElt& h, const CoxNbr& y, KLContext& kl); - void ihBetti(Homology& h, const CoxNbr& y, KLContext& kl); - const KLPol& one(); - bool isSingular(const HeckeElt& h); - bool isSingular(const KLRow& row); - void print(FILE* file, const Homology& h); - void printMuTable(FILE* file, const KLContext& kl, const Interface& I); - void showKLPol(FILE* file, KLContext& kl, const CoxNbr& x, const CoxNbr& y, - const Interface& I, const Generator& s = undef_generator); - void showMu(FILE* file, KLContext& kl, const CoxNbr& x, const CoxNbr& y, - const Interface& I); - void sortByPol(KLRow& row); +void cBasis(HeckeElt &h, const CoxNbr &y, KLContext &kl); +void extractDufloInvolutions(const KLContext &kl, const Partition &pi, + BitMap &b); +void genericSingularities(HeckeElt &h, const CoxNbr &y, KLContext &kl); +void ihBetti(Homology &h, const CoxNbr &y, KLContext &kl); +const KLPol &one(); +bool isSingular(const HeckeElt &h); +bool isSingular(const KLRow &row); +void print(FILE *file, const Homology &h); +void printMuTable(FILE *file, const KLContext &kl, const Interface &I); +void showKLPol(FILE *file, KLContext &kl, const CoxNbr &x, const CoxNbr &y, + const Interface &I, const Generator &s = undef_generator); +void showMu(FILE *file, KLContext &kl, const CoxNbr &x, const CoxNbr &y, + const Interface &I); +void sortByPol(KLRow &row); /******** type definitions **************************************************/ -class KLPol:public Polynomial { +class KLPol : public Polynomial { public: - static PolynomialType polType() {return KLPOL;} - KLPol() {}; - KLPol(const Ulong& n):Polynomial(n) {}; - KLPol(const KLCoeff& c, const_tag):Polynomial(c,const_tag()) {}; - ~KLPol() {}; + static PolynomialType polType() { return KLPOL; } + KLPol(){}; + KLPol(const Ulong &n) : Polynomial(n){}; + KLPol(const KLCoeff &c, const_tag) : Polynomial(c, const_tag()){}; + ~KLPol(){}; // KLPol& add(const KLPol& p, const long& n); // KLPol& subtract(const KLPol& p, const MuPol& mp, const Ulong& n); }; @@ -90,10 +90,11 @@ struct KLStatus { Ulong munodes; Ulong mucomputed; Ulong muzero; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLStatus));} + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLStatus)); + } KLStatus(); ~KLStatus(); }; @@ -102,130 +103,151 @@ struct MuData { CoxNbr x; KLCoeff mu; Length height; -/* constructors */ - MuData() {}; - MuData(const CoxNbr& d_x, const KLCoeff& d_mu, const Length& d_h) - :x(d_x), mu(d_mu), height(d_h) {}; - ~MuData() {}; -/* comparison */ - bool operator> (const MuData& m) const; /* inlined */ + /* constructors */ + MuData(){}; + MuData(const CoxNbr &d_x, const KLCoeff &d_mu, const Length &d_h) + : x(d_x), mu(d_mu), height(d_h){}; + ~MuData(){}; + /* comparison */ + bool operator>(const MuData &m) const; /* inlined */ }; class MuFilter { - private: - const SchubertContext& d_p; +private: + const SchubertContext &d_p; Length d_l; - public: - MuFilter(const SchubertContext& p, const Length& l); - MuFilter(const SchubertContext& p, const CoxNbr& y); + +public: + MuFilter(const SchubertContext &p, const Length &l); + MuFilter(const SchubertContext &p, const CoxNbr &y); ~MuFilter(); - bool operator() (const CoxNbr& x) const; /* inlined */ + bool operator()(const CoxNbr &x) const; /* inlined */ }; class KLContext { - private: - KLSupport* d_klsupport; - List d_klList; - List d_muList; +private: + KLSupport *d_klsupport; + List d_klList; + List d_muList; BinaryTree d_klTree; - KLStatus* d_status; + KLStatus *d_status; struct KLHelper; /* provides helper functions */ - KLHelper* d_help; + KLHelper *d_help; friend struct KLHelper; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLContext));} - KLContext(KLSupport* kls); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLContext)); + } + KLContext(KLSupport *kls); ~KLContext(); -/* accessors */ - const ExtrRow& extrList(const CoxNbr& y) const; /* inlined */ - CoxNbr inverse(const CoxNbr& x) const; /* inlined */ - const BitMap& involution() const; /* inlined */ - bool isExtrAllocated(const CoxNbr& x) const; /* inlined */ - bool isFullKL() const; /* inlined */ - bool isFullMu() const; /* inlined */ - bool isKLAllocated(const CoxNbr& x) const; /* inlined */ - bool isMuAllocated(const CoxNbr& x) const; /* inlined */ - const KLRow& klList(const CoxNbr& y) const; /* inlined */ - const KLSupport& klsupport() const; /* inlined */ - Generator last(const CoxNbr& y) const; /* inlined */ - const MuRow& muList(const CoxNbr& y) const; /* inlined */ - Rank rank() const; /* inlined */ - const SchubertContext& schubert() const; /* inlined */ - Ulong size() const; /* inlined */ - const BinaryTree& tree() const; /* inlined */ -/* manipulators */ - void applyInverse(const CoxNbr& y); - void applyIPermutation(const CoxNbr& y, const Permutation& a);/* inlined */ - void clearFullKL(); /* inlined */ - void clearFullMu(); /* inlined */ + /* accessors */ + const ExtrRow &extrList(const CoxNbr &y) const; /* inlined */ + CoxNbr inverse(const CoxNbr &x) const; /* inlined */ + const BitMap &involution() const; /* inlined */ + bool isExtrAllocated(const CoxNbr &x) const; /* inlined */ + bool isFullKL() const; /* inlined */ + bool isFullMu() const; /* inlined */ + bool isKLAllocated(const CoxNbr &x) const; /* inlined */ + bool isMuAllocated(const CoxNbr &x) const; /* inlined */ + const KLRow &klList(const CoxNbr &y) const; /* inlined */ + const KLSupport &klsupport() const; /* inlined */ + Generator last(const CoxNbr &y) const; /* inlined */ + const MuRow &muList(const CoxNbr &y) const; /* inlined */ + Rank rank() const; /* inlined */ + const SchubertContext &schubert() const; /* inlined */ + Ulong size() const; /* inlined */ + const BinaryTree &tree() const; /* inlined */ + /* manipulators */ + void applyInverse(const CoxNbr &y); + void applyIPermutation(const CoxNbr &y, const Permutation &a); /* inlined */ + void clearFullKL(); /* inlined */ + void clearFullMu(); /* inlined */ void fillKL(); void fillMu(); - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - KLCoeff mu(const CoxNbr& x, const CoxNbr& y); - void permute(const Permutation& a); - void revertSize(const Ulong& n); - void row(HeckeElt& h, const CoxNbr& y); - void setFullKL(); /* inlined */ - void setFullMu(); /* inlined */ - void setSize(const Ulong& n); -/* input/output */ + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + KLCoeff mu(const CoxNbr &x, const CoxNbr &y); + void permute(const Permutation &a); + void revertSize(const Ulong &n); + void row(HeckeElt &h, const CoxNbr &y); + void setFullKL(); /* inlined */ + void setFullMu(); /* inlined */ + void setSize(const Ulong &n); + /* input/output */ // String& append(String& str, const CoxNbr& x) const; - void print(FILE* file, const CoxNbr& x, const Interface& I) const; - /* inlined */ - void printStatus(FILE* file) const; -/* to be taken out! */ + void print(FILE *file, const CoxNbr &x, const Interface &I) const; + /* inlined */ + void printStatus(FILE *file) const; + /* to be taken out! */ void compareMu(); }; /******** inlined definitions **********************************************/ -inline bool MuData::operator> (const MuData& m) const {return x > m.x;} - -inline bool MuFilter::operator() (const CoxNbr& x) const - {Length l = d_p.length(x); return ((d_l-l)%2) && ((d_l-l) > 1);} - -inline const ExtrRow& KLContext::extrList(const CoxNbr& y) const - {return klsupport().extrList(y);} -inline CoxNbr KLContext::inverse(const CoxNbr& x) const - {return d_klsupport->inverse(x);} -inline const BitMap& KLContext::involution() const - {return d_klsupport->involution();} -inline bool KLContext::isExtrAllocated(const CoxNbr& x) const - {return d_klsupport->isExtrAllocated(x);} -inline bool KLContext::isFullKL() const - {return d_status->flags&KLStatus::kl_done;} -inline bool KLContext::isFullMu() const - {return d_status->flags&KLStatus::mu_done;} -inline bool KLContext::isKLAllocated(const CoxNbr& x) const - {return d_klList[x] != 0;} -inline bool KLContext::isMuAllocated(const CoxNbr& x) const - {return d_muList[x] != 0;} -inline const KLRow& KLContext::klList(const CoxNbr& y) const - {return *d_klList[y];} -inline const KLSupport& KLContext::klsupport() const {return *d_klsupport;} -inline Generator KLContext::last(const CoxNbr& y) const - {return d_klsupport->last(y);} -inline const MuRow& KLContext::muList(const CoxNbr& y) const - {return *d_muList[y];} -inline Rank KLContext::rank() const {return d_klsupport->rank();} -inline const SchubertContext& KLContext::schubert() const - {return d_klsupport->schubert();} -inline Ulong KLContext::size() const {return d_klList.size();} -inline const BinaryTree& KLContext::tree() const {return d_klTree;} -inline void KLContext::print(FILE* file, const CoxNbr& x, const Interface& I) - const {schubert().print(file,x,I);} - -inline void KLContext::applyIPermutation(const CoxNbr& y, const Permutation& a) - {return rightRangePermute(*d_klList[y],a);} -inline void KLContext::clearFullKL() {d_status->flags &= ~KLStatus::kl_done;} -inline void KLContext::clearFullMu() {d_status->flags &= ~KLStatus::mu_done;} -inline void KLContext::setFullKL() {d_status->flags |= KLStatus::kl_done;} -inline void KLContext::setFullMu() {d_status->flags |= KLStatus::mu_done;} +inline bool MuData::operator>(const MuData &m) const { return x > m.x; } + +inline bool MuFilter::operator()(const CoxNbr &x) const { + Length l = d_p.length(x); + return ((d_l - l) % 2) && ((d_l - l) > 1); +} +inline const ExtrRow &KLContext::extrList(const CoxNbr &y) const { + return klsupport().extrList(y); +} +inline CoxNbr KLContext::inverse(const CoxNbr &x) const { + return d_klsupport->inverse(x); +} +inline const BitMap &KLContext::involution() const { + return d_klsupport->involution(); +} +inline bool KLContext::isExtrAllocated(const CoxNbr &x) const { + return d_klsupport->isExtrAllocated(x); +} +inline bool KLContext::isFullKL() const { + return d_status->flags & KLStatus::kl_done; +} +inline bool KLContext::isFullMu() const { + return d_status->flags & KLStatus::mu_done; } +inline bool KLContext::isKLAllocated(const CoxNbr &x) const { + return d_klList[x] != 0; +} +inline bool KLContext::isMuAllocated(const CoxNbr &x) const { + return d_muList[x] != 0; +} +inline const KLRow &KLContext::klList(const CoxNbr &y) const { + return *d_klList[y]; +} +inline const KLSupport &KLContext::klsupport() const { return *d_klsupport; } +inline Generator KLContext::last(const CoxNbr &y) const { + return d_klsupport->last(y); +} +inline const MuRow &KLContext::muList(const CoxNbr &y) const { + return *d_muList[y]; +} +inline Rank KLContext::rank() const { return d_klsupport->rank(); } +inline const SchubertContext &KLContext::schubert() const { + return d_klsupport->schubert(); +} +inline Ulong KLContext::size() const { return d_klList.size(); } +inline const BinaryTree &KLContext::tree() const { return d_klTree; } +inline void KLContext::print(FILE *file, const CoxNbr &x, + const Interface &I) const { + schubert().print(file, x, I); +} + +inline void KLContext::applyIPermutation(const CoxNbr &y, + const Permutation &a) { + return rightRangePermute(*d_klList[y], a); +} +inline void KLContext::clearFullKL() { d_status->flags &= ~KLStatus::kl_done; } +inline void KLContext::clearFullMu() { d_status->flags &= ~KLStatus::mu_done; } +inline void KLContext::setFullKL() { d_status->flags |= KLStatus::kl_done; } +inline void KLContext::setFullMu() { d_status->flags |= KLStatus::mu_done; } + +} // namespace kl #endif diff --git a/klsupport.cpp b/klsupport.cpp index 4592fa8..4e24a05 100644 --- a/klsupport.cpp +++ b/klsupport.cpp @@ -1,6 +1,6 @@ /* This is klsupport.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -49,11 +49,11 @@ - KLSupport(SchubertContext*, const Interface*); - ~KLSupport(); - + - accessors : - inverseMin(const CoxNbr& x) : returns min(x,x_inverse); - - standardPath(List& g, const CoxNbr& x) : returns in g the + - standardPath(List& g, const CoxNbr& x) : returns in g the standard descent path from x - manipulators : @@ -70,19 +70,19 @@ namespace klsupport { -KLSupport::KLSupport(SchubertContext* p) - :d_schubert(p), d_extrList(1), d_inverse(1), d_last(1), d_involution(1) +KLSupport::KLSupport(SchubertContext *p) + : d_schubert(p), d_extrList(1), d_inverse(1), d_last(1), d_involution(1) { /* make first row of d_extrList, for the identity element */ d_extrList[0] = new ExtrRow(1); d_extrList.setSizeValue(1); - ExtrRow& e = *d_extrList[0]; + ExtrRow &e = *d_extrList[0]; e.setSizeValue(1); d_inverse.setSizeValue(1); - + d_last.setSizeValue(1); d_last[0] = undef_generator; @@ -107,7 +107,7 @@ KLSupport::~KLSupport() /******** accessors *********************************************************/ -CoxNbr KLSupport::inverseMin(const CoxNbr& x) const +CoxNbr KLSupport::inverseMin(const CoxNbr &x) const /* Returns the minimum of x and x_inverse. @@ -120,37 +120,36 @@ CoxNbr KLSupport::inverseMin(const CoxNbr& x) const return inverse(x); } -void KLSupport::standardPath(List& g, const CoxNbr& x) const +void KLSupport::standardPath(List &g, const CoxNbr &x) const -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); /* find sequence of shifts */ Length j = p.length(x); g.setSize(j); CoxNbr x1 = x; - + while (j) { --j; if (inverse(x1) < x1) { /* left shift */ Generator s = last(inverse(x1)); g[j] = s + rank(); - x1 = p.lshift(x1,s); - } - else { + x1 = p.lshift(x1, s); + } else { Generator s = last(x1); g[j] = last(x1); - x1 = p.rshift(x1,s); + x1 = p.rshift(x1, s); } } - + return; } /******** manipulators ******************************************************/ -void KLSupport::allocExtrRow(const CoxNbr& y) +void KLSupport::allocExtrRow(const CoxNbr &y) /* Allocates one row in d_extrList. The row contains the list of elements @@ -160,24 +159,24 @@ void KLSupport::allocExtrRow(const CoxNbr& y) Forwards the error MEMORY_WARNING if CATCH_MEMORY_ERROR is set. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); BitMap b(size()); - p.extractClosure(b,y); + p.extractClosure(b, y); if (ERRNO) return; - maximize(p,b,p.descent(y)); + maximize(p, b, p.descent(y)); - d_extrList[y] = new ExtrRow(b.begin(),b.end()); + d_extrList[y] = new ExtrRow(b.begin(), b.end()); /* an error may be set here */ return; } -void KLSupport::allocRowComputation(const CoxNbr& y) +void KLSupport::allocRowComputation(const CoxNbr &y) /* This function makes sure that all the extremal rows in the standard @@ -191,13 +190,13 @@ void KLSupport::allocRowComputation(const CoxNbr& y) Things wouldn't be so bad if there wasn't also the passage to inverses! */ -{ +{ static List e(0); - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); /* find sequence of shifts */ - standardPath(e,y); + standardPath(e, y); SubSet q(size()); @@ -213,45 +212,44 @@ void KLSupport::allocRowComputation(const CoxNbr& y) for (Ulong j = 0; j < e.size(); ++j) { Generator s = e[j]; - p.extendSubSet(q,s); /* extend the subset */ + p.extendSubSet(q, s); /* extend the subset */ if (ERRNO) - goto abort; + goto abort; - y1 = p.shift(y1,s); + y1 = p.shift(y1, s); CoxNbr y2 = inverseMin(y1); - + if (!isExtrAllocated(y2)) { /* allocate row */ - /* copy bitmap of subset to buffer */ + /* copy bitmap of subset to buffer */ - BitMap b = q.bitMap(); - if (ERRNO) - goto abort; + BitMap b = q.bitMap(); + if (ERRNO) + goto abort; - /* extremalize */ + /* extremalize */ - maximize(p,b,p.descent(y1)); - d_extrList[y1] = new ExtrRow(b.begin(),b.end()); - - /* go over to inverses if necessary */ + maximize(p, b, p.descent(y1)); + d_extrList[y1] = new ExtrRow(b.begin(), b.end()); - if (s >= rank()) { - applyInverse(y2); - d_extrList[y2]->sort(); - } + /* go over to inverses if necessary */ + + if (s >= rank()) { + applyInverse(y2); + d_extrList[y2]->sort(); + } } } - } - return; - abort: + return; +abort: Error(ERRNO); ERRNO = ERROR_WARNING; - return; + return; } -void KLSupport::applyInverse(const CoxNbr& y) +void KLSupport::applyInverse(const CoxNbr &y) /* This function puts in d_extrList[y] the row of inverses of d_extrList[yi], @@ -264,7 +262,7 @@ void KLSupport::applyInverse(const CoxNbr& y) d_extrList[y] = d_extrList[yi]; d_extrList[yi] = 0; - ExtrRow& e = *d_extrList[y]; + ExtrRow &e = *d_extrList[y]; for (Ulong j = 0; j < e.size(); ++j) { e[j] = inverse(e[j]); } @@ -272,7 +270,7 @@ void KLSupport::applyInverse(const CoxNbr& y) return; } -CoxNbr KLSupport::extendContext(const CoxWord& g) +CoxNbr KLSupport::extendContext(const CoxWord &g) /* Extends the context to accomodate g. @@ -285,7 +283,7 @@ CoxNbr KLSupport::extendContext(const CoxWord& g) { CoxNbr prev_size = size(); - SchubertContext& p = *d_schubert; + SchubertContext &p = *d_schubert; CoxNbr x = p.extendContext(g); @@ -314,21 +312,21 @@ CoxNbr KLSupport::extendContext(const CoxWord& g) for (CoxNbr x = 0; x < prev_size; ++x) { if (inverse(x) == undef_coxnbr) { /* try to extend */ Generator s = p.firstRDescent(x); - CoxNbr xs = p.rshift(x,s); + CoxNbr xs = p.rshift(x, s); if (inverse(xs) == undef_coxnbr) - d_inverse[x] = undef_coxnbr; + d_inverse[x] = undef_coxnbr; else - d_inverse[x] = p.lshift(inverse(xs),s); + d_inverse[x] = p.lshift(inverse(xs), s); } } for (CoxNbr x = prev_size; x < size(); ++x) { Generator s = p.firstRDescent(x); - CoxNbr xs = p.rshift(x,s); + CoxNbr xs = p.rshift(x, s); if (inverse(xs) == undef_coxnbr) d_inverse[x] = undef_coxnbr; else - d_inverse[x] = p.lshift(inverse(xs),s); + d_inverse[x] = p.lshift(inverse(xs), s); } for (CoxNbr x = prev_size; x < size(); ++x) { @@ -340,7 +338,7 @@ CoxNbr KLSupport::extendContext(const CoxWord& g) for (CoxNbr x = prev_size; x < size(); ++x) { Generator s = p.firstLDescent(x); - CoxNbr sx = p.lshift(x,s); + CoxNbr sx = p.lshift(x, s); if (sx) d_last[x] = d_last[sx]; else /* x = s */ @@ -349,14 +347,14 @@ CoxNbr KLSupport::extendContext(const CoxWord& g) return x; - revert: +revert: CATCH_MEMORY_OVERFLOW = false; revertSize(prev_size); return undef_coxnbr; } -void KLSupport::permute(const Permutation& a) +void KLSupport::permute(const Permutation &a) /* Applies the permutation a to the data in the context. The meaning of a @@ -372,10 +370,10 @@ void KLSupport::permute(const Permutation& a) /* permute values */ - for (CoxNbr y = 0; y < size(); ++y) { + for (CoxNbr y = 0; y < size(); ++y) { if (d_extrList[y] == 0) continue; - ExtrRow& e = *d_extrList[y]; + ExtrRow &e = *d_extrList[y]; for (Ulong j = 0; j < e.size(); ++j) { e[j] = a[e[j]]; } @@ -399,7 +397,7 @@ void KLSupport::permute(const Permutation& a) } for (CoxNbr y = a[x]; y != x; y = a[y]) { /* back up values for y */ - ExtrRow* extr_buf = d_extrList[y]; + ExtrRow *extr_buf = d_extrList[y]; CoxNbr inverse_buf = inverse(y); Generator last_buf = last(y); bool involution_buf = isInvolution(y); @@ -408,17 +406,17 @@ void KLSupport::permute(const Permutation& a) d_inverse[y] = inverse(x); d_last[y] = last(x); if (isInvolution(x)) - d_involution.setBit(y); + d_involution.setBit(y); else - d_involution.clearBit(y); + d_involution.clearBit(y); /* store backup values in x */ d_extrList[x] = extr_buf; d_inverse[x] = inverse_buf; d_last[x] = last_buf; if (involution_buf) - d_involution.setBit(x); + d_involution.setBit(x); else - d_involution.clearBit(x); + d_involution.clearBit(x); /* set bit*/ b.setBit(y); } @@ -429,7 +427,7 @@ void KLSupport::permute(const Permutation& a) return; } -void KLSupport::revertSize(const Ulong& n) +void KLSupport::revertSize(const Ulong &n) /* This function reverts the size of the context to a previous value n. Note @@ -437,7 +435,7 @@ void KLSupport::revertSize(const Ulong& n) the consistency of the various size values. */ -{ +{ d_schubert->revertSize(n); d_extrList.setSize(n); d_inverse.setSize(n); @@ -446,7 +444,7 @@ void KLSupport::revertSize(const Ulong& n) return; } -}; +}; // namespace klsupport /***************************************************************************** @@ -461,7 +459,7 @@ void KLSupport::revertSize(const Ulong& n) namespace klsupport { -KLCoeff& safeAdd(KLCoeff& a, const KLCoeff& b) +KLCoeff &safeAdd(KLCoeff &a, const KLCoeff &b) /* This function increments a with b, if the result does not exceed @@ -478,7 +476,7 @@ KLCoeff& safeAdd(KLCoeff& a, const KLCoeff& b) return a; } -SKLCoeff& safeAdd(SKLCoeff& a, const SKLCoeff& b) +SKLCoeff &safeAdd(SKLCoeff &a, const SKLCoeff &b) /* This function increments a with b if the result lies in the interval @@ -493,17 +491,15 @@ SKLCoeff& safeAdd(SKLCoeff& a, const SKLCoeff& b) { if ((b > 0) && (a > SKLCOEFF_MAX - b)) { ERRNO = SKLCOEFF_OVERFLOW; - } - else if ((b < 0) && (a < SKLCOEFF_MIN - b)) { + } else if ((b < 0) && (a < SKLCOEFF_MIN - b)) { ERRNO = SKLCOEFF_UNDERFLOW; - } - else + } else a += b; return a; } -KLCoeff& safeMultiply(KLCoeff& a, const KLCoeff& b) +KLCoeff &safeMultiply(KLCoeff &a, const KLCoeff &b) /* This function multiplies a with b, if the result does not exceed @@ -515,7 +511,7 @@ KLCoeff& safeMultiply(KLCoeff& a, const KLCoeff& b) if (a == 0) return a; - if (b <= KLCOEFF_MAX/a) + if (b <= KLCOEFF_MAX / a) a *= b; else ERRNO = KLCOEFF_OVERFLOW; @@ -523,7 +519,7 @@ KLCoeff& safeMultiply(KLCoeff& a, const KLCoeff& b) return a; } -SKLCoeff& safeMultiply(SKLCoeff& a, const SKLCoeff& b) +SKLCoeff &safeMultiply(SKLCoeff &a, const SKLCoeff &b) /* This function multiplies a with b, if the result lies between SKLCOEFF_MIN @@ -536,17 +532,16 @@ SKLCoeff& safeMultiply(SKLCoeff& a, const SKLCoeff& b) return a; if (a > 0) { - if (b > SKLCOEFF_MAX/a) + if (b > SKLCOEFF_MAX / a) ERRNO = SKLCOEFF_OVERFLOW; - else if (b < SKLCOEFF_MIN/a) + else if (b < SKLCOEFF_MIN / a) ERRNO = SKLCOEFF_UNDERFLOW; else a *= b; - } - else { - if (b > SKLCOEFF_MIN/a) + } else { + if (b > SKLCOEFF_MIN / a) ERRNO = SKLCOEFF_UNDERFLOW; - else if (b < SKLCOEFF_MAX/a) + else if (b < SKLCOEFF_MAX / a) ERRNO = SKLCOEFF_OVERFLOW; else a *= b; @@ -555,7 +550,7 @@ SKLCoeff& safeMultiply(SKLCoeff& a, const SKLCoeff& b) return a; } -KLCoeff& safeSubtract(KLCoeff& a, const KLCoeff& b) +KLCoeff &safeSubtract(KLCoeff &a, const KLCoeff &b) /* This function subtracts b from a, if the result is non-negative; sets @@ -571,4 +566,4 @@ KLCoeff& safeSubtract(KLCoeff& a, const KLCoeff& b) return a; } -}; +}; // namespace klsupport diff --git a/klsupport.h b/klsupport.h index e3af7c1..de832f0 100644 --- a/klsupport.h +++ b/klsupport.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KLSUPPORT_H /* guard against multiple inclusions */ +#ifndef KLSUPPORT_H /* guard against multiple inclusions */ #define KLSUPPORT_H #include "globals.h" @@ -16,103 +16,112 @@ #include "schubert.h" namespace klsupport { - using namespace coxeter; - using namespace coxtypes; - using namespace list; - using namespace polynomials; - using namespace schubert; +using namespace coxeter; +using namespace coxtypes; +using namespace list; +using namespace polynomials; +using namespace schubert; /******** type declarations **************************************************/ - class KLSupport; +class KLSupport; - typedef unsigned short KLCoeff; - typedef short SKLCoeff; - typedef List ExtrRow; +typedef unsigned short KLCoeff; +typedef short SKLCoeff; +typedef List ExtrRow; /******** constants **********************************************************/ - enum PolynomialType {KLPOL, UNEQ_KLPOL, INV_KLPOL, NUM_POLTYPES}; +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; +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); +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 d_extrList; +private: + SchubertContext *d_schubert; + List d_extrList; List d_inverse; List d_last; BitMap d_involution; - public: - List& 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); + +public: + List &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& 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 */ + /* 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 &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;} +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; } +} // namespace klsupport + #endif diff --git a/list.h b/list.h index e0c5630..ecc2031 100644 --- a/list.h +++ b/list.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef LIST_H /* guarantee single inclusion */ +#ifndef LIST_H /* guarantee single inclusion */ #define LIST_H #include @@ -14,82 +14,80 @@ #include "memory.h" namespace list { - using namespace coxeter; - using namespace memory; +using namespace coxeter; +using namespace memory; /******** type declarations *************************************************/ - template - class List; +template class List; /******** constants *********************************************************/ - const Ulong undef_size = ULONG_MAX; - const Ulong not_found = ULONG_MAX; +const Ulong undef_size = ULONG_MAX; +const Ulong not_found = ULONG_MAX; /******** functions provided by list.h **************************************/ - template Ulong find(const List& l, const T& m); - template Ulong insert(List& l, const T& m); - template void print(FILE* file, const List& l); +template Ulong find(const List &l, const T &m); +template Ulong insert(List &l, const T &m); +template void print(FILE *file, const List &l); /******** type definitions **************************************************/ -template -class List { - protected: - T* d_ptr; +template class List { +protected: + T *d_ptr; Ulong d_size; Ulong d_allocated; - public: + +public: typedef T eltType; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(List));} - void* operator new(size_t, void* ptr) {return ptr;} - void operator delete(void* ptr, void* placement) {}; - List() {memset(this,0,sizeof(List));} // guarantee clean memory - List(const Ulong& n); - List(const List& r); - List(const T* p, const Ulong& n); - template List(const I& first, const I& last); - template List(const I& first, const I& last, F& f); + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { return arena().free(ptr, sizeof(List)); } + void *operator new(size_t, void *ptr) { return ptr; } + void operator delete(void *ptr, void *placement){}; + List() { memset(this, 0, sizeof(List)); } // guarantee clean memory + List(const Ulong &n); + List(const List &r); + List(const T *p, const Ulong &n); + template List(const I &first, const I &last); + template List(const I &first, const I &last, F &f); ~List(); -/* modifiers */ - T& operator[] (Ulong j); /* inlined */ - const List& operator= (const List& r); - void append(const T& x); - const List& assign(const List& r); - void erase(const Ulong& n); + /* modifiers */ + T &operator[](Ulong j); /* inlined */ + const List &operator=(const List &r); + void append(const T &x); + const List &assign(const List &r); + void erase(const Ulong &n); void reverse(); - T* ptr() {return d_ptr;} - void setData(const T* source, Ulong first, Ulong r); - void setData(const T* source, Ulong r); /* inlined */ + T *ptr() { return d_ptr; } + void setData(const T *source, Ulong first, Ulong r); + void setData(const T *source, Ulong r); /* inlined */ void setSize(Ulong n); - void setSizeValue(const Ulong& n); /* inlined */ - void setZero(Ulong first, Ulong r); /* inlined */ - void setZero(Ulong r); /* inlined */ - void setZero(); /* inlined */ - void shallowCopy(const List& w); /* inlined */ - void shiftPtr(const long& d); /* inlined */ - Ulong& size(); /* inlined */ + void setSizeValue(const Ulong &n); /* inlined */ + void setZero(Ulong first, Ulong r); /* inlined */ + void setZero(Ulong r); /* inlined */ + void setZero(); /* inlined */ + void shallowCopy(const List &w); /* inlined */ + void shiftPtr(const long &d); /* inlined */ + Ulong &size(); /* inlined */ void sort(); - template void sort(C& c); /* inlined */ -/* accessors */ - const T& operator[] (Ulong j) const; /* inlined */ - bool operator== (const List& w) const; - bool operator!= (const List& w) const; - bool operator< (const List& w) const; - const T* ptr() const; /* inlined */ - const Ulong& size() const; /* inlined */ -/* iterator */ - typedef T* Iterator; - typedef const T* ConstIterator; - Iterator begin(); /* inlined */ - Iterator end(); /* inlined */ - ConstIterator begin() const; /* inlined */ - ConstIterator end() const; /* inlined */ + template void sort(C &c); /* inlined */ + /* accessors */ + const T &operator[](Ulong j) const; /* inlined */ + bool operator==(const List &w) const; + bool operator!=(const List &w) const; + bool operator<(const List &w) const; + const T *ptr() const; /* inlined */ + const Ulong &size() const; /* inlined */ + /* iterator */ + typedef T *Iterator; + typedef const T *ConstIterator; + Iterator begin(); /* inlined */ + Iterator end(); /* inlined */ + ConstIterator begin() const; /* inlined */ + ConstIterator end() const; /* inlined */ }; /******** Implementation of inline functions *******************************/ @@ -98,43 +96,53 @@ class List { /* modifiers */ -template inline T& List::operator[] (Ulong j) - {return d_ptr[j];} -template -inline void List::setData(const T* source, Ulong r) - {setData(source,0,r);} -template void List::setSizeValue(const Ulong& n) - {d_size = n;} -template inline void List::setZero(Ulong first, Ulong r) - {memset(d_ptr+first,0,r*sizeof(T));} -template inline void List::setZero(Ulong r) {setZero(0,r);} -template inline void List::setZero() {setZero(0,d_size);} -template inline void List::shallowCopy(const List& w) - {memmove(this,&w,sizeof(List));} -template inline void List::shiftPtr(const long& d) - {d_ptr += d; d_size -= d; d_allocated -= d;} -template Ulong& List::size() {return d_size;} +template inline T &List::operator[](Ulong j) { return d_ptr[j]; } +template inline void List::setData(const T *source, Ulong r) { + setData(source, 0, r); +} +template void List::setSizeValue(const Ulong &n) { d_size = n; } +template inline void List::setZero(Ulong first, Ulong r) { + memset(d_ptr + first, 0, r * sizeof(T)); +} +template inline void List::setZero(Ulong r) { setZero(0, r); } +template inline void List::setZero() { setZero(0, d_size); } +template inline void List::shallowCopy(const List &w) { + memmove(this, &w, sizeof(List)); +} +template inline void List::shiftPtr(const long &d) { + d_ptr += d; + d_size -= d; + d_allocated -= d; +} +template Ulong &List::size() { return d_size; } /* accessors */ -template inline const T& List::operator[] (Ulong j) const - {return(d_ptr[j]);} -template inline bool List::operator!= (const List& w) const - {return !operator==(w);} -template const T* List::ptr() const {return d_ptr;} -template inline const Ulong& List::size() const {return d_size;} +template inline const T &List::operator[](Ulong j) const { + return (d_ptr[j]); +} +template inline bool List::operator!=(const List &w) const { + return !operator==(w); +} +template const T *List::ptr() const { return d_ptr; } +template inline const Ulong &List::size() const { return d_size; } /* iterators */ -template inline typename List::Iterator List::begin() - {return d_ptr;} -template inline typename List::Iterator List::end() - {return d_ptr+d_size;} -template inline typename List::ConstIterator List::begin() - const {return d_ptr;} -template inline typename List::ConstIterator List::end() const - {return d_ptr+d_size;} +template inline typename List::Iterator List::begin() { + return d_ptr; +} +template inline typename List::Iterator List::end() { + return d_ptr + d_size; +} +template +inline typename List::ConstIterator List::begin() const { + return d_ptr; +} +template inline typename List::ConstIterator List::end() const { + return d_ptr + d_size; } +} // namespace list #include "list.hpp" diff --git a/list.hpp b/list.hpp index 9a7c4e5..f7b7d4f 100644 --- a/list.hpp +++ b/list.hpp @@ -1,6 +1,6 @@ /* This is list.hpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -10,7 +10,7 @@ #include "error.h" namespace list { - using namespace error; +using namespace error; }; /************************************************************************** @@ -58,39 +58,40 @@ namespace list { namespace list { -template List::List(const Ulong& n) +template +List::List(const Ulong &n) /* Allocates this to hold n elements. Relies on the fact that it always - receives clean memory from alloc, and that the default constructor does + receives clean memory from alloc, and that the default constructor does nothing. */ { - d_allocated = arena().allocSize(n,sizeof(T)); - d_ptr = static_cast (arena().alloc(n*sizeof(T))); + d_allocated = arena().allocSize(n, sizeof(T)); + d_ptr = static_cast(arena().alloc(n * sizeof(T))); d_size = 0; } - -template List::List(const List& r) +template +List::List(const List &r) /* Copy constructor. Contrary to assignment, constructs fully new objects. */ { - d_ptr = static_cast (arena().alloc(r.size()*sizeof(T))); - d_allocated = arena().allocSize(r.size(),sizeof(T)); + d_ptr = static_cast(arena().alloc(r.size() * sizeof(T))); + d_allocated = arena().allocSize(r.size(), sizeof(T)); for (Ulong j = 0; j < r.size(); ++j) { - new(d_ptr+j) T(r[j]); + new (d_ptr + j) T(r[j]); } d_size = r.d_size; } - -template List::List(const T* p, const Ulong& n) - :d_allocated(0) +template +List::List(const T *p, const Ulong &n) + : d_allocated(0) /* Constructor for the List class, allocating the list to size n, and @@ -99,14 +100,15 @@ template List::List(const T* p, const Ulong& n) */ { - d_ptr = static_cast (arena().alloc(n*sizeof(T))); - d_allocated = arena().allocSize(n,sizeof(T)); - memcpy(d_ptr,p,n*sizeof(T)); + d_ptr = static_cast(arena().alloc(n * sizeof(T))); + d_allocated = arena().allocSize(n, sizeof(T)); + memcpy(d_ptr, p, n * sizeof(T)); d_size = n; } -template template -List::List(const I& first, const I& last) +template +template +List::List(const I &first, const I &last) /* A list constructor taking iterators as parameters. It is assumed that @@ -114,15 +116,16 @@ List::List(const I& first, const I& last) */ { - memset(this,0,sizeof(List)); + memset(this, 0, sizeof(List)); for (I i = first; i != last; ++i) { append(*i); } } -template template -List::List(const I& first, const I& last, F& f) +template +template +List::List(const I &first, const I &last, F &f) /* Like the previous one, except that in addition F is a functor taking one @@ -130,14 +133,15 @@ List::List(const I& first, const I& last, F& f) */ { - memset(this,0,sizeof(List)); + memset(this, 0, sizeof(List)); for (I i = first; i != last; ++i) { append(f(*i)); } } -template List::~List() +template +List::~List() /* Destructor for the List class : releases the memory. @@ -150,12 +154,13 @@ template List::~List() for (Ulong j = 0; j < d_allocated; ++j) { d_ptr[j].~T(); } - arena().free(d_ptr,d_allocated*sizeof(T)); + arena().free(d_ptr, d_allocated * sizeof(T)); } /******** accessors *********************************************************/ -template bool List::operator== (const List& w) const +template +bool List::operator==(const List &w) const /* Equality operator for lists. Two lists are equal if they have the same @@ -175,7 +180,8 @@ template bool List::operator== (const List& w) const return true; } -template bool List::operator< (const List& w) const +template +bool List::operator<(const List &w) const /* Comparison operator for lists. Comparison is length-first, lexicographical. @@ -204,15 +210,16 @@ template bool List::operator< (const List& w) const /******** modifiers *********************************************************/ -template -const List& List::operator= (const List& r) +template +const List &List::operator=(const List &r) { assign(r); return *this; } -template void List::append(const T& x) +template +void List::append(const T &x) /* Appends one element to the list, resizing if necessary. @@ -226,30 +233,31 @@ template void List::append(const T& x) Ulong c = d_size; - if (d_allocated < c+1) { - Ulong old_size = c*sizeof(T); - Ulong new_size = (c+1)*sizeof(T); - T* new_ptr = static_cast (arena().alloc(new_size)); + if (d_allocated < c + 1) { + Ulong old_size = c * sizeof(T); + Ulong new_size = (c + 1) * sizeof(T); + T *new_ptr = static_cast(arena().alloc(new_size)); if (ERRNO) /* overflow */ return; - memcpy(new_ptr,d_ptr,old_size); + memcpy(new_ptr, d_ptr, old_size); new_ptr[c] = x; - arena().free(d_ptr,d_allocated*sizeof(T)); + arena().free(d_ptr, d_allocated * sizeof(T)); d_ptr = new_ptr; - d_allocated = arena().allocSize(c+1,sizeof(T)); - d_size = c+1; + d_allocated = arena().allocSize(c + 1, sizeof(T)); + d_size = c + 1; return; } // if we get here no resizing is necesary - setSize(c+1); + setSize(c + 1); d_ptr[c] = x; return; } -template const List& List::assign(const List& r) +template +const List &List::assign(const List &r) /* Assigns r to the current list, by a one-level copy (in other words, @@ -265,38 +273,41 @@ template const List& List::assign(const List& r) setSize(r.size()); if (ERRNO) /* overflow */ return *this; - setData(r.ptr(),r.size()); + setData(r.ptr(), r.size()); return *this; } -template void List::erase(const Ulong& n) +template +void List::erase(const Ulong &n) /* This function erases the n-th term in the list, by shifting up. */ { - memmove(d_ptr+n,d_ptr+n+1,(d_size-n-1)*sizeof(T)); + memmove(d_ptr + n, d_ptr + n + 1, (d_size - n - 1) * sizeof(T)); d_size--; } -template void List::reverse() +template +void List::reverse() /* Reverses the order of the elements in the list. */ -{ - for (Ulong j = 0; j < d_size/2; ++j) { +{ + for (Ulong j = 0; j < d_size / 2; ++j) { T a = d_ptr[j]; - d_ptr[j] = d_ptr[d_size-j-1]; - d_ptr[d_size-j-1] = a; + d_ptr[j] = d_ptr[d_size - j - 1]; + d_ptr[d_size - j - 1] = a; } return; } -template void List::setSize(Ulong n) +template +void List::setSize(Ulong n) /* Checks if the varlist will hold n nodes of data, and resizes it if not. @@ -306,12 +317,12 @@ template void List::setSize(Ulong n) { if (d_allocated < n) { /* resize */ - void *p = arena().realloc(d_ptr,d_allocated*sizeof(T),n*sizeof(T)); + void *p = arena().realloc(d_ptr, d_allocated * sizeof(T), n * sizeof(T)); if (ERRNO) /* overflow */ return; - d_ptr = static_cast (p); + d_ptr = static_cast(p); // Ulong old_alloc = d_allocated; - d_allocated = arena().allocSize(n,sizeof(T)); + d_allocated = arena().allocSize(n, sizeof(T)); // the following line causes trouble; I can't understand why! // new(d_ptr+old_alloc) T[d_allocated-old_alloc]; } @@ -321,8 +332,7 @@ template void List::setSize(Ulong n) return; } - -template +template void List::setData(const T *source, Ulong first, Ulong r) /* @@ -336,44 +346,45 @@ void List::setData(const T *source, Ulong first, Ulong r) // we have to be careful in case source points into the structure being // resized! calling setSize directly would invlaidate source. - if (d_allocated < first+r) { - Ulong old_size = first*sizeof(T); - Ulong new_size = (first+r)*sizeof(T); - T* new_ptr = static_cast (arena().alloc(new_size)); + if (d_allocated < first + r) { + Ulong old_size = first * sizeof(T); + Ulong new_size = (first + r) * sizeof(T); + T *new_ptr = static_cast(arena().alloc(new_size)); if (ERRNO) /* overflow */ return; - memcpy(new_ptr,d_ptr,first*sizeof(T)); - memcpy(new_ptr+first,source,r*sizeof(T)); - arena().free(d_ptr,d_allocated*sizeof(T)); + memcpy(new_ptr, d_ptr, first * sizeof(T)); + memcpy(new_ptr + first, source, r * sizeof(T)); + arena().free(d_ptr, d_allocated * sizeof(T)); d_ptr = new_ptr; - d_allocated = arena().allocSize(first+r,sizeof(T)); - d_size = first+r; + d_allocated = arena().allocSize(first + r, sizeof(T)); + d_size = first + r; return; } // if we get here no new memory allocation is necessary - if (d_size < first+r) - setSize(first+r); + if (d_size < first + r) + setSize(first + r); - memmove(d_ptr+first,source,r*sizeof(T)); + memmove(d_ptr + first, source, r * sizeof(T)); return; } -template void List::sort() +template +void List::sort() /* Sorts the list in the natural order of the elements. It is assumed that operator> is defined for T. */ -{ +{ /* set the starting value of h */ - Ulong h = 1; + Ulong h = 1; - for (; h < d_size/3; h = 3*h+1) + for (; h < d_size / 3; h = 3 * h + 1) ; /* do the sort */ @@ -382,8 +393,8 @@ template void List::sort() for (Ulong j = h; j < d_size; ++j) { T a = d_ptr[j]; Ulong i = j; - for (; (i >= h) && (d_ptr[i-h] > a); i -= h) - d_ptr[i] = d_ptr[i-h]; + for (; (i >= h) && (d_ptr[i - h] > a); i -= h) + d_ptr[i] = d_ptr[i - h]; d_ptr[i] = a; } } @@ -391,7 +402,9 @@ template void List::sort() return; } -template template void List::sort(C& c) +template +template +void List::sort(C &c) /* Sorts the list in the order defined by the comparison functor c. It is @@ -399,12 +412,12 @@ template template void List::sort(C& c) if x <= y (so that the relation x > y is expressed by !c(c,y)) */ -{ +{ /* set the starting value of h */ - Ulong h = 1; + Ulong h = 1; - for (; h < d_size/3; h = 3*h+1) + for (; h < d_size / 3; h = 3 * h + 1) ; /* do the sort */ @@ -413,8 +426,8 @@ template template void List::sort(C& c) for (Ulong j = h; j < d_size; ++j) { T a = d_ptr[j]; Ulong i = j; - for (; (i >= h) && !c(d_ptr[i-h],a); i -= h) - d_ptr[i] = d_ptr[i-h]; + for (; (i >= h) && !c(d_ptr[i - h], a); i -= h) + d_ptr[i] = d_ptr[i - h]; d_ptr[i] = a; } } @@ -422,8 +435,7 @@ template template void List::sort(C& c) return; } -}; - +}; // namespace list /************************************************************************** @@ -438,7 +450,8 @@ template template void List::sort(C& c) namespace list { -template Ulong insert(List& l, const T& d_m) +template +Ulong insert(List &l, const T &d_m) /* Inserts a new element in the (ordered) list, using binary search to find @@ -460,8 +473,8 @@ template Ulong insert(List& l, const T& d_m) Ulong j0 = ~0L; Ulong j1 = l.size(); - for (; j1-j0 > 1;) { - Ulong j = j0 + (j1-j0)/2; + for (; j1 - j0 > 1;) { + Ulong j = j0 + (j1 - j0) / 2; if (l[j] == m) /* m was found */ return j; if (l[j] < m) @@ -472,16 +485,17 @@ template Ulong insert(List& l, const T& d_m) /* at this point j1 = j0+1; insertion point is j1 */ - l.setSize(l.size()+1); + l.setSize(l.size() + 1); if (ERRNO) /* overflow */ return not_found; - l.setData(l.ptr()+j1,j1+1,l.size()-j1-1); /* shift tail up by one */ - new(l.ptr()+j1) T(m); + l.setData(l.ptr() + j1, j1 + 1, l.size() - j1 - 1); /* shift tail up by one */ + new (l.ptr() + j1) T(m); return j1; } -template Ulong find(const List& l, const T& m) +template +Ulong find(const List &l, const T &m) /* Finds the index of m in the list. If m is not found, returns not_found. @@ -491,8 +505,8 @@ template Ulong find(const List& l, const T& m) { Ulong j0 = ~0L; - for (Ulong j1 = l.size(); j1-j0 > 1;) { - Ulong j = j0 + (j1-j0)/2; + for (Ulong j1 = l.size(); j1 - j0 > 1;) { + Ulong j = j0 + (j1 - j0) / 2; if (l[j] == m) /* m was found */ return j; if (l[j] < m) @@ -504,7 +518,7 @@ template Ulong find(const List& l, const T& m) return not_found; } -}; +}; // namespace list /************************************************************************** @@ -518,7 +532,8 @@ template Ulong find(const List& l, const T& m) namespace list { -template void print(FILE* file, const List& l) +template +void print(FILE *file, const List &l) /* Rudimentary print function for lists. It assumes that print(FILE*,T) is @@ -527,10 +542,10 @@ template void print(FILE* file, const List& l) { for (Ulong j = 0; j < l.size(); ++j) { - print(file,l[j]); - if (j+1 < l.size()) /* more to come */ - fprintf(file,","); + print(file, l[j]); + if (j + 1 < l.size()) /* more to come */ + fprintf(file, ","); } } -}; +}; // namespace list diff --git a/main.cpp b/main.cpp index ccccf18..f2f847a 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ Free Software Foundation 675 Mass. Ave., Cambridge, MA 02139, USA - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which @@ -128,7 +128,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -150,7 +150,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS */ #include "constants.h" @@ -158,9 +158,9 @@ #include "version.h" namespace { - using namespace version; - void printVersion(); -}; +using namespace version; +void printVersion(); +}; // namespace int main() @@ -177,7 +177,6 @@ int main() exit(0); } - namespace { void printVersion() @@ -186,12 +185,13 @@ void printVersion() Prints an opening message and the version number. */ -{ +{ printf("This is %s version %s.\nEnter help if you need assistance,\ - carriage return to start the program.\n\n",NAME,VERSION); + carriage return to start the program.\n\n", + NAME, VERSION); return; } -}; +}; // namespace diff --git a/makefile b/makefile index d648ccf..23b60cb 100644 --- a/makefile +++ b/makefile @@ -28,6 +28,9 @@ cc = g++ all: coxeter #clean +format: + clang-format -i *.h *.cpp *.hpp + coxeter: $(objects) $(cc) -o coxeter $(objects) diff --git a/memory.cpp b/memory.cpp index 9c12bef..b5518cb 100644 --- a/memory.cpp +++ b/memory.cpp @@ -11,15 +11,15 @@ #include "error.h" namespace memory { - using namespace error; +using namespace error; }; namespace { - using namespace memory; - const Ulong MEMORY_MAX = ULONG_MAX; - const Ulong ABYTES = sizeof(Align); - const Ulong ARENA_BITS = 16; -}; +using namespace memory; +const Ulong MEMORY_MAX = ULONG_MAX; +const Ulong ABYTES = sizeof(Align); +const Ulong ARENA_BITS = 16; +}; // namespace /**************************************************************************** @@ -52,7 +52,7 @@ namespace memory { /** Return the memory arena. */ -Arena& arena() { +Arena &arena() { static Arena a(ARENA_BITS); return a; } @@ -64,9 +64,9 @@ Arena& arena() { ****************************************************************************/ Arena::Arena(Ulong bsBits) { - memset(d_list,0,BITS(Ulong)*sizeof(void *)); - memset(d_used,0,BITS(Ulong)*sizeof(Ulong)); - memset(d_allocated,0,BITS(Ulong)*sizeof(Ulong)); + memset(d_list, 0, BITS(Ulong) * sizeof(void *)); + memset(d_used, 0, BITS(Ulong) * sizeof(Ulong)); + memset(d_allocated, 0, BITS(Ulong) * sizeof(Ulong)); d_bsBits = bsBits; d_count = 0; } @@ -93,59 +93,59 @@ Arena::~Arena() {} using a bitmap of available blocks. */ void Arena::newBlock(unsigned b) { - for (unsigned j = b+1; j < BITS(Ulong); ++j) { + for (unsigned j = b + 1; j < BITS(Ulong); ++j) { if (d_list[j]) /* split this block up */ - { - Align *ptr = reinterpret_cast (d_list[j]); - d_list[j] = d_list[j]->next; - d_allocated[j]--; - for (unsigned i = b; i < j; ++i) { - d_list[i] = reinterpret_cast (ptr + (1L<next = reinterpret_cast (ptr); - d_list[b]->next->next = 0; - d_allocated[b]++; - return; + { + Align *ptr = reinterpret_cast(d_list[j]); + d_list[j] = d_list[j]->next; + d_allocated[j]--; + for (unsigned i = b; i < j; ++i) { + d_list[i] = reinterpret_cast(ptr + (1L << i)); + d_allocated[i]++; } + d_list[b]->next = reinterpret_cast(ptr); + d_list[b]->next->next = 0; + d_allocated[b]++; + return; + } } /* if we get here we need more memory from the system */ if (b >= d_bsBits) { /* get block directly */ - if (d_count > MEMORY_MAX-(1L< MEMORY_MAX - (1L << b)) { Error(OUT_OF_MEMORY); return; } - d_list[b] = static_cast (calloc(1L<(calloc(1L << b, ABYTES)); if (d_list[b] == 0) { Error(OUT_OF_MEMORY); return; } - d_count += 1L< MEMORY_MAX-(1L< MEMORY_MAX - (1L << d_bsBits)) { Error(OUT_OF_MEMORY); return; } - Align *ptr = static_cast (calloc(1L<(calloc(1L << d_bsBits, ABYTES)); if (ptr == 0) { Error(OUT_OF_MEMORY); return; } - d_count += 1L< (ptr + (1L<(ptr + (1L << j)); d_allocated[j]++; } - d_list[b]->next = reinterpret_cast (ptr); + d_list[b]->next = reinterpret_cast(ptr); d_allocated[b]++; return; @@ -159,8 +159,7 @@ void Arena::newBlock(unsigned b) { The memory is zero-initialized. */ -void* Arena::alloc(size_t n) -{ +void *Arena::alloc(size_t n) { if (n == 0) return 0; @@ -168,7 +167,7 @@ void* Arena::alloc(size_t n) unsigned b = 0; if (n > ABYTES) - b = lastBit(n-1)-lastbit[ABYTES]+1; + b = lastBit(n - 1) - lastbit[ABYTES] + 1; if (d_list[b] == 0) { /* need to make a new block */ newBlock(b); @@ -183,33 +182,31 @@ void* Arena::alloc(size_t n) block->next = 0; d_used[b]++; - return static_cast (block); + return static_cast(block); } /** Returns the size of the actual memory allocation provided on a request of n nodes of size m, in units of m */ -Ulong Arena::allocSize(Ulong n, Ulong m) const -{ +Ulong Arena::allocSize(Ulong n, Ulong m) const { if (n == 0) return 0; - if (n*m <= ABYTES) - return ABYTES/m; - return ((1 << lastBit(n*m-1)-lastbit[ABYTES]+1)*ABYTES)/m; + if (n * m <= ABYTES) + return ABYTES / m; + return ((1 << lastBit(n * m - 1) - lastbit[ABYTES] + 1) * ABYTES) / m; } /** Returns the actual number of bytes of the memory allocation (as opposed to allocSize, which rounds the allocation to the largest multiple of m.) */ -Ulong Arena::byteSize(Ulong n, Ulong m) const -{ +Ulong Arena::byteSize(Ulong n, Ulong m) const { if (n == 0) return 0; - if (n*m <= ABYTES) + if (n * m <= ABYTES) return ABYTES; - return (1 << lastBit(n*m-1)-lastbit[ABYTES]+1)*ABYTES; + return (1 << lastBit(n * m - 1) - lastbit[ABYTES] + 1) * ABYTES; } /** @@ -222,14 +219,13 @@ Ulong Arena::byteSize(Ulong n, Ulong m) const NOTE : equivalent to alloc if old_size = 0. */ -void *memory::Arena::realloc(void *ptr, size_t old_size, size_t new_size) -{ +void *memory::Arena::realloc(void *ptr, size_t old_size, size_t new_size) { void *new_ptr = alloc(new_size); if (ERRNO) /* overflow */ return 0; if (old_size) { - memcpy(new_ptr,ptr,old_size); - free(ptr,old_size); + memcpy(new_ptr, ptr, old_size); + free(ptr, old_size); } return new_ptr; @@ -240,8 +236,7 @@ void *memory::Arena::realloc(void *ptr, size_t old_size, size_t new_size) know to which list the pointer should be appended (it will in fact be prepended), we need to pass the size to which ptr was allocated. */ -void Arena::free(void *ptr, size_t n) -{ +void Arena::free(void *ptr, size_t n) { if (ptr == 0) return; if (n == 0) @@ -249,9 +244,9 @@ void Arena::free(void *ptr, size_t n) unsigned b = 0; if (n > ABYTES) - b = lastBit(n-1)-lastbit[ABYTES]+1; + b = lastBit(n - 1) - lastbit[ABYTES] + 1; - memset(ptr,0,(1L<next = d_list[b]; d_list[b] = block; @@ -263,22 +258,21 @@ void Arena::free(void *ptr, size_t n) /** Prints information about the memory arena. */ -void Arena::print(FILE *file) const -{ - fprintf(file,"%-10s%10s/%-10s\n","size : 2^","used","allocated"); +void Arena::print(FILE *file) const { + fprintf(file, "%-10s%10s/%-10s\n", "size : 2^", "used", "allocated"); Ulong used_count = 0; for (unsigned j = 0; j < BITS(Ulong); ++j) { - fprintf(file,"%3u%7s%10lu/%-10lu\n",j,"",d_used[j],d_allocated[j]); - used_count += (1L<(d_count),ABYTES); + fprintf(file, "\n"); + fprintf(file, "total : %10lu/%-10lu %lu-byte units used/allocated\n", + used_count, static_cast(d_count), ABYTES); } void pause() { ; } -} +} // namespace memory diff --git a/memory.h b/memory.h index c1e5314..63f7860 100644 --- a/memory.h +++ b/memory.h @@ -5,31 +5,31 @@ See file main.cpp for full copyright notice */ -#ifndef MEMORY_H /* guard against multiple inclusions */ +#ifndef MEMORY_H /* guard against multiple inclusions */ #define MEMORY_H #include "globals.h" #include "constants.h" namespace memory { - using namespace coxeter; - using namespace constants; +using namespace coxeter; +using namespace constants; /******** type declarations *************************************************/ - union Align; - class Arena; - class FixArena; -} +union Align; +class Arena; +class FixArena; +} // namespace memory /******** function declarations *********************************************/ -void* operator new (size_t size, memory::Arena& a); -void* operator new[] (size_t size, memory::Arena& a); +void *operator new(size_t size, memory::Arena &a); +void *operator new[](size_t size, memory::Arena &a); namespace memory { - Arena& arena(); - void pause(); +Arena &arena(); +void pause(); /******** Type definitions **************************************************/ @@ -39,42 +39,44 @@ union Align { }; class FixArena { - public: +public: }; class Arena { struct MemBlock { MemBlock *next; }; - MemBlock* d_list[sizeof(Ulong)*CHAR_BIT]; - Ulong d_used[sizeof(Ulong)*CHAR_BIT]; - Ulong d_allocated[sizeof(Ulong)*CHAR_BIT]; + MemBlock *d_list[sizeof(Ulong) * CHAR_BIT]; + Ulong d_used[sizeof(Ulong) * CHAR_BIT]; + Ulong d_allocated[sizeof(Ulong) * CHAR_BIT]; unsigned d_bsBits; unsigned d_count; void newBlock(unsigned b); - public: -/* constructors and destructors */ - void operator delete(void* ptr) - {arena().free(ptr,sizeof(Arena));} + +public: + /* constructors and destructors */ + void operator delete(void *ptr) { arena().free(ptr, sizeof(Arena)); } Arena(Ulong bsBits); ~Arena(); -/* modifiers */ + /* modifiers */ void *alloc(size_t n); void *realloc(void *ptr, size_t old_size, size_t new_size); void free(void *ptr, size_t n); -/* accessors */ + /* accessors */ Ulong allocSize(Ulong n, Ulong m) const; Ulong byteSize(Ulong n, Ulong m) const; - void print(FILE* file) const; + void print(FILE *file) const; }; -} +} // namespace memory /******** Inline implementations *****************************************/ -inline void* operator new(size_t size, memory::Arena& a) - {return a.alloc(size);} -inline void* operator new[](size_t size, memory::Arena& a) - {return a.alloc(size);} +inline void *operator new(size_t size, memory::Arena &a) { + return a.alloc(size); +} +inline void *operator new[](size_t size, memory::Arena &a) { + return a.alloc(size); +} #endif diff --git a/minroots.cpp b/minroots.cpp index 874b63d..137a6e0 100644 --- a/minroots.cpp +++ b/minroots.cpp @@ -1,6 +1,6 @@ /* This is minroots.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -8,54 +8,55 @@ #include "minroots.h" namespace { - using namespace minroots; +using namespace minroots; - const Ulong dihedral = MINNBR_MAX + 4; - const int first_dotval = locked; - const int first_negdotval = neg_cos; - const int dotval_size = 13; - const int dotval_negsize = 4; -}; +const Ulong dihedral = MINNBR_MAX + 4; +const int first_dotval = locked; +const int first_negdotval = neg_cos; +const int dotval_size = 13; +const int dotval_negsize = 4; +}; // namespace /* auxiliary classes */ namespace { - class InitMinTable:public MinTable - { - public: - InitMinTable() {}; - InitMinTable(CoxGraph& G); - MinNbr dihedralShift(MinNbr r, Generator s, Generator t, - Ulong c); - void initMinTable(CoxGraph& G); - void fillDepthOneRow(CoxGraph& G, MinNbr r, Generator s); - void fillDihedralRoots(CoxGraph& G); - void fillDihedralRow(CoxGraph& G, MinNbr r, Generator s, Length d); - void fillMinTable(CoxGraph& G); - void fillReflectionRow(CoxGraph& G, MinNbr r, Generator s); - void newDepthOneRoot(CoxGraph& G, MinNbr r, Generator s); - void newDepthTwoRoot(CoxGraph& G, MinNbr r, Generator s); - void newDihedralRoot(CoxGraph& G, MinNbr r, Generator s, Length d); - void newMinRoot(CoxGraph& G, MinNbr r, Generator s); - void setMinMemory(unsigned long n) {d_min.setSize(n); d_dot.setSize(n);} - inline MinNbr size() {return d_size;} - }; +class InitMinTable : public MinTable { +public: + InitMinTable(){}; + InitMinTable(CoxGraph &G); + MinNbr dihedralShift(MinNbr r, Generator s, Generator t, Ulong c); + void initMinTable(CoxGraph &G); + void fillDepthOneRow(CoxGraph &G, MinNbr r, Generator s); + void fillDihedralRoots(CoxGraph &G); + void fillDihedralRow(CoxGraph &G, MinNbr r, Generator s, Length d); + void fillMinTable(CoxGraph &G); + void fillReflectionRow(CoxGraph &G, MinNbr r, Generator s); + void newDepthOneRoot(CoxGraph &G, MinNbr r, Generator s); + void newDepthTwoRoot(CoxGraph &G, MinNbr r, Generator s); + void newDihedralRoot(CoxGraph &G, MinNbr r, Generator s, Length d); + void newMinRoot(CoxGraph &G, MinNbr r, Generator s); + void setMinMemory(unsigned long n) { + d_min.setSize(n); + d_dot.setSize(n); + } + inline MinNbr size() { return d_size; } +}; - DotVal bondCosineSum(CoxEntry m, int a, int b); +DotVal bondCosineSum(CoxEntry m, int a, int b); - DotVal *CS3; - DotVal *CS4; - DotVal *CS5; - DotVal *CS6; - DotVal *CSm; -}; +DotVal *CS3; +DotVal *CS4; +DotVal *CS5; +DotVal *CS6; +DotVal *CSm; +}; // namespace /*************************************************************************** This module implements a construction of the minimal root machine of - Brink and Howlett. We refer to Brink and Howlett's paper "A finiteness - property and an automatic structure for Coxeter groups", Math. Annalen 296 + Brink and Howlett. We refer to Brink and Howlett's paper "A finiteness + property and an automatic structure for Coxeter groups", Math. Annalen 296 (1993), pp. 179-190, for a description of the concept of a minimal root (called elementary roots by them), and a proof of their finiteness. See alos Casselman, ... , for a description of how this finite state @@ -87,9 +88,9 @@ namespace { interior component. The connected components of the complement of the interior component are in 1-1 correspondence with the exterior points in the bonds. So each of these components has a well-defined cyclotomy - attached to it. In this case, it turns out that there is a unique minimal - root with support I and all coefficients < 2; it has coefficient 1 on all - interior points, and coefficient c_m on all point of an exterior component + attached to it. In this case, it turns out that there is a unique minimal + root with support I and all coefficients < 2; it has coefficient 1 on all + interior points, and coefficient c_m on all point of an exterior component of cyclotomy m, where c_m = 2 cos(pi/m). This "basic root" r_I precedes all minimal roots with support I. @@ -127,7 +128,7 @@ namespace { - +- cos(pi/m) (denoted cos, neg_cos) : here cos should be interpreted as "a number in [sqrt(2)/2,1[" - +- (sqrt(5)-1)/4 (denoted hinvgold, neg_hinvgold), only when m = 5; - - +- cos(2 pi/m), (denoted cos2, neg_cos2), only when m > 6, + - +- cos(2 pi/m), (denoted cos2, neg_cos2), only when m > 6, where cos2 should be interpreted as "a number in ]1/2,cos[" - +- cos(k pi/m) (denoted undef_posdot, undef_negdot), only when m > 6, and only when the root is dihedral, where undef_posdot @@ -145,8 +146,8 @@ namespace { = + c(s,t) if s != t We will always assume in the sequel that is not already locked. - Then we need to do a formal evalution of the above. Now if t is in the - support of the root, and if we agree to treat interior points in all cases + Then we need to do a formal evalution of the above. Now if t is in the + support of the root, and if we agree to treat interior points in all cases as if they had cyclotomy five, then the results of Brink alluded to above show that in all cases the above computation can be done within the cyclotomy of s, i.e., we may compute : @@ -192,11 +193,11 @@ namespace { namespace { -class InitStaticConstants /* for initialization only! */ - { - public: - InitStaticConstants(); - }; +class InitStaticConstants /* for initialization only! */ +{ +public: + InitStaticConstants(); +}; InitStaticConstants::InitStaticConstants() @@ -216,346 +217,346 @@ InitStaticConstants::InitStaticConstants() */ { - CS3 = (DotVal *)memory::arena().alloc((dotval_negsize+1)*dotval_size* - sizeof(DotVal)); - CS4 = (DotVal *)memory::arena().alloc(dotval_negsize*dotval_size* - sizeof(DotVal)); - CS5 = (DotVal *)memory::arena().alloc(dotval_negsize*dotval_size* - sizeof(DotVal)); - CS6 = (DotVal *)memory::arena().alloc(dotval_negsize*dotval_size* - sizeof(DotVal)); - CSm = (DotVal *)memory::arena().alloc((dotval_negsize+1)*dotval_size* - sizeof(DotVal)); + CS3 = (DotVal *)memory::arena().alloc((dotval_negsize + 1) * dotval_size * + sizeof(DotVal)); + CS4 = (DotVal *)memory::arena().alloc(dotval_negsize * dotval_size * + sizeof(DotVal)); + CS5 = (DotVal *)memory::arena().alloc(dotval_negsize * dotval_size * + sizeof(DotVal)); + CS6 = (DotVal *)memory::arena().alloc(dotval_negsize * dotval_size * + sizeof(DotVal)); + CSm = (DotVal *)memory::arena().alloc((dotval_negsize + 1) * dotval_size * + sizeof(DotVal)); CS3 += dotval_size; CSm += dotval_size; - CS3[-13] = locked; /* locked - cos(*) */ - CS3[-12] = undef_dotval; /* undef_negdot - cos(*) : can't occur */ - CS3[-11] = locked; /* - cos - cos(*) */ - CS3[-10] = undef_dotval; /* - cos2 - cos(*) : can't occur */ - CS3[-9] = undef_dotval; /* - half - cos(*) : can't occur */ - CS3[-8] = undef_dotval; /* - hinvgold - cos(*) : can't occur */ - CS3[-7] = undef_dotval; /* zero - cos(*) : can't occur */ - CS3[-6] = undef_dotval; /* hinvgold - cos(*) : can't occur */ - CS3[-5] = neg_hinvgold; /* half - cos(*) : can't occur */ - CS3[-4] = undef_dotval; /* cos2 - cos(*) : can't occur */ - CS3[-3] = undef_dotval; /* cos - cos(*) : can't occur */ - CS3[-2] = undef_dotval; /* undef_posdot - cos(*) : can't occur */ - CS3[-1] = undef_dotval; /* one - cos(*) : can't occur */ - - CS3[0] = locked; /* locked - cos */ - CS3[1] = locked; /* undef_negdot - cos */ - CS3[2] = locked; /* - cos - cos */ - CS3[3] = locked; /* - cos2 - cos */ - CS3[4] = locked; /* - half - cos */ - CS3[5] = locked; /* - hinvgold - cos */ - CS3[6] = neg_cos; /* zero - cos */ - CS3[7] = neg_half; /* hinvgold - cos in cyclotomy 5 */ - CS3[8] = neg_hinvgold; /* half - cos in cyclotomy 5 */ - CS3[9] = undef_dotval; /* cos2 - cos : can't occur */ - CS3[10] = zero; /* cos - cos */ - CS3[11] = undef_dotval; /* undef_posdot - cos : can't occur */ - CS3[12] = undef_dotval; /* one - cos : can't occur */ - - CS3[13] = locked; /* locked - cos2 */ - CS3[14] = undef_dotval; /* undef_negdot - cos2 : can't occur */ - CS3[15] = locked; /* - cos - cos2 */ - CS3[16] = locked; /* - cos2 - cos2 */ - CS3[17] = locked; /* - half - cos2 */ - CS3[18] = undef_dotval; /* - hinvgold - cos2 : can't occur */ - CS3[19] = neg_cos2; /* zero - cos2 */ - CS3[20] = undef_dotval; /* hinvgold - cos2 : can't occur */ - CS3[21] = undef_dotval; /* half - cos2 : can't occur */ - CS3[22] = zero; /* cos2 - cos2 */ - CS3[23] = undef_dotval; /* cos - cos2 : can't occur*/ - CS3[24] = undef_dotval; /* undef_posdot - cos2 : can't occur */ - CS3[25] = undef_dotval; /* one - cos2 : can't occur */ - - CS3[26] = locked; /* locked - half */ - CS3[27] = undef_dotval; /* undef_negdot - half : can't occur */ - CS3[28] = locked; /* - cos - half */ - CS3[29] = locked; /* - cos2 - half */ - CS3[30] = locked; /* - half - half */ - CS3[31] = neg_cos; /* - hinvgold - half in cyclotomy 5 */ - CS3[32] = neg_half; /* zero - half */ - CS3[33] = undef_dotval; /* hinvgold - half : can't occur */ - CS3[34] = zero; /* half - half */ - CS3[35] = undef_dotval; /* cos2 - half : can't occur */ - CS3[36] = hinvgold; /* cos - half in cyclotomy 5 */ - CS3[37] = undef_dotval; /* undef_posdot - half : can't occur */ - CS3[38] = half; /* one - half */ - - CS3[39] = locked; /* locked - hinvgold */ - CS3[40] = undef_dotval; /* undef_negdot - hinvgold : can't occur */ - CS3[41] = locked; /* - cos - hinvgold */ - CS3[42] = locked; /* - cos2 - hinvgold : can't occur */ - CS3[43] = neg_cos; /* - half - hinvgold in cyclotomy 5 */ - CS3[44] = undef_dotval; /* - hinvgold - hinvgold : can't occur */ - CS3[45] = neg_hinvgold; /* zero - hinvgold */ - CS3[46] = zero; /* hinvgold - hinvgold */ - CS3[47] = undef_dotval; /* half - hinvgold : can't occur */ - CS3[48] = undef_dotval; /* cos2 - hinvgold : can't occur */ - CS3[49] = half; /* cos - hinvgold in cyclotomy 5 */ - CS3[50] = undef_dotval; /* undef_posdot - hinvgold : can't occur */ - CS3[51] = undef_dotval; /* one - hinvgold : can't occur */ + CS3[-13] = locked; /* locked - cos(*) */ + CS3[-12] = undef_dotval; /* undef_negdot - cos(*) : can't occur */ + CS3[-11] = locked; /* - cos - cos(*) */ + CS3[-10] = undef_dotval; /* - cos2 - cos(*) : can't occur */ + CS3[-9] = undef_dotval; /* - half - cos(*) : can't occur */ + CS3[-8] = undef_dotval; /* - hinvgold - cos(*) : can't occur */ + CS3[-7] = undef_dotval; /* zero - cos(*) : can't occur */ + CS3[-6] = undef_dotval; /* hinvgold - cos(*) : can't occur */ + CS3[-5] = neg_hinvgold; /* half - cos(*) : can't occur */ + CS3[-4] = undef_dotval; /* cos2 - cos(*) : can't occur */ + CS3[-3] = undef_dotval; /* cos - cos(*) : can't occur */ + CS3[-2] = undef_dotval; /* undef_posdot - cos(*) : can't occur */ + CS3[-1] = undef_dotval; /* one - cos(*) : can't occur */ + + CS3[0] = locked; /* locked - cos */ + CS3[1] = locked; /* undef_negdot - cos */ + CS3[2] = locked; /* - cos - cos */ + CS3[3] = locked; /* - cos2 - cos */ + CS3[4] = locked; /* - half - cos */ + CS3[5] = locked; /* - hinvgold - cos */ + CS3[6] = neg_cos; /* zero - cos */ + CS3[7] = neg_half; /* hinvgold - cos in cyclotomy 5 */ + CS3[8] = neg_hinvgold; /* half - cos in cyclotomy 5 */ + CS3[9] = undef_dotval; /* cos2 - cos : can't occur */ + CS3[10] = zero; /* cos - cos */ + CS3[11] = undef_dotval; /* undef_posdot - cos : can't occur */ + CS3[12] = undef_dotval; /* one - cos : can't occur */ + + CS3[13] = locked; /* locked - cos2 */ + CS3[14] = undef_dotval; /* undef_negdot - cos2 : can't occur */ + CS3[15] = locked; /* - cos - cos2 */ + CS3[16] = locked; /* - cos2 - cos2 */ + CS3[17] = locked; /* - half - cos2 */ + CS3[18] = undef_dotval; /* - hinvgold - cos2 : can't occur */ + CS3[19] = neg_cos2; /* zero - cos2 */ + CS3[20] = undef_dotval; /* hinvgold - cos2 : can't occur */ + CS3[21] = undef_dotval; /* half - cos2 : can't occur */ + CS3[22] = zero; /* cos2 - cos2 */ + CS3[23] = undef_dotval; /* cos - cos2 : can't occur*/ + CS3[24] = undef_dotval; /* undef_posdot - cos2 : can't occur */ + CS3[25] = undef_dotval; /* one - cos2 : can't occur */ + + CS3[26] = locked; /* locked - half */ + CS3[27] = undef_dotval; /* undef_negdot - half : can't occur */ + CS3[28] = locked; /* - cos - half */ + CS3[29] = locked; /* - cos2 - half */ + CS3[30] = locked; /* - half - half */ + CS3[31] = neg_cos; /* - hinvgold - half in cyclotomy 5 */ + CS3[32] = neg_half; /* zero - half */ + CS3[33] = undef_dotval; /* hinvgold - half : can't occur */ + CS3[34] = zero; /* half - half */ + CS3[35] = undef_dotval; /* cos2 - half : can't occur */ + CS3[36] = hinvgold; /* cos - half in cyclotomy 5 */ + CS3[37] = undef_dotval; /* undef_posdot - half : can't occur */ + CS3[38] = half; /* one - half */ + + CS3[39] = locked; /* locked - hinvgold */ + CS3[40] = undef_dotval; /* undef_negdot - hinvgold : can't occur */ + CS3[41] = locked; /* - cos - hinvgold */ + CS3[42] = locked; /* - cos2 - hinvgold : can't occur */ + CS3[43] = neg_cos; /* - half - hinvgold in cyclotomy 5 */ + CS3[44] = undef_dotval; /* - hinvgold - hinvgold : can't occur */ + CS3[45] = neg_hinvgold; /* zero - hinvgold */ + CS3[46] = zero; /* hinvgold - hinvgold */ + CS3[47] = undef_dotval; /* half - hinvgold : can't occur */ + CS3[48] = undef_dotval; /* cos2 - hinvgold : can't occur */ + CS3[49] = half; /* cos - hinvgold in cyclotomy 5 */ + CS3[50] = undef_dotval; /* undef_posdot - hinvgold : can't occur */ + CS3[51] = undef_dotval; /* one - hinvgold : can't occur */ /* the matrix CS4 gives a + 2 cos.b, for b < 0, assuming cyclotomy 4, i.e., cos^2 = 1/2 */ - CS4[0] = locked; /* locked - sqrt(2).cos */ - CS4[1] = undef_dotval; /* undef_negdot - sqrt(2).cos : can't occur */ - CS4[2] = locked; /* - cos - sqrt(2).cos */ - CS4[3] = locked; /* - cos2 - sqrt(2).cos */ - CS4[4] = locked; /* - half - sqrt(2).cos */ - CS4[5] = locked; /* - hinvgold - sqrt(2).cos */ - CS4[6] = locked; /* zero - sqrt(2).cos */ - CS4[7] = undef_dotval; /* hinvgold - sqrt(2).cos : can't occur */ - CS4[8] = neg_half; /* half - sqrt(2).cos */ - CS4[9] = undef_dotval; /* cos2 - sqrt(2).cos : can't occur */ - CS4[10] = undef_dotval; /* cos - sqrt(2).cos : can't occur */ - CS4[11] = undef_dotval; /* undef_posdot - sqrt(2).cos : can't occur */ - CS4[12] = zero; /* one - sqrt(2).cos */ - - CS4[13] = locked; /* locked - sqrt(2).cos2 */ - CS4[14] = undef_dotval; /* undef_negdot - sqrt(2).cos2 : can't occur */ - CS4[15] = locked; /* - cos - sqrt(2).cos2 */ - CS4[16] = locked; /* - cos2 - sqrt(2).cos2 : can't occur */ - CS4[17] = locked; /* - half - sqrt(2).cos2 */ - CS4[18] = locked; /* - hinvgold - sqrt(2).cos2 : can't occur */ - CS4[19] = locked; /* zero - sqrt(2).cos2 */ - CS4[20] = undef_dotval; /* hinvgold - sqrt(2).cos2 : can't occur */ - CS4[21] = undef_dotval; /* half - sqrt(2).cos2 : can't occur */ - CS4[22] = undef_dotval; /* cos2 - sqrt(2).cos2 : can't occur */ - CS4[23] = undef_dotval; /* cos - sqrt(2).cos2 : can't occur */ - CS4[24] = undef_dotval; /* undef_posdot - sqrt(2).cos2 : can't occur */ - CS4[25] = undef_dotval; /* one - sqrt(2).cos2 : can't occur */ - - CS4[26] = locked; /* locked - sqrt(2).half */ - CS4[27] = undef_dotval; /* undef_negdot - sqrt(2).half : can't occur */ - CS4[28] = locked; /* - cos - sqrt(2).half */ - CS4[29] = locked; /* - cos2 - sqrt(2).half */ - CS4[30] = locked; /* - half - sqrt(2).half */ - CS4[31] = undef_dotval; /* - hinvgold - sqrt(2).half : can't occur */ - CS4[32] = neg_cos; /* zero - sqrt(2).half */ - CS4[33] = undef_dotval; /* hinvgold - sqrt(2).half : can't occur */ - CS4[34] = undef_dotval; /* half - sqrt(2).half : can't occur */ - CS4[35] = undef_dotval; /* cos2 - sqrt(2).half : can't occur */ - CS4[36] = zero; /* cos - sqrt(2).half */ - CS4[37] = undef_dotval; /* undef_posdot - sqrt(2).half : can't occur */ - CS4[38] = undef_dotval; /* one - sqrt(2).half : can't occur */ - - CS4[39] = locked; /* locked - sqrt(2).hinvgold */ - CS4[40] = undef_dotval; /* undef_negdot - sqrt(2).hinvgold : can't occur */ - CS4[41] = locked; /* - cos - sqrt(2).hinvgold */ - CS4[42] = locked; /* - cos2 - sqrt(2).hinvgold : can't occur */ - CS4[43] = neg_cos; /* - half - sqrt(2).hinvgold in cyclotomy 5 */ - CS4[44] = undef_dotval; /* - hinvgold - sqrt(2).hinvgold : can't occur */ - CS4[45] = neg_hinvgold; /* zero - sqrt(2).hinvgold */ - CS4[46] = zero; /* hinvgold - sqrt(2).hinvgold */ - CS4[47] = undef_dotval; /* half - sqrt(2).hinvgold : can't occur */ - CS4[48] = undef_dotval; /* cos2 - sqrt(2).hinvgold : can't occur */ - CS4[49] = half; /* cos - sqrt(2).hinvgold in cyclotomy 5 */ - CS4[50] = undef_dotval; /* undef_posdot - sqrt(2).hinvgold : can't occur */ - CS4[51] = undef_dotval; /* one - sqrt(2).hinvgold : can't occur */ + CS4[0] = locked; /* locked - sqrt(2).cos */ + CS4[1] = undef_dotval; /* undef_negdot - sqrt(2).cos : can't occur */ + CS4[2] = locked; /* - cos - sqrt(2).cos */ + CS4[3] = locked; /* - cos2 - sqrt(2).cos */ + CS4[4] = locked; /* - half - sqrt(2).cos */ + CS4[5] = locked; /* - hinvgold - sqrt(2).cos */ + CS4[6] = locked; /* zero - sqrt(2).cos */ + CS4[7] = undef_dotval; /* hinvgold - sqrt(2).cos : can't occur */ + CS4[8] = neg_half; /* half - sqrt(2).cos */ + CS4[9] = undef_dotval; /* cos2 - sqrt(2).cos : can't occur */ + CS4[10] = undef_dotval; /* cos - sqrt(2).cos : can't occur */ + CS4[11] = undef_dotval; /* undef_posdot - sqrt(2).cos : can't occur */ + CS4[12] = zero; /* one - sqrt(2).cos */ + + CS4[13] = locked; /* locked - sqrt(2).cos2 */ + CS4[14] = undef_dotval; /* undef_negdot - sqrt(2).cos2 : can't occur */ + CS4[15] = locked; /* - cos - sqrt(2).cos2 */ + CS4[16] = locked; /* - cos2 - sqrt(2).cos2 : can't occur */ + CS4[17] = locked; /* - half - sqrt(2).cos2 */ + CS4[18] = locked; /* - hinvgold - sqrt(2).cos2 : can't occur */ + CS4[19] = locked; /* zero - sqrt(2).cos2 */ + CS4[20] = undef_dotval; /* hinvgold - sqrt(2).cos2 : can't occur */ + CS4[21] = undef_dotval; /* half - sqrt(2).cos2 : can't occur */ + CS4[22] = undef_dotval; /* cos2 - sqrt(2).cos2 : can't occur */ + CS4[23] = undef_dotval; /* cos - sqrt(2).cos2 : can't occur */ + CS4[24] = undef_dotval; /* undef_posdot - sqrt(2).cos2 : can't occur */ + CS4[25] = undef_dotval; /* one - sqrt(2).cos2 : can't occur */ + + CS4[26] = locked; /* locked - sqrt(2).half */ + CS4[27] = undef_dotval; /* undef_negdot - sqrt(2).half : can't occur */ + CS4[28] = locked; /* - cos - sqrt(2).half */ + CS4[29] = locked; /* - cos2 - sqrt(2).half */ + CS4[30] = locked; /* - half - sqrt(2).half */ + CS4[31] = undef_dotval; /* - hinvgold - sqrt(2).half : can't occur */ + CS4[32] = neg_cos; /* zero - sqrt(2).half */ + CS4[33] = undef_dotval; /* hinvgold - sqrt(2).half : can't occur */ + CS4[34] = undef_dotval; /* half - sqrt(2).half : can't occur */ + CS4[35] = undef_dotval; /* cos2 - sqrt(2).half : can't occur */ + CS4[36] = zero; /* cos - sqrt(2).half */ + CS4[37] = undef_dotval; /* undef_posdot - sqrt(2).half : can't occur */ + CS4[38] = undef_dotval; /* one - sqrt(2).half : can't occur */ + + CS4[39] = locked; /* locked - sqrt(2).hinvgold */ + CS4[40] = undef_dotval; /* undef_negdot - sqrt(2).hinvgold : can't occur */ + CS4[41] = locked; /* - cos - sqrt(2).hinvgold */ + CS4[42] = locked; /* - cos2 - sqrt(2).hinvgold : can't occur */ + CS4[43] = neg_cos; /* - half - sqrt(2).hinvgold in cyclotomy 5 */ + CS4[44] = undef_dotval; /* - hinvgold - sqrt(2).hinvgold : can't occur */ + CS4[45] = neg_hinvgold; /* zero - sqrt(2).hinvgold */ + CS4[46] = zero; /* hinvgold - sqrt(2).hinvgold */ + CS4[47] = undef_dotval; /* half - sqrt(2).hinvgold : can't occur */ + CS4[48] = undef_dotval; /* cos2 - sqrt(2).hinvgold : can't occur */ + CS4[49] = half; /* cos - sqrt(2).hinvgold in cyclotomy 5 */ + CS4[50] = undef_dotval; /* undef_posdot - sqrt(2).hinvgold : can't occur */ + CS4[51] = undef_dotval; /* one - sqrt(2).hinvgold : can't occur */ /* the matrix CS5 gives a + 2 cos.b, for b < 0, assuming cyclotomy 5, i.e., cos = hinvgold + half, 2 cos.cos = cos + half, 2 cos.hinvgold = half */ - CS5[0] = locked; /* locked - 2 cos.cos */ - CS5[1] = undef_dotval; /* undef_negdot - 2 cos.cos : can't occur */ - CS5[2] = locked; /* - cos - 2 cos.cos */ - CS5[3] = locked; /* - cos2 - 2 cos.cos */ - CS5[4] = locked; /* - half - 2 cos.cos */ - CS5[5] = locked; /* - hinvgold - 2 cos.cos */ - CS5[6] = locked; /* zero - 2 cos.cos */ - CS5[7] = locked; /* hinvgold - 2 cos.cos in cyclotomy 5 */ - CS5[8] = neg_cos; /* half - 2 cos.cos in cyclotomy 5 */ - CS5[9] = undef_dotval; /* cos2 - 2 cos.cos : can't occur */ - CS5[10] = neg_half; /* cos - 2 cos.cos in cyclotomy 5 */ - CS5[11] = undef_dotval; /* undef_posdot - 2 cos.cos : can't occur */ - CS5[12] = neg_hinvgold; /* one - 2 cos.cos in cyclotomy 5 */ - - CS5[13] = locked; /* locked - 2 cos.cos2 */ - CS5[14] = undef_dotval; /* undef_negdot - 2 cos.cos2 : can't occur */ - CS5[15] = locked; /* - cos - 2 cos.cos2 */ - CS5[16] = locked; /* - cos2 - 2 cos.cos2 */ - CS5[17] = locked; /* - half - 2 cos.cos2 */ - CS5[18] = locked; /* - hinvgold - 2 cos.cos2 : can't occur */ - CS5[19] = locked; /* zero - 2 cos.cos2 */ - CS5[20] = undef_dotval; /* hinvgold - 2 cos.cos2 : can't occur */ - CS5[21] = undef_dotval; /* half - 2 cos.cos2 : can't occur */ - CS5[22] = undef_dotval; /* cos2 - 2 cos.cos2 */ - CS5[23] = undef_dotval; /* cos - 2 cos.cos2 : can't occur*/ - CS5[24] = undef_dotval; /* undef_posdot - 2 cos.cos2 : can't occur */ - CS5[25] = undef_dotval; /* one - 2 cos.cos2 : can't occur */ - - CS5[26] = locked; /* locked - cos */ - CS5[27] = undef_dotval; /* undef_negdot - cos : can't occur */ - CS5[28] = locked; /* - cos - cos */ - CS5[29] = locked; /* - cos2 - cos */ - CS5[30] = locked; /* - half - cos */ - CS5[31] = locked; /* - hinvgold - cos = - sqrt(5)/2 < -1 */ - CS5[32] = neg_cos; /* zero - cos */ - CS5[33] = neg_half; /* hinvgold - cos */ - CS5[34] = neg_hinvgold; /* half - cos */ - CS5[35] = undef_dotval; /* cos2 - cos : can't occur */ - CS5[36] = zero; /* cos - cos */ - CS5[37] = undef_dotval; /* undef_posdot - cos : can't occur */ - CS5[38] = undef_dotval; /* one - cos : can't occur */ - - CS5[39] = locked; /* locked - half */ - CS5[40] = undef_dotval; /* undef_negdot - half : can't occur */ - CS5[41] = locked; /* - cos - half */ - CS5[42] = locked; /* - cos2 - half : can't occur */ - CS5[43] = locked; /* - half - half */ - CS5[44] = neg_cos; /* - hinvgold - half */ - CS5[45] = neg_half; /* zero - half */ - CS5[46] = undef_dotval; /* hinvgold - half : can't occur*/ - CS5[47] = zero; /* half - half */ - CS5[48] = undef_dotval; /* cos2 - half : can't occur */ - CS5[49] = hinvgold; /* cos - half in cyclotomy 5 */ - CS5[50] = undef_dotval; /* undef_posdot - half : can't occur */ - CS5[51] = half; /* one - half */ + CS5[0] = locked; /* locked - 2 cos.cos */ + CS5[1] = undef_dotval; /* undef_negdot - 2 cos.cos : can't occur */ + CS5[2] = locked; /* - cos - 2 cos.cos */ + CS5[3] = locked; /* - cos2 - 2 cos.cos */ + CS5[4] = locked; /* - half - 2 cos.cos */ + CS5[5] = locked; /* - hinvgold - 2 cos.cos */ + CS5[6] = locked; /* zero - 2 cos.cos */ + CS5[7] = locked; /* hinvgold - 2 cos.cos in cyclotomy 5 */ + CS5[8] = neg_cos; /* half - 2 cos.cos in cyclotomy 5 */ + CS5[9] = undef_dotval; /* cos2 - 2 cos.cos : can't occur */ + CS5[10] = neg_half; /* cos - 2 cos.cos in cyclotomy 5 */ + CS5[11] = undef_dotval; /* undef_posdot - 2 cos.cos : can't occur */ + CS5[12] = neg_hinvgold; /* one - 2 cos.cos in cyclotomy 5 */ + + CS5[13] = locked; /* locked - 2 cos.cos2 */ + CS5[14] = undef_dotval; /* undef_negdot - 2 cos.cos2 : can't occur */ + CS5[15] = locked; /* - cos - 2 cos.cos2 */ + CS5[16] = locked; /* - cos2 - 2 cos.cos2 */ + CS5[17] = locked; /* - half - 2 cos.cos2 */ + CS5[18] = locked; /* - hinvgold - 2 cos.cos2 : can't occur */ + CS5[19] = locked; /* zero - 2 cos.cos2 */ + CS5[20] = undef_dotval; /* hinvgold - 2 cos.cos2 : can't occur */ + CS5[21] = undef_dotval; /* half - 2 cos.cos2 : can't occur */ + CS5[22] = undef_dotval; /* cos2 - 2 cos.cos2 */ + CS5[23] = undef_dotval; /* cos - 2 cos.cos2 : can't occur*/ + CS5[24] = undef_dotval; /* undef_posdot - 2 cos.cos2 : can't occur */ + CS5[25] = undef_dotval; /* one - 2 cos.cos2 : can't occur */ + + CS5[26] = locked; /* locked - cos */ + CS5[27] = undef_dotval; /* undef_negdot - cos : can't occur */ + CS5[28] = locked; /* - cos - cos */ + CS5[29] = locked; /* - cos2 - cos */ + CS5[30] = locked; /* - half - cos */ + CS5[31] = locked; /* - hinvgold - cos = - sqrt(5)/2 < -1 */ + CS5[32] = neg_cos; /* zero - cos */ + CS5[33] = neg_half; /* hinvgold - cos */ + CS5[34] = neg_hinvgold; /* half - cos */ + CS5[35] = undef_dotval; /* cos2 - cos : can't occur */ + CS5[36] = zero; /* cos - cos */ + CS5[37] = undef_dotval; /* undef_posdot - cos : can't occur */ + CS5[38] = undef_dotval; /* one - cos : can't occur */ + + CS5[39] = locked; /* locked - half */ + CS5[40] = undef_dotval; /* undef_negdot - half : can't occur */ + CS5[41] = locked; /* - cos - half */ + CS5[42] = locked; /* - cos2 - half : can't occur */ + CS5[43] = locked; /* - half - half */ + CS5[44] = neg_cos; /* - hinvgold - half */ + CS5[45] = neg_half; /* zero - half */ + CS5[46] = undef_dotval; /* hinvgold - half : can't occur*/ + CS5[47] = zero; /* half - half */ + CS5[48] = undef_dotval; /* cos2 - half : can't occur */ + CS5[49] = hinvgold; /* cos - half in cyclotomy 5 */ + CS5[50] = undef_dotval; /* undef_posdot - half : can't occur */ + CS5[51] = half; /* one - half */ /* the matrix CS6 gives a + sqrt(3).b, for b < 0, assuming cyclotomy 6, i.e., cos^2 = 3/2 */ - CS6[0] = locked; /* locked - sqrt(3).cos */ - CS6[1] = undef_dotval; /* undef_negdot - sqrt(3).cos : can't occur */ - CS6[2] = locked; /* - cos - sqrt(3).cos */ - CS6[3] = locked; /* - cos2 - sqrt(3).cos */ - CS6[4] = locked; /* - half - sqrt(3).cos */ - CS6[5] = locked; /* - hinvgold - sqrt(3).cos */ - CS6[6] = locked; /* zero - sqrt(3).cos */ - CS6[7] = undef_dotval; /* hinvgold - sqrt(3).cos : can't occur */ - CS6[8] = locked; /* half - sqrt(3).cos in cyclotomy 6 */ - CS6[9] = undef_dotval; /* cos2 - sqrt(3).cos : can't occur */ - CS6[10] = undef_dotval; /* cos - sqrt(3).cos : can't occur */ - CS6[11] = undef_dotval; /* undef_posdot - sqrt(3).cos : can't occur */ - CS6[12] = neg_half; /* one - sqrt(3).cos in cyclotomy 6*/ - - CS6[13] = locked; /* locked - sqrt(3).cos2 */ - CS6[14] = undef_dotval; /* undef_negdot - sqrt(3).cos2 : can't occur */ - CS6[15] = locked; /* - cos - sqrt(3).cos2 */ - CS6[16] = locked; /* - cos2 - sqrt(3).cos2 */ - CS6[17] = locked; /* - half - sqrt(3).cos2 */ - CS6[18] = locked; /* - hinvgold - sqrt(3).cos2 */ - CS6[19] = locked; /* zero - sqrt(3).cos2 */ - CS6[20] = undef_dotval; /* hinvgold - sqrt(3).cos2 : can't occur */ - CS6[21] = undef_dotval; /* half - sqrt(3).cos2 : can't occur */ - CS6[22] = undef_dotval; /* cos2 - sqrt(3).cos2 : can't occur */ - CS6[23] = undef_dotval; /* cos - sqrt(3).cos2 : can't occur*/ - CS6[24] = undef_dotval; /* undef_posdot - sqrt(3).cos2 : can't occur */ - CS6[25] = undef_dotval; /* one - sqrt(3).cos2 : can't occur */ - - CS6[26] = locked; /* locked - sqrt(3).half */ - CS6[27] = undef_dotval; /* undef_negdot - sqrt(3).half : can't occur */ - CS6[28] = locked; /* - cos - sqrt(3).half */ - CS6[29] = locked; /* - cos2 - sqrt(3).half */ - CS6[30] = locked; /* - half - sqrt(3).half */ - CS6[31] = locked; /* - hinvgold - sqrt(3).half */ - CS6[32] = neg_cos; /* zero - sqrt(3).half */ - CS6[33] = undef_dotval; /* hinvgold - sqrt(3).half : can't occur */ - CS6[34] = undef_dotval; /* half - sqrt(3).half : can't occur */ - CS6[35] = undef_dotval; /* cos2 - sqrt(3).half : can't occur */ - CS6[36] = zero; /* cos - sqrt(3).half in cyclotomy 6 */ - CS6[37] = undef_dotval; /* undef_posdot - sqrt(3).half : can't occur */ - CS6[38] = undef_dotval; /* one - sqrt(3).half : can't occur */ - - CS6[39] = locked; /* locked - sqrt(3).hinvgold */ - CS6[40] = undef_dotval; /* undef_negdot - sqrt(3).hinvgold : can't occur */ - CS6[41] = locked; /* - cos - sqrt(3).hinvgold */ - CS6[42] = locked; /* - cos2 - sqrt(3).hinvgold */ - CS6[43] = locked; /* - half - sqrt(3).hinvgold */ - CS6[44] = undef_dotval; /* - hinvgold - sqrt(3).hinvgold : can't occur */ - CS6[45] = undef_dotval; /* zero - sqrt(3).hinvgold : can't occur */ - CS6[46] = undef_dotval; /* hinvgold - sqrt(3).hinvgold : can't occur*/ - CS6[47] = undef_dotval; /* half - sqrt(3).hinvgold : can't occur */ - CS6[48] = undef_dotval; /* cos2 - sqrt(3).hinvgold : can't occur */ - CS6[49] = undef_dotval; /* cos - sqrt(3).hinvgold : can't occur */ - CS6[50] = undef_dotval; /* undef_posdot - sqrt(3).hinvgold : can't occur */ - CS6[51] = undef_dotval; /* one - sqrt(3).hinvgold : can't occur */ - - /* the matrix CSm gives a + 2 2 cos.b, for b < 0, assuming cyclotomy m > 6 + CS6[0] = locked; /* locked - sqrt(3).cos */ + CS6[1] = undef_dotval; /* undef_negdot - sqrt(3).cos : can't occur */ + CS6[2] = locked; /* - cos - sqrt(3).cos */ + CS6[3] = locked; /* - cos2 - sqrt(3).cos */ + CS6[4] = locked; /* - half - sqrt(3).cos */ + CS6[5] = locked; /* - hinvgold - sqrt(3).cos */ + CS6[6] = locked; /* zero - sqrt(3).cos */ + CS6[7] = undef_dotval; /* hinvgold - sqrt(3).cos : can't occur */ + CS6[8] = locked; /* half - sqrt(3).cos in cyclotomy 6 */ + CS6[9] = undef_dotval; /* cos2 - sqrt(3).cos : can't occur */ + CS6[10] = undef_dotval; /* cos - sqrt(3).cos : can't occur */ + CS6[11] = undef_dotval; /* undef_posdot - sqrt(3).cos : can't occur */ + CS6[12] = neg_half; /* one - sqrt(3).cos in cyclotomy 6*/ + + CS6[13] = locked; /* locked - sqrt(3).cos2 */ + CS6[14] = undef_dotval; /* undef_negdot - sqrt(3).cos2 : can't occur */ + CS6[15] = locked; /* - cos - sqrt(3).cos2 */ + CS6[16] = locked; /* - cos2 - sqrt(3).cos2 */ + CS6[17] = locked; /* - half - sqrt(3).cos2 */ + CS6[18] = locked; /* - hinvgold - sqrt(3).cos2 */ + CS6[19] = locked; /* zero - sqrt(3).cos2 */ + CS6[20] = undef_dotval; /* hinvgold - sqrt(3).cos2 : can't occur */ + CS6[21] = undef_dotval; /* half - sqrt(3).cos2 : can't occur */ + CS6[22] = undef_dotval; /* cos2 - sqrt(3).cos2 : can't occur */ + CS6[23] = undef_dotval; /* cos - sqrt(3).cos2 : can't occur*/ + CS6[24] = undef_dotval; /* undef_posdot - sqrt(3).cos2 : can't occur */ + CS6[25] = undef_dotval; /* one - sqrt(3).cos2 : can't occur */ + + CS6[26] = locked; /* locked - sqrt(3).half */ + CS6[27] = undef_dotval; /* undef_negdot - sqrt(3).half : can't occur */ + CS6[28] = locked; /* - cos - sqrt(3).half */ + CS6[29] = locked; /* - cos2 - sqrt(3).half */ + CS6[30] = locked; /* - half - sqrt(3).half */ + CS6[31] = locked; /* - hinvgold - sqrt(3).half */ + CS6[32] = neg_cos; /* zero - sqrt(3).half */ + CS6[33] = undef_dotval; /* hinvgold - sqrt(3).half : can't occur */ + CS6[34] = undef_dotval; /* half - sqrt(3).half : can't occur */ + CS6[35] = undef_dotval; /* cos2 - sqrt(3).half : can't occur */ + CS6[36] = zero; /* cos - sqrt(3).half in cyclotomy 6 */ + CS6[37] = undef_dotval; /* undef_posdot - sqrt(3).half : can't occur */ + CS6[38] = undef_dotval; /* one - sqrt(3).half : can't occur */ + + CS6[39] = locked; /* locked - sqrt(3).hinvgold */ + CS6[40] = undef_dotval; /* undef_negdot - sqrt(3).hinvgold : can't occur */ + CS6[41] = locked; /* - cos - sqrt(3).hinvgold */ + CS6[42] = locked; /* - cos2 - sqrt(3).hinvgold */ + CS6[43] = locked; /* - half - sqrt(3).hinvgold */ + CS6[44] = undef_dotval; /* - hinvgold - sqrt(3).hinvgold : can't occur */ + CS6[45] = undef_dotval; /* zero - sqrt(3).hinvgold : can't occur */ + CS6[46] = undef_dotval; /* hinvgold - sqrt(3).hinvgold : can't occur*/ + CS6[47] = undef_dotval; /* half - sqrt(3).hinvgold : can't occur */ + CS6[48] = undef_dotval; /* cos2 - sqrt(3).hinvgold : can't occur */ + CS6[49] = undef_dotval; /* cos - sqrt(3).hinvgold : can't occur */ + CS6[50] = undef_dotval; /* undef_posdot - sqrt(3).hinvgold : can't occur */ + CS6[51] = undef_dotval; /* one - sqrt(3).hinvgold : can't occur */ + + /* the matrix CSm gives a + 2 2 cos.b, for b < 0, assuming cyclotomy m > 6 we have the identities c_m.cos(pi/m) = cos(pi/m) + 1, c_m.cos(2pi/m) = cos(3pi/m) + cos(pi/m) and since cos(3pi/7) + cos(pi/7) = 1 + cos(2pi/7) > 2, c_m.cos(2pi/m) > 2 for all m > 6 */ - CSm[-13] = locked; /* locked - c_m.cos(*) */ - CSm[-12] = locked; /* undef_negdot - c_m.cos(*) */ - CSm[-11] = locked; /* - cos - c_m.cos(*) */ - CSm[-10] = locked; /* - cos2 - c_m.cos(*) */ - CSm[-9] = undef_dotval; /* - half - c_m.cos(*) : can't occur */ - CSm[-8] = undef_dotval; /* - hinvgold - c_m.cos(*) : can't occur */ - CSm[-7] = undef_dotval; /* zero - c_m.cos(*) : can't occur */ - CSm[-6] = undef_dotval; /* hinvgold - c_m.cos(*) : can't occur */ - CSm[-5] = undef_dotval; /* half - c_m.cos(*) : can't occur */ - CSm[-4] = undef_negdot; /* cos2 - c_m.cos(*) */ - CSm[-3] = undef_dotval; /* cos - c_m.cos(*) : can't occur*/ - CSm[-2] = undef_negdot; /* undef_posdot - c_m.cos(*) */ - CSm[-1] = undef_dotval; /* one - c_m.cos(*) : can't occur */ - - CSm[0] = locked; /* locked - c_m.cos */ - CSm[1] = undef_dotval; /* undef_negdot - c_m.cos : can't occur */ - CSm[2] = locked; /* - cos - c_m.cos */ - CSm[3] = locked; /* - cos2 - c_m.cos */ - CSm[4] = locked; /* - half - c_m.cos */ - CSm[5] = locked; /* - hinvgold - c_m.cos */ - CSm[6] = locked; /* zero - c_m.cos */ - CSm[7] = undef_dotval; /* hinvgold - c_m.cos : can't occur */ - CSm[8] = locked; /* half - c_m.cos */ - CSm[9] = locked; /* cos2 - c_m.cos = -1 */ - CSm[10] = undef_dotval; /* cos - c_m.cos : can't occur*/ - CSm[11] = undef_dotval; /* undef_posdot - c_m.cos : can't occur */ - CSm[12] = neg_cos2; /* one - c_m.cos */ - - CSm[13] = locked; /* locked - c_m.cos2 */ - CSm[14] = undef_dotval; /* undef_negdot - c_m.cos2 : can't occur */ - CSm[15] = locked; /* - cos - c_m.cos2 */ - CSm[16] = locked; /* - cos2 - c_m.cos2 */ - CSm[17] = locked; /* - half - c_m.cos2 */ - CSm[18] = locked; /* - hinvgold - c_m.cos2 */ - CSm[19] = locked; /* zero - c_m.cos2 */ - CSm[20] = undef_dotval; /* hinvgold - c_m.cos2 : can't occur */ - CSm[21] = undef_dotval; /* half - c_m.cos2 : can't occur */ - CSm[22] = locked; /* cos2 - c_m.cos2 : can't occur */ - CSm[23] = undef_negdot; /* cos - c_m.cos2 = -cos3 */ - CSm[24] = undef_dotval; /* undef_posdot - c_m.cos2 : can't occur */ - CSm[25] = undef_dotval; /* one - c_m.cos2 : can't occur */ - - CSm[26] = locked; /* locked - c_m.half */ - CSm[27] = undef_dotval; /* undef_negdot - c_m.half : can't occur */ - CSm[28] = locked; /* - cos - c_m.half */ - CSm[29] = locked; /* - cos2 - c_m.half */ - CSm[30] = locked; /* - half - c_m.half */ - CSm[31] = locked; /* - hinvgold - c_m.half */ - CSm[32] = neg_cos; /* zero - c_m.half */ - CSm[33] = undef_dotval; /* hinvgold - c_m.half : can't occur */ - CSm[34] = undef_dotval; /* half - c_m.half : can't occur */ - CSm[35] = undef_dotval; /* cos2 - c_m.half : can't occur */ - CSm[36] = zero; /* cos - c_m.half */ - CSm[37] = undef_dotval; /* undef_posdot - c_m.half : can't occur */ - CSm[38] = half; /* one - c_m.half : can't occur */ - - CSm[39] = locked; /* locked - c_m.hinvgold */ - CSm[40] = undef_dotval; /* undef_negdot - c_m.hinvgold : can't occur */ - CSm[41] = locked; /* - cos - c_m.hinvgold */ - CSm[42] = locked; /* - cos2 - c_m.hinvgold */ - CSm[43] = locked; /* - half - c_m.hinvgold */ - CSm[44] = undef_dotval; /* - hinvgold - c_m.hinvgold : can't occur */ - CSm[45] = undef_dotval; /* zero - c_m.hinvgold : can't occur */ - CSm[46] = undef_dotval; /* hinvgold - c_m.hinvgold : can't occur */ - CSm[47] = undef_dotval; /* half - c_m.hinvgold : can't occur */ - CSm[48] = undef_dotval; /* cos2 - c_m.hinvgold : can't occur */ - CSm[49] = undef_dotval; /* cos - c_m.hinvgold : can't occur */ - CSm[50] = undef_dotval; /* undef_posdot - c_m.hinvgold : can't occur */ - CSm[51] = undef_dotval; /* one - c_m.hinvgold : can't occur */ + CSm[-13] = locked; /* locked - c_m.cos(*) */ + CSm[-12] = locked; /* undef_negdot - c_m.cos(*) */ + CSm[-11] = locked; /* - cos - c_m.cos(*) */ + CSm[-10] = locked; /* - cos2 - c_m.cos(*) */ + CSm[-9] = undef_dotval; /* - half - c_m.cos(*) : can't occur */ + CSm[-8] = undef_dotval; /* - hinvgold - c_m.cos(*) : can't occur */ + CSm[-7] = undef_dotval; /* zero - c_m.cos(*) : can't occur */ + CSm[-6] = undef_dotval; /* hinvgold - c_m.cos(*) : can't occur */ + CSm[-5] = undef_dotval; /* half - c_m.cos(*) : can't occur */ + CSm[-4] = undef_negdot; /* cos2 - c_m.cos(*) */ + CSm[-3] = undef_dotval; /* cos - c_m.cos(*) : can't occur*/ + CSm[-2] = undef_negdot; /* undef_posdot - c_m.cos(*) */ + CSm[-1] = undef_dotval; /* one - c_m.cos(*) : can't occur */ + + CSm[0] = locked; /* locked - c_m.cos */ + CSm[1] = undef_dotval; /* undef_negdot - c_m.cos : can't occur */ + CSm[2] = locked; /* - cos - c_m.cos */ + CSm[3] = locked; /* - cos2 - c_m.cos */ + CSm[4] = locked; /* - half - c_m.cos */ + CSm[5] = locked; /* - hinvgold - c_m.cos */ + CSm[6] = locked; /* zero - c_m.cos */ + CSm[7] = undef_dotval; /* hinvgold - c_m.cos : can't occur */ + CSm[8] = locked; /* half - c_m.cos */ + CSm[9] = locked; /* cos2 - c_m.cos = -1 */ + CSm[10] = undef_dotval; /* cos - c_m.cos : can't occur*/ + CSm[11] = undef_dotval; /* undef_posdot - c_m.cos : can't occur */ + CSm[12] = neg_cos2; /* one - c_m.cos */ + + CSm[13] = locked; /* locked - c_m.cos2 */ + CSm[14] = undef_dotval; /* undef_negdot - c_m.cos2 : can't occur */ + CSm[15] = locked; /* - cos - c_m.cos2 */ + CSm[16] = locked; /* - cos2 - c_m.cos2 */ + CSm[17] = locked; /* - half - c_m.cos2 */ + CSm[18] = locked; /* - hinvgold - c_m.cos2 */ + CSm[19] = locked; /* zero - c_m.cos2 */ + CSm[20] = undef_dotval; /* hinvgold - c_m.cos2 : can't occur */ + CSm[21] = undef_dotval; /* half - c_m.cos2 : can't occur */ + CSm[22] = locked; /* cos2 - c_m.cos2 : can't occur */ + CSm[23] = undef_negdot; /* cos - c_m.cos2 = -cos3 */ + CSm[24] = undef_dotval; /* undef_posdot - c_m.cos2 : can't occur */ + CSm[25] = undef_dotval; /* one - c_m.cos2 : can't occur */ + + CSm[26] = locked; /* locked - c_m.half */ + CSm[27] = undef_dotval; /* undef_negdot - c_m.half : can't occur */ + CSm[28] = locked; /* - cos - c_m.half */ + CSm[29] = locked; /* - cos2 - c_m.half */ + CSm[30] = locked; /* - half - c_m.half */ + CSm[31] = locked; /* - hinvgold - c_m.half */ + CSm[32] = neg_cos; /* zero - c_m.half */ + CSm[33] = undef_dotval; /* hinvgold - c_m.half : can't occur */ + CSm[34] = undef_dotval; /* half - c_m.half : can't occur */ + CSm[35] = undef_dotval; /* cos2 - c_m.half : can't occur */ + CSm[36] = zero; /* cos - c_m.half */ + CSm[37] = undef_dotval; /* undef_posdot - c_m.half : can't occur */ + CSm[38] = half; /* one - c_m.half : can't occur */ + + CSm[39] = locked; /* locked - c_m.hinvgold */ + CSm[40] = undef_dotval; /* undef_negdot - c_m.hinvgold : can't occur */ + CSm[41] = locked; /* - cos - c_m.hinvgold */ + CSm[42] = locked; /* - cos2 - c_m.hinvgold */ + CSm[43] = locked; /* - half - c_m.hinvgold */ + CSm[44] = undef_dotval; /* - hinvgold - c_m.hinvgold : can't occur */ + CSm[45] = undef_dotval; /* zero - c_m.hinvgold : can't occur */ + CSm[46] = undef_dotval; /* hinvgold - c_m.hinvgold : can't occur */ + CSm[47] = undef_dotval; /* half - c_m.hinvgold : can't occur */ + CSm[48] = undef_dotval; /* cos2 - c_m.hinvgold : can't occur */ + CSm[49] = undef_dotval; /* cos - c_m.hinvgold : can't occur */ + CSm[50] = undef_dotval; /* undef_posdot - c_m.hinvgold : can't occur */ + CSm[51] = undef_dotval; /* one - c_m.hinvgold : can't occur */ return; } -}; +}; // namespace /**************************************************************************** @@ -565,7 +566,7 @@ InitStaticConstants::InitStaticConstants() construction of MinTable. NOTE : this looks a rather clumsy, and could probably be improved. - The problem is that the constructing functions need access to the + The problem is that the constructing functions need access to the representation, but we don't want them to be member functions. An alternative would be to make them private members. @@ -573,9 +574,9 @@ InitStaticConstants::InitStaticConstants() namespace { -InitMinTable::InitMinTable(CoxGraph& G) +InitMinTable::InitMinTable(CoxGraph &G) -{ +{ static InitStaticConstants a; d_rank = G.rank(); @@ -584,44 +585,43 @@ InitMinTable::InitMinTable(CoxGraph& G) return; } -void InitMinTable::initMinTable(CoxGraph& G) +void InitMinTable::initMinTable(CoxGraph &G) { d_min.setSize(rank()); d_dot.setSize(rank()); - d_min[0] = new(arena()) MinNbr[rank()*rank()]; - d_dot[0] = new(arena()) DotProduct[rank()*rank()]; + d_min[0] = new (arena()) MinNbr[rank() * rank()]; + d_dot[0] = new (arena()) DotProduct[rank() * rank()]; - for (Generator s = 1; s < rank(); s++) - { - d_dot[s] = d_dot[s-1] + rank(); - d_min[s] = d_min[s-1] + rank(); - } + for (Generator s = 1; s < rank(); s++) { + d_dot[s] = d_dot[s - 1] + rank(); + d_min[s] = d_min[s - 1] + rank(); + } for (MinNbr r = 0; r < rank(); r++) { for (Generator s = 0; s < rank(); s++) - switch (G.M(r,s)) { + switch (G.M(r, s)) { case 0: - d_dot[r][s] = locked; - d_min[r][s] = not_minimal; - break; + d_dot[r][s] = locked; + d_min[r][s] = not_minimal; + break; case 1: - d_dot[r][s] = dotval::one; - d_min[r][s] = not_positive; - break; + d_dot[r][s] = dotval::one; + d_min[r][s] = not_positive; + break; case 2: - d_dot[r][s] = zero; - d_min[r][s] = r; - break; + d_dot[r][s] = zero; + d_min[r][s] = r; + break; case 3: - d_dot[r][s] = neg_half; - d_min[r][s] = dihedral; - break; + d_dot[r][s] = neg_half; + d_min[r][s] = dihedral; + break; default: - d_dot[r][s] = neg_cos; - d_min[r][s] = dihedral; - break; + d_dot[r][s] = neg_cos; + d_min[r][s] = dihedral; + break; }; } @@ -630,8 +630,7 @@ void InitMinTable::initMinTable(CoxGraph& G) return; } -MinNbr InitMinTable::dihedralShift(MinNbr r, Generator s, Generator t, - Ulong c) +MinNbr InitMinTable::dihedralShift(MinNbr r, Generator s, Generator t, Ulong c) /* This function shifts r by stst... (c terms). @@ -644,9 +643,9 @@ MinNbr InitMinTable::dihedralShift(MinNbr r, Generator s, Generator t, u = s; for (j = 0; j < c; j++) { - if (min(r,u) >= undef_minnbr) - return min(r,u); - r = min(r,u); + if (min(r, u) >= undef_minnbr) + return min(r, u); + r = min(r, u); if (u == s) u = t; else @@ -656,24 +655,23 @@ MinNbr InitMinTable::dihedralShift(MinNbr r, Generator s, Generator t, return r; } - -void InitMinTable::fillDihedralRoots(CoxGraph& G) +void InitMinTable::fillDihedralRoots(CoxGraph &G) /* Assuming M has been initialized by InitMinTable, fills in the rows corresponding to the dihedral roots. */ -{ +{ MinNbr r = 0; /* fill in roots of depth 1 */ for (; r < rank(); ++r) { for (Generator s = 0; s < rank(); ++s) - if (min(r,s) == dihedral) { - newDepthOneRoot(G,r,s); - d_size++; + if (min(r, s) == dihedral) { + newDepthOneRoot(G, r, s); + d_size++; } } @@ -683,9 +681,9 @@ void InitMinTable::fillDihedralRoots(CoxGraph& G) for (; r < c; ++r) { for (Generator s = 0; s < rank(); ++s) - if (min(r,s) == dihedral) { - newDepthTwoRoot(G,r,s); - d_size++; + if (min(r, s) == dihedral) { + newDepthTwoRoot(G, r, s); + d_size++; } } @@ -695,39 +693,37 @@ void InitMinTable::fillDihedralRoots(CoxGraph& G) c = d_size; for (; r < c; ++r) { for (Generator s = 0; s < rank(); ++s) - if (min(r,s) == dihedral) { - newDihedralRoot(G,r,s,d); - d_size++; - } + if (min(r, s) == dihedral) { + newDihedralRoot(G, r, s, d); + d_size++; + } } } return; } - -void InitMinTable::fillDepthOneRow(CoxGraph& G, MinNbr r, Generator s) +void InitMinTable::fillDepthOneRow(CoxGraph &G, MinNbr r, Generator s) { - Generator u = min(r,s); - MinNbr* ps = d_min[s]; + Generator u = min(r, s); + MinNbr *ps = d_min[s]; for (Generator t = 0; t < rank(); t++) { if (t == s) continue; if (t == u) { /* t is the other element in the support */ - CoxEntry m = G.M(s,t); + CoxEntry m = G.M(s, t); if (m == 3) { /* descent */ - d_min[r][t] = s; - ps[t] = r; - } - else if (m == 4) /* commutation */ - d_min[r][t] = r; + d_min[r][t] = s; + ps[t] = r; + } else if (m == 4) /* commutation */ + d_min[r][t] = r; else - d_min[r][t] = dihedral; + d_min[r][t] = dihedral; continue; } - switch (dot(r,t)) { + switch (dot(r, t)) { case zero: d_min[r][t] = r; break; @@ -747,44 +743,42 @@ void InitMinTable::fillDepthOneRow(CoxGraph& G, MinNbr r, Generator s) return; } - -void InitMinTable::fillDihedralRow(CoxGraph& G, MinNbr r, Generator s, - Length d) +void InitMinTable::fillDihedralRow(CoxGraph &G, MinNbr r, Generator s, Length d) { - MinNbr p = min(r,s); + MinNbr p = min(r, s); for (Generator t = 0; t < rank(); t++) { if (t == s) continue; - if (min(p,t) < p) { /* t is the other element in the support */ - if (dot(r,t) < 0) - d_min[r][t] = dihedral; - else if (dot(r,t) == 0) - d_min[r][t] = r; + if (min(p, t) < p) { /* t is the other element in the support */ + if (dot(r, t) < 0) + d_min[r][t] = dihedral; + else if (dot(r, t) == 0) + d_min[r][t] = r; else { /* descent */ - CoxEntry m = G.M(s,t); - MinNbr y; - switch (m % 4) { - case 0: - case 2: - d_min[r][t] = r; - break; - case 1: - y = dihedralShift(t,s,t,d-1); - d_min[r][t] = y; - d_min[y][t] = r; - break; - case 3: - y = dihedralShift(s,t,s,d-1); - d_min[r][t] = y; - d_min[y][t] = r; - break; - } + CoxEntry m = G.M(s, t); + MinNbr y; + switch (m % 4) { + case 0: + case 2: + d_min[r][t] = r; + break; + case 1: + y = dihedralShift(t, s, t, d - 1); + d_min[r][t] = y; + d_min[y][t] = r; + break; + case 3: + y = dihedralShift(s, t, s, d - 1); + d_min[r][t] = y; + d_min[y][t] = r; + break; + } } continue; } - switch (dot(r,t)) { + switch (dot(r, t)) { case zero: d_min[r][t] = r; break; @@ -800,16 +794,15 @@ void InitMinTable::fillDihedralRow(CoxGraph& G, MinNbr r, Generator s, break; } } - + return; } - -void InitMinTable::fillReflectionRow(CoxGraph& G, MinNbr r, Generator s) +void InitMinTable::fillReflectionRow(CoxGraph &G, MinNbr r, Generator s) /* - This function fills in d_min[r], where r has just been created through s, - and d_dot[r] is filled in. It is assumed that d_min[r][s] is already filled + This function fills in d_min[r], where r has just been created through s, + and d_dot[r] is filled in. It is assumed that d_min[r][s] is already filled in. */ @@ -817,24 +810,23 @@ void InitMinTable::fillReflectionRow(CoxGraph& G, MinNbr r, Generator s) for (Generator t = 0; t < rank(); t++) { if (t == s) continue; - switch (dot(r,t)) { + switch (dot(r, t)) { case dotval::cos: case cos2: - case half: /* descent */ + case half: /* descent */ case hinvgold: - if (G.star(bits::lmask[t],s)) { /* M(t,s) > 2 */ - CoxEntry m = G.M(s,t); - MinNbr y = dihedralShift(r,s,t,2*m-1); - d_min[r][t] = y; - d_min[y][t] = r; - } - else { /* commuting descent */ - MinNbr y; - y = min(r,s); - y = min(y,t); - y = min(y,s); - d_min[r][t] = y; - d_min[y][t] = r; + if (G.star(bits::lmask[t], s)) { /* M(t,s) > 2 */ + CoxEntry m = G.M(s, t); + MinNbr y = dihedralShift(r, s, t, 2 * m - 1); + d_min[r][t] = y; + d_min[y][t] = r; + } else { /* commuting descent */ + MinNbr y; + y = min(r, s); + y = min(y, t); + y = min(y, s); + d_min[r][t] = y; + d_min[y][t] = r; } break; case zero: @@ -857,18 +849,17 @@ void InitMinTable::fillReflectionRow(CoxGraph& G, MinNbr r, Generator s) return; } +void InitMinTable::fillMinTable(CoxGraph &G) -void InitMinTable::fillMinTable(CoxGraph& G) - -{ +{ fillDihedralRoots(G); for (Ulong r = rank(); r < d_size; r++) { for (Generator s = 0; s < rank(); ++s) - if (min(r,s) == undef_minnbr) { - newMinRoot(G,r,s); - d_size++; - // printf("%d\r",d_size); // count roots + if (min(r, s) == undef_minnbr) { + newMinRoot(G, r, s); + d_size++; + // printf("%d\r",d_size); // count roots } } @@ -877,128 +868,118 @@ void InitMinTable::fillMinTable(CoxGraph& G) return; } - -void InitMinTable::newDepthOneRoot(CoxGraph& G, MinNbr r, Generator s) +void InitMinTable::newDepthOneRoot(CoxGraph &G, MinNbr r, Generator s) { - setMinMemory(d_size+1); + setMinMemory(d_size + 1); - d_min[d_size]= new(arena()) MinNbr[rank()]; - d_dot[d_size]= new(arena()) DotProduct[rank()]; + d_min[d_size] = new (arena()) MinNbr[rank()]; + d_dot[d_size] = new (arena()) DotProduct[rank()]; d_min[d_size][s] = r; d_min[r][s] = d_size; - memcpy(d_dot[d_size],d_dot[r],rank()*sizeof(DotProduct)); + memcpy(d_dot[d_size], d_dot[r], rank() * sizeof(DotProduct)); d_dot[d_size][s] = -d_dot[d_size][s]; - for (LFlags f = G.star(s); f; f &= f-1) { + for (LFlags f = G.star(s); f; f &= f - 1) { Generator t = bits::firstBit(f); - if (dot(r,t) == locked) + if (dot(r, t) == locked) continue; - d_dot[d_size][t] = - bondCosineSum(G.M(s,t),dot(r,t),dot(r,s)); + d_dot[d_size][t] = bondCosineSum(G.M(s, t), dot(r, t), dot(r, s)); } - fillDepthOneRow(G,d_size,s); + fillDepthOneRow(G, d_size, s); return; } - -void InitMinTable::newDepthTwoRoot(CoxGraph& G, MinNbr r, Generator s) +void InitMinTable::newDepthTwoRoot(CoxGraph &G, MinNbr r, Generator s) { - setMinMemory(d_size+1); + setMinMemory(d_size + 1); - d_min[d_size]= new(arena()) MinNbr[rank()]; - d_dot[d_size]= new(arena()) DotProduct[rank()]; + d_min[d_size] = new (arena()) MinNbr[rank()]; + d_dot[d_size] = new (arena()) DotProduct[rank()]; d_min[d_size][s] = r; d_min[r][s] = d_size; - memcpy(d_dot[d_size],d_dot[r],rank()*sizeof(DotProduct)); + memcpy(d_dot[d_size], d_dot[r], rank() * sizeof(DotProduct)); d_dot[d_size][s] = -d_dot[d_size][s]; - for (LFlags f = G.star(s); f; f &= f-1) { + for (LFlags f = G.star(s); f; f &= f - 1) { Generator t = bits::firstBit(f); - if (dot(r,t) == locked) + if (dot(r, t) == locked) continue; - d_dot[d_size][t] = - bondCosineSum(G.M(s,t),dot(r,t),dot(r,s)); + d_dot[d_size][t] = bondCosineSum(G.M(s, t), dot(r, t), dot(r, s)); } - fillDihedralRow(G,d_size,s,2); + fillDihedralRow(G, d_size, s, 2); return; } - -void InitMinTable::newDihedralRoot(CoxGraph& G, MinNbr r, Generator s, - Length d) +void InitMinTable::newDihedralRoot(CoxGraph &G, MinNbr r, Generator s, Length d) { - setMinMemory(d_size+1); + setMinMemory(d_size + 1); - d_min[d_size]= new(arena()) MinNbr[rank()]; - d_dot[d_size]= new(arena()) DotProduct[rank()]; + d_min[d_size] = new (arena()) MinNbr[rank()]; + d_dot[d_size] = new (arena()) DotProduct[rank()]; d_min[d_size][s] = r; d_min[r][s] = d_size; - memcpy(d_dot[d_size],d_dot[r],rank()*sizeof(DotProduct)); + memcpy(d_dot[d_size], d_dot[r], rank() * sizeof(DotProduct)); d_dot[d_size][s] = -d_dot[d_size][s]; - for (LFlags f = G.star(s); f; f &= f-1) { + for (LFlags f = G.star(s); f; f &= f - 1) { Generator t = bits::firstBit(f); - if (dot(r,t) == locked) + if (dot(r, t) == locked) continue; - CoxEntry m = G.M(s,t); - d_dot[d_size][t] = - bondCosineSum(m,dot(r,t),dot(r,s)); - + CoxEntry m = G.M(s, t); + d_dot[d_size][t] = bondCosineSum(m, dot(r, t), dot(r, s)); + /* correction if maximal depth is reached */ - - if (dot(d_size,t) == undef_negdot) /* t is the other element */ - if (d == (m-1)/2) - d_dot[d_size][t] = -d_dot[d_size][t]; + + if (dot(d_size, t) == undef_negdot) /* t is the other element */ + if (d == (m - 1) / 2) + d_dot[d_size][t] = -d_dot[d_size][t]; } - fillDihedralRow(G,d_size,s,d); + fillDihedralRow(G, d_size, s, d); return; } - -void InitMinTable::newMinRoot(CoxGraph& G, MinNbr r, Generator s) +void InitMinTable::newMinRoot(CoxGraph &G, MinNbr r, Generator s) { - setMinMemory(d_size+1); + setMinMemory(d_size + 1); - d_min[d_size]= new(arena()) MinNbr[rank()]; - d_dot[d_size]= new(arena()) DotProduct[rank()]; + d_min[d_size] = new (arena()) MinNbr[rank()]; + d_dot[d_size] = new (arena()) DotProduct[rank()]; d_min[d_size][s] = r; d_min[r][s] = d_size; - memcpy(d_dot[d_size],d_dot[r],rank()*sizeof(DotProduct)); + memcpy(d_dot[d_size], d_dot[r], rank() * sizeof(DotProduct)); d_dot[d_size][s] = -d_dot[d_size][s]; - for (LFlags f = G.star(s); f; f &= f-1) { + for (LFlags f = G.star(s); f; f &= f - 1) { Generator t = bits::firstBit(f); - if (dot(r,t) == locked) + if (dot(r, t) == locked) continue; - d_dot[d_size][t] = - bondCosineSum(G.M(s,t),dot(r,t),dot(r,s)); + d_dot[d_size][t] = bondCosineSum(G.M(s, t), dot(r, t), dot(r, s)); } - fillReflectionRow(G,d_size,s); - + fillReflectionRow(G, d_size, s); + return; } -}; - +}; // namespace /**************************************************************************** @@ -1017,7 +998,7 @@ void InitMinTable::newMinRoot(CoxGraph& G, MinNbr r, Generator s) - ldescent(g) : left descent set; - rdescent(g) : right descent set; - the fundamental string operations which are the raison d'etre of minroot + the fundamental string operations which are the raison d'etre of minroot tables : - insert(g,s) : inserts the generator s into the normal form g; @@ -1036,10 +1017,10 @@ void InitMinTable::newMinRoot(CoxGraph& G, MinNbr r, Generator s) namespace minroots { -MinTable::MinTable(CoxGraph& G) +MinTable::MinTable(CoxGraph &G) { - new(this) InitMinTable(G); + new (this) InitMinTable(G); return; } @@ -1059,22 +1040,22 @@ MinTable::~MinTable() /* undo general allocations */ for (Ulong j = d_rank; j < d_min.size(); ++j) { - arena().free(d_min[j],d_rank*sizeof(MinNbr)); + arena().free(d_min[j], d_rank * sizeof(MinNbr)); } for (Ulong j = d_rank; j < d_dot.size(); ++j) { - arena().free(d_dot[j],d_rank*sizeof(DotProduct)); + arena().free(d_dot[j], d_rank * sizeof(DotProduct)); } /* undo first allocation */ - arena().free(d_min[0],d_rank*d_rank*sizeof(MinNbr)); - arena().free(d_dot[0],d_rank*d_rank*sizeof(DotProduct)); + arena().free(d_min[0], d_rank * d_rank * sizeof(MinNbr)); + arena().free(d_dot[0], d_rank * d_rank * sizeof(DotProduct)); return; } -LFlags MinTable::descent(const CoxWord& g) const +LFlags MinTable::descent(const CoxWord &g) const /* Returns the two-sided descent set of g, in the usual format : the right @@ -1088,7 +1069,7 @@ LFlags MinTable::descent(const CoxWord& g) const LFlags f = 0; for (Generator s = 0; s < d_rank; ++s) { - if (isDescent(g,s)) + if (isDescent(g, s)) f |= lmask[s]; } @@ -1096,20 +1077,20 @@ LFlags MinTable::descent(const CoxWord& g) const inverse(h); for (Generator s = 0; s < d_rank; ++s) { - if (isDescent(h,s)) - f |= lmask[d_rank+s]; + if (isDescent(h, s)) + f |= lmask[d_rank + s]; } return f; } -LFlags MinTable::ldescent(const CoxWord& g) const +LFlags MinTable::ldescent(const CoxWord &g) const /* Returns the left descent set of g. */ -{ +{ static CoxWord h(0); h = g; @@ -1117,14 +1098,14 @@ LFlags MinTable::ldescent(const CoxWord& g) const LFlags f = 0; for (Generator s = 0; s < d_rank; ++s) { - if (isDescent(h,s)) + if (isDescent(h, s)) f |= lmask[s]; } return f; } -LFlags MinTable::rdescent(const CoxWord& g) const +LFlags MinTable::rdescent(const CoxWord &g) const /* Returns the right descent set of g. @@ -1134,27 +1115,27 @@ LFlags MinTable::rdescent(const CoxWord& g) const LFlags f = 0; for (Generator s = 0; s < d_rank; ++s) { - if (isDescent(g,s)) + if (isDescent(g, s)) f |= lmask[s]; } return f; } -void MinTable::fill(CoxGraph& G) +void MinTable::fill(CoxGraph &G) { - InitMinTable* T = (InitMinTable *)this; + InitMinTable *T = (InitMinTable *)this; T->fillMinTable(G); } -int MinTable::insert(CoxWord& g, const Generator& s, - const Permutation& order) const +int MinTable::insert(CoxWord &g, const Generator &s, + const Permutation &order) const /* This function is like prod below, except that it is now assumed that g is a ShortLex Normal form (always w.r.t. the ordering defined by - order), and we wish the result to be again a normal form. It is known + order), and we wish the result to be again a normal form. It is known that this will be achieved by an appropriate insertion or deletion. More precisely, if the word gs is non-reduced, there is only one @@ -1174,34 +1155,33 @@ int MinTable::insert(CoxWord& g, const Generator& s, Length p = g.length(); Ulong q = p; - for (Ulong j = p; j;) - { - --j; - r = min(r,g[j]-1); + for (Ulong j = p; j;) { + --j; + r = min(r, g[j] - 1); - if (r == not_positive) { /* reduction */ - g.erase(j); - return -1; - } - - if ((r < rank()) && (order[r] < order[g[j]-1])) { - /* better insertion point */ - i = r; - q = j; - } + if (r == not_positive) { /* reduction */ + g.erase(j); + return -1; + } - if (r == not_minimal) /* no further insertions */ - break; + if ((r < rank()) && (order[r] < order[g[j] - 1])) { + /* better insertion point */ + i = r; + q = j; } + if (r == not_minimal) /* no further insertions */ + break; + } + /* if we get here g.s is reduced */ - g.insert(q,i+1); + g.insert(q, i + 1); return 1; } -bool MinTable::inOrder(const CoxWord& d_g, const CoxWord& d_h) const +bool MinTable::inOrder(const CoxWord &d_g, const CoxWord &d_h) const /* This function tells whether g <= h using the well-known elementary @@ -1218,16 +1198,16 @@ bool MinTable::inOrder(const CoxWord& d_g, const CoxWord& d_h) const if (h.length() == 0) return g.length() == 0; - Generator s = h[h.length()-1]-1; // last term of h - if (isDescent(g,s)) - prod(g,s); - h.erase(h.length()-1); + Generator s = h[h.length() - 1] - 1; // last term of h + if (isDescent(g, s)) + prod(g, s); + h.erase(h.length() - 1); - return inOrder(g,h); + return inOrder(g, h); } -bool MinTable::inOrder(List& a, const CoxWord& d_g, - const CoxWord& d_h) const +bool MinTable::inOrder(List &a, const CoxWord &d_g, + const CoxWord &d_h) const /* Like the previous inOrder, but puts in a the places where the erasures take @@ -1237,7 +1217,7 @@ bool MinTable::inOrder(List& a, const CoxWord& d_g, */ { - if (!inOrder(d_g,d_h)) + if (!inOrder(d_g, d_h)) return false; CoxWord g(d_g); @@ -1245,12 +1225,12 @@ bool MinTable::inOrder(List& a, const CoxWord& d_g, List b(0); while (h.length()) { - Generator s = h[h.length()-1]-1; // last term of h - if (isDescent(g,s)) - prod(g,s); + Generator s = h[h.length() - 1] - 1; // last term of h + if (isDescent(g, s)) + prod(g, s); else /* there is an erasure */ - b.append(h.length()-1); - h.erase(h.length()-1); + b.append(h.length() - 1); + h.erase(h.length() - 1); } a.setSize(b.size()); @@ -1258,12 +1238,12 @@ bool MinTable::inOrder(List& a, const CoxWord& d_g, // copy b to a in opposite order for (Ulong j = 0; j < b.size(); ++j) - a[a.size()-1-j] = b[j]; + a[a.size() - 1 - j] = b[j]; return true; } -const CoxWord& MinTable::inverse(CoxWord& g) const +const CoxWord &MinTable::inverse(CoxWord &g) const /* Inverses g. As we have made the assummption that only reduced words @@ -1277,17 +1257,16 @@ const CoxWord& MinTable::inverse(CoxWord& g) const { Length p = g.length(); - for (Length j = 0; j < p/2; ++j) { - CoxLetter u = g[p-j-1]; - g[p-j-1] = g[j]; + for (Length j = 0; j < p / 2; ++j) { + CoxLetter u = g[p - j - 1]; + g[p - j - 1] = g[j]; g[j] = u; } return g; } - -bool MinTable::isDescent(const CoxWord& g, const Generator& s) const +bool MinTable::isDescent(const CoxWord &g, const Generator &s) const /* Returns true if s is a descent generator of g, false otherwise. @@ -1298,8 +1277,8 @@ bool MinTable::isDescent(const CoxWord& g, const Generator& s) const for (Ulong j = g.length(); j;) { --j; - Generator t = g[j]-1; - r = min(r,t); + Generator t = g[j] - 1; + r = min(r, t); if (r == not_positive) { /* found reduction */ return true; } @@ -1312,28 +1291,27 @@ bool MinTable::isDescent(const CoxWord& g, const Generator& s) const return false; } - -const CoxWord& MinTable::normalForm(CoxWord& g, const Permutation& order) const +const CoxWord &MinTable::normalForm(CoxWord &g, const Permutation &order) const /* - Transforms g into its shortlex normal form (as defined by order) by a + Transforms g into its shortlex normal form (as defined by order) by a sequence of insertions. As always, it is assumed that g is reduced. */ { Ulong p = g.length(); - g.setLength(p-1); - g.insert(0,0); + g.setLength(p - 1); + g.insert(0, 0); g.setLength(0); for (Ulong j = 0; j < p; ++j) - insert(g,g[j+1]-1,order); + insert(g, g[j + 1] - 1, order); return g; } -const CoxWord& MinTable::power(CoxWord& g, const Ulong& m) const +const CoxWord &MinTable::power(CoxWord &g, const Ulong &m) const /* Raises a to the m-th power. This can be done very quickly, by squarings @@ -1352,21 +1330,20 @@ const CoxWord& MinTable::power(CoxWord& g, const Ulong& m) const CoxWord h = g; Ulong p; - for (p = m; ~p & hi_bit; p <<= 1) /* shift m up to high powers */ + for (p = m; ~p & hi_bit; p <<= 1) /* shift m up to high powers */ ; - - for (Ulong j = m >> 1; j; j >>= 1) - { - p <<= 1; - prod(g,g); /* g = g*g */ - if (p & hi_bit) - prod(g,h); /* g = g*h */ - } + + for (Ulong j = m >> 1; j; j >>= 1) { + p <<= 1; + prod(g, g); /* g = g*g */ + if (p & hi_bit) + prod(g, h); /* g = g*h */ + } return g; } -int MinTable::prod(CoxWord& g, const Generator& s) const +int MinTable::prod(CoxWord &g, const Generator &s) const /* This is the fundamental function provided by the mintable structure. It @@ -1394,29 +1371,27 @@ int MinTable::prod(CoxWord& g, const Generator& s) const MinNbr r = s; Length p = g.length(); - for (Ulong j = p; j;) - { - --j; - Generator t = g[j]-1; - r = min(r,t); - if (r == not_positive) { /* found reduction */ - g.erase(j); - return -1; - } - if (r == not_minimal) /* no reduction */ - break; + for (Ulong j = p; j;) { + --j; + Generator t = g[j] - 1; + r = min(r, t); + if (r == not_positive) { /* found reduction */ + g.erase(j); + return -1; } + if (r == not_minimal) /* no reduction */ + break; + } /* if we get here g.s is reduced */ - g.setLength(p+1); - g[p] = s+1; - g[p+1] = '\0'; + g.setLength(p + 1); + g[p] = s + 1; + g[p + 1] = '\0'; return 1; } - -int MinTable::prod(CoxWord& g, CoxLetter *const h, const Ulong& n) const +int MinTable::prod(CoxWord &g, CoxLetter *const h, const Ulong &n) const /* Does the product consecutively by the letters in h. Returns the @@ -1428,14 +1403,13 @@ int MinTable::prod(CoxWord& g, CoxLetter *const h, const Ulong& n) const for (Ulong j = 0; j < n; ++j) { Generator s = h[j] - 1; - p += prod(g,s); + p += prod(g, s); } return p; } - -int MinTable::prod(CoxWord& g, const CoxWord& h) const +int MinTable::prod(CoxWord &g, const CoxWord &h) const /* Does the product consecutively by the letters in h. Returns the @@ -1452,14 +1426,13 @@ int MinTable::prod(CoxWord& g, const CoxWord& h) const for (Ulong j = 0; j < buf.length(); ++j) { Generator s = buf[j] - 1; - p += prod(g,s); + p += prod(g, s); } return p; } - -const CoxWord& MinTable::reduced(CoxWord& g, CoxWord& h) const +const CoxWord &MinTable::reduced(CoxWord &g, CoxWord &h) const /* Writes in g a reduced word corresponding to the arbitrary generator @@ -1473,13 +1446,12 @@ const CoxWord& MinTable::reduced(CoxWord& g, CoxWord& h) const g[0] = 0; for (Ulong j = 0; j < h.length(); ++j) - prod(g,h[j]-1); + prod(g, h[j] - 1); return g; - } -}; +}; // namespace minroots /**************************************************************************** @@ -1492,7 +1464,6 @@ const CoxWord& MinTable::reduced(CoxWord& g, CoxWord& h) const ****************************************************************************/ - namespace { DotVal bondCosineSum(CoxEntry m, int a, int b) @@ -1502,24 +1473,23 @@ DotVal bondCosineSum(CoxEntry m, int a, int b) switch (m) { case 3: - return CS3[k*dotval_size + j]; + return CS3[k * dotval_size + j]; case 4: - return CS4[k*dotval_size + j]; + return CS4[k * dotval_size + j]; break; case 5: - return CS5[k*dotval_size + j]; + return CS5[k * dotval_size + j]; break; case 6: - return CS6[k*dotval_size + j]; + return CS6[k * dotval_size + j]; break; default: - return CSm[k*dotval_size + j]; + return CSm[k * dotval_size + j]; break; } } -}; - +}; // namespace /**************************************************************************** @@ -1537,46 +1507,44 @@ DotVal bondCosineSum(CoxEntry m, int a, int b) ****************************************************************************/ -Length minroots::depth(MinTable& T, MinNbr r) +Length minroots::depth(MinTable &T, MinNbr r) { Length d = 0; - MinNbr& rv = r; + MinNbr &rv = r; - while(1) { + while (1) { Generator s; for (s = 0; s < T.rank(); ++s) - if (T.min(r,s) < rv) - break; + if (T.min(r, s) < rv) + break; if (s == T.rank()) break; ++d; - rv = T.min(r,s); + rv = T.min(r, s); } return d; } - -LFlags minroots::descent(MinTable& T, MinNbr r) +LFlags minroots::descent(MinTable &T, MinNbr r) { LFlags A = 0; for (Ulong j = 0; j < T.rank(); ++j) - if (T.dot(r,j) > 0) + if (T.dot(r, j) > 0) A |= bits::lmask[j]; return A; } - -CoxWord& minroots::reduced(MinTable& T, MinNbr r) +CoxWord &minroots::reduced(MinTable &T, MinNbr r) /* Returns a reduced expression for the reflection corresponding to r. - The expression is returned in &buf, which is a safe place until the next + The expression is returned in &buf, which is a safe place until the next call to reduced. */ @@ -1588,29 +1556,28 @@ CoxWord& minroots::reduced(MinTable& T, MinNbr r) while (1) { Generator s; for (s = 0; s < T.rank(); s++) - if (T.min(r,s) < r) - break; + if (T.min(r, s) < r) + break; if (s == T.rank()) break; buf.setLength(d); - buf[d] = s+1; - r = T.min(r,s); + buf[d] = s + 1; + r = T.min(r, s); d++; } - buf.setLength(2*d+1); - buf[d] = r+1; + buf.setLength(2 * d + 1); + buf[d] = r + 1; for (Length j = 1; j <= d; j++) - buf[d+j] = buf[d-j]; + buf[d + j] = buf[d - j]; + + buf[2 * d + 1] = '\0'; - buf[2*d+1] = '\0'; - return buf; } - -LFlags minroots::support(MinTable& T, MinNbr r) +LFlags minroots::support(MinTable &T, MinNbr r) /* Returns the support fo the root of index r. @@ -1619,21 +1586,20 @@ LFlags minroots::support(MinTable& T, MinNbr r) { LFlags f = 0; - while(1) { + while (1) { Generator s; for (s = 0; s < T.rank(); ++s) - if (T.min(r,s) < r) - break; + if (T.min(r, s) < r) + break; if (s == T.rank()) break; f |= bits::lmask[s]; - r = T.min(r,s); + r = T.min(r, s); } return f | bits::lmask[r]; } - /**************************************************************************** Chapter IV - Input/Output @@ -1646,60 +1612,58 @@ LFlags minroots::support(MinTable& T, MinNbr r) ****************************************************************************/ -String& minroots::append(String& str, const DotVal& a) +String &minroots::append(String &str, const DotVal &a) { - switch (a) - { - case undef_dotval: - io::append(str,"undef_minnbr"); - return str; - case undef_negdot: - io::append(str,"-c(*)/2"); - return str; - case locked : - io::append(str,"*"); - return str; - case neg_cos : - io::append(str,"-c/2"); - return str; - case neg_cos2 : - io::append(str,"-c(2)/2"); - return str; - case neg_half : - io::append(str,"-1/2"); - return str; - case neg_hinvgold : - io::append(str,"-c(2,5)/2"); - return str; - case zero : - io::append(str,"0"); - return str; - case hinvgold : - io::append(str,"c(2,5)/2"); - return str; - case half : - io::append(str,"1/2"); - return str; - case cos2 : - io::append(str,"c(2)/2"); - return str; - case dotval::cos : - io::append(str,"c/2"); - return str; - case dotval::one : - io::append(str,"1"); - return str; - case undef_posdot: - io::append(str,"c(*)/2"); - return str; - default: // should not happen - return str; - }; + switch (a) { + case undef_dotval: + io::append(str, "undef_minnbr"); + return str; + case undef_negdot: + io::append(str, "-c(*)/2"); + return str; + case locked: + io::append(str, "*"); + return str; + case neg_cos: + io::append(str, "-c/2"); + return str; + case neg_cos2: + io::append(str, "-c(2)/2"); + return str; + case neg_half: + io::append(str, "-1/2"); + return str; + case neg_hinvgold: + io::append(str, "-c(2,5)/2"); + return str; + case zero: + io::append(str, "0"); + return str; + case hinvgold: + io::append(str, "c(2,5)/2"); + return str; + case half: + io::append(str, "1/2"); + return str; + case cos2: + io::append(str, "c(2)/2"); + return str; + case dotval::cos: + io::append(str, "c/2"); + return str; + case dotval::one: + io::append(str, "1"); + return str; + case undef_posdot: + io::append(str, "c(*)/2"); + return str; + default: // should not happen + return str; + }; } - -void minroots::print(FILE *file, MinTable& T) +void minroots::print(FILE *file, MinTable &T) /* This function prints out the abstract minimal root table, @@ -1711,32 +1675,30 @@ void minroots::print(FILE *file, MinTable& T) { MinNbr r; - MinNbr& rv = r; - - int d = io::digits(T.size()-1,10); /* largest possible value */ - - for (rv = 0; rv < T.size(); ++rv) - { - fprintf(file," %*u : ",d,rv); - for (Generator s = 0; s < T.rank(); s++) - switch (T.min(r,s)) - { - case undef_minnbr: - case dihedral: - fprintf(file,"%*s",d+1,"*"); - break; - case not_minimal: - fprintf(file,"%*s",d+1,"+"); - break; - case not_positive: - fprintf(file,"%*s",d+1,"-"); - break; - default: - fprintf(file,"%*u",d+1,T.min(r,s)); - break; - }; - fprintf(file,"\n"); - } + MinNbr &rv = r; + + int d = io::digits(T.size() - 1, 10); /* largest possible value */ + + for (rv = 0; rv < T.size(); ++rv) { + fprintf(file, " %*u : ", d, rv); + for (Generator s = 0; s < T.rank(); s++) + switch (T.min(r, s)) { + case undef_minnbr: + case dihedral: + fprintf(file, "%*s", d + 1, "*"); + break; + case not_minimal: + fprintf(file, "%*s", d + 1, "+"); + break; + case not_positive: + fprintf(file, "%*s", d + 1, "-"); + break; + default: + fprintf(file, "%*u", d + 1, T.min(r, s)); + break; + }; + fprintf(file, "\n"); + } return; } diff --git a/minroots.h b/minroots.h index 3248fac..30073f2 100644 --- a/minroots.h +++ b/minroots.h @@ -5,33 +5,33 @@ See file main.cpp for full copyright notice */ -#ifndef MINROOTS_H /* guarantee single inclusion */ +#ifndef MINROOTS_H /* guarantee single inclusion */ #define MINROOTS_H #include #include "globals.h" namespace minroots { - using namespace coxeter; +using namespace coxeter; }; /******** type declarations *************************************************/ namespace minroots { - typedef unsigned MinNbr; - typedef signed char DotProduct; - class MinTable; -}; +typedef unsigned MinNbr; +typedef signed char DotProduct; +class MinTable; +}; // namespace minroots /* constants */ namespace minroots { - const MinNbr MINNBR_MAX = UINT_MAX-4; /* top values are reserved */ - const MinNbr MINROOT_MAX = MINNBR_MAX; /* should not exceed MINNBR_MAX */ - const MinNbr undef_minnbr = MINNBR_MAX + 1; - const MinNbr not_minimal = MINNBR_MAX + 2; - const MinNbr not_positive = MINNBR_MAX + 3; -}; +const MinNbr MINNBR_MAX = UINT_MAX - 4; /* top values are reserved */ +const MinNbr MINROOT_MAX = MINNBR_MAX; /* should not exceed MINNBR_MAX */ +const MinNbr undef_minnbr = MINNBR_MAX + 1; +const MinNbr not_minimal = MINNBR_MAX + 2; +const MinNbr not_positive = MINNBR_MAX + 3; +}; // namespace minroots /******** function declarations *********************************************/ @@ -41,20 +41,20 @@ namespace minroots { #include "io.h" namespace minroots { - using namespace bits; - using namespace coxtypes; - using namespace dotval; - using namespace io; -}; +using namespace bits; +using namespace coxtypes; +using namespace dotval; +using namespace io; +}; // namespace minroots namespace minroots { - String& append(String& str, const DotVal& a); - LFlags descent(MinTable& T, MinNbr r); - Length depth(MinTable& T, MinNbr r); - void print(FILE *file, MinTable& T); - CoxWord& reduced(MinTable& T, MinNbr r); - LFlags support(MinTable& T, MinNbr r); -}; +String &append(String &str, const DotVal &a); +LFlags descent(MinTable &T, MinNbr r); +Length depth(MinTable &T, MinNbr r); +void print(FILE *file, MinTable &T); +CoxWord &reduced(MinTable &T, MinNbr r); +LFlags support(MinTable &T, MinNbr r); +}; // namespace minroots /******* type definitions ****************************************************/ @@ -63,61 +63,63 @@ namespace minroots { #include "memory.h" namespace minroots { - using namespace graph; - using namespace list; - using namespace memory; -}; +using namespace graph; +using namespace list; +using namespace memory; +}; // namespace minroots class minroots::MinTable { - protected: +protected: Rank d_rank; MinNbr d_size; - List d_min; - List d_dot; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(MinTable));} - void* operator new(size_t, void* ptr) {return ptr;} - void operator delete(void* ptr, void* placement) {}; - MinTable() {}; - MinTable(CoxGraph& G); + List d_min; + List d_dot; + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(MinTable)); + } + void *operator new(size_t, void *ptr) { return ptr; } + void operator delete(void *ptr, void *placement){}; + MinTable(){}; + MinTable(CoxGraph &G); ~MinTable(); -/* manipulators */ - void fill(CoxGraph& G); -/* accessors */ - LFlags descent(const CoxWord& g) const; - DotVal dot(MinNbr r, Generator s) const; /* inlined */ - int insert(CoxWord& g, const Generator& s, const Permutation& order) const; - const CoxWord& inverse(CoxWord& g) const; - bool inOrder(const CoxWord& g, const CoxWord& h) const; - bool inOrder(List& a, const CoxWord& g, const CoxWord& h) const; - bool isDescent(const CoxWord& g, const Generator& s) const; - LFlags ldescent(const CoxWord& g) const; - const CoxWord& normalForm(CoxWord& g, const Permutation& order) const; - MinNbr min(MinNbr r, Generator s) const; /* inlined */ - int prod(CoxWord& g, const Generator& s) const; - int prod(CoxWord& g, CoxLetter *const h, const Ulong& n) const; - int prod(CoxWord& g, const CoxWord& h) const; - Rank rank() const; /* inlined */ - LFlags rdescent(const CoxWord& g) const; - const CoxWord& reduced(CoxWord& g, CoxWord& h) const; - MinNbr size() const; /* inlined */ - const CoxWord& power(CoxWord& a, const Ulong& m) const; + /* manipulators */ + void fill(CoxGraph &G); + /* accessors */ + LFlags descent(const CoxWord &g) const; + DotVal dot(MinNbr r, Generator s) const; /* inlined */ + int insert(CoxWord &g, const Generator &s, const Permutation &order) const; + const CoxWord &inverse(CoxWord &g) const; + bool inOrder(const CoxWord &g, const CoxWord &h) const; + bool inOrder(List &a, const CoxWord &g, const CoxWord &h) const; + bool isDescent(const CoxWord &g, const Generator &s) const; + LFlags ldescent(const CoxWord &g) const; + const CoxWord &normalForm(CoxWord &g, const Permutation &order) const; + MinNbr min(MinNbr r, Generator s) const; /* inlined */ + int prod(CoxWord &g, const Generator &s) const; + int prod(CoxWord &g, CoxLetter *const h, const Ulong &n) const; + int prod(CoxWord &g, const CoxWord &h) const; + Rank rank() const; /* inlined */ + LFlags rdescent(const CoxWord &g) const; + const CoxWord &reduced(CoxWord &g, CoxWord &h) const; + MinNbr size() const; /* inlined */ + const CoxWord &power(CoxWord &a, const Ulong &m) const; }; /******** Inline definitions **********************************************/ namespace minroots { -inline DotVal MinTable::dot(MinNbr r, Generator s) const - {return DotVal(d_dot[r][s]);} -inline MinNbr MinTable::min(MinNbr r, Generator s) const - {return d_min[r][s];} -inline Rank MinTable::rank() const {return d_rank;} -inline MinNbr MinTable::size() const {return d_size;} +inline DotVal MinTable::dot(MinNbr r, Generator s) const { + return DotVal(d_dot[r][s]); +} +inline MinNbr MinTable::min(MinNbr r, Generator s) const { return d_min[r][s]; } +inline Rank MinTable::rank() const { return d_rank; } +inline MinNbr MinTable::size() const { return d_size; } -}; +}; // namespace minroots #endif diff --git a/polynomials.h b/polynomials.h index a1c2043..c9fc98b 100644 --- a/polynomials.h +++ b/polynomials.h @@ -5,261 +5,295 @@ See file main.cpp for full copyright notice */ -#ifndef POLYNOMIALS_H /* include guard */ +#ifndef POLYNOMIALS_H /* include guard */ #define POLYNOMIALS_H #include "globals.h" #include namespace polynomials { - using namespace coxeter; +using namespace coxeter; }; /******** type declarations **************************************************/ namespace polynomials { - typedef Ulong Degree; - typedef long SDegree; - class Monomial; - template class Polynomial; - template class LaurentPolynomial; -}; +typedef Ulong Degree; +typedef long SDegree; +class Monomial; +template class Polynomial; +template class LaurentPolynomial; +}; // namespace polynomials /******** constants **********************************************************/ namespace polynomials { - const Degree undef_degree = ~0; - const Degree DEGREE_MAX = ULONG_MAX-1; - const SDegree SDEGREE_MAX = LONG_MAX; - const SDegree SDEGREE_MIN = LONG_MIN+1; - const SDegree undef_valuation = LONG_MIN; -}; +const Degree undef_degree = ~0; +const Degree DEGREE_MAX = ULONG_MAX - 1; +const SDegree SDEGREE_MAX = LONG_MAX; +const SDegree SDEGREE_MIN = LONG_MIN + 1; +const SDegree undef_valuation = LONG_MIN; +}; // namespace polynomials /******** function definitions ***********************************************/ #include "io.h" namespace polynomials { - using namespace io; +using namespace io; }; namespace polynomials { - template - bool operator== (const Polynomial& p, const Polynomial& q); - template - bool operator!= (const Polynomial& p, const Polynomial& q); - template - bool operator<= (const Polynomial& p, const Polynomial& q); - template - bool operator>= (const Polynomial& p, const Polynomial& q); - template - bool operator< (const Polynomial& p, const Polynomial& q); - template - bool operator> (const Polynomial& p, const Polynomial& q); - template - String& append(String& str, const Polynomial &p, const char *x); - template - String& append(String& str, const Polynomial& p, const Degree& d, - const long& m, const char *x); - template - String& append(String& str, const Polynomial& p, const Degree& d, - const long& m, const char *x,GAP); - template - String& append(String& str, const Polynomial& p, const Degree& d, - const long& m, const char *x,Terse); - template - void print(FILE* file, const Polynomial& p, const char *x); - template - void print(FILE* file, const LaurentPolynomial& p, const char *x); - template - void print(FILE* file, const Polynomial& p, const Degree& d, - const long& m, const char *x); - template - void print(FILE* file, const Polynomial& p, const Degree& d, - const long& m, const char *x,GAP); - template - void print(FILE* file, const Polynomial& p, const Degree& d, - const long& m, const char *x,Terse); - template - SDegree sumDegree(const LaurentPolynomial& p, - const LaurentPolynomial& q); - template - SDegree sumValuation(const LaurentPolynomial& p, - const LaurentPolynomial& q); -}; +template +bool operator==(const Polynomial &p, const Polynomial &q); +template +bool operator!=(const Polynomial &p, const Polynomial &q); +template +bool operator<=(const Polynomial &p, const Polynomial &q); +template +bool operator>=(const Polynomial &p, const Polynomial &q); +template +bool operator<(const Polynomial &p, const Polynomial &q); +template +bool operator>(const Polynomial &p, const Polynomial &q); +template +String &append(String &str, const Polynomial &p, const char *x); +template +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x); +template +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x, GAP); +template +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x, Terse); +template +void print(FILE *file, const Polynomial &p, const char *x); +template +void print(FILE *file, const LaurentPolynomial &p, const char *x); +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x); +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x, GAP); +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x, Terse); +template +SDegree sumDegree(const LaurentPolynomial &p, const LaurentPolynomial &q); +template +SDegree sumValuation(const LaurentPolynomial &p, + const LaurentPolynomial &q); +}; // namespace polynomials /******** type definitions ***************************************************/ #include "vector.h" namespace polynomials { - using namespace vector; +using namespace vector; }; namespace polynomials { template class Polynomial { - protected: +protected: Vector v; - public: - typedef struct {} const_tag; -/* constructors and destructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Polynomial));} + +public: + typedef struct { + } const_tag; + /* constructors and destructors */ + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(Polynomial)); + } Polynomial(){}; - Polynomial(Degree d):v(d+1) {}; - Polynomial(const Polynomial& q):v(q.v) {}; - Polynomial(T* const& ptr, const Degree& d):v(ptr,d+1) {}; - Polynomial(const T& c, const_tag):v(1) {v[0] = c; setDegValue(0);} + Polynomial(Degree d) : v(d + 1){}; + Polynomial(const Polynomial &q) : v(q.v){}; + Polynomial(T *const &ptr, const Degree &d) : v(ptr, d + 1){}; + Polynomial(const T &c, const_tag) : v(1) { + v[0] = c; + setDegValue(0); + } ~Polynomial(); -/* manipulators */ - T& operator[] (const Ulong& j); /* inlined */ - void reduceDeg(); /* inlined */ - void setDeg(const Degree& d); /* inlined */ - void setDegValue(const Degree& d); /* inlined */ - void setVect(const T *source, const Ulong& n); /* inlined */ - void setZero(); /* inlined */ - void setZero(const Ulong& r); /* inlined */ - void setZero(const Ulong& first, const Ulong& r); /* inlined */ - Vector& vect(); /* inlined */ -/* accessors */ - const T& operator[] (const Ulong& j) const; /* inlined */ - Ulong deg() const; /* inlined */ - bool isZero() const; /* inlined */ - const Vector& vect() const; /* inlined */ -/* operators and operations */ - Polynomial& operator= (const Polynomial& q); /* inlined */ - Polynomial& operator+= (const Polynomial& q); - Polynomial& operator-= (const Polynomial& q); - Polynomial& operator*= (const T& a); - Polynomial& operator*= (const Polynomial& q); - Polynomial& operator/= (const Polynomial& q); + /* manipulators */ + T &operator[](const Ulong &j); /* inlined */ + void reduceDeg(); /* inlined */ + void setDeg(const Degree &d); /* inlined */ + void setDegValue(const Degree &d); /* inlined */ + void setVect(const T *source, const Ulong &n); /* inlined */ + void setZero(); /* inlined */ + void setZero(const Ulong &r); /* inlined */ + void setZero(const Ulong &first, const Ulong &r); /* inlined */ + Vector &vect(); /* inlined */ + /* accessors */ + const T &operator[](const Ulong &j) const; /* inlined */ + Ulong deg() const; /* inlined */ + bool isZero() const; /* inlined */ + const Vector &vect() const; /* inlined */ + /* operators and operations */ + Polynomial &operator=(const Polynomial &q); /* inlined */ + Polynomial &operator+=(const Polynomial &q); + Polynomial &operator-=(const Polynomial &q); + Polynomial &operator*=(const T &a); + Polynomial &operator*=(const Polynomial &q); + Polynomial &operator/=(const Polynomial &q); }; -class Monomial - { - private: - Degree n; - public: - Monomial(Degree d){n = d;}; - }; +class Monomial { +private: + Degree n; + +public: + Monomial(Degree d) { n = d; }; +}; template class LaurentPolynomial { - protected: +protected: Polynomial d_pol; SDegree d_valuation; /* degree of first non-zero coefficient */ - public: -/* constructors and destructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(LaurentPolynomial));} - LaurentPolynomial() {}; - LaurentPolynomial(const SDegree& d, const SDegree& o = 0); +public: + /* constructors and destructors */ + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(LaurentPolynomial)); + } + LaurentPolynomial(){}; + LaurentPolynomial(const SDegree &d, const SDegree &o = 0); ~LaurentPolynomial(); -/* accessors */ - const T& operator[] (const SDegree& j) const; /* inlined */ + /* accessors */ + const T &operator[](const SDegree &j) const; /* inlined */ - bool operator== (const LaurentPolynomial& p) const; - bool operator!= (const LaurentPolynomial& p) const; /* inlined */ - bool operator<= (const LaurentPolynomial& p) const; - bool operator>= (const LaurentPolynomial& p) const; - bool operator< (const LaurentPolynomial& p) const; /* inlined */ - bool operator> (const LaurentPolynomial& p) const; /* inlined */ + bool operator==(const LaurentPolynomial &p) const; + bool operator!=(const LaurentPolynomial &p) const; /* inlined */ + bool operator<=(const LaurentPolynomial &p) const; + bool operator>=(const LaurentPolynomial &p) const; + bool operator<(const LaurentPolynomial &p) const; /* inlined */ + bool operator>(const LaurentPolynomial &p) const; /* inlined */ - SDegree deg() const; /* inlined */ - bool isZero() const; /* inlined */ - SDegree val() const; /* inlined */ + SDegree deg() const; /* inlined */ + bool isZero() const; /* inlined */ + SDegree val() const; /* inlined */ -/* manipulators */ - T& operator[] (const SDegree& j); /* inlined */ + /* manipulators */ + T &operator[](const SDegree &j); /* inlined */ void adjustBounds(); - void setBounds(const SDegree& n, const SDegree& m); - void setDeg(const SDegree& n); - void setDegValue(const SDegree& n); /* inlined */ - void setVal(const SDegree& n); - void setValValue(const SDegree& n); /* inlined */ - void setZero(); /* inlined */ + void setBounds(const SDegree &n, const SDegree &m); + void setDeg(const SDegree &n); + void setDegValue(const SDegree &n); /* inlined */ + void setVal(const SDegree &n); + void setValValue(const SDegree &n); /* inlined */ + void setZero(); /* inlined */ }; -}; +}; // namespace polynomials /******** inline definitions **************************************************/ namespace polynomials { template -inline bool operator!= (const Polynomial& p, const Polynomial& q) - {return !(p == q);} +inline bool operator!=(const Polynomial &p, const Polynomial &q) { + return !(p == q); +} template -inline bool operator< (const Polynomial& p, const Polynomial& q) - {return !(p >= q);} +inline bool operator<(const Polynomial &p, const Polynomial &q) { + return !(p >= q); +} template -inline bool operator> (const Polynomial& p, const Polynomial& q) - {return !(p <= q);} - -template -inline const T& LaurentPolynomial::operator[] (const SDegree& j) const - {return d_pol[j-d_valuation];} -template inline T& LaurentPolynomial::operator[] (const SDegree& j) - {return d_pol[j-d_valuation];} - -template -inline bool LaurentPolynomial::operator!= (const LaurentPolynomial& p) - const {return !operator== (p);} -template -inline bool LaurentPolynomial::operator> (const LaurentPolynomial& p) - const {return !operator<= (p);} -template -inline bool LaurentPolynomial::operator< (const LaurentPolynomial& p) - const {return !operator>= (p);} - -template inline SDegree LaurentPolynomial::deg() const - {return d_pol.deg()+d_valuation;} -template -inline bool LaurentPolynomial::isZero() const {return d_pol.isZero();} -template -inline void LaurentPolynomial::setDegValue(const SDegree& n) - {d_pol.setDegValue(n-d_valuation);} -template -inline void LaurentPolynomial::setValValue(const SDegree& n) - {d_valuation = n;} -template inline SDegree LaurentPolynomial::val() const - {return d_valuation;} -template inline void LaurentPolynomial::setZero() - {d_pol.setZero();} - -template inline T& Polynomial::operator[] (const Ulong& j) - {return v[j];} -template inline void Polynomial::reduceDeg() {v.reduceDim();} -template inline void Polynomial::setDeg(const Degree& d) - {v.setDim(d+1);} -template inline void Polynomial::setDegValue(const Degree& d) - {v.setDimValue(d+1);} -template inline void Polynomial::setVect(const T *source, - const Ulong& n) - {v.setVect(source,n);} -template inline void Polynomial::setZero() - {v.dim() = 0;} -template inline void Polynomial::setZero(const Ulong& r) - {v.setZero(r);} -template inline void Polynomial::setZero(const Ulong& first, - const Ulong& r) - {v.setZero(first,r);} -template inline Vector& Polynomial::vect() {return v;} - -template inline const T& Polynomial::operator[] (const Ulong& j) - const {return v[j];} -template -inline Polynomial& Polynomial::operator= (const Polynomial& q) - {v = q.v; return *this;} - -template inline Ulong Polynomial::deg() const {return v.dim()-1;} -template inline bool Polynomial::isZero() const - {return deg() == undef_degree;} -template inline const Vector& Polynomial::vect() const - {return v;} +inline bool operator>(const Polynomial &p, const Polynomial &q) { + return !(p <= q); +} -}; +template +inline const T &LaurentPolynomial::operator[](const SDegree &j) const { + return d_pol[j - d_valuation]; +} +template +inline T &LaurentPolynomial::operator[](const SDegree &j) { + return d_pol[j - d_valuation]; +} + +template +inline bool LaurentPolynomial::operator!=(const LaurentPolynomial &p) const { + return !operator==(p); +} +template +inline bool LaurentPolynomial::operator>(const LaurentPolynomial &p) const { + return !operator<=(p); +} +template +inline bool LaurentPolynomial::operator<(const LaurentPolynomial &p) const { + return !operator>=(p); +} + +template inline SDegree LaurentPolynomial::deg() const { + return d_pol.deg() + d_valuation; +} +template inline bool LaurentPolynomial::isZero() const { + return d_pol.isZero(); +} +template +inline void LaurentPolynomial::setDegValue(const SDegree &n) { + d_pol.setDegValue(n - d_valuation); +} +template +inline void LaurentPolynomial::setValValue(const SDegree &n) { + d_valuation = n; +} +template inline SDegree LaurentPolynomial::val() const { + return d_valuation; +} +template inline void LaurentPolynomial::setZero() { + d_pol.setZero(); +} + +template inline T &Polynomial::operator[](const Ulong &j) { + return v[j]; +} +template inline void Polynomial::reduceDeg() { v.reduceDim(); } +template inline void Polynomial::setDeg(const Degree &d) { + v.setDim(d + 1); +} +template inline void Polynomial::setDegValue(const Degree &d) { + v.setDimValue(d + 1); +} +template +inline void Polynomial::setVect(const T *source, const Ulong &n) { + v.setVect(source, n); +} +template inline void Polynomial::setZero() { v.dim() = 0; } +template inline void Polynomial::setZero(const Ulong &r) { + v.setZero(r); +} +template +inline void Polynomial::setZero(const Ulong &first, const Ulong &r) { + v.setZero(first, r); +} +template inline Vector &Polynomial::vect() { return v; } + +template +inline const T &Polynomial::operator[](const Ulong &j) const { + return v[j]; +} +template +inline Polynomial &Polynomial::operator=(const Polynomial &q) { + v = q.v; + return *this; +} + +template inline Ulong Polynomial::deg() const { + return v.dim() - 1; +} +template inline bool Polynomial::isZero() const { + return deg() == undef_degree; +} +template inline const Vector &Polynomial::vect() const { + return v; +} + +}; // namespace polynomials #include "polynomials.hpp" diff --git a/polynomials.hpp b/polynomials.hpp index 52292ea..8a5d106 100644 --- a/polynomials.hpp +++ b/polynomials.hpp @@ -1,13 +1,13 @@ /* This is polynomials.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ /**************************************************************************** - This module defines the polynomials used in this program. + This module defines the polynomials used in this program. A polynomial is in fact just a vector, suitably reinterpreted. The degree of the polynomial is the (reduced) dimension of the vector @@ -25,7 +25,8 @@ namespace polynomials { -template Polynomial::~Polynomial() +template +Polynomial::~Polynomial() /* Destruction is automatic. @@ -35,8 +36,8 @@ template Polynomial::~Polynomial() /******** operators *********************************************************/ -template -Polynomial& Polynomial::operator+= (const Polynomial& q) +template +Polynomial &Polynomial::operator+=(const Polynomial &q) /* Adds q to the current polynomial. @@ -45,7 +46,7 @@ Polynomial& Polynomial::operator+= (const Polynomial& q) { /* check for zero */ - if (q.isZero()) /* do nothing */ + if (q.isZero()) /* do nothing */ return *this; if (isZero()) { /* set p to q */ @@ -54,14 +55,13 @@ Polynomial& Polynomial::operator+= (const Polynomial& q) } v += q.v; - v.reduceDim(); /* set the degree to the correct value */ + v.reduceDim(); /* set the degree to the correct value */ return *this; } - -template -Polynomial& Polynomial::operator-= (const Polynomial& q) +template +Polynomial &Polynomial::operator-=(const Polynomial &q) /* Adds q to the current polynomial. @@ -72,7 +72,7 @@ Polynomial& Polynomial::operator-= (const Polynomial& q) /* check for zero */ - if (q.isZero()) /* do nothing */ + if (q.isZero()) /* do nothing */ return *this; if (isZero()) { /* set p to -q */ @@ -83,16 +83,16 @@ Polynomial& Polynomial::operator-= (const Polynomial& q) } v -= q.v; - v.reduceDim(); /* set the degree to the correct value */ + v.reduceDim(); /* set the degree to the correct value */ return *this; } -template -Polynomial& Polynomial::operator*= (const Polynomial& q) +template +Polynomial &Polynomial::operator*=(const Polynomial &q) /* - Multiplies the current polynomial by q. + Multiplies the current polynomial by q. NOTE : we have used tmp as workspace for simplicity, although this can be eliminated altogether. @@ -101,47 +101,47 @@ Polynomial& Polynomial::operator*= (const Polynomial& q) { static Vector tmp; - if ( isZero() || q.isZero() ) /* result is 0 */ - { - setDeg(undef_degree); - return *this; - } + if (isZero() || q.isZero()) /* result is 0 */ + { + setDeg(undef_degree); + return *this; + } - tmp.setDim(deg()+q.deg()+1); + tmp.setDim(deg() + q.deg() + 1); Degree i, j; for (i = 0; i <= deg(); i++) for (j = 0; j <= q.deg(); j++) - tmp[i+j] += v[i]*q[j]; + tmp[i + j] += v[i] * q[j]; - setDeg(deg()+q.deg()+1); + setDeg(deg() + q.deg() + 1); v = tmp; return *this; } - -template Polynomial& Polynomial::operator*= (const T& a) +template +Polynomial &Polynomial::operator*=(const T &a) /* Scalar multiplication by a. */ { - if ( isZero() || (a == 0) /* should be isZero(a) */) /* result is 0 */ - { - setDeg(undef_degree); - return *this; - } + if (isZero() || (a == 0) /* should be isZero(a) */) /* result is 0 */ + { + setDeg(undef_degree); + return *this; + } v *= a; return *this; } -template -Polynomial& Polynomial::operator/= (const Polynomial& q) +template +Polynomial &Polynomial::operator/=(const Polynomial &q) /* Euclidian division by q; we assume that the leading coefficient of @@ -157,20 +157,19 @@ Polynomial& Polynomial::operator/= (const Polynomial& q) Degree i, j; - for (j = deg()-q.deg()+1; j;) - { - j--; - for (i = 0; i < q.deg(); i++) - v[i+j] -= v[q.deg()+j]*q[i]; - } + for (j = deg() - q.deg() + 1; j;) { + j--; + for (i = 0; i < q.deg(); i++) + v[i + j] -= v[q.deg() + j] * q[i]; + } - v.setVect(v.ptr()+q.deg(),deg()-q.deg()+1); - setDeg(deg()-q.deg()); + v.setVect(v.ptr() + q.deg(), deg() - q.deg() + 1); + setDeg(deg() - q.deg()); return *this; } -}; +}; // namespace polynomials /***************************************************************************** @@ -190,12 +189,12 @@ Polynomial& Polynomial::operator/= (const Polynomial& q) namespace polynomials { -template -bool operator== (const Polynomial& p, const Polynomial& q) +template +bool operator==(const Polynomial &p, const Polynomial &q) /* Equality operator for polynomials. Two polynomials are equal, if both - are zero, or if their degrees are equal and the corresponding coefficients + are zero, or if their degrees are equal and the corresponding coefficients are equal. It is assumed that operator != is defined for T. */ @@ -214,12 +213,12 @@ bool operator== (const Polynomial& p, const Polynomial& q) return true; } -template -bool operator<= (const Polynomial& p, const Polynomial& q) +template +bool operator<=(const Polynomial &p, const Polynomial &q) /* - We have p <= q if either p = 0, or deg(p) < deg(q), or degrees are equal and - coefficients are in order, starting from the top. It is assumed that + We have p <= q if either p = 0, or deg(p) < deg(q), or degrees are equal and + coefficients are in order, starting from the top. It is assumed that operator< is defined for T */ @@ -231,7 +230,7 @@ bool operator<= (const Polynomial& p, const Polynomial& q) /* now degrees are equal */ - for (Ulong j = p.deg()+1; j;) { /* loop is empty if p = 0 */ + for (Ulong j = p.deg() + 1; j;) { /* loop is empty if p = 0 */ --j; if (p[j] > q[j]) return false; @@ -244,13 +243,13 @@ bool operator<= (const Polynomial& p, const Polynomial& q) return true; } -template -bool operator>= (const Polynomial& p, const Polynomial& q) +template +bool operator>=(const Polynomial &p, const Polynomial &q) /* - We have p >= q if either deg(p) > deg(q), or degrees are equal and coefficients - are in order, starting from the top. It is assumed that operator< is defined - for T + We have p >= q if either deg(p) > deg(q), or degrees are equal and + coefficients are in order, starting from the top. It is assumed that operator< + is defined for T */ { @@ -261,7 +260,7 @@ bool operator>= (const Polynomial& p, const Polynomial& q) /* now degrees are equal */ - for (Ulong j = p.deg()+1; j;) { /* loop is empty if p = 0 */ + for (Ulong j = p.deg() + 1; j;) { /* loop is empty if p = 0 */ --j; if (p[j] < q[j]) return false; @@ -274,7 +273,7 @@ bool operator>= (const Polynomial& p, const Polynomial& q) return true; } -}; +}; // namespace polynomials /************************************************************************** @@ -287,7 +286,7 @@ bool operator>= (const Polynomial& p, const Polynomial& q) - append(str,p,d,m,x) : same, substituting X^d and shifting degrees by m; - append(str,p,d,m,x,GAP) : same as the previous one, in GAP style; - append(str,p,d,m,x,Terse) : same as the previous one, in Terse style; - - print(file,p,x) : appends the representation of p to the file (also + - print(file,p,x) : appends the representation of p to the file (also defined for Laurent polynomials); - print(str,p,d,m,x) : same, substituting X^d and shifting degrees by m; - print(str,p,d,m,x,GAP) : same as the previous one, in GAP style; @@ -298,7 +297,7 @@ bool operator>= (const Polynomial& p, const Polynomial& q) namespace polynomials { template -String& append(String& str, const Polynomial &p, const char *x) +String &append(String &str, const Polynomial &p, const char *x) /* Appends the string representation of p to l, using the string x to @@ -307,12 +306,12 @@ String& append(String& str, const Polynomial &p, const char *x) { if (p.isZero()) { - io::append(str,"0"); + io::append(str, "0"); return str; } int firstcoeff = 1; - Degree j = p.deg()+1; + Degree j = p.deg() + 1; while (j) { j--; @@ -320,41 +319,38 @@ String& append(String& str, const Polynomial &p, const char *x) continue; if (firstcoeff) firstcoeff = 0; - else - if (p[j] > 0) - append(str,"+"); - switch (j) - { - case 0: - append(str,p[j]); - break; - default: - if ((p[j] != 1) && (p[j] != (T)(-1))) - append(str,p[j]); - else if (p[j] == (T)(-1)) - append(str,"-"); - break; - }; - switch (j) - { - case 0: - break; - case 1: - append(str,x); - break; - default: - append(str,x); - append(str,"^"); - append(str,j); - break; - }; + else if (p[j] > 0) + append(str, "+"); + switch (j) { + case 0: + append(str, p[j]); + break; + default: + if ((p[j] != 1) && (p[j] != (T)(-1))) + append(str, p[j]); + else if (p[j] == (T)(-1)) + append(str, "-"); + break; + }; + switch (j) { + case 0: + break; + case 1: + append(str, x); + break; + default: + append(str, x); + append(str, "^"); + append(str, j); + break; + }; } - + return str; } template -String& append(String& str, const LaurentPolynomial &p, const char *x) +String &append(String &str, const LaurentPolynomial &p, const char *x) /* Appends the string representation of p to l, using the string x to @@ -363,7 +359,7 @@ String& append(String& str, const LaurentPolynomial &p, const char *x) { if (p.isZero()) { - io::append(str,"0"); + io::append(str, "0"); return str; } @@ -374,42 +370,39 @@ String& append(String& str, const LaurentPolynomial &p, const char *x) continue; if (firstcoeff) firstcoeff = 0; - else - if (p[j] > 0) - append(str,"+"); - switch (j) - { - case 0: - append(str,p[j]); - break; - default: - if ((p[j] != 1) && (p[j] != (T)(-1))) - append(str,p[j]); - else if (p[j] == (T)(-1)) - append(str,"-"); - break; - }; - switch (j) - { - case 0: - break; - case 1: - append(str,x); - break; - default: - append(str,x); - append(str,"^"); - append(str,j); - break; - }; - } + else if (p[j] > 0) + append(str, "+"); + switch (j) { + case 0: + append(str, p[j]); + break; + default: + if ((p[j] != 1) && (p[j] != (T)(-1))) + append(str, p[j]); + else if (p[j] == (T)(-1)) + append(str, "-"); + break; + }; + switch (j) { + case 0: + break; + case 1: + append(str, x); + break; + default: + append(str, x); + append(str, "^"); + append(str, j); + break; + }; + } return str; } template -String& append(String& str, const Polynomial &p, const Degree& d, - const long& m, const char *x) +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x) /* Appends the string representation of p to str, using the string x to @@ -419,12 +412,12 @@ String& append(String& str, const Polynomial &p, const Degree& d, { if (p.deg() == undef_degree) { - io::append(str,"0"); + io::append(str, "0"); return str; } int firstcoeff = 1; - Degree j = p.deg()+1; + Degree j = p.deg() + 1; while (j) { j--; @@ -432,41 +425,40 @@ String& append(String& str, const Polynomial &p, const Degree& d, continue; if (firstcoeff) firstcoeff = 0; - else - if (p[j] > 0) - append(str,"+"); - long a = j*d + m; + else if (p[j] > 0) + append(str, "+"); + long a = j * d + m; switch (a) { case 0: - append(str,p[j]); + append(str, p[j]); break; default: if ((p[j] != (T)1) && (p[j] != (T)(-1))) - append(str,p[j]); + append(str, p[j]); else if (p[j] == (T)(-1)) - append(str,"-"); + append(str, "-"); break; }; switch (a) { case 0: break; case 1: - append(str,x); + append(str, x); break; default: - append(str,x); - append(str,"^"); - append(str,a); + append(str, x); + append(str, "^"); + append(str, a); break; }; } - + return str; } template -String& append(String& str, const Polynomial &p, const Degree& d, - const long& m, const char *x, GAP) +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x, GAP) /* Appends the GAP representation of p to str, using the string x to @@ -479,12 +471,12 @@ String& append(String& str, const Polynomial &p, const Degree& d, { if (p.deg() == undef_degree) { - io::append(str,"0"); + io::append(str, "0"); return str; } int firstcoeff = 1; - Degree j = p.deg()+1; + Degree j = p.deg() + 1; while (j) { j--; @@ -492,43 +484,41 @@ String& append(String& str, const Polynomial &p, const Degree& d, continue; if (firstcoeff) firstcoeff = 0; - else - if (p[j] > 0) - append(str,"+"); - long a = j*d + m; + else if (p[j] > 0) + append(str, "+"); + long a = j * d + m; switch (a) { case 0: - append(str,p[j]); + append(str, p[j]); break; default: if ((p[j] != (T)1) && (p[j] != (T)(-1))) { - append(str,p[j]); - append(str,"*"); - } - else if (p[j] == (T)(-1)) - append(str,"-"); + append(str, p[j]); + append(str, "*"); + } else if (p[j] == (T)(-1)) + append(str, "-"); break; }; switch (a) { case 0: break; case 1: - append(str,x); + append(str, x); break; default: - append(str,x); - append(str,"^"); - append(str,a); + append(str, x); + append(str, "^"); + append(str, a); break; }; } - + return str; } template -String& append(String& str, const Polynomial &p, const Degree& d, - const long& m, const char *x, Terse) +String &append(String &str, const Polynomial &p, const Degree &d, + const long &m, const char *x, Terse) /* Appends the Terse representation of p to str, using the string x to @@ -543,59 +533,60 @@ String& append(String& str, const Polynomial &p, const Degree& d, { if (p.deg() == undef_degree) { - io::append(str,"()"); + io::append(str, "()"); return str; } if ((d != 1) || (m != 0)) { - io::append(str,"("); - io::append(str,d); - io::append(str,","); - io::append(str,m); - io::append(str,")"); + io::append(str, "("); + io::append(str, d); + io::append(str, ","); + io::append(str, m); + io::append(str, ")"); } - io::append(str,"("); + io::append(str, "("); for (Ulong j = 0; j <= p.deg(); ++j) { - io::append(str,p[j]); - if ((j+1) <= p.deg()) /* there is more to come */ - io::append(str,","); + io::append(str, p[j]); + if ((j + 1) <= p.deg()) /* there is more to come */ + io::append(str, ","); } - - io::append(str,")"); - + + io::append(str, ")"); + return str; } -template void print(FILE* file, const Polynomial& p, - const char* x) +template +void print(FILE *file, const Polynomial &p, const char *x) { static String buf(0); reset(buf); - append(buf,p,x); - print(file,buf); + append(buf, p, x); + print(file, buf); return; } -template void print(FILE* file, const LaurentPolynomial& p, - const char* x) +template +void print(FILE *file, const LaurentPolynomial &p, const char *x) { static String buf(0); reset(buf); - append(buf,p,x); - print(file,buf); + append(buf, p, x); + print(file, buf); return; } -template void print(FILE* file, const Polynomial& p, - const Degree& d, const long& m, const char* x) +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x) /* Prints the polynomial with x^d substituted for x, and shifted by m (so that @@ -606,15 +597,15 @@ template void print(FILE* file, const Polynomial& p, static String buf(0); reset(buf); - append(buf,p,d,m,x); - print(file,buf); + append(buf, p, d, m, x); + print(file, buf); return; } -template void print(FILE* file, const Polynomial& p, - const Degree& d, const long& m, const char* x, - GAP) +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x, GAP) /* Prints the polynomial with x^d substituted for x, and shifted by m (so that @@ -625,15 +616,15 @@ template void print(FILE* file, const Polynomial& p, static String buf(0); reset(buf); - append(buf,p,d,m,x,GAP()); - print(file,buf); + append(buf, p, d, m, x, GAP()); + print(file, buf); return; } -template void print(FILE* file, const Polynomial& p, - const Degree& d, const long& m, const char* x, - Terse) +template +void print(FILE *file, const Polynomial &p, const Degree &d, const long &m, + const char *x, Terse) /* Prints the polynomial in terse style. @@ -643,8 +634,8 @@ template void print(FILE* file, const Polynomial& p, static String buf(0); reset(buf); - append(buf,p,d,m,x,Terse()); - print(file,buf); + append(buf, p, d, m, x, Terse()); + print(file, buf); return; } @@ -662,7 +653,7 @@ template void print(FILE* file, const Polynomial& p, - constructors and destructors : - - LaurentPolynomial(const SDegree&, const SDegree&) : constructs a + - LaurentPolynomial(const SDegree&, const SDegree&) : constructs a Laurent polynomial capable of holding the given degree and valuation; - ~LaurentPolynomial(); @@ -692,9 +683,9 @@ template void print(FILE* file, const Polynomial& p, *****************************************************************************/ -template -LaurentPolynomial::LaurentPolynomial(const SDegree& d, const SDegree& o) - :d_pol(d-o),d_valuation(o) +template +LaurentPolynomial::LaurentPolynomial(const SDegree &d, const SDegree &o) + : d_pol(d - o), d_valuation(o) /* Constructs a Laurent polynomial with capacity d-o+1. @@ -702,7 +693,8 @@ LaurentPolynomial::LaurentPolynomial(const SDegree& d, const SDegree& o) {} -template LaurentPolynomial::~LaurentPolynomial() +template +LaurentPolynomial::~LaurentPolynomial() /* Automatic destruction is enough. @@ -712,8 +704,8 @@ template LaurentPolynomial::~LaurentPolynomial() /******** accessors *********************************************************/ -template -bool LaurentPolynomial::operator== (const LaurentPolynomial& p) const +template +bool LaurentPolynomial::operator==(const LaurentPolynomial &p) const /* Comparison operator for Laurent polynomials. Two Laurent polynomials are @@ -733,8 +725,8 @@ bool LaurentPolynomial::operator== (const LaurentPolynomial& p) const return d_pol == p.d_pol; } -template -bool LaurentPolynomial::operator<= (const LaurentPolynomial& p) const +template +bool LaurentPolynomial::operator<=(const LaurentPolynomial &p) const /* Comparison operator for Laurent polynomials. Zero is larger than any @@ -749,11 +741,11 @@ bool LaurentPolynomial::operator<= (const LaurentPolynomial& p) const if (d_valuation < p.d_valuation) return true; - return d_pol <= p.d_pol; + return d_pol <= p.d_pol; } -template -bool LaurentPolynomial::operator>= (const LaurentPolynomial& p) const +template +bool LaurentPolynomial::operator>=(const LaurentPolynomial &p) const /* Comparison operator for Laurent polynomials. Zero is larger than any @@ -768,12 +760,13 @@ bool LaurentPolynomial::operator>= (const LaurentPolynomial& p) const if (d_valuation > p.d_valuation) return true; - return d_pol >= p.d_pol; + return d_pol >= p.d_pol; } /******** manipulators ******************************************************/ -template void LaurentPolynomial::adjustBounds() +template +void LaurentPolynomial::adjustBounds() /* Adjusts the degree and valuation so that they answer their definition, @@ -785,7 +778,7 @@ template void LaurentPolynomial::adjustBounds() { if (isZero()) return; - + Ulong a = 0; for (; a < d_pol.deg(); ++a) { @@ -795,7 +788,7 @@ template void LaurentPolynomial::adjustBounds() if (a) { /* valuation is wrong */ d_valuation += a; - d_pol.setVect(d_pol.vect().ptr()+a,0); + d_pol.setVect(d_pol.vect().ptr() + a, 0); } d_pol.reduceDeg(); @@ -803,8 +796,8 @@ template void LaurentPolynomial::adjustBounds() return; } -template -void LaurentPolynomial::setBounds(const SDegree& n, const SDegree& m) +template +void LaurentPolynomial::setBounds(const SDegree &n, const SDegree &m) /* Sets both the degree and the valuation; safe to use even on a garbaged @@ -814,13 +807,13 @@ void LaurentPolynomial::setBounds(const SDegree& n, const SDegree& m) */ { - d_pol.setDeg(n-m); + d_pol.setDeg(n - m); d_valuation = m; return; } -template -void LaurentPolynomial::setDeg(const SDegree& n) +template +void LaurentPolynomial::setDeg(const SDegree &n) /* This function sets the degree of the polynomial to n, making more room @@ -831,12 +824,12 @@ void LaurentPolynomial::setDeg(const SDegree& n) */ { - d_pol.setDeg(n-d_valuation); + d_pol.setDeg(n - d_valuation); return; } -template -void LaurentPolynomial::setVal(const SDegree& n) +template +void LaurentPolynomial::setVal(const SDegree &n) /* This function sets the valuation of the polynomial to n, making more space @@ -848,9 +841,8 @@ void LaurentPolynomial::setVal(const SDegree& n) { d_valuation = n; - d_pol.setDeg(deg()-n); + d_pol.setDeg(deg() - n); return; } -}; - +}; // namespace polynomials diff --git a/posets.cpp b/posets.cpp index e0ad65b..8cf6f6e 100644 --- a/posets.cpp +++ b/posets.cpp @@ -1,6 +1,6 @@ /* This is posets.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -19,11 +19,11 @@ namespace { - using namespace posets; +using namespace posets; - PosetElt firstMinimal(const OrientedGraph& G, const BitMap& b); +PosetElt firstMinimal(const OrientedGraph &G, const BitMap &b); -} +} // namespace /**************************************************************************** @@ -61,7 +61,8 @@ Poset::Poset() {} -Poset::Poset(const Ulong& n):d_closure(n) +Poset::Poset(const Ulong &n) + : d_closure(n) /* Constructs a Poset structure capable of accomodating a Poset of size n. @@ -71,11 +72,12 @@ Poset::Poset(const Ulong& n):d_closure(n) d_closure.setSizeValue(n); for (Ulong j = 0; j < n; ++j) { - new(d_closure.ptr()+j) BitMap(n); + new (d_closure.ptr() + j) BitMap(n); } } -Poset::Poset(const OrientedGraph& G):d_closure(G.size()) +Poset::Poset(const OrientedGraph &G) + : d_closure(G.size()) /* Constructs the poset defined by the graph G, assumed to be acyclic; i.e., @@ -84,13 +86,13 @@ Poset::Poset(const OrientedGraph& G):d_closure(G.size()) relations, as a matter of convention.) */ -{ +{ static BitMap b(0); d_closure.setSizeValue(G.size()); for (Ulong j = 0; j < size(); ++j) { - new(d_closure.ptr()+j) BitMap(size()); + new (d_closure.ptr() + j) BitMap(size()); } /* set the bitmaps */ @@ -99,9 +101,9 @@ Poset::Poset(const OrientedGraph& G):d_closure(G.size()) b.reset(); for (Ulong j = 0; j < size(); ++j) { - PosetElt x = firstMinimal(G,b); + PosetElt x = firstMinimal(G, b); b.setBit(x); - const EdgeList& e = G.edge(x); + const EdgeList &e = G.edge(x); d_closure[x].setBit(x); for (Ulong i = 0; i < e.size(); ++i) { d_closure[x] |= d_closure[e[i]]; @@ -121,7 +123,7 @@ Poset::~Poset() /******** accessors *********************************************************/ -void Poset::findMaximals(const BitMap& D, Set& a) const +void Poset::findMaximals(const BitMap &D, Set &a) const /* This function writes in a the maximal elements of D. It assumes that @@ -137,7 +139,7 @@ void Poset::findMaximals(const BitMap& D, Set& a) const b.assign(D); for (PosetElt x = b.lastBit(); x < b.size(); x = b.lastBit()) { - insert(a,x); + insert(a, x); b.andnot(d_closure[x]); } } @@ -153,13 +155,13 @@ bool Poset::isTriangular() const { for (PosetElt x = 0; x < size(); ++x) { - if (!d_closure[x].isEmpty(x+1)) + if (!d_closure[x].isEmpty(x + 1)) return false; } return true; } -void Poset::hasseDiagram(OrientedGraph& H) +void Poset::hasseDiagram(OrientedGraph &H) /* This function returns in H the Hasse diagram of the poset, i.e. for each @@ -171,14 +173,14 @@ void Poset::hasseDiagram(OrientedGraph& H) for (PosetElt x = 0; x < size(); ++x) { d_closure[x].clearBit(x); - findMaximals(d_closure[x],H.edge(x)); + findMaximals(d_closure[x], H.edge(x)); d_closure[x].setBit(x); } } /******** input/output ******************************************************/ -}; +}; // namespace posets /***************************************************************************** @@ -186,14 +188,14 @@ void Poset::hasseDiagram(OrientedGraph& H) This chapter defines some auxiliary functions used in this module : - - firstMinimal(G,b) : return the first x in G minimal in the complement + - firstMinimal(G,b) : return the first x in G minimal in the complement of b; *****************************************************************************/ namespace { -PosetElt firstMinimal(const OrientedGraph& G, const BitMap& b) +PosetElt firstMinimal(const OrientedGraph &G, const BitMap &b) /* This function is an auxiliary to Poset(G). Given a bitmap b, which is @@ -211,12 +213,12 @@ PosetElt firstMinimal(const OrientedGraph& G, const BitMap& b) for (; x < G.size(); ++x) { if (b.getBit(x)) continue; - const EdgeList& e = G.edge(x); + const EdgeList &e = G.edge(x); for (Ulong i = 0; i < e.size(); ++i) { if (!b.getBit(e[i])) - goto nextx; + goto nextx; } - /* if we reach this point our element is found */ + /* if we reach this point our element is found */ break; nextx: continue; @@ -225,5 +227,4 @@ PosetElt firstMinimal(const OrientedGraph& G, const BitMap& b) return x; } -}; - +}; // namespace diff --git a/posets.h b/posets.h index cd934f7..906c0f1 100644 --- a/posets.h +++ b/posets.h @@ -5,21 +5,21 @@ See file main.cpp for full copyright notice */ -#ifndef POSETS_H /* guard against multiple inclusions */ +#ifndef POSETS_H /* guard against multiple inclusions */ #define POSETS_H #include "globals.h" namespace posets { - using namespace coxeter; +using namespace coxeter; }; /******** type declarations *************************************************/ namespace posets { - typedef Ulong PosetElt; - class Poset; -}; +typedef Ulong PosetElt; +class Poset; +}; // namespace posets /******** type definitions **************************************************/ @@ -29,40 +29,42 @@ namespace posets { #include "wgraph.h" namespace posets { - using namespace bits; - using namespace list; - using namespace wgraph; -}; +using namespace bits; +using namespace list; +using namespace wgraph; +}; // namespace posets namespace posets { class Poset { List d_closure; - public: -/* constructors and destructors */ - void operator delete(void* ptr, size_t size) - {return arena().free(ptr,sizeof(Poset));} + +public: + /* constructors and destructors */ + void operator delete(void *ptr, size_t size) { + return arena().free(ptr, sizeof(Poset)); + } Poset(); Poset(const Ulong &n); - Poset(const OrientedGraph& G); + Poset(const OrientedGraph &G); ~Poset(); -/* manipulators */ -/* accessors */ - void findMaximals(const BitMap& D, Set& a) const; + /* manipulators */ + /* accessors */ + void findMaximals(const BitMap &D, Set &a) const; bool isTriangular() const; Ulong size() const; - void hasseDiagram(OrientedGraph& H); -/* input/output */ + void hasseDiagram(OrientedGraph &H); + /* input/output */ }; -}; +}; // namespace posets /******** inline implementations ********************************************/ namespace posets { -inline Ulong Poset::size() const {return d_closure.size();} +inline Ulong Poset::size() const { return d_closure.size(); } -}; +}; // namespace posets #endif diff --git a/schubert.cpp b/schubert.cpp index 38f0c45..59ea0e9 100644 --- a/schubert.cpp +++ b/schubert.cpp @@ -1,6 +1,6 @@ /* This is schubert.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -10,7 +10,7 @@ #include "error.h" namespace schubert { - using namespace error; +using namespace error; }; /**************************************************************************** @@ -78,22 +78,22 @@ namespace schubert { 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", + 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; +using namespace schubert; +using namespace bits; - const char* undef_str = "undefined"; +const char *undef_str = "undefined"; - void resetOne(SubSet& q); +void resetOne(SubSet &q); -}; +}; // namespace /**************************************************************************** @@ -127,7 +127,7 @@ namespace { - 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; @@ -144,9 +144,9 @@ 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) +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 @@ -162,21 +162,21 @@ StandardSchubertContext::StandardSchubertContext(const CoxGraph& G) d_shift.setSizeValue(1); d_star.setSizeValue(1); - d_shift[0] = new(arena()) CoxNbr[2*rank()]; - for (Ulong j = 0; j < 2*static_cast(d_rank); ++j) + d_shift[0] = new (arena()) CoxNbr[2 * rank()]; + for (Ulong j = 0; j < 2 * static_cast(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] = 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(d_rank); ++j) - new(d_downset+j) BitMap(1); + d_downset = new (arena()) BitMap[2 * d_rank]; + for (Ulong j = 0; j < 2 * static_cast(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 = new (arena()) BitMap[2]; + new (d_parity) BitMap(1); + new (d_parity + 1) BitMap(1); d_parity[0].setBit(0); } @@ -204,20 +204,20 @@ StandardSchubertContext::~StandardSchubertContext() delete *d_history.pop(); } - for (Ulong j = 0; j < 2*static_cast(d_rank); ++j) { + for (Ulong j = 0; j < 2 * static_cast(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)); + 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 +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 @@ -232,14 +232,14 @@ CoxWord& StandardSchubertContext::append(CoxWord& g, const CoxNbr& d_x) const while (x) { Generator s = firstBit(ldescent(x)); - g.append(s+1); - x = lshift(x,s); + g.append(s + 1); + x = lshift(x, s); } return g; } -CoxNbr StandardSchubertContext::contextNumber(const CoxWord& g) const +CoxNbr StandardSchubertContext::contextNumber(const CoxWord &g) const /* This functions returns the number corresponding to g in the current @@ -250,8 +250,8 @@ CoxNbr StandardSchubertContext::contextNumber(const CoxWord& g) const CoxNbr x = 0; for (Ulong j = 0; j < g.length(); ++j) { - Generator s = g[j]-1; - x = rshift(x,s); + Generator s = g[j] - 1; + x = rshift(x, s); if (x == undef_coxnbr) break; } @@ -259,7 +259,7 @@ CoxNbr StandardSchubertContext::contextNumber(const CoxWord& g) const return x; } -void StandardSchubertContext::extractClosure(BitMap& b, const CoxNbr& x) const +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 @@ -275,8 +275,8 @@ void StandardSchubertContext::extractClosure(BitMap& b, const CoxNbr& x) const for (CoxNbr x1 = x; x1;) { Generator s = firstLDescent(x1); - extendSubSet(q,s); - x1 = d_shift[x1][s+d_rank]; + extendSubSet(q, s); + x1 = d_shift[x1][s + d_rank]; } b = q.bitMap(); @@ -308,13 +308,12 @@ bool StandardSchubertContext::inOrder(CoxNbr x, CoxNbr y) const CoxNbr ys = d_shift[y][s]; if (xs < x) - return inOrder(xs,ys); + return inOrder(xs, ys); else /* xs > x */ - return inOrder(x,ys); + return inOrder(x, ys); } -CoxNbr StandardSchubertContext::maximize(const CoxNbr& x, const LFlags& f) - const +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 @@ -326,24 +325,22 @@ CoxNbr StandardSchubertContext::maximize(const CoxNbr& x, const LFlags& f) 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]; - } + 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 +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., + is always defined. It is assumed that f is a valid set of flags, i.e., contained in S \coprod S. */ @@ -351,18 +348,17 @@ CoxNbr StandardSchubertContext::minimize(const CoxNbr& x, const LFlags& f) 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]; - } + 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 +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 @@ -378,15 +374,15 @@ CoxWord& StandardSchubertContext::normalForm(CoxWord& g, const CoxNbr& d_x, CoxNbr x = d_x; while (x) { - Generator s = minDescent(ldescent(x),order); - g.append(s+1); - x = lshift(x,s); + Generator s = minDescent(ldescent(x), order); + g.append(s + 1); + x = lshift(x, s); } return g; } -LFlags StandardSchubertContext::twoDescent(const CoxNbr& x) const +LFlags StandardSchubertContext::twoDescent(const CoxNbr &x) const /* Returns the "super-descent" set of x; this is the union of the descent @@ -397,9 +393,9 @@ LFlags StandardSchubertContext::twoDescent(const CoxNbr& x) const { LFlags f = descent(x); - for (LFlags f1 = f; f1; f1 &= f1-1) { + for (LFlags f1 = f; f1; f1 &= f1 - 1) { Generator s = firstBit(f1); - CoxNbr xs = shift(x,s); + CoxNbr xs = shift(x, s); f |= descent(xs); } @@ -408,7 +404,7 @@ LFlags StandardSchubertContext::twoDescent(const CoxNbr& x) const /******** modifiers ********************************************************/ -CoxNbr StandardSchubertContext::extendContext(const CoxWord& g) +CoxNbr StandardSchubertContext::extendContext(const CoxWord &g) /* This function extends the context to the smallest one containing the @@ -428,7 +424,7 @@ CoxNbr StandardSchubertContext::extendContext(const CoxWord& g) { CoxNbr y = 0; - SubSet& q = d_subset; + SubSet &q = d_subset; resetOne(q); @@ -437,41 +433,40 @@ CoxNbr StandardSchubertContext::extendContext(const CoxWord& g) CATCH_MEMORY_OVERFLOW = true; for (; j < g.length(); ++j) { - Generator s = g[j]-1; - if (rshift(y,s) == undef_coxnbr) + Generator s = g[j] - 1; + if (rshift(y, s) == undef_coxnbr) break; - extendSubSet(q,s); + extendSubSet(q, s); if (ERRNO) goto error_handling; - y = rshift(y,s); + y = rshift(y, s); } for (; j < g.length(); ++j) { - Generator s = g[j]-1; - fullExtension(q,s); + 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); + d_maxlength = j + 1; + y = rshift(y, s); } CATCH_MEMORY_OVERFLOW = false; return y; - error_handling: +error_handling: Error(ERRNO); ERRNO = EXTENSION_FAIL; - return(undef_coxnbr); + return (undef_coxnbr); } - -void StandardSchubertContext::extendSubSet(SubSet& q, const Generator& s) const +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 + 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. @@ -496,11 +491,11 @@ void StandardSchubertContext::extendSubSet(SubSet& q, const Generator& s) const return; } -void StandardSchubertContext::permute(const Permutation& a) +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 + 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; @@ -516,21 +511,21 @@ void StandardSchubertContext::permute(const Permutation& a) { static BitMap b(0); static CoatomList hasse_buf; /* quick fix; can go when all lists are - pointer lists */ + pointer lists */ /* permute values */ for (CoxNbr x = 0; x < d_size; ++x) { - CoatomList& c = d_hasse[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) { + 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]]; + d_shift[x][s] = a[d_shift[x][s]]; } } @@ -554,7 +549,7 @@ void StandardSchubertContext::permute(const Permutation& a) Length length_buf = d_length[y]; hasse_buf.shallowCopy(d_hasse[y]); LFlags descent_buf = d_descent[y]; - CoxNbr* shift_buf = d_shift[y]; + CoxNbr *shift_buf = d_shift[y]; /* put values for x in y */ @@ -572,20 +567,20 @@ void StandardSchubertContext::permute(const Permutation& a) /* 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); + 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); + 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); + d_parity[1].setBit(y, d_parity[1].getBit(x)); + d_parity[1].setBit(x, t); /* set bit*/ @@ -593,10 +588,9 @@ void StandardSchubertContext::permute(const Permutation& a) } b.setBit(x); } - } -void StandardSchubertContext::revertSize(const Ulong& n) +void StandardSchubertContext::revertSize(const Ulong &n) /* This function reverts the size of the context to some previous value. It @@ -614,7 +608,7 @@ void StandardSchubertContext::revertSize(const Ulong& n) Ulong m = size(); while (m > n) { - ContextExtension* h = *d_history.pop(); + ContextExtension *h = *d_history.pop(); m -= h->size(); delete h; } @@ -622,7 +616,7 @@ void StandardSchubertContext::revertSize(const Ulong& n) return; } -void StandardSchubertContext::setSize(const Ulong& n) +void StandardSchubertContext::setSize(const Ulong &n) /* Resizes the various data structures to accomodate a context of size n. @@ -642,7 +636,7 @@ void StandardSchubertContext::setSize(const Ulong& n) CATCH_MEMORY_OVERFLOW = true; - ContextExtension* e = new ContextExtension(*this,n-size()); + ContextExtension *e = new ContextExtension(*this, n - size()); if (ERRNO) /* extension failed */ goto revert; @@ -653,7 +647,7 @@ void StandardSchubertContext::setSize(const Ulong& n) return; - revert: +revert: CATCH_MEMORY_OVERFLOW = false; revertSize(prev_size); return; @@ -661,52 +655,51 @@ void StandardSchubertContext::setSize(const Ulong& n) /******** input/output ****************************************************/ -String& StandardSchubertContext::append(String& str, const CoxNbr& x) - const +String &StandardSchubertContext::append(String &str, const CoxNbr &x) const { if (x == undef_coxnbr) - io::append(str,undef_str); + io::append(str, undef_str); else - coxtypes::append(str,x); + coxtypes::append(str, x); return str; } -String& StandardSchubertContext::append(String& str, const CoxNbr& x, - const Interface& I) const +String &StandardSchubertContext::append(String &str, const CoxNbr &x, + const Interface &I) const { if (x == undef_coxnbr) - return io::append(str,undef_str); + return io::append(str, undef_str); else { CoxWord g(0); - normalForm(g,x,I.order()); - return I.append(str,g); + normalForm(g, x, I.order()); + return I.append(str, g); } } -void StandardSchubertContext::print(FILE* file, const CoxNbr& x) const +void StandardSchubertContext::print(FILE *file, const CoxNbr &x) const { if (x == undef_coxnbr) - fprintf(file,"%s",undef_str); + fprintf(file, "%s", undef_str); else - fprintf(file,"%lu",static_cast(x)); + fprintf(file, "%lu", static_cast(x)); return; } -void StandardSchubertContext::print(FILE* file, const CoxNbr& x, - const Interface& I) const +void StandardSchubertContext::print(FILE *file, const CoxNbr &x, + const Interface &I) const { if (x == undef_coxnbr) - fprintf(file,"%s",undef_str); + fprintf(file, "%s", undef_str); else { CoxWord g(0); - normalForm(g,x,I.order()); - I.print(file,g); + normalForm(g, x, I.order()); + I.print(file, g); } return; @@ -719,11 +712,11 @@ void StandardSchubertContext::print(FILE* file, const CoxNbr& x, 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 + - 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 + - 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 @@ -731,8 +724,8 @@ void StandardSchubertContext::print(FILE* file, const CoxNbr& x, *****************************************************************************/ -void StandardSchubertContext::fillCoatoms(const Ulong& first, - const Generator& s) +void StandardSchubertContext::fillCoatoms(const Ulong &first, + const Generator &s) /* This auxiliary fills the coatom lists of the new elements in p. @@ -747,19 +740,19 @@ void StandardSchubertContext::fillCoatoms(const Ulong& first, 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]; + 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); + insert(c, zs); } /* copy to d_hasse[x] */ @@ -770,8 +763,8 @@ void StandardSchubertContext::fillCoatoms(const Ulong& first, return; } -void StandardSchubertContext::fillDihedralShifts(const CoxNbr& x, - const Generator& s) +void StandardSchubertContext::fillDihedralShifts(const CoxNbr &x, + const Generator &s) /* This function fills in the shifts for x in the dihedral case. It is @@ -793,16 +786,15 @@ void StandardSchubertContext::fillDihedralShifts(const CoxNbr& x, t = firstRDescent(xs); s1 = s + d_rank; t1 = t + d_rank; - m = d_graph.M(s,t); - } - else { /* action is on the left */ + 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); + m = d_graph.M(s1, t1); } - const CoatomList& c = d_hasse[x]; + const CoatomList &c = d_hasse[x]; CoxNbr z; /* the other coatom of x */ if (c[0] == xs) @@ -822,22 +814,19 @@ void StandardSchubertContext::fillDihedralShifts(const CoxNbr& x, d_shift[z][s1] = x; d_shift[x][t1] = xs; d_shift[xs][t1] = x; - } - else { /* xs = sx; xt = tx */ + } 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 */ + } 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 */ + } else { /* xs and tx */ d_shift[x][t1] = z; d_shift[z][t1] = x; d_descent[x] |= lmask[t1]; @@ -848,8 +837,8 @@ void StandardSchubertContext::fillDihedralShifts(const CoxNbr& x, return; } -void StandardSchubertContext::fillShifts(const CoxNbr& first, - const Generator& s) +void StandardSchubertContext::fillShifts(const CoxNbr &first, + const Generator &s) /* This function fills in the shift tables of the new elements in p. It is @@ -878,28 +867,27 @@ void StandardSchubertContext::fillShifts(const CoxNbr& first, } for (; x < d_size; ++x) { - const CoatomList& c = d_hasse[x]; + const CoatomList &c = d_hasse[x]; if (c.size() == 2) { /* dihedral case */ - fillDihedralShifts(x,s); + fillDihedralShifts(x, s); continue; } - for (Generator t = 0; t < 2*d_rank; ++t) { /* examine shift by t */ + for (Generator t = 0; t < 2 * d_rank; ++t) { /* examine shift by t */ if (t == s) - continue; + 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 (!(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; @@ -914,7 +902,7 @@ void StandardSchubertContext::fillShifts(const CoxNbr& first, return; } -void StandardSchubertContext::fillStar(const CoxNbr& first) +void StandardSchubertContext::fillStar(const CoxNbr &first) /* This function fills in the star operations for the new elements. Each @@ -936,7 +924,7 @@ void StandardSchubertContext::fillStar(const CoxNbr& first) */ { - const List& ops = d_graph.starOps(); + const List &ops = d_graph.starOps(); for (CoxNbr x = first; x < d_size; ++x) { @@ -946,30 +934,30 @@ void StandardSchubertContext::fillStar(const CoxNbr& first) /* determine if x is in right domain */ LFlags f = fx & ops[j]; if ((f == 0) || (f == ops[j])) - continue; + continue; - CoxNbr x_min = minimize(x,ops[j]); + 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); + CoxEntry m = d_graph.M(s, t); - if (2*d < m) /* star is either undef_coxnbr or increasing */ - continue; + 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; + 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; + 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; } } @@ -978,30 +966,30 @@ void StandardSchubertContext::fillStar(const CoxNbr& first) /* determine if x is in left domain */ LFlags f = fx & ops[j]; if ((f == 0) || (f == ops[j])) - continue; + continue; LFlags lops = ops[j] << d_rank; - CoxNbr x_min = minimize(x,lops); + 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); + CoxEntry m = d_graph.M(s, t); - if (2*d < m) /* star is either undef_coxnbr or increasing */ - continue; + 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; + 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); - x1 = d_shift[x1][s1+d_rank]; - } - d_star[x][j+nStarOps()] = x1; - d_star[x1][j+nStarOps()] = x; + CoxNbr x1 = x; + while ((d_length[x1] - d_length[x_min]) > (m - d)) { + LFlags f1 = ldescent(x1) & ops[j]; + Generator s1 = firstBit(f1); + x1 = d_shift[x1][s1 + d_rank]; + } + d_star[x][j + nStarOps()] = x1; + d_star[x1][j + nStarOps()] = x; } } } @@ -1009,11 +997,11 @@ void StandardSchubertContext::fillStar(const CoxNbr& first) return; } -void StandardSchubertContext::fullExtension(SubSet& q, const Generator& s) +void StandardSchubertContext::fullExtension(SubSet &q, const Generator &s) /* Given a context p, a subset q of p holding [e,y], and a generator s s.t. - y.s is not contained in p, this function extends p to hold y, and puts in + y.s is not contained in p, this function extends p to hold y, and puts in q the interval [e,y.s] (here s can be either a right or a left shift.) Sets the following errors : @@ -1028,15 +1016,15 @@ void StandardSchubertContext::fullExtension(SubSet& q, const Generator& s) CATCH_MEMORY_OVERFLOW is set; i.e., we don't want to exit brutally if we get a memory overflow, losing all previous computations. - If an overflow error occurs, it is guaranteed that the context stays in + If an overflow error occurs, it is guaranteed that the context stays in its original form (except for sizes of varlists.) */ { /* check length overflow */ - CoxNbr y = q[q.size()-1]; /* largest element in q */ - + CoxNbr y = q[q.size() - 1]; /* largest element in q */ + if (d_length[y] == LENGTH_MAX) { /* overflow */ ERRNO = LENGTH_OVERFLOW; return; @@ -1061,49 +1049,50 @@ void StandardSchubertContext::fullExtension(SubSet& q, const Generator& s) /* resize context */ CoxNbr prev_size = d_size; - setSize(d_size+c); + setSize(d_size + c); if (ERRNO) /* memory overflow */ goto revert; /* fill in lengths and shifts by s */ - { CoxNbr xs = prev_size; /* first new element */ - - for (Ulong j = 0; j < q.size(); ++j) { - CoxNbr x = q[j]; - if (d_shift[x][s] == undef_coxnbr) { - d_shift[x][s] = xs; - d_shift[xs][s] = x; - d_length[xs] = d_length[x] + 1; - d_parity[d_length[xs]%2].setBit(xs); - d_descent[xs] |= lmask[s]; - d_downset[s].setBit(xs); - xs++; + { + CoxNbr xs = prev_size; /* first new element */ + + for (Ulong j = 0; j < q.size(); ++j) { + CoxNbr x = q[j]; + if (d_shift[x][s] == undef_coxnbr) { + d_shift[x][s] = xs; + d_shift[xs][s] = x; + d_length[xs] = d_length[x] + 1; + d_parity[d_length[xs] % 2].setBit(xs); + d_descent[xs] |= lmask[s]; + d_downset[s].setBit(xs); + xs++; + } } - } - /* fill in the new elements */ + /* fill in the new elements */ - fillCoatoms(prev_size,s); - fillShifts(prev_size,s); - fillStar(prev_size); + fillCoatoms(prev_size, s); + fillShifts(prev_size, s); + fillStar(prev_size); - /* update q */ + /* update q */ - extendSubSet(q,s); + extendSubSet(q, s); - if (ERRNO) - goto revert; + if (ERRNO) + goto revert; } return; - revert: +revert: setSize(prev_size); return; } -}; +}; // namespace schubert /**************************************************************************** @@ -1126,9 +1115,9 @@ void StandardSchubertContext::fullExtension(SubSet& q, const Generator& s) namespace schubert { -StandardSchubertContext::ContextExtension::ContextExtension - (StandardSchubertContext& p, const Ulong& c) - :d_schubert(p),d_size(c) +StandardSchubertContext::ContextExtension::ContextExtension( + StandardSchubertContext &p, const Ulong &c) + : d_schubert(p), d_size(c) /* This function manages the resizing of the SchubertContext p from its @@ -1139,7 +1128,7 @@ StandardSchubertContext::ContextExtension::ContextExtension if (c == 0) return; - Ulong n = p.size()+c; + Ulong n = p.size() + c; p.d_length.setSize(n); if (ERRNO) @@ -1159,22 +1148,22 @@ StandardSchubertContext::ContextExtension::ContextExtension /* make room for shift tables and star tables */ - d_shift = new(arena()) CoxNbr[2*p.rank()*c]; + d_shift = new (arena()) CoxNbr[2 * p.rank() * c]; if (ERRNO) goto revert; - memset(d_shift,0xFF,2*p.rank()*c*sizeof(CoxNbr)); + memset(d_shift, 0xFF, 2 * p.rank() * c * sizeof(CoxNbr)); p.d_shift[p.d_size] = d_shift; - for (Ulong j = p.d_size+1; j < n; ++j) - p.d_shift[j] = p.d_shift[j-1] + 2*p.rank(); - d_star = new(arena()) CoxNbr[2*p.nStarOps()*c]; + for (Ulong j = p.d_size + 1; j < n; ++j) + p.d_shift[j] = p.d_shift[j - 1] + 2 * p.rank(); + d_star = new (arena()) CoxNbr[2 * p.nStarOps() * c]; if (ERRNO) goto revert; - memset(d_star,0xFF,2*p.nStarOps()*c*sizeof(CoxNbr)); + memset(d_star, 0xFF, 2 * p.nStarOps() * c * sizeof(CoxNbr)); p.d_star[p.d_size] = d_star; - for (Ulong j = p.d_size+1; j < n; ++j) - p.d_star[j] = p.d_star[j-1] + 2*p.nStarOps(); + for (Ulong j = p.d_size + 1; j < n; ++j) + p.d_star[j] = p.d_star[j - 1] + 2 * p.nStarOps(); - for (Ulong j = 0; j < 2*static_cast(p.rank()); ++j) { + for (Ulong j = 0; j < 2 * static_cast(p.rank()); ++j) { p.d_downset[j].setSize(n); if (ERRNO) goto revert; @@ -1190,12 +1179,12 @@ StandardSchubertContext::ContextExtension::ContextExtension return; - revert: +revert: p.d_length.setSize(p.d_size); p.d_hasse.setSize(p.d_size); p.d_descent.setSize(p.d_size); p.d_shift.setSize(p.d_size); - for (Ulong j = 0; j < 2*static_cast(p.rank()); ++j) { + for (Ulong j = 0; j < 2 * static_cast(p.rank()); ++j) { p.d_downset[j].setSize(p.d_size); } p.d_parity[0].setSize(p.d_size); @@ -1206,7 +1195,7 @@ StandardSchubertContext::ContextExtension::ContextExtension StandardSchubertContext::ContextExtension::~ContextExtension() /* - Destruction of a context extension. + Destruction of a context extension. NOTE : this is currently unfinished, and usable only for the destruction of a whole context. It should resize the lists downwards, and put @@ -1216,20 +1205,20 @@ StandardSchubertContext::ContextExtension::~ContextExtension() */ { - StandardSchubertContext& p = d_schubert; - Ulong prev_size = p.d_size-d_size; + StandardSchubertContext &p = d_schubert; + Ulong prev_size = p.d_size - d_size; /* the pointers d_shift and d_star were allocated previously */ - arena().free(d_shift,2*p.rank()*d_size*sizeof(CoxNbr)); - arena().free(d_star,2*p.nStarOps()*d_size*sizeof(CoxNbr)); + arena().free(d_shift, 2 * p.rank() * d_size * sizeof(CoxNbr)); + arena().free(d_star, 2 * p.nStarOps() * d_size * sizeof(CoxNbr)); p.d_size = prev_size; return; } -}; +}; // namespace schubert /**************************************************************************** @@ -1259,9 +1248,9 @@ StandardSchubertContext::ContextExtension::~ContextExtension() namespace schubert { -ClosureIterator::ClosureIterator(const SchubertContext& p) - :d_schubert(p),d_subSet(p.size()),d_g(p.maxlength()),d_subSize(1), - d_visited(p.size()),d_current(0),d_valid(true) +ClosureIterator::ClosureIterator(const SchubertContext &p) + : d_schubert(p), d_subSet(p.size()), d_g(p.maxlength()), d_subSize(1), + d_visited(p.size()), d_current(0), d_valid(true) { d_visited.reset(); @@ -1291,21 +1280,21 @@ void ClosureIterator::operator++() */ { - const SchubertContext& p = d_schubert; + const SchubertContext &p = d_schubert; /* look at extensions of the current word */ LFlags f = p.S() & ~p.rdescent(d_current); - for (; f; f &= f-1) { + for (; f; f &= f - 1) { Generator s = firstBit(f); - CoxNbr x = p.shift(d_current,s); + CoxNbr x = p.shift(d_current, s); if (x == undef_coxnbr) continue; if (d_visited.getBit(x)) continue; /* if we get here, x is the next element */ - update(x,s); + update(x, s); return; } @@ -1313,18 +1302,18 @@ void ClosureIterator::operator++() while (p.length(d_current)) { Length r = p.length(d_current); - Generator s = d_g[r-1]-1; - d_current = p.shift(d_current,s); - for (Generator t = s+1; t < p.rank(); ++t) { - if (p.isDescent(d_current,t)) - continue; - CoxNbr x = p.shift(d_current,t); + Generator s = d_g[r - 1] - 1; + d_current = p.shift(d_current, s); + for (Generator t = s + 1; t < p.rank(); ++t) { + if (p.isDescent(d_current, t)) + continue; + CoxNbr x = p.shift(d_current, t); if (x == undef_coxnbr) - continue; + continue; if (d_visited.getBit(x)) - continue; + continue; /* if we get here, x is the next element */ - update(x,t); + update(x, t); return; } } @@ -1337,7 +1326,7 @@ void ClosureIterator::operator++() /******** private functions *************************************************/ -void ClosureIterator::update(const CoxNbr& x, const Generator& s) +void ClosureIterator::update(const CoxNbr &x, const Generator &s) /* Updates the structure, where the new current element is x, gotten through @@ -1347,32 +1336,32 @@ void ClosureIterator::update(const CoxNbr& x, const Generator& s) */ { - const SchubertContext& p = d_schubert; + const SchubertContext &p = d_schubert; d_current = x; d_visited.setBit(x); Length r = p.length(x); d_g.setLength(r); - d_g[r-1] = s+1; + d_g[r - 1] = s + 1; Length prev_r = d_subSize.size(); /* erase top of subset */ - for (Ulong j = d_subSize[r-1]; j < d_subSize[prev_r-1]; ++j) { + for (Ulong j = d_subSize[r - 1]; j < d_subSize[prev_r - 1]; ++j) { CoxNbr z = d_subSet[j]; d_subSet.bitMap().clearBit(z); } - d_subSet.setListSize(d_subSize[r-1]); + d_subSet.setListSize(d_subSize[r - 1]); - p.extendSubSet(d_subSet,s); - d_subSize.setSize(r+1); + p.extendSubSet(d_subSet, s); + d_subSize.setSize(r + 1); d_subSize[r] = d_subSet.size(); return; } -}; +}; // namespace schubert /**************************************************************************** @@ -1391,7 +1380,7 @@ void ClosureIterator::update(const CoxNbr& x, const Generator& s) namespace schubert { -void extractInvolutions(const SchubertContext& p, BitMap& b) +void extractInvolutions(const SchubertContext &p, BitMap &b) /* This function extracts from b the involutions contained in it. First @@ -1410,11 +1399,11 @@ void extractInvolutions(const SchubertContext& p, BitMap& b) CoxNbr xl = x; CoxNbr xr = x; while (xl) { - Generator s = p.firstRDescent(xl); - xl = p.rshift(xl,s); - xr = p.lshift(xr,s); - if (p.rdescent(xl) != p.ldescent(xr)) - goto not_involution; + Generator s = p.firstRDescent(xl); + xl = p.rshift(xl, s); + xr = p.lshift(xr, s); + if (p.rdescent(xl) != p.ldescent(xr)) + goto not_involution; } } /* if we get here, we have an involution */ @@ -1425,7 +1414,7 @@ void extractInvolutions(const SchubertContext& p, BitMap& b) } } -void maximize(const SchubertContext& p, BitMap& b, const LFlags& f) +void maximize(const SchubertContext &p, BitMap &b, const LFlags &f) /* This function extracts from b the maximal elements w.r.t. f, by @@ -1435,16 +1424,16 @@ void maximize(const SchubertContext& p, BitMap& b, const LFlags& f) { LFlags f1 = f; - while(f1) { + while (f1) { Generator s = firstBit(f1); b &= p.downset(s); - f1 &= f1-1; + f1 &= f1 - 1; } return; } -void minimize(const SchubertContext& p, BitMap& b, const LFlags& f) +void minimize(const SchubertContext &p, BitMap &b, const LFlags &f) /* This function extracts from b the minimal elements w.r.t. f, by @@ -1454,17 +1443,17 @@ void minimize(const SchubertContext& p, BitMap& b, const LFlags& f) { LFlags f1 = f; - while(f1) { + while (f1) { Generator s = firstBit(f1); b.andnot(p.downset(s)); - f1 &= f1-1; + f1 &= f1 - 1; } return; } -bool shortLexOrder(const SchubertContext& p, const CoxNbr& d_x, - const CoxNbr& d_y, const Permutation& order) +bool shortLexOrder(const SchubertContext &p, const CoxNbr &d_x, + const CoxNbr &d_y, const Permutation &order) /* This function checks if x <= y in the ShortLex order of the normal forms @@ -1485,14 +1474,14 @@ bool shortLexOrder(const SchubertContext& p, const CoxNbr& d_x, CoxNbr x = d_x; CoxNbr y = d_y; - Generator s_x = p.firstLDescent(x,order); - Generator s_y = p.firstLDescent(y,order); + Generator s_x = p.firstLDescent(x, order); + Generator s_y = p.firstLDescent(y, order); while (s_x == s_y) { - x = p.lshift(x,s_x); - y = p.lshift(y,s_y); - s_x = p.firstLDescent(x,order); - s_y = p.firstLDescent(y,order); + x = p.lshift(x, s_x); + y = p.lshift(y, s_y); + s_x = p.firstLDescent(x, order); + s_y = p.firstLDescent(y, order); } if (order[s_x] < order[s_y]) @@ -1503,7 +1492,7 @@ bool shortLexOrder(const SchubertContext& p, const CoxNbr& d_x, return false; // unreachable } -}; +}; // namespace schubert /**************************************************************************** @@ -1520,86 +1509,86 @@ bool shortLexOrder(const SchubertContext& p, const CoxNbr& d_x, namespace schubert { -void print(FILE* file, const SchubertContext& p) +void print(FILE *file, const SchubertContext &p) /* This function prints out the contents of the Schubert context. */ { - fprintf(file,"size : %lu maxlength : %lu",static_cast(p.size()), - static_cast(p.maxlength())); - fprintf(file,"\n\n"); + fprintf(file, "size : %lu maxlength : %lu", static_cast(p.size()), + static_cast(p.maxlength())); + fprintf(file, "\n\n"); for (CoxNbr x = 0; x < p.size(); ++x) { - fprintf(file,"%4lu : ",static_cast(x)); + fprintf(file, "%4lu : ", static_cast(x)); for (Generator s = 0; s < p.rank(); ++s) { - if (p.rshift(x,s) == undef_coxnbr) - fprintf(file,"%4s","*"); + if (p.rshift(x, s) == undef_coxnbr) + fprintf(file, "%4s", "*"); else - fprintf(file,"%4lu",static_cast(p.rshift(x,s))); + fprintf(file, "%4lu", static_cast(p.rshift(x, s))); } - fprintf(file,";"); + fprintf(file, ";"); for (Generator s = 0; s < p.rank(); ++s) { - if (p.lshift(x,s) == undef_coxnbr) - fprintf(file,"%4s","*"); + if (p.lshift(x, s) == undef_coxnbr) + fprintf(file, "%4s", "*"); else - fprintf(file,"%4lu",static_cast(p.lshift(x,s))); + fprintf(file, "%4lu", static_cast(p.lshift(x, s))); } - fprintf(file,";"); + fprintf(file, ";"); - fprintf(file," {"); - const CoatomList& c = p.hasse(x); + fprintf(file, " {"); + const CoatomList &c = p.hasse(x); for (Ulong j = 0; j < c.size(); ++j) { - fprintf(file,"%lu",static_cast(c[j])); - if (j+1 < c.size()) /* there is more to come */ - fprintf(file,","); + fprintf(file, "%lu", static_cast(c[j])); + if (j + 1 < c.size()) /* there is more to come */ + fprintf(file, ","); } - fprintf(file,"}"); + fprintf(file, "}"); - fprintf(file," R:("); + fprintf(file, " R:("); for (LFlags f = p.rdescent(x); f;) { - fprintf(file,"%lu",static_cast(firstBit(f)+1)); - f &= f-1; + fprintf(file, "%lu", static_cast(firstBit(f) + 1)); + f &= f - 1; if (f) /* there is more to come */ - fprintf(file,","); + fprintf(file, ","); } - fprintf(file,")"); + fprintf(file, ")"); - fprintf(file," L:("); + fprintf(file, " L:("); for (LFlags f = p.ldescent(x); f;) { - fprintf(file,"%lu",static_cast(firstBit(f)+1)); - f &= f-1; + fprintf(file, "%lu", static_cast(firstBit(f) + 1)); + f &= f - 1; if (f) /* there is more to come */ - fprintf(file,","); + fprintf(file, ","); } - fprintf(file,")"); + fprintf(file, ")"); - fprintf(file,"\n"); + fprintf(file, "\n"); } - fprintf(file,"\nStar operations :\n\n"); + fprintf(file, "\nStar operations :\n\n"); for (CoxNbr x = 0; x < p.size(); ++x) { - fprintf(file,"%4lu : ",static_cast(x)); - for (Ulong r = 0; r < 2*p.nStarOps(); ++r) { - if (p.star(x,r) == undef_coxnbr) - fprintf(file,"%5s","*"); + fprintf(file, "%4lu : ", static_cast(x)); + for (Ulong r = 0; r < 2 * p.nStarOps(); ++r) { + if (p.star(x, r) == undef_coxnbr) + fprintf(file, "%5s", "*"); else - fprintf(file,"%5lu",static_cast(p.star(x,r))); + fprintf(file, "%5lu", static_cast(p.star(x, r))); } - fprintf(file,"\n"); + fprintf(file, "\n"); } - fprintf(file,"\n"); + fprintf(file, "\n"); return; } -void printBitMap(FILE* file, const BitMap& b, const SchubertContext& p, - const Interface& I) +void printBitMap(FILE *file, const BitMap &b, const SchubertContext &p, + const Interface &I) /* This function prints the elements of the bitmap (assumed to hold a subset @@ -1609,23 +1598,23 @@ void printBitMap(FILE* file, const BitMap& b, const SchubertContext& p, { bool first = true; - fprintf(file,"{"); + fprintf(file, "{"); for (BitMap::Iterator i = b.begin(); i != b.end(); ++i) { if (first) first = false; else - fprintf(file,","); + fprintf(file, ","); CoxWord g(0); - p.append(g,*i); - I.print(file,g); + p.append(g, *i); + I.print(file, g); } - - fprintf(file,"}"); + + fprintf(file, "}"); } -void printPartition(FILE* file, const Partition& pi, const SchubertContext& p, - const Interface& I) +void printPartition(FILE *file, const Partition &pi, const SchubertContext &p, + const Interface &I) /* This function prints the partition pi, assumed to hold a partition of the @@ -1636,53 +1625,53 @@ void printPartition(FILE* file, const Partition& pi, const SchubertContext& p, Ulong count = 0; for (PartitionIterator i(pi); i; ++i) { - const Set& c = i(); - fprintf(file,"%lu(%lu):{",count,c.size()); + const Set &c = i(); + fprintf(file, "%lu(%lu):{", count, c.size()); for (Ulong j = 0; j < c.size(); ++j) { CoxWord g(0); - p.append(g,c[j]); - I.print(file,g); - if (j+1 < c.size()) /* there is more to come */ - fprintf(file,","); + p.append(g, c[j]); + I.print(file, g); + if (j + 1 < c.size()) /* there is more to come */ + fprintf(file, ","); } - fprintf(file,"}\n"); + fprintf(file, "}\n"); ++count; } return; } -void printPartition(FILE* file, const Partition& pi, const BitMap& b, - const SchubertContext& p, const Interface& I) +void printPartition(FILE *file, const Partition &pi, const BitMap &b, + const SchubertContext &p, const Interface &I) /* Prints the partition pi restricted to the subset flagged by b. */ { - List q(b.begin(),b.end()); // replaces readBitMap - Partition pi_b(b.begin(),b.end(),pi); + List q(b.begin(), b.end()); // replaces readBitMap + Partition pi_b(b.begin(), b.end(), pi); Ulong count = 0; for (PartitionIterator i(pi_b); i; ++i) { - const Set& c = i(); - fprintf(file,"%lu(%lu):{",count,c.size()); + const Set &c = i(); + fprintf(file, "%lu(%lu):{", count, c.size()); for (Ulong j = 0; j < c.size(); ++j) { CoxWord g(0); - p.append(g,q[c[j]]); - I.print(file,g); - if (j+1 < c.size()) /* there is more to come */ - fprintf(file,","); + p.append(g, q[c[j]]); + I.print(file, g); + if (j + 1 < c.size()) /* there is more to come */ + fprintf(file, ","); } - fprintf(file,"}\n"); + fprintf(file, "}\n"); ++count; } return; } -}; +}; // namespace schubert /**************************************************************************** @@ -1703,20 +1692,20 @@ void printPartition(FILE* file, const Partition& pi, const BitMap& b, namespace schubert { -void betti(Homology& h, const CoxNbr& y, const SchubertContext& p) +void betti(Homology &h, const CoxNbr &y, const SchubertContext &p) /* This function puts the ordinary betti numbers of the row in h, in a - simple-minded approach. No overflow is possible here. + simple-minded approach. No overflow is possible here. It is assumed that row is a row in kllist. */ { BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); - h.setSize(p.length(y)+1); + h.setSize(p.length(y) + 1); h.setZero(); BitMap::Iterator b_end = b.end(); @@ -1728,11 +1717,11 @@ void betti(Homology& h, const CoxNbr& y, const SchubertContext& p) return; } -Ulong min(const Set& c, NFCompare& nfc) +Ulong min(const Set &c, NFCompare &nfc) /* This function extracts the minimal element form c. It is defined for - Set instead of List so as to be able to apply it directly to + Set instead of List so as to be able to apply it directly to partition classes. */ @@ -1743,21 +1732,21 @@ Ulong min(const Set& c, NFCompare& nfc) Ulong m = c[0]; for (Ulong j = 1; j < c.size(); ++j) { - if (!nfc(m,c[j])) + if (!nfc(m, c[j])) m = c[j]; } return m; } -void extractMaximals(const SchubertContext& p, List& c) +void extractMaximals(const SchubertContext &p, List &c) /* - This function erases from c all elements that are not maximal elements for + This function erases from c all elements that are not maximal elements for the Bruhat order among the entries in c. - It is assumed that c is sorted in an ordering compatible with the Bruhat - order; so if we start from the top, we will always encounter a maximal + It is assumed that c is sorted in an ordering compatible with the Bruhat + order; so if we start from the top, we will always encounter a maximal element before any lower one. */ @@ -1766,24 +1755,23 @@ void extractMaximals(const SchubertContext& p, List& c) for (Ulong j = c.size(); j;) { --j; - for (Ulong i = c.size()-extr_count; i < c.size(); ++i) { - if (p.inOrder(c[j],c[i])) /* forget j */ - goto nextj; + for (Ulong i = c.size() - extr_count; i < c.size(); ++i) { + if (p.inOrder(c[j], c[i])) /* forget j */ + goto nextj; } extr_count++; - c[c.size()-extr_count] = c[j]; + c[c.size() - extr_count] = c[j]; nextj: continue; } - c.setData(c.ptr()+c.size()-extr_count,0,extr_count); + c.setData(c.ptr() + c.size() - extr_count, 0, extr_count); c.setSize(extr_count); return; } -void extractMaximals(const SchubertContext& p, List& c, - List& a) +void extractMaximals(const SchubertContext &p, List &c, List &a) /* Like the previous one, but puts the indices in c of the maximal elements @@ -1797,8 +1785,8 @@ void extractMaximals(const SchubertContext& p, List& c, for (Ulong j = c.size(); j;) { --j; for (Ulong i = 0; i < e.size(); ++i) { - if (p.inOrder(c[j],e[i])) /* forget j */ - goto nextj; + if (p.inOrder(c[j], e[i])) /* forget j */ + goto nextj; } a.append(j); e.append(c[j]); @@ -1811,7 +1799,7 @@ void extractMaximals(const SchubertContext& p, List& c, return; } -Ulong minDescent(const LFlags& d_f, const Permutation& order) +Ulong minDescent(const LFlags &d_f, const Permutation &order) /* Returns the set bit position in f for which order is smallest. In practice, @@ -1824,9 +1812,9 @@ Ulong minDescent(const LFlags& d_f, const Permutation& order) { LFlags f = d_f; Ulong m = firstBit(f); - f &= f-1; + f &= f - 1; - for (; f; f &= f-1) { + for (; f; f &= f - 1) { Ulong m1 = firstBit(f); if (order[m1] < order[m]) m = m1; @@ -1835,7 +1823,7 @@ Ulong minDescent(const LFlags& d_f, const Permutation& order) return m; } -void readBitMap(List& c, const BitMap& b) +void readBitMap(List &c, const BitMap &b) /* This function reads in c from b (analogous to readBitMap in bits::SubSet). @@ -1844,7 +1832,7 @@ void readBitMap(List& c, const BitMap& b) { c.setSize(b.bitCount()); - BitMap::Iterator i = b.begin(); + BitMap::Iterator i = b.begin(); for (Ulong j = 0; j < c.size(); ++j) { c[j] = *i; @@ -1852,11 +1840,11 @@ void readBitMap(List& c, const BitMap& b) } } -}; +}; // namespace schubert namespace { -void resetOne(SubSet& q) +void resetOne(SubSet &q) /* Resets q to hold the one-element subset {0}. @@ -1873,11 +1861,11 @@ void resetOne(SubSet& q) return; } -}; +}; // namespace namespace schubert { -void setBitMap(BitMap& b, const List& c) +void setBitMap(BitMap &b, const List &c) /* Reads c into b. It is assumed that b has already been set to the current @@ -1891,7 +1879,7 @@ void setBitMap(BitMap& b, const List& c) b.setBit(c[j]); } -Ulong sum(const Homology& h) +Ulong sum(const Homology &h) { Ulong a = 0; @@ -1903,4 +1891,4 @@ Ulong sum(const Homology& h) return a; } -}; +}; // namespace schubert diff --git a/schubert.h b/schubert.h index 0a921c6..33cca72 100644 --- a/schubert.h +++ b/schubert.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef SCHUBERT_H /* guard against multiple inclusions */ +#ifndef SCHUBERT_H /* guard against multiple inclusions */ #define SCHUBERT_H #include "globals.h" @@ -18,314 +18,348 @@ #include "stack.h" namespace schubert { - using namespace coxeter; - using namespace coxtypes; - using namespace bits; - using namespace interface; - using namespace graph; - using namespace io; - using namespace list; - using namespace stack; +using namespace coxeter; +using namespace coxtypes; +using namespace bits; +using namespace interface; +using namespace graph; +using namespace io; +using namespace list; +using namespace stack; /******** type declarations *************************************************/ - class ClosureIterator; - class SchubertContext; - class StandardSchubertContext; +class ClosureIterator; +class SchubertContext; +class StandardSchubertContext; - struct NFCompare; +struct NFCompare; - typedef List CoatomList; - typedef List Homology; +typedef List CoatomList; +typedef List Homology; /******** function declarations *********************************************/ - void betti(Homology& h, const CoxNbr& y, const SchubertContext& p); - void extractInvolutions(const SchubertContext& p, BitMap& b); - void extractMaximals(const SchubertContext& p, List& c); - void extractMaximals(const SchubertContext& p, List& c, - List& a); - void maximize(const SchubertContext& p, BitMap& b, const LFlags& f); - Ulong min(const Set& c, NFCompare& nfc); - Ulong minDescent(const LFlags& f, const Permutation& order); - void minimize(const SchubertContext& p, BitMap& b, const LFlags& f); - void print(FILE* file, const SchubertContext& p); - void printBitMap(FILE* file, const BitMap& pi, const SchubertContext& p, - const Interface& I); - void printList(FILE* file, const List& v, const SchubertContext& p, - const Interface& I); - void printPartition(FILE* file, const Partition& pi, - const SchubertContext& p, const Interface& I); - void printPartition(FILE* file, const Partition& pi, const BitMap& b, - const SchubertContext& p, const Interface& I); - void readBitMap(List& c, const BitMap& b); - bool shortLexOrder(const SchubertContext& p, const CoxNbr& x, - const CoxNbr& y, const Permutation& order); - void setBitMap(BitMap& b, const List& c); - Ulong sum(const Homology& h); +void betti(Homology &h, const CoxNbr &y, const SchubertContext &p); +void extractInvolutions(const SchubertContext &p, BitMap &b); +void extractMaximals(const SchubertContext &p, List &c); +void extractMaximals(const SchubertContext &p, List &c, List &a); +void maximize(const SchubertContext &p, BitMap &b, const LFlags &f); +Ulong min(const Set &c, NFCompare &nfc); +Ulong minDescent(const LFlags &f, const Permutation &order); +void minimize(const SchubertContext &p, BitMap &b, const LFlags &f); +void print(FILE *file, const SchubertContext &p); +void printBitMap(FILE *file, const BitMap &pi, const SchubertContext &p, + const Interface &I); +void printList(FILE *file, const List &v, const SchubertContext &p, + const Interface &I); +void printPartition(FILE *file, const Partition &pi, const SchubertContext &p, + const Interface &I); +void printPartition(FILE *file, const Partition &pi, const BitMap &b, + const SchubertContext &p, const Interface &I); +void readBitMap(List &c, const BitMap &b); +bool shortLexOrder(const SchubertContext &p, const CoxNbr &x, const CoxNbr &y, + const Permutation &order); +void setBitMap(BitMap &b, const List &c); +Ulong sum(const Homology &h); /******** type definitions *************************************************/ struct NFCompare { - const SchubertContext& p; - const Permutation& order; - NFCompare(const SchubertContext& q, const Permutation& generator_ordering) - :p(q),order(generator_ordering) {}; - ~NFCompare() {}; - bool operator()(const CoxNbr& x, const CoxNbr& y) - {return shortLexOrder(p,x,y,order);} + const SchubertContext &p; + const Permutation ℴ + NFCompare(const SchubertContext &q, const Permutation &generator_ordering) + : p(q), order(generator_ordering){}; + ~NFCompare(){}; + bool operator()(const CoxNbr &x, const CoxNbr &y) { + return shortLexOrder(p, x, y, order); + } }; class SchubertContext { friend class ClosureIterator; - public: - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(SchubertContext));} - virtual ~SchubertContext() {}; -/* accessors */ - virtual CoxWord& append(CoxWord& g, const CoxNbr& x) const = 0; - virtual LFlags ascent(const CoxNbr& x) const = 0; - virtual CoxNbr contextNumber(const CoxWord& g) const = 0; - virtual LFlags descent(const CoxNbr& x) const = 0; - virtual const BitMap& downset(const Generator& s) const = 0; - virtual void extendSubSet(SubSet& q, const Generator& s) const = 0; - virtual void extractClosure(BitMap& b, const CoxNbr& x) const = 0; - virtual Generator firstDescent(const CoxNbr& x) const = 0; - virtual Generator firstLDescent(const CoxNbr& x) const = 0; - virtual Generator firstRDescent(const CoxNbr& x) const = 0; - virtual Generator firstDescent(const CoxNbr& x, const Permutation& order) - const = 0; - virtual Generator firstLDescent(const CoxNbr& x, const Permutation& order) - const = 0; - virtual Generator firstRDescent(const CoxNbr& x, const Permutation& order) - const = 0; - virtual const CoatomList& hasse(const CoxNbr& x) const = 0; + +public: + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(SchubertContext)); + } + virtual ~SchubertContext(){}; + /* accessors */ + virtual CoxWord &append(CoxWord &g, const CoxNbr &x) const = 0; + virtual LFlags ascent(const CoxNbr &x) const = 0; + virtual CoxNbr contextNumber(const CoxWord &g) const = 0; + virtual LFlags descent(const CoxNbr &x) const = 0; + virtual const BitMap &downset(const Generator &s) const = 0; + virtual void extendSubSet(SubSet &q, const Generator &s) const = 0; + virtual void extractClosure(BitMap &b, const CoxNbr &x) const = 0; + virtual Generator firstDescent(const CoxNbr &x) const = 0; + virtual Generator firstLDescent(const CoxNbr &x) const = 0; + virtual Generator firstRDescent(const CoxNbr &x) const = 0; + virtual Generator firstDescent(const CoxNbr &x, + const Permutation &order) const = 0; + virtual Generator firstLDescent(const CoxNbr &x, + const Permutation &order) const = 0; + virtual Generator firstRDescent(const CoxNbr &x, + const Permutation &order) const = 0; + virtual const CoatomList &hasse(const CoxNbr &x) const = 0; virtual bool inOrder(CoxNbr x, CoxNbr y) const = 0; - virtual bool isDescent(const CoxNbr& x, const Generator& s) const = 0; - virtual LFlags lascent(const CoxNbr& x) const = 0; - virtual LFlags ldescent(const CoxNbr& x) const = 0; - virtual Length length(const CoxNbr& x) const = 0; - virtual CoxNbr lshift(const CoxNbr& x, const Generator& s) const = 0; - virtual CoxNbr maximize(const CoxNbr& x, const LFlags& f) const = 0; + virtual bool isDescent(const CoxNbr &x, const Generator &s) const = 0; + virtual LFlags lascent(const CoxNbr &x) const = 0; + virtual LFlags ldescent(const CoxNbr &x) const = 0; + virtual Length length(const CoxNbr &x) const = 0; + virtual CoxNbr lshift(const CoxNbr &x, const Generator &s) const = 0; + virtual CoxNbr maximize(const CoxNbr &x, const LFlags &f) const = 0; virtual Length maxlength() const = 0; - virtual CoxNbr minimize(const CoxNbr& x, const LFlags& f) const = 0; - virtual CoxWord& normalForm(CoxWord& g, const CoxNbr& x, - const Permutation& order) const = 0; + virtual CoxNbr minimize(const CoxNbr &x, const LFlags &f) const = 0; + virtual CoxWord &normalForm(CoxWord &g, const CoxNbr &x, + const Permutation &order) const = 0; virtual Ulong nStarOps() const = 0; - virtual const BitMap& parity(const CoxNbr& x) const = 0; + virtual const BitMap &parity(const CoxNbr &x) const = 0; virtual Rank rank() const = 0; - virtual LFlags rascent(const CoxNbr& x) const = 0; - virtual LFlags rdescent(const CoxNbr& x) const = 0; - virtual CoxNbr rshift(const CoxNbr& x, const Generator& s) const = 0; + virtual LFlags rascent(const CoxNbr &x) const = 0; + virtual LFlags rdescent(const CoxNbr &x) const = 0; + virtual CoxNbr rshift(const CoxNbr &x, const Generator &s) const = 0; virtual LFlags S() const = 0; - virtual CoxNbr shift(const CoxNbr& x, const Generator& s) const = 0; + virtual CoxNbr shift(const CoxNbr &x, const Generator &s) const = 0; virtual CoxNbr size() const = 0; - virtual CoxNbr star(CoxNbr x, const Ulong& r) const = 0; - virtual LFlags twoDescent(const CoxNbr& x) const = 0; - virtual const Type& type() const = 0; -/* modifiers */ - virtual CoxNbr extendContext(const CoxWord& g) = 0; - virtual void permute(const Permutation& a) = 0; - virtual void revertSize(const Ulong& n) = 0; - virtual void setSize(const Ulong& n) = 0; -/* input-output */ - virtual String& append(String&, const CoxNbr& x) const = 0; - virtual String& append(String&, const CoxNbr& x, const Interface& I) - const = 0; - virtual void print(FILE* file, const CoxNbr& x) const = 0; - virtual void print(FILE* file, const CoxNbr& x, const Interface& I) - const = 0; + virtual CoxNbr star(CoxNbr x, const Ulong &r) const = 0; + virtual LFlags twoDescent(const CoxNbr &x) const = 0; + virtual const Type &type() const = 0; + /* modifiers */ + virtual CoxNbr extendContext(const CoxWord &g) = 0; + virtual void permute(const Permutation &a) = 0; + virtual void revertSize(const Ulong &n) = 0; + virtual void setSize(const Ulong &n) = 0; + /* input-output */ + virtual String &append(String &, const CoxNbr &x) const = 0; + virtual String &append(String &, const CoxNbr &x, + const Interface &I) const = 0; + virtual void print(FILE *file, const CoxNbr &x) const = 0; + virtual void print(FILE *file, const CoxNbr &x, const Interface &I) const = 0; }; -class StandardSchubertContext:public SchubertContext { - private: -/* private class declaration */ +class StandardSchubertContext : public SchubertContext { +private: + /* private class declaration */ class ContextExtension { private: - StandardSchubertContext& d_schubert; + StandardSchubertContext &d_schubert; Ulong d_size; - CoxNbr* d_shift; - CoxNbr* d_star; + CoxNbr *d_shift; + CoxNbr *d_star; + public: - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(ContextExtension));} - ContextExtension(StandardSchubertContext& p, const Ulong& c); + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(ContextExtension)); + } + ContextExtension(StandardSchubertContext &p, const Ulong &c); ~ContextExtension(); - Ulong size() {return d_size;} + Ulong size() { return d_size; } }; - const CoxGraph& d_graph; + const CoxGraph &d_graph; Rank d_rank; Length d_maxlength; CoxNbr d_size; List d_length; List d_hasse; List d_descent; - List d_shift; - List d_star; - BitMap* d_downset; - BitMap* d_parity; + List d_shift; + List d_star; + BitMap *d_downset; + BitMap *d_parity; SubSet d_subset; - Stack d_history; -/* private member functions */ - void fillCoatoms(const Ulong& first, const Generator& s); - void fillDihedralShifts(const CoxNbr& x, const Generator& s); - void fillShifts(const CoxNbr& first, const Generator& s); - void fillStar(const CoxNbr& first); - void fullExtension(SubSet& q, const Generator& s); - void subSetExtension(SubSet& q, const Generator& s) const; - public: - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(StandardSchubertContext));} -/* friend declaration */ - friend ContextExtension::ContextExtension(StandardSchubertContext&, - const Ulong& c); + Stack d_history; + /* private member functions */ + void fillCoatoms(const Ulong &first, const Generator &s); + void fillDihedralShifts(const CoxNbr &x, const Generator &s); + void fillShifts(const CoxNbr &first, const Generator &s); + void fillStar(const CoxNbr &first); + void fullExtension(SubSet &q, const Generator &s); + void subSetExtension(SubSet &q, const Generator &s) const; + +public: + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(StandardSchubertContext)); + } + /* friend declaration */ + friend ContextExtension::ContextExtension(StandardSchubertContext &, + const Ulong &c); friend ContextExtension::~ContextExtension(); -/* constructors and destructors */ - StandardSchubertContext(const CoxGraph& G); + /* constructors and destructors */ + StandardSchubertContext(const CoxGraph &G); ~StandardSchubertContext(); -/* accessors */ - CoxWord& append(CoxWord& g, const CoxNbr& x) const; - LFlags ascent(const CoxNbr& x) const; /* inlined */ - CoxNbr contextNumber(const CoxWord& g) const; - LFlags descent(const CoxNbr& x) const; /* inlined */ - const BitMap& downset(const Generator& s) const; /* inlined */ - void extendSubSet(SubSet& q, const Generator& s) const; - void extractClosure(BitMap& b, const CoxNbr& x) const; - Generator firstDescent(const CoxNbr& x) const; /* inlined */ - Generator firstLDescent(const CoxNbr& x) const; /* inlined */ - Generator firstRDescent(const CoxNbr& x) const; /* inlined */ - Generator firstDescent(const CoxNbr& x, const Permutation& order) - const; /* inlined */ - Generator firstLDescent(const CoxNbr& x, const Permutation& order) - const; /* inlined */ - Generator firstRDescent(const CoxNbr& x, const Permutation& order) - const; /* inlined */ - const CoatomList& hasse(const CoxNbr& x) const; /* inlined */ + /* accessors */ + CoxWord &append(CoxWord &g, const CoxNbr &x) const; + LFlags ascent(const CoxNbr &x) const; /* inlined */ + CoxNbr contextNumber(const CoxWord &g) const; + LFlags descent(const CoxNbr &x) const; /* inlined */ + const BitMap &downset(const Generator &s) const; /* inlined */ + void extendSubSet(SubSet &q, const Generator &s) const; + void extractClosure(BitMap &b, const CoxNbr &x) const; + Generator firstDescent(const CoxNbr &x) const; /* inlined */ + Generator firstLDescent(const CoxNbr &x) const; /* inlined */ + Generator firstRDescent(const CoxNbr &x) const; /* inlined */ + Generator firstDescent(const CoxNbr &x, + const Permutation &order) const; /* inlined */ + Generator firstLDescent(const CoxNbr &x, + const Permutation &order) const; /* inlined */ + Generator firstRDescent(const CoxNbr &x, + const Permutation &order) const; /* inlined */ + const CoatomList &hasse(const CoxNbr &x) const; /* inlined */ bool inOrder(CoxNbr x, CoxNbr y) const; - bool isDescent(const CoxNbr& x, const Generator& s) const; /* inlined */ - bool isSuperExtremal(const CoxNbr& x, const CoxNbr& y) const; - LFlags lascent(const CoxNbr& x) const; /* inlined */ - LFlags ldescent(const CoxNbr& x) const; /* inlined */ - Length length(const CoxNbr& x) const; /* inlined */ - CoxNbr lshift(const CoxNbr& x, const Generator& s) const; /* inlined */ - CoxNbr maximize(const CoxNbr& x, const LFlags& f) const; - Length maxlength() const; /* inlined */ - CoxNbr minimize(const CoxNbr& x, const LFlags& f) const; - CoxWord& normalForm(CoxWord& g, const CoxNbr& x, const Permutation& order) - const; - Ulong nStarOps() const; /* inlined */ - const BitMap& parity(const CoxNbr& x) const; /* inlined */ - Rank rank() const; /* inlined */ - LFlags rascent(const CoxNbr& x) const; /* inlined */ - LFlags rdescent(const CoxNbr& x) const; /* inlined */ - CoxNbr rshift(const CoxNbr& x, const Generator& s) const; /* inlined */ - LFlags S() const; /* inlined */ - CoxNbr shift(const CoxNbr& x, const Generator& s) const; /* inlined */ - CoxNbr size() const; /* inlined */ - CoxNbr star(CoxNbr x, const Ulong& r) const; /* inlined */ - LFlags twoDescent(const CoxNbr& x) const; - const Type& type() const; /* inlined */ -/* manipulators */ - CoxNbr extendContext(const CoxWord& g); - void permute(const Permutation& a); - void revertSize(const Ulong& n); - void setSize(const Ulong& n); -/* i/o */ - String& append(String&, const CoxNbr& x) const; - String& append(String&, const CoxNbr& x, const Interface& I) const; - void print(FILE* file, const CoxNbr& x) const; - void print(FILE* file, const CoxNbr& x, const Interface& I) const; + bool isDescent(const CoxNbr &x, const Generator &s) const; /* inlined */ + bool isSuperExtremal(const CoxNbr &x, const CoxNbr &y) const; + LFlags lascent(const CoxNbr &x) const; /* inlined */ + LFlags ldescent(const CoxNbr &x) const; /* inlined */ + Length length(const CoxNbr &x) const; /* inlined */ + CoxNbr lshift(const CoxNbr &x, const Generator &s) const; /* inlined */ + CoxNbr maximize(const CoxNbr &x, const LFlags &f) const; + Length maxlength() const; /* inlined */ + CoxNbr minimize(const CoxNbr &x, const LFlags &f) const; + CoxWord &normalForm(CoxWord &g, const CoxNbr &x, + const Permutation &order) const; + Ulong nStarOps() const; /* inlined */ + const BitMap &parity(const CoxNbr &x) const; /* inlined */ + Rank rank() const; /* inlined */ + LFlags rascent(const CoxNbr &x) const; /* inlined */ + LFlags rdescent(const CoxNbr &x) const; /* inlined */ + CoxNbr rshift(const CoxNbr &x, const Generator &s) const; /* inlined */ + LFlags S() const; /* inlined */ + CoxNbr shift(const CoxNbr &x, const Generator &s) const; /* inlined */ + CoxNbr size() const; /* inlined */ + CoxNbr star(CoxNbr x, const Ulong &r) const; /* inlined */ + LFlags twoDescent(const CoxNbr &x) const; + const Type &type() const; /* inlined */ + /* manipulators */ + CoxNbr extendContext(const CoxWord &g); + void permute(const Permutation &a); + void revertSize(const Ulong &n); + void setSize(const Ulong &n); + /* i/o */ + String &append(String &, const CoxNbr &x) const; + String &append(String &, const CoxNbr &x, const Interface &I) const; + void print(FILE *file, const CoxNbr &x) const; + void print(FILE *file, const CoxNbr &x, const Interface &I) const; }; class ClosureIterator { - private: - const SchubertContext& d_schubert; +private: + const SchubertContext &d_schubert; SubSet d_subSet; CoxWord d_g; List d_subSize; BitMap d_visited; CoxNbr d_current; bool d_valid; -/* private functions */ - void update(const CoxNbr& x, const Generator& s); - public: -/* constructors and destructors */ - ClosureIterator(const SchubertContext& p); - ~ClosureIterator() {}; -/* iterator operators */ - operator bool() const; /* inlined */ + /* private functions */ + void update(const CoxNbr &x, const Generator &s); + +public: + /* constructors and destructors */ + ClosureIterator(const SchubertContext &p); + ~ClosureIterator(){}; + /* iterator operators */ + operator bool() const; /* inlined */ void operator++(); - const SubSet& operator()() const; /* inlined */ -/* accessors */ - const CoxNbr& current() const; /* inlined */ + const SubSet &operator()() const; /* inlined */ + /* accessors */ + const CoxNbr ¤t() const; /* inlined */ }; /******** inline definitions **********************************************/ - inline LFlags StandardSchubertContext::ascent(const CoxNbr& x) const - {return ~d_descent[x]&leqmask[2*d_rank-1];} - inline LFlags StandardSchubertContext::descent(const CoxNbr& x) const - {return d_descent[x];} - inline const BitMap& StandardSchubertContext::downset(const Generator& s) - const {return d_downset[s];} - inline Generator StandardSchubertContext::firstDescent(const CoxNbr& x) const - {return firstBit(descent(x));} - inline Generator StandardSchubertContext::firstLDescent(const CoxNbr& x) - const {return firstBit(ldescent(x));} - inline Generator StandardSchubertContext::firstRDescent(const CoxNbr& x) - const {return firstBit(rdescent(x));} - inline Generator StandardSchubertContext::firstDescent(const CoxNbr& x, - const Permutation& order) const {return firstRDescent(x,order);} - inline Generator StandardSchubertContext::firstLDescent(const CoxNbr& x, - const Permutation& order) const {return minDescent(ldescent(x),order);} - inline Generator StandardSchubertContext::firstRDescent(const CoxNbr& x, - const Permutation& order) const {return minDescent(rdescent(x),order);} - inline const CoatomList& StandardSchubertContext::hasse(const CoxNbr& x) - const {return d_hasse[x];} - inline bool StandardSchubertContext::isDescent(const CoxNbr& x, - const Generator& s) - const {return d_descent[x]&lmask[s];} - inline LFlags StandardSchubertContext::lascent(const CoxNbr& x) const - {return ~ldescent(x)&leqmask[d_rank-1];} - inline LFlags StandardSchubertContext::ldescent(const CoxNbr& x) const - {return d_descent[x] >> d_rank;} - inline Length StandardSchubertContext::length(const CoxNbr& x) const - {return d_length[x];} - inline CoxNbr StandardSchubertContext::lshift(const CoxNbr& x, - const Generator& s) - const {return d_shift[x][d_rank+s];} - inline Length StandardSchubertContext::maxlength() const - {return d_maxlength;} - inline Ulong StandardSchubertContext::nStarOps() const - {return d_graph.starOps().size();} - inline const BitMap& StandardSchubertContext::parity(const CoxNbr& x) const - {return d_parity[d_length[x]%2];} - inline Rank StandardSchubertContext::rank() const {return d_rank;} - inline LFlags StandardSchubertContext::rascent(const CoxNbr& x) const - {return ~rdescent(x)&leqmask[d_rank-1];} - inline LFlags StandardSchubertContext::rdescent(const CoxNbr& x) const - {return d_descent[x] & leqmask[d_rank-1];} - inline CoxNbr StandardSchubertContext::rshift(const CoxNbr& x, - const Generator& s) - const {return d_shift[x][s];} - inline LFlags StandardSchubertContext::S() const {return leqmask[d_rank-1];} - inline CoxNbr StandardSchubertContext::shift(const CoxNbr& x, - const Generator& s) - const {return d_shift[x][s];} - inline CoxNbr StandardSchubertContext::size() const {return d_size;} - inline CoxNbr StandardSchubertContext::star(CoxNbr x, - const Ulong& r) const - {return d_star[x][r];} - inline const Type& StandardSchubertContext::type() const - {return d_graph.type();} +inline LFlags StandardSchubertContext::ascent(const CoxNbr &x) const { + return ~d_descent[x] & leqmask[2 * d_rank - 1]; +} +inline LFlags StandardSchubertContext::descent(const CoxNbr &x) const { + return d_descent[x]; +} +inline const BitMap & +StandardSchubertContext::downset(const Generator &s) const { + return d_downset[s]; +} +inline Generator StandardSchubertContext::firstDescent(const CoxNbr &x) const { + return firstBit(descent(x)); +} +inline Generator StandardSchubertContext::firstLDescent(const CoxNbr &x) const { + return firstBit(ldescent(x)); +} +inline Generator StandardSchubertContext::firstRDescent(const CoxNbr &x) const { + return firstBit(rdescent(x)); +} +inline Generator +StandardSchubertContext::firstDescent(const CoxNbr &x, + const Permutation &order) const { + return firstRDescent(x, order); +} +inline Generator +StandardSchubertContext::firstLDescent(const CoxNbr &x, + const Permutation &order) const { + return minDescent(ldescent(x), order); +} +inline Generator +StandardSchubertContext::firstRDescent(const CoxNbr &x, + const Permutation &order) const { + return minDescent(rdescent(x), order); +} +inline const CoatomList &StandardSchubertContext::hasse(const CoxNbr &x) const { + return d_hasse[x]; +} +inline bool StandardSchubertContext::isDescent(const CoxNbr &x, + const Generator &s) const { + return d_descent[x] & lmask[s]; +} +inline LFlags StandardSchubertContext::lascent(const CoxNbr &x) const { + return ~ldescent(x) & leqmask[d_rank - 1]; +} +inline LFlags StandardSchubertContext::ldescent(const CoxNbr &x) const { + return d_descent[x] >> d_rank; +} +inline Length StandardSchubertContext::length(const CoxNbr &x) const { + return d_length[x]; +} +inline CoxNbr StandardSchubertContext::lshift(const CoxNbr &x, + const Generator &s) const { + return d_shift[x][d_rank + s]; +} +inline Length StandardSchubertContext::maxlength() const { return d_maxlength; } +inline Ulong StandardSchubertContext::nStarOps() const { + return d_graph.starOps().size(); +} +inline const BitMap &StandardSchubertContext::parity(const CoxNbr &x) const { + return d_parity[d_length[x] % 2]; +} +inline Rank StandardSchubertContext::rank() const { return d_rank; } +inline LFlags StandardSchubertContext::rascent(const CoxNbr &x) const { + return ~rdescent(x) & leqmask[d_rank - 1]; +} +inline LFlags StandardSchubertContext::rdescent(const CoxNbr &x) const { + return d_descent[x] & leqmask[d_rank - 1]; +} +inline CoxNbr StandardSchubertContext::rshift(const CoxNbr &x, + const Generator &s) const { + return d_shift[x][s]; +} +inline LFlags StandardSchubertContext::S() const { return leqmask[d_rank - 1]; } +inline CoxNbr StandardSchubertContext::shift(const CoxNbr &x, + const Generator &s) const { + return d_shift[x][s]; +} +inline CoxNbr StandardSchubertContext::size() const { return d_size; } +inline CoxNbr StandardSchubertContext::star(CoxNbr x, const Ulong &r) const { + return d_star[x][r]; +} +inline const Type &StandardSchubertContext::type() const { + return d_graph.type(); +} - inline const SubSet& ClosureIterator::operator()() const {return d_subSet;} - inline ClosureIterator::operator bool() const {return d_valid;} - inline const CoxNbr& ClosureIterator::current() const {return d_current;} +inline const SubSet &ClosureIterator::operator()() const { return d_subSet; } +inline ClosureIterator::operator bool() const { return d_valid; } +inline const CoxNbr &ClosureIterator::current() const { return d_current; } -} +} // namespace schubert #endif diff --git a/search.h b/search.h index cd61f01..012fe10 100644 --- a/search.h +++ b/search.h @@ -5,77 +5,72 @@ See file main.cpp for full copyright notice */ -#ifndef SEARCH_H /* guard against multiple inclusions */ +#ifndef SEARCH_H /* guard against multiple inclusions */ #define SEARCH_H #include "globals.h" #include "list.h" namespace search { - using namespace coxeter; - using namespace list; +using namespace coxeter; +using namespace list; /******** type declarations *************************************************/ - template - class BinaryTree; +template class BinaryTree; - template - struct TreeNode; +template struct TreeNode; /******** function declarations *********************************************/ - template - void print(FILE* file, const BinaryTree& t); - template - void print(FILE*, TreeNode*, const char*); +template void print(FILE *file, const BinaryTree &t); +template void print(FILE *, TreeNode *, const char *); /******** type definitions **************************************************/ -template -struct TreeNode { - TreeNode* left; - TreeNode* right; +template struct TreeNode { + TreeNode *left; + TreeNode *right; T data; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TreeNode));} - TreeNode(const T& a); + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TreeNode)); + } + TreeNode(const T &a); ~TreeNode(); }; -template -class BinaryTree { - protected: +template class BinaryTree { +protected: Ulong d_size; - TreeNode* d_root; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(BinaryTree));} + TreeNode *d_root; + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(BinaryTree)); + } BinaryTree(); virtual ~BinaryTree(); -/* accessors */ + /* accessors */ Ulong size() const; - TreeNode* root() const; -/* modifiers */ - T* find(const T& a); + TreeNode *root() const; + /* modifiers */ + T *find(const T &a); }; /******** inline definitions ************************************************/ -template -inline Ulong BinaryTree::size() const - {return d_size;} - -template -inline TreeNode* BinaryTree::root() const - {return d_root;} +template inline Ulong BinaryTree::size() const { return d_size; } +template inline TreeNode *BinaryTree::root() const { + return d_root; } +} // namespace search + #include "search.hpp" #endif diff --git a/search.hpp b/search.hpp index 51923c8..f0e73d8 100644 --- a/search.hpp +++ b/search.hpp @@ -1,6 +1,6 @@ /* This is search.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -8,7 +8,7 @@ #include "memory.h" namespace search { - using namespace memory; +using namespace memory; }; /**************************************************************************** @@ -20,7 +20,6 @@ namespace search { ****************************************************************************/ - /**************************************************************************** Chapter I -- The BinaryTree class. @@ -46,12 +45,14 @@ namespace search { namespace search { -template BinaryTree::BinaryTree() - :d_size(0), d_root(0) +template +BinaryTree::BinaryTree() + : d_size(0), d_root(0) {} -template BinaryTree::~BinaryTree() +template +BinaryTree::~BinaryTree() /* The tree is destructed recursively by ~TreeNode(). @@ -61,7 +62,8 @@ template BinaryTree::~BinaryTree() delete d_root; } -template T* BinaryTree::find(const T& a) +template +T *BinaryTree::find(const T &a) /* Finds the element a in the tree; creates a new node if a is not found. @@ -72,7 +74,7 @@ template T* BinaryTree::find(const T& a) */ { - TreeNode** c = &d_root; + TreeNode **c = &d_root; while (*c) { if (a == (*c)->data) /* a was found */ @@ -80,7 +82,7 @@ template T* BinaryTree::find(const T& a) if (a < (*c)->data) /* go to left tree */ c = &((*c)->left); else /* go to right tree */ - c = &((*c)->right); + c = &((*c)->right); } /* at this point c points to the insertion point */ @@ -94,7 +96,7 @@ template T* BinaryTree::find(const T& a) return &((*c)->data); } -}; +}; // namespace search /***************************************************************************** @@ -108,18 +110,21 @@ template T* BinaryTree::find(const T& a) namespace search { -template TreeNode::TreeNode(const T& a):data(a) +template +TreeNode::TreeNode(const T &a) + : data(a) {} -template TreeNode::~TreeNode() +template +TreeNode::~TreeNode() { delete left; delete right; } -}; +}; // namespace search /***************************************************************************** @@ -130,23 +135,25 @@ template TreeNode::~TreeNode() - print(file,t) : prints the tree on the file; *****************************************************************************/ - + namespace search { -template void print(FILE* file, const BinaryTree& t) +template +void print(FILE *file, const BinaryTree &t) /* Prints out the tree on the output file. */ { - fprintf(file,"size : %lu\n\n",t.size()); - print(file,t.root()); + fprintf(file, "size : %lu\n\n", t.size()); + print(file, t.root()); return; } -template void print(FILE* file, TreeNode* c, const char* varname) +template +void print(FILE *file, TreeNode *c, const char *varname) /* Recursively prints out the nodes, indenting to express the tree structure. @@ -159,18 +166,18 @@ template void print(FILE* file, TreeNode* c, const char* varname) return; // indentation += 2; - print(file,c->left,varname); + print(file, c->left, varname); // indentation -= 2; - fprintf(file,"%*s",indentation,""); - print(file,c->data,varname); - fprintf(file,"\n"); + fprintf(file, "%*s", indentation, ""); + print(file, c->data, varname); + fprintf(file, "\n"); // indentation += 2; - print(file,c->right,varname); + print(file, c->right, varname); // indentation -= 2; return; } -}; +}; // namespace search diff --git a/special.cpp b/special.cpp index 5b1b96e..f44e877 100644 --- a/special.cpp +++ b/special.cpp @@ -13,14 +13,13 @@ /******** local definitions **************************************************/ namespace { - using namespace special; +using namespace special; - void special_f(); - void special_h(); - - const char* special_tag = "user-defined command"; -}; +void special_f(); +void special_h(); +const char *special_tag = "user-defined command"; +}; // namespace /************************************************************************ @@ -30,8 +29,7 @@ namespace { ************************************************************************/ - -void special::addSpecialCommands(commands::CommandTree* tree) +void special::addSpecialCommands(commands::CommandTree *tree) /* This function should be edited if you want to add new commands to the @@ -45,8 +43,8 @@ void special::addSpecialCommands(commands::CommandTree* tree) The commands are added to the main command tree of the program (the tree argument is used for convienience, since this function is called - when mainCommandTree() is not yet functional); it would also be possible - to add special command trees, but we have decided to leave this to users + when mainCommandTree() is not yet functional); it would also be possible + to add special command trees, but we have decided to leave this to users willing to delve into commands.c. */ @@ -58,7 +56,7 @@ void special::addSpecialCommands(commands::CommandTree* tree) /* the last argument is optional; it defaults to default_help, declared in commands.h */ - tree->add("special",special_tag,&special_f,&special_h); + tree->add("special", special_tag, &special_f, &special_h); /* add user-defined commands here ... */ @@ -73,8 +71,8 @@ void special_f() Comment out the default code below and replace by your own code. */ -{ - fprintf(stderr,"not implemented\n"); +{ + fprintf(stderr, "not implemented\n"); return; } @@ -85,9 +83,8 @@ void special_h() */ { - io::printFile(stderr,"special.defhelp",directories::MESSAGE_DIR); + io::printFile(stderr, "special.defhelp", directories::MESSAGE_DIR); return; } -}; - +}; // namespace diff --git a/special.h b/special.h index 76eb40b..5b80146 100644 --- a/special.h +++ b/special.h @@ -6,19 +6,19 @@ */ -#ifndef SPECIAL_H /* guard against multiple inclusions */ +#ifndef SPECIAL_H /* guard against multiple inclusions */ #define SPECIAL_H #include "globals.h" #include "commands.h" namespace special { - using namespace coxeter; +using namespace coxeter; /******** function declarations *********************************************/ - void addSpecialCommands(commands::CommandTree* tree); +void addSpecialCommands(commands::CommandTree *tree); -} +} // namespace special #endif diff --git a/stack.h b/stack.h index 7b50253..25c65b1 100644 --- a/stack.h +++ b/stack.h @@ -5,78 +5,72 @@ See file main.cpp for full copyright notice */ -#ifndef STACK_H /* guard against multiple inclusions */ +#ifndef STACK_H /* guard against multiple inclusions */ #define STACK_H #include "globals.h" #include "list.h" namespace stack { - using namespace coxeter; - using namespace list; +using namespace coxeter; +using namespace list; /* class declarations */ - template class Fifo; - template class Stack; +template class Fifo; +template class Stack; /******* class definitions *************************************************/ -template -class Fifo { - private: +template class Fifo { +private: List d_list; Ulong d_first; Ulong d_last; Ulong d_size; - public: -/* constructors and destructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Fifo));} + +public: + /* constructors and destructors */ + void operator delete(void *ptr) { return arena().free(ptr, sizeof(Fifo)); } Fifo(); - ~Fifo() {}; -/* modifiers */ - const T& pop(); - void push(const T&); -/* accessors */ + ~Fifo(){}; + /* modifiers */ + const T &pop(); + void push(const T &); + /* accessors */ Ulong size() const; - const T& top() const; + const T &top() const; }; -template -class Stack { - private: +template class Stack { +private: List d_list; - public: -/* constructors and destructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Stack));} + +public: + /* constructors and destructors */ + void operator delete(void *ptr) { return arena().free(ptr, sizeof(Stack)); } Stack(); ~Stack(); -/* modifiers */ - const T* pop(); - void push(const T&); -/* accessors */ + /* modifiers */ + const T *pop(); + void push(const T &); + /* accessors */ Ulong size() const; - const T& top() const; + const T &top() const; }; /******** Inline implementations ******************************************/ - template - inline Ulong Stack::size() const - {return d_list.size();} - template - inline const T& Stack::top() const - {return d_list[d_list.size()-1];} - - template - inline Ulong Fifo::size() const - {return d_size;} - template - inline const T& Fifo::top() const - {return d_list[d_first];} +template inline Ulong Stack::size() const { return d_list.size(); } +template inline const T &Stack::top() const { + return d_list[d_list.size() - 1]; +} + +template inline Ulong Fifo::size() const { return d_size; } +template inline const T &Fifo::top() const { + return d_list[d_first]; } +} // namespace stack #include "stack.hpp" diff --git a/stack.hpp b/stack.hpp index 0224f49..d1e13f7 100644 --- a/stack.hpp +++ b/stack.hpp @@ -1,6 +1,6 @@ /* This is stack.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -42,12 +42,14 @@ namespace stack { -template Fifo::Fifo() - : d_list(0), d_first(0), d_last(~0L), d_size(0) +template +Fifo::Fifo() + : d_list(0), d_first(0), d_last(~0L), d_size(0) {} -template void Fifo::push(const T& object) +template +void Fifo::push(const T &object) /* Pushes an object on the list, enlarging the list if necessary. @@ -57,13 +59,13 @@ template void Fifo::push(const T& object) d_last++; if (d_last == d_first) { /* we need more space */ - d_list.setSize(d_list.size()+1); - if (d_first < (d_list.size()-1)) { /* move up */ - d_list.setData(d_list.ptr()+d_first,d_first+1,d_list.size()-d_first-1); + d_list.setSize(d_list.size() + 1); + if (d_first < (d_list.size() - 1)) { /* move up */ + d_list.setData(d_list.ptr() + d_first, d_first + 1, + d_list.size() - d_first - 1); } d_first++; - } - else if (d_last == d_list.size()) /* wrap around */ + } else if (d_last == d_list.size()) /* wrap around */ d_last = 0; d_list[d_last] = object; @@ -72,7 +74,8 @@ template void Fifo::push(const T& object) return; } -template const T& Fifo::pop() +template +const T &Fifo::pop() /* Pops the list; it is assumed that the user has checked for non-emptyness. @@ -81,20 +84,19 @@ template const T& Fifo::pop() { if (d_first == d_list.size()) d_first = 0; - const T& result = d_list[d_first]; + const T &result = d_list[d_first]; d_size--; if (d_size == 0) { /* reset an empty list */ d_first = d_list.size(); d_last = ~0L; - } - else + } else d_first++; return result; } -}; +}; // namespace stack /**************************************************************************** @@ -113,11 +115,13 @@ template const T& Fifo::pop() namespace stack { -template Stack::Stack() +template +Stack::Stack() {} -template Stack::~Stack() +template +Stack::~Stack() /* Destructing the components is enough. @@ -125,7 +129,8 @@ template Stack::~Stack() {} -template void Stack::push(const T& object) +template +void Stack::push(const T &object) /* Assumes that copy constructor is defined for class T. @@ -135,7 +140,8 @@ template void Stack::push(const T& object) d_list.append(object); } -template const T* Stack::pop() +template +const T *Stack::pop() /* Pops the stack, returning the address of the corresponding object. @@ -144,11 +150,11 @@ template const T* Stack::pop() { if (d_list.size() != 0) { - d_list.setSize(d_list.size()-1); + d_list.setSize(d_list.size() - 1); return &d_list[d_list.size()]; } return 0; } -}; +}; // namespace stack diff --git a/transducer.cpp b/transducer.cpp index 25c250a..8b8c7e6 100644 --- a/transducer.cpp +++ b/transducer.cpp @@ -1,6 +1,6 @@ /* This is transducer.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -11,24 +11,24 @@ #include "error.h" namespace transducer { - using namespace error; - using namespace transducer; -}; +using namespace error; +using namespace transducer; +}; // namespace transducer /******** local definitions *************************************************/ namespace { - using namespace transducer; +using namespace transducer; - ParNbr dihedralMin(SubQuotient *X, ParNbr y, Generator s, Generator t); - ParNbr dihedralShift(SubQuotient *X, ParNbr y, Generator s, - Generator t, Ulong c); -}; +ParNbr dihedralMin(SubQuotient *X, ParNbr y, Generator s, Generator t); +ParNbr dihedralShift(SubQuotient *X, ParNbr y, Generator s, Generator t, + Ulong c); +}; // namespace /**************************************************************************** This file contains code for handling the basic group operations using the - transducer representation, as described in my paper in J. of Symb. Comp. 27 + transducer representation, as described in my paper in J. of Symb. Comp. 27 (1999), pp. 311--324. This is certainly the preferred way for handling finite Coxeter groups : @@ -61,17 +61,17 @@ namespace { namespace transducer { -FiltrationTerm::FiltrationTerm(CoxGraph& G, Rank l, FiltrationTerm* p) - :d_next(p) +FiltrationTerm::FiltrationTerm(CoxGraph &G, Rank l, FiltrationTerm *p) + : d_next(p) /* Constructs the l-th term of the filtration of the group of graph G. */ { - d_X = new SubQuotient(G,l); + d_X = new SubQuotient(G, l); d_np.setSize(1); - new(d_np.ptr()) CoxWord(0); + new (d_np.ptr()) CoxWord(0); } FiltrationTerm::~FiltrationTerm() @@ -100,12 +100,12 @@ void FiltrationTerm::fillNormalPieces() */ { - Ulong old_size = d_np.size(); /* is always > 0 */ + Ulong old_size = d_np.size(); /* is always > 0 */ d_np.setSize(size()); for (Ulong j = old_size; j < size(); ++j) - new(d_np.ptr()+j) CoxWord(length(j)); + new (d_np.ptr() + j) CoxWord(length(j)); for (ParNbr x = old_size; x < size(); ++x) { @@ -113,21 +113,21 @@ void FiltrationTerm::fillNormalPieces() Generator t = undef_generator; for (Generator s = 0; s < rank(); ++s) { - if (shift(x,s) < y) { /* this s is better than what we had */ - y = shift(x,s); - t = s; - } + if (shift(x, s) < y) { /* this s is better than what we had */ + y = shift(x, s); + t = s; + } } d_np[x] = d_np[y]; - d_np[x][length(y)] = t+1; + d_np[x][length(y)] = t + 1; d_np[x].setLength(length(x)); } return; } -}; +}; // namespace transducer /**************************************************************************** @@ -165,21 +165,21 @@ void FiltrationTerm::fillNormalPieces() namespace transducer { -SubQuotient::SubQuotient(CoxGraph& G, Rank l) - :d_rank(l),d_size(1),d_graph(G),d_shift(l),d_length(1) +SubQuotient::SubQuotient(CoxGraph &G, Rank l) + : d_rank(l), d_size(1), d_graph(G), d_shift(l), d_length(1) /* - This function makes the l-th subquotient in the group corresponding to G + This function makes the l-th subquotient in the group corresponding to G and initializes its first node. */ { d_shift.setSize(l); - for (Generator s = 0; s < l-1; ++s) - shiftref(0,s) = undef_parnbr + s+1; + for (Generator s = 0; s < l - 1; ++s) + shiftref(0, s) = undef_parnbr + s + 1; - shiftref(0,l-1) = undef_parnbr; + shiftref(0, l - 1) = undef_parnbr; return; } @@ -228,31 +228,31 @@ ParNbr SubQuotient::extend(ParNbr x, Generator s) moreover we can find xst by applying more t,s,t, ... ubtil we get to the appropriate length. This fills in all the downwards shifts from xs, hence all the upwwards shifts that become defined from the - addition of the new elements, and stay within X_l. + addition of the new elements, and stay within X_l. The shifts that are not yet filled in correspond to either undef_parnbr, - or cases where xst = uxs for some u < l-1. Then xsts = ux, and in + or cases where xst = uxs for some u < l-1. Then xsts = ux, and in particular xsts < xst. Again this can be decided from applying t,s,t, ... to x, and the resulting xsts can be computed. So we can decide in all cases. */ { - if (shift(x,s) != undef_parnbr) /* no need to extend */ - return shift(x,s); + if (shift(x, s) != undef_parnbr) /* no need to extend */ + return shift(x, s); - if (length(x) == LENGTH_MAX) /* overflow */ { + if (length(x) == LENGTH_MAX) /* overflow */ { ERRNO = LENGTH_OVERFLOW; return undef_parnbr; } static SubSet Q; - schubertClosure(Q,x); + schubertClosure(Q, x); Ulong c = 0; for (Ulong j = 0; j < Q.size(); ++j) /* count new elements */ - if (shift(Q[j],s) == undef_parnbr) + if (shift(Q[j], s) == undef_parnbr) ++c; if (c > PARNBR_MAX - d_size) { /* overflow --- quite possible! */ @@ -262,17 +262,17 @@ ParNbr SubQuotient::extend(ParNbr x, Generator s) /* resize */ - d_shift.setSize(d_rank*(d_size+c)); - d_length.setSize(d_size+c); + d_shift.setSize(d_rank * (d_size + c)); + d_length.setSize(d_size + c); /* fill in shifts by s */ Ulong prev_size = d_size; - for (Ulong j = 0; j < Q.size(); ++j) - if (shift(Q[j],s) == undef_parnbr) { - shiftref(Q[j],s) = d_size; - shiftref(d_size,s) = Q[j]; + for (Ulong j = 0; j < Q.size(); ++j) + if (shift(Q[j], s) == undef_parnbr) { + shiftref(Q[j], s) = d_size; + shiftref(d_size, s) = Q[j]; lengthref(d_size) = length(Q[j]) + 1; ++d_size; } @@ -283,47 +283,46 @@ ParNbr SubQuotient::extend(ParNbr x, Generator s) for (Generator t = 0; t < d_rank; ++t) { if (t == s) - continue; + continue; - shiftref(z,t) = undef_parnbr; /* initialzation */ - CoxEntry m = d_graph.M(s,t); + shiftref(z, t) = undef_parnbr; /* initialzation */ + CoxEntry m = d_graph.M(s, t); if (m == 0) - continue; + continue; - ParNbr y = dihedralMin(this,z,s,t); + ParNbr y = dihedralMin(this, z, s, t); Length d = length(z) - length(y); - if (d < m-1) /* zt > z, no transduction */ - continue; + if (d < m - 1) /* zt > z, no transduction */ + continue; if (d == m) { /* zt < z */ - if (m%2) - y = dihedralShift(this,y,t,s,m-1); - else - y = dihedralShift(this,y,s,t,m-1); - shiftref(z,t) = y; - shiftref(y,t) = z; - continue; + if (m % 2) + y = dihedralShift(this, y, t, s, m - 1); + else + y = dihedralShift(this, y, s, t, m - 1); + shiftref(z, t) = y; + shiftref(y, t) = z; + continue; } /* now d == m-1 */ - if (m%2) - y = dihedralShift(this,y,s,t,m-1); + if (m % 2) + y = dihedralShift(this, y, s, t, m - 1); else - y = dihedralShift(this,y,t,s,m-1); + y = dihedralShift(this, y, t, s, m - 1); - if (y > undef_parnbr) /* zt = uz */ - shiftref(z,t) = y; + if (y > undef_parnbr) /* zt = uz */ + shiftref(z, t) = y; } } - return size()-1; + return size() - 1; } - -void SubQuotient::fill(const CoxGraph& G) +void SubQuotient::fill(const CoxGraph &G) /* This function fills the subquotient of rank l for the group defined by @@ -343,50 +342,50 @@ void SubQuotient::fill(const CoxGraph& G) { for (Ulong x = 0; x < d_size; ++x) { /* find all extensions of x */ for (Generator s = 0; s < rank(); ++s) { - if (shift(x,s) == undef_parnbr) { /* extend */ + if (shift(x, s) == undef_parnbr) { /* extend */ - d_shift.setSize(d_rank*(d_size+1)); - d_length.setSize(d_size+1); + d_shift.setSize(d_rank * (d_size + 1)); + d_length.setSize(d_size + 1); - shiftref(d_size,s) = x; - shiftref(x,s) = d_size; - lengthref(d_size) = length(x) + 1; + shiftref(d_size, s) = x; + shiftref(x, s) = d_size; + lengthref(d_size) = length(x) + 1; - for (Generator t = 0; t < rank(); t++) { /* find shifts */ + for (Generator t = 0; t < rank(); t++) { /* find shifts */ - if (t == s) - continue; /* next t */ + if (t == s) + continue; /* next t */ - shiftref(d_size,t) = undef_parnbr; + shiftref(d_size, t) = undef_parnbr; - CoxEntry m = G.M(s,t); - ParNbr y = dihedralMin(this,d_size,s,t); - Length d = length(d_size) - length(y); + CoxEntry m = G.M(s, t); + ParNbr y = dihedralMin(this, d_size, s, t); + Length d = length(d_size) - length(y); - if (d < m-1) - continue; /* next t */ + if (d < m - 1) + continue; /* next t */ - if (d == m) { - if (m%2) - y = dihedralShift(this,y,t,s,m-1); - else - y = dihedralShift(this,y,s,t,m-1); - shiftref(d_size,t) = y; - shiftref(y,t) = d_size; - continue; /* next t */ - } + if (d == m) { + if (m % 2) + y = dihedralShift(this, y, t, s, m - 1); + else + y = dihedralShift(this, y, s, t, m - 1); + shiftref(d_size, t) = y; + shiftref(y, t) = d_size; + continue; /* next t */ + } - /* now d == m-1 */ + /* now d == m-1 */ - if (m%2) - y = dihedralShift(this,y,s,t,m-1); - else - y = dihedralShift(this,y,t,s,m-1); + if (m % 2) + y = dihedralShift(this, y, s, t, m - 1); + else + y = dihedralShift(this, y, t, s, m - 1); - if (y > undef_parnbr) /* y holds transduction value */ - shiftref(d_size,t) = y; - } - ++d_size; + if (y > undef_parnbr) /* y holds transduction value */ + shiftref(d_size, t) = y; + } + ++d_size; } } } @@ -396,7 +395,7 @@ void SubQuotient::fill(const CoxGraph& G) /******* accessors *********************************************************/ -Generator SubQuotient::firstDescent(const ParNbr& x) const +Generator SubQuotient::firstDescent(const ParNbr &x) const /* Returns the smallest s such that x.s < x, rank() if there is no such @@ -405,22 +404,21 @@ Generator SubQuotient::firstDescent(const ParNbr& x) const { for (Generator s = 0; s < rank(); ++s) - if (shift(x,s) < x) + if (shift(x, s) < x) return s; return rank(); } - -void SubQuotient::schubertClosure(SubSet& Q, ParNbr x) +void SubQuotient::schubertClosure(SubSet &Q, ParNbr x) /* This function returns in Q the set of all z in X such that z <= x in the Bruhat order, resizing Q if necessary. */ -{ - static bits::BitMap f; /* should become bitmap type */ +{ + static bits::BitMap f; /* should become bitmap type */ static CoxWord g; f.setSize(size()); @@ -431,30 +429,30 @@ void SubQuotient::schubertClosure(SubSet& Q, ParNbr x) Q[0] = 0; Ulong prev_size = 1; - reduced(g,x); + reduced(g, x); for (Ulong j = 0; j < g.length(); ++j) { Ulong c = 0; - Generator s = g[j]-1; + Generator s = g[j] - 1; for (Ulong z = 0; z < prev_size; ++z) { /* count new elements */ - if (shift(z,s) > undef_parnbr) /* undef_parnbr is impossible */ - continue; - if (!f.getBit(shift(z,s))) - ++c; + if (shift(z, s) > undef_parnbr) /* undef_parnbr is impossible */ + continue; + if (!f.getBit(shift(z, s))) + ++c; } - Q.setSize(Q.size() + c); /* should become Q += c ? */ + Q.setSize(Q.size() + c); /* should become Q += c ? */ ParNbr firstfree = prev_size; for (Ulong z = 0; z < prev_size; ++z) { - if (shift(z,s) > undef_parnbr) - continue; - if (!f.getBit(shift(z,s))) { /* add new element */ - f.setBit(shift(z,s)); - Q[firstfree] = shift(z,s); - ++firstfree; + if (shift(z, s) > undef_parnbr) + continue; + if (!f.getBit(shift(z, s))) { /* add new element */ + f.setBit(shift(z, s)); + Q[firstfree] = shift(z, s); + ++firstfree; } } prev_size += c; @@ -463,7 +461,7 @@ void SubQuotient::schubertClosure(SubSet& Q, ParNbr x) return; } -CoxWord& SubQuotient::reduced(CoxWord& g, ParNbr x) const +CoxWord &SubQuotient::reduced(CoxWord &g, ParNbr x) const { Length p = length(x); @@ -471,15 +469,14 @@ CoxWord& SubQuotient::reduced(CoxWord& g, ParNbr x) const for (Ulong j = 1; x; ++j) { /* take off last generator */ Generator s = firstDescent(x); - g[p-j] = s + 1; - x = shift(x,s); + g[p - j] = s + 1; + x = shift(x, s); } return g; } -}; - +}; // namespace transducer /**************************************************************************** @@ -495,14 +492,16 @@ CoxWord& SubQuotient::reduced(CoxWord& g, ParNbr x) const namespace transducer { -Transducer::Transducer(CoxGraph& G):d_filtration(G.rank()) +Transducer::Transducer(CoxGraph &G) + : d_filtration(G.rank()) -{ +{ Rank l = G.rank(); - for (Rank j = 0; j < l-1; j++) - new(d_filtration.ptr()+j) FiltrationTerm(G,l-j,d_filtration.ptr()+j+1); - new(d_filtration.ptr() + l-1) FiltrationTerm(G,1); + for (Rank j = 0; j < l - 1; j++) + new (d_filtration.ptr() + j) + FiltrationTerm(G, l - j, d_filtration.ptr() + j + 1); + new (d_filtration.ptr() + l - 1) FiltrationTerm(G, 1); d_filtration.setSize(l); } @@ -514,7 +513,7 @@ Transducer::~Transducer() {} -}; +}; // namespace transducer /**************************************************************************** @@ -534,11 +533,11 @@ Transducer::~Transducer() namespace { -ParNbr dihedralMin(SubQuotient* X, ParNbr y, Generator s, Generator t) +ParNbr dihedralMin(SubQuotient *X, ParNbr y, Generator s, Generator t) /* - Given a legal element y in X, and two generators s and t, returns the - minimal element in the right coset of y under the parabolic subgroup + Given a legal element y in X, and two generators s and t, returns the + minimal element in the right coset of y under the parabolic subgroup generated by s and t (this will always lie in the domain of the automaton, and is computable from the automaton information). @@ -549,27 +548,25 @@ ParNbr dihedralMin(SubQuotient* X, ParNbr y, Generator s, Generator t) { Generator u; - if (X->shift(y,s) >= y) + if (X->shift(y, s) >= y) u = t; else u = s; - - while(1) - { - if (X->shift(y,u) >= y) - return y; - else - y = X->shift(y,u); - if (u == s) - u = t; - else - u = s; - } -} + while (1) { + if (X->shift(y, u) >= y) + return y; + else + y = X->shift(y, u); + if (u == s) + u = t; + else + u = s; + } +} -ParNbr dihedralShift(SubQuotient* X, ParNbr y, Generator s, - Generator t, Ulong c) +ParNbr dihedralShift(SubQuotient *X, ParNbr y, Generator s, Generator t, + Ulong c) /* Given a legal element y in the automaton for V, and two generators @@ -583,18 +580,17 @@ ParNbr dihedralShift(SubQuotient* X, ParNbr y, Generator s, { Generator u = s; - for (Ulong j = 0; j < c; j++) - { - if (X->shift(y,u) >= undef_parnbr) - return X->shift(y,u); - y = X->shift(y,u); - if (u == s) - u = t; - else - u = s; - } + for (Ulong j = 0; j < c; j++) { + if (X->shift(y, u) >= undef_parnbr) + return X->shift(y, u); + y = X->shift(y, u); + if (u == s) + u = t; + else + u = s; + } return y; } -}; +}; // namespace diff --git a/transducer.h b/transducer.h index a5737c6..af36c72 100644 --- a/transducer.h +++ b/transducer.h @@ -5,33 +5,33 @@ See file main.cpp for full copyright notice */ -#ifndef TRANSDUCER_H /* guarantee single inclusion */ +#ifndef TRANSDUCER_H /* guarantee single inclusion */ #define TRANSDUCER_H #include "globals.h" namespace transducer { - using namespace coxeter; +using namespace coxeter; }; /******** type declarations *************************************************/ namespace transducer { - class FiltrationTerm; - class SubQuotient; - class Transducer; -}; +class FiltrationTerm; +class SubQuotient; +class Transducer; +}; // namespace transducer /******** constants *********************************************************/ #include "coxtypes.h" namespace transducer { - using namespace coxtypes; +using namespace coxtypes; }; namespace transducer { - static const ParNbr undef_parnbr = PARNBR_MAX + 1; +static const ParNbr undef_parnbr = PARNBR_MAX + 1; }; /******** type definitions **************************************************/ @@ -41,42 +41,43 @@ namespace transducer { #include "memory.h" namespace transducer { - using namespace list; - using namespace memory; - using namespace graph; -}; +using namespace list; +using namespace memory; +using namespace graph; +}; // namespace transducer class transducer::SubQuotient { - private: -/* typedef in class scope */ +private: + /* typedef in class scope */ typedef List SubSet; -/* data */ + /* data */ Rank d_rank; Ulong d_size; - CoxGraph& d_graph; + CoxGraph &d_graph; List d_shift; List d_length; - ParNbr& shiftref(ParNbr x, Generator s) - {return d_shift[x*d_rank+s];} - Length& lengthref(ParNbr x) {return d_length[x];} - public: -/* constructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(SubQuotient));} - SubQuotient(CoxGraph& G, Rank l); + ParNbr &shiftref(ParNbr x, Generator s) { return d_shift[x * d_rank + s]; } + Length &lengthref(ParNbr x) { return d_length[x]; } + +public: + /* constructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(SubQuotient)); + } + SubQuotient(CoxGraph &G, Rank l); ~SubQuotient(); -/* manipulators */ + /* manipulators */ ParNbr extend(ParNbr x, Generator s); - void fill(const CoxGraph& G); -/* accessors */ - Generator firstDescent(const ParNbr& x) const; - Length length(const ParNbr& x) const; /* inlined */ - Rank rank() const; /* inlined */ - CoxWord& reduced(CoxWord& g, ParNbr x) const; - ParNbr shift(const ParNbr& x, const Generator& s) const; /* inlined */ - Ulong size() const; /* inlined */ - void schubertClosure(SubSet& Q, ParNbr x); + void fill(const CoxGraph &G); + /* accessors */ + Generator firstDescent(const ParNbr &x) const; + Length length(const ParNbr &x) const; /* inlined */ + Rank rank() const; /* inlined */ + CoxWord &reduced(CoxWord &g, ParNbr x) const; + ParNbr shift(const ParNbr &x, const Generator &s) const; /* inlined */ + Ulong size() const; /* inlined */ + void schubertClosure(SubSet &Q, ParNbr x); }; class transducer::FiltrationTerm { @@ -84,41 +85,45 @@ class transducer::FiltrationTerm { FiltrationTerm *d_next; List d_np; void fillNormalPieces(); - public: -/* constructors */ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(FiltrationTerm));} - FiltrationTerm() {}; - FiltrationTerm(CoxGraph& G, Rank l, FiltrationTerm* p = 0); + +public: + /* constructors */ + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(FiltrationTerm)); + } + FiltrationTerm(){}; + FiltrationTerm(CoxGraph &G, Rank l, FiltrationTerm *p = 0); ~FiltrationTerm(); -/* manipulators */ - ParNbr extend(const ParNbr& x, const Generator& s); /* inlined */ - void fill(const CoxGraph& G); /* inlined */ -/* accessors */ - CoxLetter firstDescent (const ParNbr& x) const; /* inlined */ - Length length(const ParNbr& x) const; /* inlined */ - FiltrationTerm *next() const; /* inlined */ - const CoxWord& np(const ParNbr& x) const; /* inlined */ - Rank rank() const; /* inlined */ - CoxWord& reduced(CoxWord& g, ParNbr x) const; /* inlined */ - ParNbr shift(const ParNbr& x, const Generator& s) const; /* inlined */ - Ulong size() const; /* inlined */ + /* manipulators */ + ParNbr extend(const ParNbr &x, const Generator &s); /* inlined */ + void fill(const CoxGraph &G); /* inlined */ + /* accessors */ + CoxLetter firstDescent(const ParNbr &x) const; /* inlined */ + Length length(const ParNbr &x) const; /* inlined */ + FiltrationTerm *next() const; /* inlined */ + const CoxWord &np(const ParNbr &x) const; /* inlined */ + Rank rank() const; /* inlined */ + CoxWord &reduced(CoxWord &g, ParNbr x) const; /* inlined */ + ParNbr shift(const ParNbr &x, const Generator &s) const; /* inlined */ + Ulong size() const; /* inlined */ }; class transducer::Transducer { - private: +private: List d_filtration; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Transducer));} - Transducer(CoxGraph& G); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(Transducer)); + } + Transducer(CoxGraph &G); ~Transducer(); -/* manipulators */ - FiltrationTerm* transducer(const Rank& l) {return d_filtration.ptr()+l;} -/* accessors */ - const FiltrationTerm* transducer(const Rank& l) const; + /* manipulators */ + FiltrationTerm *transducer(const Rank &l) { return d_filtration.ptr() + l; } + /* accessors */ + const FiltrationTerm *transducer(const Rank &l) const; }; /******** inline implementations ********************************************/ @@ -127,37 +132,47 @@ namespace transducer { /* SubQuotient */ -inline Length SubQuotient::length(const ParNbr& x) const {return d_length[x];} -inline Rank SubQuotient::rank() const {return d_rank;} -inline ParNbr SubQuotient::shift(const ParNbr& x, const Generator& s) const - {return d_shift[x*d_rank+s];} -inline Ulong SubQuotient::size() const {return d_size;} +inline Length SubQuotient::length(const ParNbr &x) const { return d_length[x]; } +inline Rank SubQuotient::rank() const { return d_rank; } +inline ParNbr SubQuotient::shift(const ParNbr &x, const Generator &s) const { + return d_shift[x * d_rank + s]; +} +inline Ulong SubQuotient::size() const { return d_size; } /* FiltrationTerm */ -inline ParNbr FiltrationTerm::extend(const ParNbr& x, const Generator& s) - {return d_X->extend(x,s);} -inline void FiltrationTerm::fill(const CoxGraph& G) - {d_X->fill(G); fillNormalPieces();} -inline CoxLetter FiltrationTerm::firstDescent (const ParNbr& x) const - {return d_X->firstDescent(x);} -inline Length FiltrationTerm::length(const ParNbr& x) const - {return d_X->length(x);} -inline FiltrationTerm* FiltrationTerm::next() const {return d_next;} -inline const CoxWord& FiltrationTerm::np(const ParNbr& x) const - {return d_np[x];} -inline Rank FiltrationTerm::rank() const {return d_X->rank();} -inline CoxWord& FiltrationTerm::reduced(CoxWord& g, ParNbr x) const - {return d_X->reduced(g,x);} -inline ParNbr FiltrationTerm::shift(const ParNbr& x, const Generator& s) const - {return d_X->shift(x,s);} -inline Ulong FiltrationTerm::size() const {return d_X->size();} +inline ParNbr FiltrationTerm::extend(const ParNbr &x, const Generator &s) { + return d_X->extend(x, s); +} +inline void FiltrationTerm::fill(const CoxGraph &G) { + d_X->fill(G); + fillNormalPieces(); +} +inline CoxLetter FiltrationTerm::firstDescent(const ParNbr &x) const { + return d_X->firstDescent(x); +} +inline Length FiltrationTerm::length(const ParNbr &x) const { + return d_X->length(x); +} +inline FiltrationTerm *FiltrationTerm::next() const { return d_next; } +inline const CoxWord &FiltrationTerm::np(const ParNbr &x) const { + return d_np[x]; +} +inline Rank FiltrationTerm::rank() const { return d_X->rank(); } +inline CoxWord &FiltrationTerm::reduced(CoxWord &g, ParNbr x) const { + return d_X->reduced(g, x); +} +inline ParNbr FiltrationTerm::shift(const ParNbr &x, const Generator &s) const { + return d_X->shift(x, s); +} +inline Ulong FiltrationTerm::size() const { return d_X->size(); } /* Transducer */ -inline const FiltrationTerm* Transducer::transducer(const Rank& l) const - {return d_filtration.ptr()+l;} +inline const FiltrationTerm *Transducer::transducer(const Rank &l) const { + return d_filtration.ptr() + l; +} -}; +}; // namespace transducer #endif diff --git a/type.cpp b/type.cpp index 7f87d4f..2958eac 100644 --- a/type.cpp +++ b/type.cpp @@ -9,9 +9,9 @@ namespace { - const char* affinetypes ="abcdefg"; - const char *finitetypes = "ABCDEFGHI"; -}; +const char *affinetypes = "abcdefg"; +const char *finitetypes = "ABCDEFGHI"; +}; // namespace /**************************************************************************** @@ -23,7 +23,8 @@ namespace { namespace coxeter { -Type::Type():d_name("") +Type::Type() + : d_name("") /* Default constructor; yields the undefined type. @@ -31,7 +32,8 @@ Type::Type():d_name("") {} -Type::Type(const char* str):d_name(str) +Type::Type(const char *str) + : d_name(str) /* Makes the type with name str. @@ -62,7 +64,7 @@ Type::~Type() *****************************************************************************/ -bool isAffineType(const Type& x) +bool isAffineType(const Type &x) /* Recognizes the type of an affine group. This function defines the class @@ -72,12 +74,12 @@ bool isAffineType(const Type& x) */ { - if (strchr(affinetypes,x[0]) == NULL) + if (strchr(affinetypes, x[0]) == NULL) return false; return true; } -bool isFiniteType(const Type& type) +bool isFiniteType(const Type &type) /* Recognizes the type of a finite group. Non-irreducible types are @@ -89,14 +91,14 @@ bool isFiniteType(const Type& type) { for (Ulong j = 0; j < type.name().length(); ++j) { - if (strchr(finitetypes,type[j]) == NULL) + if (strchr(finitetypes, type[j]) == NULL) return false; } return true; } -bool isTypeA(const Type& type) +bool isTypeA(const Type &type) /* Recognizes if the group is of type A; it is assumed that isFiniteType @@ -107,7 +109,7 @@ bool isTypeA(const Type& type) return type[0] == 'A'; } -bool isTypeB(const Type& type) +bool isTypeB(const Type &type) /* Recognizes if the group is of type B; it is assumed that isFiniteType @@ -118,7 +120,7 @@ bool isTypeB(const Type& type) return type[0] == 'B'; } -bool isTypeD(const Type& type) +bool isTypeD(const Type &type) /* Recognizes if the group is of type D; it is assumed that isFiniteType @@ -129,5 +131,4 @@ bool isTypeD(const Type& type) return type[0] == 'D'; } -}; - +}; // namespace coxeter diff --git a/type.h b/type.h index 2abffd8..ee09f20 100644 --- a/type.h +++ b/type.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef TYPE_H /* guard against multiple inclusions */ +#ifndef TYPE_H /* guard against multiple inclusions */ #define TYPE_H #include "globals.h" @@ -15,48 +15,47 @@ namespace coxeter { /******** type declarations *************************************************/ - class Type; +class Type; /******** function declarations *********************************************/ - bool isAffineType(const Type& type); - bool isFiniteType(const Type& type); - bool isTypeA(const Type& type); - bool isTypeB(const Type& type); - bool isTypeD(const Type& type); +bool isAffineType(const Type &type); +bool isFiniteType(const Type &type); +bool isTypeA(const Type &type); +bool isTypeB(const Type &type); +bool isTypeD(const Type &type); /******** type definitions **************************************************/ - using namespace io; +using namespace io; class Type { - private: +private: String d_name; - public: -// constructors and destructors - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(Type));} + +public: + // constructors and destructors + void operator delete(void *ptr) { return arena().free(ptr, sizeof(Type)); } Type(); - Type(const char*); + Type(const char *); ~Type(); -// accessors - const char& operator[] (const Ulong& j) const; - const String& name() const; -// manipulators - char& operator[] (const Ulong& j); - String& name(); + // accessors + const char &operator[](const Ulong &j) const; + const String &name() const; + // manipulators + char &operator[](const Ulong &j); + String &name(); }; const Type undef_type(""); /******** inlined definitions **********************************************/ -inline const char& Type::operator[] (const Ulong& j) const - {return d_name[j];} -inline const String& Type::name() const {return d_name;} -inline char& Type::operator[] (const Ulong& j) {return d_name[j];} -inline String& Type::name() {return d_name;} +inline const char &Type::operator[](const Ulong &j) const { return d_name[j]; } +inline const String &Type::name() const { return d_name; } +inline char &Type::operator[](const Ulong &j) { return d_name[j]; } +inline String &Type::name() { return d_name; } -}; +}; // namespace coxeter #endif diff --git a/typeA.cpp b/typeA.cpp index 9351aae..ad7fd1c 100644 --- a/typeA.cpp +++ b/typeA.cpp @@ -20,7 +20,8 @@ namespace coxeter { -TypeACoxGroup::TypeACoxGroup(const Rank& l):FiniteCoxGroup(Type("A"),l) +TypeACoxGroup::TypeACoxGroup(const Rank &l) + : FiniteCoxGroup(Type("A"), l) /* Constructor for the type A Coxeter groups. @@ -36,13 +37,13 @@ TypeACoxGroup::~TypeACoxGroup() {} -bool TypeACoxGroup::parseGroupElement(ParseInterface& P) const +bool TypeACoxGroup::parseGroupElement(ParseInterface &P) const { Ulong r = P.offset; if (parseContextNumber(P)) { // the next token is a ContextNumber - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; @@ -52,21 +53,19 @@ bool TypeACoxGroup::parseGroupElement(ParseInterface& P) const if (hasPermutationInput()) { typeAInterface().parsePermutation(P); - } - else { - interface().parseCoxWord(P,mintable()); + } else { + interface().parseCoxWord(P, mintable()); } - if (ERRNO) { // no CoxWord could be parsed + if (ERRNO) { // no CoxWord could be parsed if (P.offset == r) { // nothing was parsed ERRNO = 0; return false; - } - else // parse error + } else // parse error return true; } - modify: +modify: // if we get to this point, a group element was successfully read @@ -77,7 +76,7 @@ bool TypeACoxGroup::parseGroupElement(ParseInterface& P) const // flush the current group element - prod(P.a[P.nestlevel],P.c); + prod(P.a[P.nestlevel], P.c); P.c.reset(); if (P.offset == r) // nothing was read; c is unchanged @@ -86,7 +85,6 @@ bool TypeACoxGroup::parseGroupElement(ParseInterface& P) const return true; } - /**************************************************************************** Chapter II --- Derived classes @@ -96,7 +94,8 @@ bool TypeACoxGroup::parseGroupElement(ParseInterface& P) const *****************************************************************************/ -TypeAMedRankCoxGroup::TypeAMedRankCoxGroup(const Rank& l):TypeACoxGroup(l) +TypeAMedRankCoxGroup::TypeAMedRankCoxGroup(const Rank &l) + : TypeACoxGroup(l) { mintable().fill(graph()); @@ -110,7 +109,7 @@ TypeAMedRankCoxGroup::~TypeAMedRankCoxGroup() {} -bool TypeASmallCoxGroup::parseDenseArray(ParseInterface& P) const +bool TypeASmallCoxGroup::parseDenseArray(ParseInterface &P) const /* Tries to parse a DenseArray from P. This is a '#' character, followed @@ -119,10 +118,10 @@ bool TypeASmallCoxGroup::parseDenseArray(ParseInterface& P) const */ { - const Interface& I = interface(); + const Interface &I = interface(); Token tok = 0; - Ulong p = I.getToken(P,tok); + Ulong p = I.getToken(P, tok); if (p == 0) return false; @@ -133,23 +132,22 @@ bool TypeASmallCoxGroup::parseDenseArray(ParseInterface& P) const // if we get to this point, we must read a valid integer P.offset += p; - CoxNbr x = interface::readCoxNbr(P,d_order); + CoxNbr x = interface::readCoxNbr(P, d_order); - if (x == undef_coxnbr) { //error + if (x == undef_coxnbr) { // error P.offset -= p; - Error(DENSEARRAY_OVERFLOW,d_order); + Error(DENSEARRAY_OVERFLOW, d_order); ERRNO = PARSE_ERROR; - } - else { // x is valid + } else { // x is valid CoxWord g(0); - prodD(g,x); - CoxGroup::prod(P.c,g); + prodD(g, x); + CoxGroup::prod(P.c, g); } return true; } -bool TypeASmallCoxGroup::parseGroupElement(ParseInterface& P) const +bool TypeASmallCoxGroup::parseGroupElement(ParseInterface &P) const /* This is the parseGroupElement function for the SmallCoxGroup type. In @@ -166,14 +164,14 @@ bool TypeASmallCoxGroup::parseGroupElement(ParseInterface& P) const Ulong r = P.offset; if (parseContextNumber(P)) { // next token is a context number - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; } if (parseDenseArray(P)) { // next token is a dense array - if (ERRNO) // parse error + if (ERRNO) // parse error return true; else goto modify; @@ -183,21 +181,19 @@ bool TypeASmallCoxGroup::parseGroupElement(ParseInterface& P) const if (hasPermutationInput()) { typeAInterface().parsePermutation(P); - } - else { - interface().parseCoxWord(P,mintable()); + } else { + interface().parseCoxWord(P, mintable()); } - if (ERRNO) { // no CoxWord could be parsed + if (ERRNO) { // no CoxWord could be parsed if (P.offset == r) { // nothing was parsed ERRNO = 0; return false; - } - else // parse error + } else // parse error return true; } - modify: +modify: // if we get to this point, a group element was successfully read @@ -208,7 +204,7 @@ bool TypeASmallCoxGroup::parseGroupElement(ParseInterface& P) const // flush the current group element - prod(P.a[P.nestlevel],P.c); + prod(P.a[P.nestlevel], P.c); P.c.reset(); if (P.offset == r) // nothing was read; c is unchanged @@ -217,7 +213,7 @@ bool TypeASmallCoxGroup::parseGroupElement(ParseInterface& P) const return true; } -int TypeASmallCoxGroup::prodD(CoxWord& g, const DenseArray& d_x) const +int TypeASmallCoxGroup::prodD(CoxWord &g, const DenseArray &d_x) const /* Does the multiplication of g by x, by recovering the normal pieces of x. @@ -225,15 +221,15 @@ int TypeASmallCoxGroup::prodD(CoxWord& g, const DenseArray& d_x) const */ { - const Transducer& T = d_transducer[0]; + const Transducer &T = d_transducer[0]; DenseArray x = d_x; int l = 0; for (Ulong j = 0; j < rank(); ++j) { - const FiltrationTerm& X = T.transducer(rank()-1-j)[0]; - ParNbr c = x%X.size(); - l += CoxGroup::prod(g,X.np(c)); + const FiltrationTerm &X = T.transducer(rank() - 1 - j)[0]; + ParNbr c = x % X.size(); + l += CoxGroup::prod(g, X.np(c)); x /= X.size(); } @@ -250,11 +246,12 @@ int TypeASmallCoxGroup::prodD(CoxWord& g, const DenseArray& d_x) const *****************************************************************************/ -TypeAInterface::TypeAInterface(const Rank& l):Interface(Type("A"),l) +TypeAInterface::TypeAInterface(const Rank &l) + : Interface(Type("A"), l) { - d_pInterface = new Interface(Type("A"),l+1); - GroupEltInterface GI(l+1,HexadecimalFromZero()); + d_pInterface = new Interface(Type("A"), l + 1); + GroupEltInterface GI(l + 1, HexadecimalFromZero()); d_pInterface->setIn(GI); d_pInterface->setOut(GI); }; @@ -265,7 +262,7 @@ TypeAInterface::~TypeAInterface() delete d_pInterface; }; -String& TypeAInterface::append(String& str, const CoxWord& g) const +String &TypeAInterface::append(String &str, const CoxWord &g) const /* Special append function for type A. If hasPermutationOutput is true, @@ -276,15 +273,14 @@ String& TypeAInterface::append(String& str, const CoxWord& g) const if (hasPermutationOutput()) { // print out as permutation CoxWord a(0); a.setLength(d_pInterface->rank()); - coxWordToPermutation(a,g); - return d_pInterface->append(str,a); - } - else { - return interface::append(str,g,*d_out); + coxWordToPermutation(a, g); + return d_pInterface->append(str, a); + } else { + return interface::append(str, g, *d_out); } } -bool TypeAInterface::parsePermutation(ParseInterface& P) const +bool TypeAInterface::parsePermutation(ParseInterface &P) const /* Parses a permutation. For us, a permutation should be represented as a @@ -303,12 +299,12 @@ bool TypeAInterface::parsePermutation(ParseInterface& P) const } if (P.offset > r) - permutationToCoxWord(P.c,P.c); + permutationToCoxWord(P.c, P.c); return true; } -void TypeAInterface::print(FILE* file, const CoxWord& g) const +void TypeAInterface::print(FILE *file, const CoxWord &g) const /* Special print function for type A. If hasPermutationOutput is true, @@ -319,17 +315,16 @@ void TypeAInterface::print(FILE* file, const CoxWord& g) const if (hasPermutationOutput()) { // print out as permutation CoxWord a(0); a.setLength(d_pInterface->rank()); - coxWordToPermutation(a,g); - d_pInterface->print(file,a); - } - else { - interface::print(file,g,*d_out); + coxWordToPermutation(a, g); + d_pInterface->print(file, a); + } else { + interface::print(file, g, *d_out); } return; } -void TypeAInterface::setIn(const GroupEltInterface& i) +void TypeAInterface::setIn(const GroupEltInterface &i) /* Resets d_in to i, and clears hasPermutationInput. @@ -346,7 +341,7 @@ void TypeAInterface::setIn(const GroupEltInterface& i) return; } -void TypeAInterface::setOut(const GroupEltInterface& i) +void TypeAInterface::setOut(const GroupEltInterface &i) /* Resets d_out to i, and clears hasPermutationOutput. @@ -373,7 +368,7 @@ void TypeAInterface::setOut(const GroupEltInterface& i) ******************************************************************************/ -void coxWordToPermutation(CoxWord& a, const CoxWord& g) +void coxWordToPermutation(CoxWord &a, const CoxWord &g) /* Puts in a the permutation of the numbers {0,...,l} whose reduced @@ -388,20 +383,20 @@ void coxWordToPermutation(CoxWord& a, const CoxWord& g) CoxWord h(g); for (Ulong j = 0; j < a.length(); ++j) - a[j] = j+1; + a[j] = j + 1; for (Ulong j = 0; j < h.length(); ++j) { - Generator s = h[j]-1; + Generator s = h[j] - 1; // interchange a[s] and a[s+1] - Generator t = a[s+1]; - a[s+1] = a[s]; + Generator t = a[s + 1]; + a[s + 1] = a[s]; a[s] = t; } return; } -void permutationToCoxWord(CoxWord& g, const CoxWord& a) +void permutationToCoxWord(CoxWord &g, const CoxWord &a) /* Puts in g the standard normal form of a, which is assumed to hold @@ -419,12 +414,12 @@ void permutationToCoxWord(CoxWord& g, const CoxWord& a) CoxWord b(a); Length c = 0; - for (Rank l = b.length()-1; l; --l) { + for (Rank l = b.length() - 1; l; --l) { Rank j = 0; - for (; b[l-j] != l+1; ++j) + for (; b[l - j] != l + 1; ++j) ; - for (Rank i = l-j; i < l; ++i) - b[i] = b[i+1]; + for (Rank i = l - j; i < l; ++i) + b[i] = b[i + 1]; b[l] = j; c += j; } @@ -435,11 +430,11 @@ void permutationToCoxWord(CoxWord& g, const CoxWord& a) for (Ulong j = 1; j < b.length(); ++j) { for (Ulong i = 0; i < b[j]; ++i) - g[c+i] = j-i; + g[c + i] = j - i; c += b[j]; } return; } -} +} // namespace coxeter diff --git a/typeA.h b/typeA.h index a173ce9..36d22a0 100644 --- a/typeA.h +++ b/typeA.h @@ -9,202 +9,224 @@ as permutations. */ -#ifndef TYPEA_H /* guard against multiple inclusions */ +#ifndef TYPEA_H /* guard against multiple inclusions */ #define TYPEA_H #include "globals.h" #include "fcoxgroup.h" namespace coxeter { - using namespace fcoxgroup; +using namespace fcoxgroup; //******** type declarations ************************************************* - class TypeAInterface; - class TypeACoxGroup; - class TypeABigRankCoxGroup; - class GeneralTypeABRCoxGroup; - class TypeAMedRankCoxGroup; - class GeneralTypeAMRCoxGroup; - class TypeASmallRankCoxGroup; - class GeneralTypeASRCoxGroup; - class TypeASmallCoxGroup; - class GeneralTypeASCoxGroup; +class TypeAInterface; +class TypeACoxGroup; +class TypeABigRankCoxGroup; +class GeneralTypeABRCoxGroup; +class TypeAMedRankCoxGroup; +class GeneralTypeAMRCoxGroup; +class TypeASmallRankCoxGroup; +class GeneralTypeASRCoxGroup; +class TypeASmallCoxGroup; +class GeneralTypeASCoxGroup; //******** function declarations ********************************************* - void coxWordToPermutation(CoxWord& a, const CoxWord& g); - void permutationToCoxWord(CoxWord& g, const CoxWord& a); +void coxWordToPermutation(CoxWord &a, const CoxWord &g); +void permutationToCoxWord(CoxWord &g, const CoxWord &a); //******** type definitions ************************************************** -class TypeACoxGroup:public FiniteCoxGroup { - TypeAInterface* d_typeAInterface; - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeACoxGroup));} +class TypeACoxGroup : public FiniteCoxGroup { + TypeAInterface *d_typeAInterface; - TypeACoxGroup(const Rank& l); +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeACoxGroup)); + } + + TypeACoxGroup(const Rank &l); virtual ~TypeACoxGroup(); -// accessors - void coxWordToPermutation(CoxWord& a, const CoxWord& g) const; - bool hasPermutationInput() const; /* inlined */ - bool hasPermutationOutput() const; /* inlined */ - void permutationToCoxWord(CoxWord& g, const CoxWord& a) const; - const TypeAInterface& typeAInterface() const; /* inlined */ -// manipulators - void setPermutationInput(bool b); /* inlined */ - void setPermutationOutput(bool b); /* inlined */ - TypeAInterface& typeAInterface(); /* inlined */ -// i/o - virtual bool parseGroupElement(ParseInterface& P) const; + // accessors + void coxWordToPermutation(CoxWord &a, const CoxWord &g) const; + bool hasPermutationInput() const; /* inlined */ + bool hasPermutationOutput() const; /* inlined */ + void permutationToCoxWord(CoxWord &g, const CoxWord &a) const; + const TypeAInterface &typeAInterface() const; /* inlined */ + // manipulators + void setPermutationInput(bool b); /* inlined */ + void setPermutationOutput(bool b); /* inlined */ + TypeAInterface &typeAInterface(); /* inlined */ + // i/o + virtual bool parseGroupElement(ParseInterface &P) const; }; -class TypeABigRankCoxGroup:public TypeACoxGroup { - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeABigRankCoxGroup));} +class TypeABigRankCoxGroup : public TypeACoxGroup { +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeABigRankCoxGroup)); + } - TypeABigRankCoxGroup(const Rank& l):TypeACoxGroup(l) {}; - virtual ~TypeABigRankCoxGroup() {}; + TypeABigRankCoxGroup(const Rank &l) : TypeACoxGroup(l){}; + virtual ~TypeABigRankCoxGroup(){}; }; -class GeneralTypeABRCoxGroup:public TypeABigRankCoxGroup { // leaf class - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralTypeABRCoxGroup));} +class GeneralTypeABRCoxGroup : public TypeABigRankCoxGroup { // leaf class +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralTypeABRCoxGroup)); + } - GeneralTypeABRCoxGroup(const Rank& l):TypeABigRankCoxGroup(l) {}; - ~GeneralTypeABRCoxGroup() {}; + GeneralTypeABRCoxGroup(const Rank &l) : TypeABigRankCoxGroup(l){}; + ~GeneralTypeABRCoxGroup(){}; }; -class TypeAMedRankCoxGroup:public TypeACoxGroup { - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeAMedRankCoxGroup));} +class TypeAMedRankCoxGroup : public TypeACoxGroup { +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeAMedRankCoxGroup)); + } - TypeAMedRankCoxGroup(const Rank& l); + TypeAMedRankCoxGroup(const Rank &l); virtual ~TypeAMedRankCoxGroup(); }; -class GeneralTypeAMRCoxGroup:public TypeAMedRankCoxGroup { // leaf class - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralTypeAMRCoxGroup));} +class GeneralTypeAMRCoxGroup : public TypeAMedRankCoxGroup { // leaf class +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralTypeAMRCoxGroup)); + } - GeneralTypeAMRCoxGroup(const Rank& l):TypeAMedRankCoxGroup(l) {}; - ~GeneralTypeAMRCoxGroup() {}; + GeneralTypeAMRCoxGroup(const Rank &l) : TypeAMedRankCoxGroup(l){}; + ~GeneralTypeAMRCoxGroup(){}; }; -class TypeASmallRankCoxGroup:public TypeAMedRankCoxGroup { - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeASmallRankCoxGroup));} +class TypeASmallRankCoxGroup : public TypeAMedRankCoxGroup { +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeASmallRankCoxGroup)); + } - TypeASmallRankCoxGroup(const Rank& l):TypeAMedRankCoxGroup(l) {}; - virtual ~TypeASmallRankCoxGroup() {}; + TypeASmallRankCoxGroup(const Rank &l) : TypeAMedRankCoxGroup(l){}; + virtual ~TypeASmallRankCoxGroup(){}; }; -class GeneralTypeASRCoxGroup:public TypeASmallRankCoxGroup { // leaf class - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralTypeASRCoxGroup));} +class GeneralTypeASRCoxGroup : public TypeASmallRankCoxGroup { // leaf class +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralTypeASRCoxGroup)); + } - GeneralTypeASRCoxGroup(const Rank& l):TypeASmallRankCoxGroup(l) {}; - ~GeneralTypeASRCoxGroup() {}; + GeneralTypeASRCoxGroup(const Rank &l) : TypeASmallRankCoxGroup(l){}; + ~GeneralTypeASRCoxGroup(){}; }; -class TypeASmallCoxGroup: public TypeASmallRankCoxGroup { - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeASmallCoxGroup));} - - TypeASmallCoxGroup(const Rank& l):TypeASmallRankCoxGroup(l) {}; - virtual ~TypeASmallCoxGroup() {}; -// accessors - int prodD(CoxWord& g, const DenseArray& d_x) const; -// i/o - bool parseDenseArray(ParseInterface& P) const; - virtual bool parseGroupElement(ParseInterface& P) const; +class TypeASmallCoxGroup : public TypeASmallRankCoxGroup { +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeASmallCoxGroup)); + } + + TypeASmallCoxGroup(const Rank &l) : TypeASmallRankCoxGroup(l){}; + virtual ~TypeASmallCoxGroup(){}; + // accessors + int prodD(CoxWord &g, const DenseArray &d_x) const; + // i/o + bool parseDenseArray(ParseInterface &P) const; + virtual bool parseGroupElement(ParseInterface &P) const; }; -class GeneralTypeASCoxGroup:public TypeASmallCoxGroup { // leaf class - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(GeneralTypeASCoxGroup));} +class GeneralTypeASCoxGroup : public TypeASmallCoxGroup { // leaf class +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(GeneralTypeASCoxGroup)); + } - GeneralTypeASCoxGroup(const Rank& l):TypeASmallCoxGroup(l) {}; - ~GeneralTypeASCoxGroup() {}; + GeneralTypeASCoxGroup(const Rank &l) : TypeASmallCoxGroup(l){}; + ~GeneralTypeASCoxGroup(){}; }; -class TypeAInterface:public Interface { - Interface* d_pInterface; +class TypeAInterface : public Interface { + Interface *d_pInterface; bool d_hasPermutationInput; bool d_hasPermutationOutput; - public: -// constructors and destructors - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(TypeAInterface));} - TypeAInterface(const Rank& l); +public: + // constructors and destructors + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(TypeAInterface)); + } + + TypeAInterface(const Rank &l); virtual ~TypeAInterface(); -// accessors - bool hasPermutationInput() const; /* inlined */ - bool hasPermutationOutput() const; /* inlined */ - bool parsePermutation(ParseInterface& P) const; -// manipulators - virtual void setIn(const GroupEltInterface& i); - virtual void setOut(const GroupEltInterface& i); - void setPermutationInput(bool b); /* inlined */ - void setPermutationOutput(bool b); /* inlined */ -// i/o - virtual String& append(String& str, const CoxWord& g) const; - virtual void print(FILE* file, const CoxWord& g) const; + // accessors + bool hasPermutationInput() const; /* inlined */ + bool hasPermutationOutput() const; /* inlined */ + bool parsePermutation(ParseInterface &P) const; + // manipulators + virtual void setIn(const GroupEltInterface &i); + virtual void setOut(const GroupEltInterface &i); + void setPermutationInput(bool b); /* inlined */ + void setPermutationOutput(bool b); /* inlined */ + // i/o + virtual String &append(String &str, const CoxWord &g) const; + virtual void print(FILE *file, const CoxWord &g) const; }; //******** inline definitions ************************************************ -inline bool TypeAInterface::hasPermutationInput() const - {return d_hasPermutationInput;} -inline bool TypeAInterface::hasPermutationOutput() const - {return d_hasPermutationOutput;} -inline void TypeAInterface::setPermutationInput(bool b) - {d_hasPermutationInput = b;} -inline void TypeAInterface::setPermutationOutput(bool b) - {d_hasPermutationOutput = b;} - -inline bool TypeACoxGroup::hasPermutationInput() const - {return d_typeAInterface->hasPermutationInput();} -inline bool TypeACoxGroup::hasPermutationOutput() const - {return d_typeAInterface->hasPermutationOutput();} -inline void TypeACoxGroup::setPermutationInput(bool b) - {typeAInterface().setPermutationInput(b);} -inline void TypeACoxGroup::setPermutationOutput(bool b) - {typeAInterface().setPermutationOutput(b);} -inline const TypeAInterface& TypeACoxGroup::typeAInterface() const - {return *d_typeAInterface;} -inline TypeAInterface& TypeACoxGroup::typeAInterface() - {return *d_typeAInterface;} +inline bool TypeAInterface::hasPermutationInput() const { + return d_hasPermutationInput; +} +inline bool TypeAInterface::hasPermutationOutput() const { + return d_hasPermutationOutput; +} +inline void TypeAInterface::setPermutationInput(bool b) { + d_hasPermutationInput = b; +} +inline void TypeAInterface::setPermutationOutput(bool b) { + d_hasPermutationOutput = b; +} +inline bool TypeACoxGroup::hasPermutationInput() const { + return d_typeAInterface->hasPermutationInput(); } +inline bool TypeACoxGroup::hasPermutationOutput() const { + return d_typeAInterface->hasPermutationOutput(); +} +inline void TypeACoxGroup::setPermutationInput(bool b) { + typeAInterface().setPermutationInput(b); +} +inline void TypeACoxGroup::setPermutationOutput(bool b) { + typeAInterface().setPermutationOutput(b); +} +inline const TypeAInterface &TypeACoxGroup::typeAInterface() const { + return *d_typeAInterface; +} +inline TypeAInterface &TypeACoxGroup::typeAInterface() { + return *d_typeAInterface; +} + +} // namespace coxeter #endif diff --git a/uneqkl.cpp b/uneqkl.cpp index 2e9ad14..62f6694 100644 --- a/uneqkl.cpp +++ b/uneqkl.cpp @@ -1,6 +1,6 @@ /* This is uneqkl.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ @@ -9,86 +9,91 @@ #include "interactive.h" namespace uneqkl { - using namespace interactive; +using namespace interactive; } namespace { - using namespace uneqkl; +using namespace uneqkl; - void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, - const Ulong& d, const long& m); - void positivePart(KLPol& p, const KLPol& q, const Ulong& d, const long& m); - const MuPol* writeMu(BinaryTree& t, const KLPol& p); -}; +void muSubtraction(KLPol &p, const MuPol &mp, const KLPol &q, const Ulong &d, + const long &m); +void positivePart(KLPol &p, const KLPol &q, const Ulong &d, const long &m); +const MuPol *writeMu(BinaryTree &t, const KLPol &p); +}; // namespace namespace uneqkl { - struct KLContext::KLHelper { -/* data */ - KLContext* d_kl; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLHelper));} - KLHelper(KLContext* kl):d_kl(kl) {}; - ~KLHelper() {}; -/* member functions */ - void allocExtrRow(const CoxNbr& y) {klsupport().allocExtrRow(y);} - void allocKLRow(const CoxNbr& y); - void allocMuRow(const Generator& s, const CoxNbr& y); - void allocMuRow(MuRow& row, const Generator& s, const CoxNbr& y); - bool checkKLRow(const CoxNbr& y); - bool checkMuRow(const Generator& s, const CoxNbr& y); - void ensureKLRow(const CoxNbr& y); - const ExtrRow& extrList(const CoxNbr& y) {return klsupport().extrList(y);} - void fillKLRow(const CoxNbr& y, const Generator& s = undef_generator); - void fillMuRow(const Generator& s, const CoxNbr& y); - const KLPol* fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& s = undef_generator); - const MuPol* fillMu(const Generator& s, const CoxNbr& x, const CoxNbr& y); - const KLPol& find(const KLPol& p) {return d_kl->d_klTree.find(p)[0];} - Ulong genL(const Generator& s) {return d_kl->genL(s);} - void initWorkspace(const CoxNbr& y, List& pol, const Generator& s); - CoxNbr inverse(const CoxNbr& y) {return klsupport().inverse(y);} - void inverseMin(CoxNbr& y, Generator& s); - bool isExtrAllocated(const CoxNbr& y) - {return klsupport().isExtrAllocated(y);} - bool isKLAllocated(const CoxNbr& y) {return d_kl->isKLAllocated(y);} - KLRow& klList(const CoxNbr& y) {return d_kl->d_klList[y][0];} - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y) - {return d_kl->klPol(x,y);} - KLSupport& klsupport() {return d_kl->d_klsupport[0];} - BinaryTree& klTree() {return d_kl->d_klTree;} - Generator last(const CoxNbr& x) {return klsupport().last(x);} - Ulong length(const CoxNbr& x) {return d_kl->length(x);} - const MuPol& mu(const Generator& s, const CoxNbr& x, const CoxNbr& y) - {return d_kl->mu(s,x,y);} - void muCorrection(List& pol, const Generator& s, const CoxNbr& y); - void muCorrection(const CoxNbr& x, const Generator& s, const CoxNbr& y, - List& pol, const Ulong& a); - MuRow& muList(const Generator& s, const CoxNbr& y) - {return d_kl->d_muTable[s][0][y][0];} - MuTable& muTable(const Generator& s) {return d_kl->d_muTable[s][0];} - BinaryTree& muTree() {return d_kl->d_muTree;} - void prepareRowComputation(const CoxNbr& y, const Generator& s); - Rank rank() {return d_kl->rank();} - const SchubertContext& schubert() {return klsupport().schubert();} - void secondTerm(const CoxNbr& y, List& pol, const Generator& s); - Ulong size() {return d_kl->size();} - KLStatus& status() {return *d_kl->d_status;} - void writeMuRow(const MuRow& row, const Generator& s, const CoxNbr& y); - void writeKLRow(const CoxNbr& y, List& pol); - }; - +struct KLContext::KLHelper { + /* data */ + KLContext *d_kl; + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLHelper)); + } + KLHelper(KLContext *kl) : d_kl(kl){}; + ~KLHelper(){}; + /* member functions */ + void allocExtrRow(const CoxNbr &y) { klsupport().allocExtrRow(y); } + void allocKLRow(const CoxNbr &y); + void allocMuRow(const Generator &s, const CoxNbr &y); + void allocMuRow(MuRow &row, const Generator &s, const CoxNbr &y); + bool checkKLRow(const CoxNbr &y); + bool checkMuRow(const Generator &s, const CoxNbr &y); + void ensureKLRow(const CoxNbr &y); + const ExtrRow &extrList(const CoxNbr &y) { return klsupport().extrList(y); } + void fillKLRow(const CoxNbr &y, const Generator &s = undef_generator); + void fillMuRow(const Generator &s, const CoxNbr &y); + const KLPol *fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &s = undef_generator); + const MuPol *fillMu(const Generator &s, const CoxNbr &x, const CoxNbr &y); + const KLPol &find(const KLPol &p) { return d_kl->d_klTree.find(p)[0]; } + Ulong genL(const Generator &s) { return d_kl->genL(s); } + void initWorkspace(const CoxNbr &y, List &pol, const Generator &s); + CoxNbr inverse(const CoxNbr &y) { return klsupport().inverse(y); } + void inverseMin(CoxNbr &y, Generator &s); + bool isExtrAllocated(const CoxNbr &y) { + return klsupport().isExtrAllocated(y); + } + bool isKLAllocated(const CoxNbr &y) { return d_kl->isKLAllocated(y); } + KLRow &klList(const CoxNbr &y) { return d_kl->d_klList[y][0]; } + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y) { + return d_kl->klPol(x, y); + } + KLSupport &klsupport() { return d_kl->d_klsupport[0]; } + BinaryTree &klTree() { return d_kl->d_klTree; } + Generator last(const CoxNbr &x) { return klsupport().last(x); } + Ulong length(const CoxNbr &x) { return d_kl->length(x); } + const MuPol &mu(const Generator &s, const CoxNbr &x, const CoxNbr &y) { + return d_kl->mu(s, x, y); + } + void muCorrection(List &pol, const Generator &s, const CoxNbr &y); + void muCorrection(const CoxNbr &x, const Generator &s, const CoxNbr &y, + List &pol, const Ulong &a); + MuRow &muList(const Generator &s, const CoxNbr &y) { + return d_kl->d_muTable[s][0][y][0]; + } + MuTable &muTable(const Generator &s) { return d_kl->d_muTable[s][0]; } + BinaryTree &muTree() { return d_kl->d_muTree; } + void prepareRowComputation(const CoxNbr &y, const Generator &s); + Rank rank() { return d_kl->rank(); } + const SchubertContext &schubert() { return klsupport().schubert(); } + void secondTerm(const CoxNbr &y, List &pol, const Generator &s); + Ulong size() { return d_kl->size(); } + KLStatus &status() { return *d_kl->d_status; } + void writeMuRow(const MuRow &row, const Generator &s, const CoxNbr &y); + void writeKLRow(const CoxNbr &y, List &pol); }; +}; // namespace uneqkl + /* This module contains code for the computation of kl polynomials with unequal parameters. Even though the general setup is similar to that for the ordinary kl polynomials, there are several important technical differences : - + - the polynomials are now Laurent polynomials in the indeterminate q; morevoer they need not have positive coefficients. - the mu-coefficients are no longer integers, but Laurent polynomials @@ -107,7 +112,7 @@ namespace uneqkl { t_{sw} when sw > w, and t_{sw} - a_s.t_w otherwise, where a_s = v_s^{-1}-v_s. Also we have t_s^{-1} = t_s + a_s for each s in S. - Then there is an A-antilinear ring involution on H defined as usual by + Then there is an A-antilinear ring involution on H defined as usual by t_x^{-1} = t_{x^{-1}}^{-1}. This defines a formal R-function on the group W, hence a Kazhdan-Lusztig basis c_x, x in W. As usual, c_x is the unique self-adjoint element in H such that c_x = t_x mod H_{<0}, where H_{<0} is @@ -142,9 +147,9 @@ namespace uneqkl { p(x,y) = p(sx,sy) if sx < x, x not comparable to sy = p(sx,sy)+v_s.p(x,sy)-sum_{x<=z x, sx not comparable to sy - = v_s^{-1}.p(x,sy)+p(sx,sy)-sum_{x<=z x, sx not comparable to sy + = v_s^{-1}.p(x,sy)+p(sx,sy)-sum_{x<=zsize()); - MuTable& t = *d_muTable[s]; + MuTable &t = *d_muTable[s]; t.setSizeValue(kls->size()); t[0] = new MuRow(0); } @@ -251,12 +256,11 @@ KLContext::KLContext(KLSupport* kls, const CoxGraph& G, const Interface& I) for (CoxNbr x = 1; x < d_length.size(); ++x) { Generator s = last(x); - CoxNbr xs = schubert().shift(x,s); + CoxNbr xs = schubert().shift(x, s); d_length[x] = d_length[xs] + d_L[s]; } - end: - ; +end:; } KLContext::~KLContext() @@ -267,7 +271,7 @@ KLContext::~KLContext() } for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; + MuTable &t = *d_muTable[s]; for (Ulong j = 0; j < t.size(); ++j) { delete t[j]; } @@ -279,7 +283,7 @@ KLContext::~KLContext() /******** manipulators *******************************************************/ -void KLContext::applyInverse(const CoxNbr& x) +void KLContext::applyInverse(const CoxNbr &x) /* Exchanges rows for x and x_inverse in klList. It is assumed that the row @@ -324,7 +328,7 @@ void KLContext::fillMu() return; } -void KLContext::fillMu(const Generator& s) +void KLContext::fillMu(const Generator &s) /* Fills the full mu table for generator s for the current context. @@ -332,16 +336,16 @@ void KLContext::fillMu(const Generator& s) { for (CoxNbr y = 0; y < size(); ++y) { - if (schubert().isDescent(y,s)) + if (schubert().isDescent(y, s)) continue; - if (!d_help->checkMuRow(s,y)) - d_help->fillMuRow(s,y); + if (!d_help->checkMuRow(s, y)) + d_help->fillMuRow(s, y); } return; } -const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y) +const KLPol &KLContext::klPol(const CoxNbr &d_x, const CoxNbr &d_y) /* This function returns the Kazhdan-Lusztig polynomial P_{x,y}. It is @@ -350,13 +354,13 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y) */ { - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); CoxNbr x = d_x; CoxNbr y = d_y; /* put x in extremal position w.r.t. y */ - x = p.maximize(x,p.descent(y)); + x = p.maximize(x, p.descent(y)); /* go to inverses if necessary */ @@ -375,11 +379,11 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y) /* find x in extrList[y] */ - Ulong m = find(extrList(y),x); - const KLPol* pol = (*d_klList[y])[m]; + Ulong m = find(extrList(y), x); + const KLPol *pol = (*d_klList[y])[m]; if (pol == 0) { /* we have to compute the polynomial */ - pol = d_help->fillKLPol(x,y); + pol = d_help->fillKLPol(x, y); if (ERRNO) return errorPol(); } @@ -387,8 +391,7 @@ const KLPol& KLContext::klPol(const CoxNbr& d_x, const CoxNbr& d_y) return *pol; } -const MuPol& KLContext::mu(const Generator& s, const CoxNbr& x, - const CoxNbr& y) +const MuPol &KLContext::mu(const Generator &s, const CoxNbr &x, const CoxNbr &y) /* This function returns mu^s_{x,y}, filling it in if necessary. It is @@ -397,23 +400,23 @@ const MuPol& KLContext::mu(const Generator& s, const CoxNbr& x, */ { - if (!isMuAllocated(s,y)) - d_help->allocMuRow(s,y); + if (!isMuAllocated(s, y)) + d_help->allocMuRow(s, y); - const MuRow& mu_row = muList(s,y); + const MuRow &mu_row = muList(s, y); /* find x in row */ - MuData mx(x,0); - Ulong m = find(mu_row,mx); + MuData mx(x, 0); + Ulong m = find(mu_row, mx); if (m == not_found) return zero(); - const MuPol* mp = mu_row[m].pol; + const MuPol *mp = mu_row[m].pol; if (mp == 0) { /* mu-polynomial must be computed */ - mp = d_help->fillMu(s,x,y); + mp = d_help->fillMu(s, x, y); if (ERRNO) return errorMuPol(); } @@ -421,7 +424,7 @@ const MuPol& KLContext::mu(const Generator& s, const CoxNbr& x, return *mp; } -void KLContext::permute(const Permutation& a) +void KLContext::permute(const Permutation &a) /* Applies the permutation a to the context. See the permute function of @@ -432,13 +435,13 @@ void KLContext::permute(const Permutation& a) /* permute values */ for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; + MuTable &t = *d_muTable[s]; for (CoxNbr y = 0; y < size(); ++y) { - if (!isMuAllocated(s,y)) - continue; - MuRow& row = *t[y]; + if (!isMuAllocated(s, y)) + continue; + MuRow &row = *t[y]; for (Ulong j = 0; j < row.size(); ++j) - row[j].x = a[row[j].x]; + row[j].x = a[row[j].x]; row.sort(); } } @@ -455,29 +458,29 @@ void KLContext::permute(const Permutation& a) continue; } - List mu_buf(0); + List mu_buf(0); mu_buf.setSize(d_muTable.size()); for (CoxNbr y = a[x]; y != x; y = a[y]) { /* back up values for y */ - KLRow* kl_buf = d_klList[y]; + KLRow *kl_buf = d_klList[y]; for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; - mu_buf[s] = t[y]; + MuTable &t = *d_muTable[s]; + mu_buf[s] = t[y]; } Length length_buf = d_length[y]; /* put values for x in y */ d_klList[y] = d_klList[x]; for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; - t[y] = t[x]; + MuTable &t = *d_muTable[s]; + t[y] = t[x]; } d_length[y] = d_length[x]; /* store backup values in x */ d_klList[x] = kl_buf; for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; - t[x] = mu_buf[s]; + MuTable &t = *d_muTable[s]; + t[x] = mu_buf[s]; } d_length[x] = length_buf; /* set bit*/ @@ -490,7 +493,7 @@ void KLContext::permute(const Permutation& a) return; } -void KLContext::revertSize(const Ulong& n) +void KLContext::revertSize(const Ulong &n) /* Reverts the sizes of the lists to size n. This is meant to be used @@ -503,7 +506,7 @@ void KLContext::revertSize(const Ulong& n) d_klList.setSize(n); for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; + MuTable &t = *d_muTable[s]; t.setSize(n); } @@ -512,7 +515,7 @@ void KLContext::revertSize(const Ulong& n) return; } -void KLContext::row(HeckeElt& h, const CoxNbr& y) +void KLContext::row(HeckeElt &h, const CoxNbr &y) /* This function makes sure that the row corresponding to y in the k-l table @@ -532,20 +535,19 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) { if (y <= inverse(y)) { - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); h.setSize(e.size()); - const KLRow& klr = klList(y); + const KLRow &klr = klList(y); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(e[j],klr[j]); + h[j].setData(e[j], klr[j]); } - } - else { /* go over to inverses */ + } else { /* go over to inverses */ CoxNbr yi = inverse(y); - const ExtrRow& e = extrList(yi); + const ExtrRow &e = extrList(yi); h.setSize(e.size()); - const KLRow& klr = klList(yi); + const KLRow &klr = klList(yi); for (Ulong j = 0; j < e.size(); ++j) { - h[j].setData(inverse(e[j]),klr[j]); + h[j].setData(inverse(e[j]), klr[j]); } h.sort(); /* make sure list is ordered */ } @@ -553,13 +555,13 @@ void KLContext::row(HeckeElt& h, const CoxNbr& y) return; - error_exit: +error_exit: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::setSize(const Ulong& n) +void KLContext::setSize(const Ulong &n) /* This function adjusts the size of the context to a context of size n. @@ -575,7 +577,7 @@ void KLContext::setSize(const Ulong& n) goto revert; for (Generator s = 0; s < d_muTable.size(); ++s) { - MuTable& t = *d_muTable[s]; + MuTable &t = *d_muTable[s]; t.setSize(n); if (ERRNO) goto revert; @@ -591,19 +593,19 @@ void KLContext::setSize(const Ulong& n) for (CoxNbr x = prev_size; x < n; ++x) { Generator s = last(x); - CoxNbr xs = schubert().shift(x,s); + CoxNbr xs = schubert().shift(x, s); d_length[x] = d_length[xs] + genL(s); } return; - revert: +revert: CATCH_MEMORY_OVERFLOW = false; revertSize(prev_size); return; } -}; +}; // namespace uneqkl /***************************************************************************** @@ -633,12 +635,12 @@ void KLContext::setSize(const Ulong& n) namespace uneqkl { -void KLContext::KLHelper::allocKLRow(const CoxNbr& y) +void KLContext::KLHelper::allocKLRow(const CoxNbr &y) /* Allocates one previously unallocated row in the k-l table. It is assumed that y <= inverse(y). Allocates the corresponding extremal row if necessary. - + Forwards a memory error in case of failure if CATCH_MEMORY_ERROR is set. */ @@ -659,7 +661,7 @@ void KLContext::KLHelper::allocKLRow(const CoxNbr& y) return; } -void KLContext::KLHelper::allocMuRow(const Generator& s, const CoxNbr& y) +void KLContext::KLHelper::allocMuRow(const Generator &s, const CoxNbr &y) /* Allocates one previously unallocated row in muTable(s). @@ -670,18 +672,18 @@ void KLContext::KLHelper::allocMuRow(const Generator& s, const CoxNbr& y) */ { - MuTable& t = muTable(s); + MuTable &t = muTable(s); t[y] = new MuRow(0); - allocMuRow(muList(s,y),s,y); + allocMuRow(muList(s, y), s, y); - d_kl->d_status->munodes += muList(s,y).size(); + d_kl->d_status->munodes += muList(s, y).size(); d_kl->d_status->murows++; return; } -void KLContext::KLHelper::allocMuRow(MuRow& row, const Generator& s, - const CoxNbr& y) +void KLContext::KLHelper::allocMuRow(MuRow &row, const Generator &s, + const CoxNbr &y) /* Allocates row to the full mu-row for y and s. @@ -693,21 +695,21 @@ void KLContext::KLHelper::allocMuRow(MuRow& row, const Generator& s, { BitMap b(0); - schubert().extractClosure(b,y); + schubert().extractClosure(b, y); b &= schubert().downset(s); row.setSize(0); BitMap::Iterator b_end = b.end(); - + for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { - MuData md(*k,0); + MuData md(*k, 0); row.append(md); } - + return; } -bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) +bool KLContext::KLHelper::checkKLRow(const CoxNbr &d_y) /* Checks if the row corresponding to y in the k-l table has been completely @@ -722,7 +724,7 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) if (!isKLAllocated(y)) return false; - const KLRow& kl_row = klList(y); + const KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j] == 0) return false; @@ -731,7 +733,7 @@ bool KLContext::KLHelper::checkKLRow(const CoxNbr& d_y) return true; } -bool KLContext::KLHelper::checkMuRow(const Generator& s, const CoxNbr& y) +bool KLContext::KLHelper::checkMuRow(const Generator &s, const CoxNbr &y) /* Checks if the row corresponding to y in muTable[s] has been completely @@ -739,12 +741,12 @@ bool KLContext::KLHelper::checkMuRow(const Generator& s, const CoxNbr& y) */ { - const MuTable& t = muTable(s); + const MuTable &t = muTable(s); if (t[y] == 0) return false; - const MuRow& mr = *t[y]; + const MuRow &mr = *t[y]; for (Ulong j = 0; j < mr.size(); ++j) { if (mr[j].pol == 0) @@ -754,13 +756,13 @@ bool KLContext::KLHelper::checkMuRow(const Generator& s, const CoxNbr& y) return true; } -void KLContext::KLHelper::ensureKLRow(const CoxNbr& y) +void KLContext::KLHelper::ensureKLRow(const CoxNbr &y) /* Makes sure that the k-l row for y is available. */ -{ +{ if (!checkKLRow(y)) { klsupport().allocRowComputation(y); if (ERRNO) @@ -770,15 +772,15 @@ void KLContext::KLHelper::ensureKLRow(const CoxNbr& y) goto abort; } return; - - abort: + +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, - const Generator& d_s) +const KLPol *KLContext::KLHelper::fillKLPol(const CoxNbr &x, const CoxNbr &y, + const Generator &d_s) /* This function fills in a single polynomial in the k-l table (as opposed to @@ -792,25 +794,25 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, { static List pol(0); /* workspace stack */ - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); Generator s = d_s; - /* If d_s is undef_coxnbr, we compute the polynomial using descent by last + /* If d_s is undef_coxnbr, we compute the polynomial using descent by last term in normal form */ if (s == undef_generator) s = last(y); - CoxNbr ys = p.shift(y,s); - CoxNbr xs = p.shift(x,s); + CoxNbr ys = p.shift(y, s); + CoxNbr xs = p.shift(x, s); /* check if x is comparable to ys */ - if (!p.inOrder(x,ys)) { /* return the answer immediately */ + if (!p.inOrder(x, ys)) { /* return the answer immediately */ status().klcomputed++; - Ulong m = list::find(extrList(y),x); - klList(y)[m] = &klPol(xs,ys); + Ulong m = list::find(extrList(y), x); + klList(y)[m] = &klPol(xs, ys); return klList(y)[m]; } @@ -819,51 +821,51 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, CATCH_MEMORY_OVERFLOW = true; Ulong a = pol.size(); - pol.setSize(a+1); + pol.setSize(a + 1); /* initialize the workspace to P_{xs,ys} */ - const KLPol& p_xsys = klPol(xs,ys); + const KLPol &p_xsys = klPol(xs, ys); if (ERRNO) goto abort; pol[a] = p_xsys; /* add q.P_{x,ys} */ - { - const KLPol& p_xys = klPol(x,ys); + { + const KLPol &p_xys = klPol(x, ys); if (ERRNO) goto abort; - pol[a].add(p_xys,genL(s)); + pol[a].add(p_xys, genL(s)); if (ERRNO) goto abort; } /* subtract correction terms */ - muCorrection(x,s,y,pol,a); + muCorrection(x, s, y, pol, a); if (ERRNO) goto abort; /* find address of polynomial */ { - const KLPol& p_xy = find(pol[a]); + const KLPol &p_xy = find(pol[a]); if (ERRNO) goto abort; - Ulong m = list::find(extrList(y),x); + Ulong m = list::find(extrList(y), x); klList(y)[m] = &p_xy; - + /* return workspace and exit */ - + CATCH_MEMORY_OVERFLOW = false; - pol.setSize(a); + pol.setSize(a); status().klcomputed++; return &p_xy; } - abort: /* an error occurred */ +abort: /* an error occurred */ CATCH_MEMORY_OVERFLOW = false; if (ERRNO != MEMORY_WARNING) @@ -872,7 +874,7 @@ const KLPol* KLContext::KLHelper::fillKLPol(const CoxNbr& x, const CoxNbr& y, return 0; } -void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y, const Generator& d_s) +void KLContext::KLHelper::fillKLRow(const CoxNbr &d_y, const Generator &d_s) /* This function fills one row in the k-l table entirely. This can be done @@ -900,43 +902,43 @@ void KLContext::KLHelper::fillKLRow(const CoxNbr& d_y, const Generator& d_s) if (s == undef_generator) s = last(y); - prepareRowComputation(y,s); + prepareRowComputation(y, s); if (ERRNO) goto abort; - /* prepare workspace; pol holds the row of polynomials; + /* prepare workspace; pol holds the row of polynomials; initialize workspace with P_{xs,ys} */ - initWorkspace(y,pol,s); + initWorkspace(y, pol, s); /* add q.P_{x,ys} when appropriate */ - secondTerm(y,pol,s); + secondTerm(y, pol, s); if (ERRNO) goto abort; /* subtract correcting terms */ - muCorrection(pol,s,y); + muCorrection(pol, s, y); if (ERRNO) goto abort; /* copy results to row */ - writeKLRow(y,pol); + writeKLRow(y, pol); if (ERRNO) goto abort; return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -const MuPol* KLContext::KLHelper::fillMu(const Generator& s, const CoxNbr& x, - const CoxNbr& y) +const MuPol *KLContext::KLHelper::fillMu(const Generator &s, const CoxNbr &x, + const CoxNbr &y) /* Fills in the mu-polynomial for s,x,y. It is assumed that x < y, sy > y, @@ -958,56 +960,56 @@ const MuPol* KLContext::KLHelper::fillMu(const Generator& s, const CoxNbr& x, { static List pos_mu(0); // workspace stack - MuRow& mu_row = muList(s,y); + MuRow &mu_row = muList(s, y); - /* initialize a with the value u^(L(x)-L(y)+L(s))P_{x,y}(u^2) */ + /* initialize a with the value u^(L(x)-L(y)+L(s))P_{x,y}(u^2) */ - const KLPol& pol = klPol(x,y); + const KLPol &pol = klPol(x, y); if (ERRNO) { - Error(MU_FAIL,x,y); + Error(MU_FAIL, x, y); ERRNO = ERROR_WARNING; return 0; } Ulong a = pos_mu.size(); - pos_mu.setSize(a+1); - positivePart(pos_mu[a],pol,2,length(x)-length(y)+genL(s)); + pos_mu.setSize(a + 1); + positivePart(pos_mu[a], pol, 2, length(x) - length(y) + genL(s)); - MuData mx(x,0); - Ulong m = list::find(mu_row,mx); // search cannot fail + MuData mx(x, 0); + Ulong m = list::find(mu_row, mx); // search cannot fail /* subtract correcting terms */ - const SchubertContext& p = schubert(); + const SchubertContext &p = schubert(); - for (Ulong j = m+1; j < mu_row.size(); ++j) { + for (Ulong j = m + 1; j < mu_row.size(); ++j) { CoxNbr z = mu_row[j].x; - if (!p.inOrder(x,z)) + if (!p.inOrder(x, z)) continue; - const KLPol& pol = klPol(x,z); + const KLPol &pol = klPol(x, z); if (ERRNO) { - Error(MU_FAIL,x,y); + Error(MU_FAIL, x, y); ERRNO = ERROR_WARNING; return 0; } - const MuPol& mq = d_kl->mu(s,z,y); + const MuPol &mq = d_kl->mu(s, z, y); if (!mq.isZero()) - muSubtraction(pos_mu[a],mq,pol,2,length(x)-length(z)); + muSubtraction(pos_mu[a], mq, pol, 2, length(x) - length(z)); if (ERRNO) { - Error(MU_FAIL,x,y); + Error(MU_FAIL, x, y); ERRNO = ERROR_WARNING; return 0; } } - + /* write mu-polynomial and return value */ - mu_row[m].pol = writeMu(muTree(),pos_mu[a]); - pos_mu.setSize(a); + mu_row[m].pol = writeMu(muTree(), pos_mu[a]); + pos_mu.setSize(a); return mu_row[m].pol; } -void KLContext::KLHelper::fillMuRow(const Generator& s, const CoxNbr& y) +void KLContext::KLHelper::fillMuRow(const Generator &s, const CoxNbr &y) /* This function fills one row in the mu-list for s. Recall that mu(x,y,s) is @@ -1032,19 +1034,19 @@ void KLContext::KLHelper::fillMuRow(const Generator& s, const CoxNbr& y) */ { - static List > posMu(0); + static List> posMu(0); static List muRow(0); - /* the polynomial pos_mu(x) (really pos_mu[j], x = mu_list[j].x) holds the - positive part of the mu-polynomial */ + /* the polynomial pos_mu(x) (really pos_mu[j], x = mu_list[j].x) holds the + positive part of the mu-polynomial */ /* get workspace */ Ulong a = posMu.size(); - posMu.setSize(a+1); - muRow.setSize(a+1); + posMu.setSize(a + 1); + muRow.setSize(a + 1); - allocMuRow(muRow[a],s,y); + allocMuRow(muRow[a], s, y); posMu[a].setSize(muRow[a].size()); CoxNbr x; @@ -1054,10 +1056,10 @@ void KLContext::KLHelper::fillMuRow(const Generator& s, const CoxNbr& y) for (Ulong j = 0; j < muRow[a].size(); ++j) { ensureKLRow(y); x = muRow[a][j].x; - const KLPol& pol = klPol(x,y); + const KLPol &pol = klPol(x, y); if (ERRNO) /* this cannot happen in typical usage */ goto abort; - positivePart(posMu[a][j],pol,2,length(x)-length(y)+genL(s)); + positivePart(posMu[a][j], pol, 2, length(x) - length(y) + genL(s)); } /* we run through muRow[a] in decreasing order; for each z in the list, @@ -1070,7 +1072,7 @@ void KLContext::KLHelper::fillMuRow(const Generator& s, const CoxNbr& y) /* write the mu-polynomial for z */ - muRow[a][j].pol = writeMu(muTree(),posMu[a][j]); + muRow[a][j].pol = writeMu(muTree(), posMu[a][j]); d_kl->d_status->mucomputed++; if (muRow[a][j].pol->isZero()) { d_kl->d_status->muzero++; @@ -1084,43 +1086,43 @@ void KLContext::KLHelper::fillMuRow(const Generator& s, const CoxNbr& y) if (ERRNO) goto abort; BitMap b(0); - schubert().extractClosure(b,z); + schubert().extractClosure(b, z); b &= schubert().downset(s); b.clearBit(z); BitMap::Iterator b_end = b.end(); Ulong i = 0; - + for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { x = *k; while (muRow[a][i].x != x) - ++i; - const KLPol& pol = klPol(x,z); + ++i; + const KLPol &pol = klPol(x, z); if (ERRNO) - goto abort; - muSubtraction(posMu[a][i],muRow[a][j].pol[0],pol,2, - length(x)-length(z)); + goto abort; + muSubtraction(posMu[a][i], muRow[a][j].pol[0], pol, 2, + length(x) - length(z)); if (ERRNO) - goto abort; + goto abort; ++i; } } - writeMuRow(muRow[a],s,y); + writeMuRow(muRow[a], s, y); muRow.setSize(a); - posMu.setSize(a); + posMu.setSize(a); return; - abort: - Error(MU_FAIL,x,y); +abort: + Error(MU_FAIL, x, y); ERRNO = ERROR_WARNING; posMu.setSize(a); return; } -void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol, - const Generator& s) +void KLContext::KLHelper::initWorkspace(const CoxNbr &y, List &pol, + const Generator &s) /* This function sets pol to a row of one polynomial for each x in klList(y), @@ -1130,9 +1132,9 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol, so that the row for ys is available. */ -{ - const SchubertContext& p = schubert(); - const ExtrRow& e = extrList(y); +{ + const SchubertContext &p = schubert(); + const ExtrRow &e = extrList(y); pol.setSize(e.size()); if (ERRNO) goto abort; @@ -1140,23 +1142,23 @@ void KLContext::KLHelper::initWorkspace(const CoxNbr& y, List& pol, /* initialize with values P_{xs,ys} */ { - CoxNbr ys = p.rshift(y,s); - + CoxNbr ys = p.rshift(y, s); + for (Ulong j = 0; j < e.size(); ++j) { - CoxNbr xs = p.shift(e[j],s); - pol[j] = klPol(xs,ys); /* no error can occur here */ + CoxNbr xs = p.shift(e[j], s); + pol[j] = klPol(xs, ys); /* no error can occur here */ } } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::inverseMin(CoxNbr& y, Generator& s) +void KLContext::KLHelper::inverseMin(CoxNbr &y, Generator &s) /* Changes y to inverse(y), and s to the same generator on the other side, @@ -1175,8 +1177,8 @@ void KLContext::KLHelper::inverseMin(CoxNbr& y, Generator& s) return; } -void KLContext::KLHelper::muCorrection(List& pol, const Generator& s, - const CoxNbr& y) +void KLContext::KLHelper::muCorrection(List &pol, const Generator &s, + const CoxNbr &y) /* This function carries out the "mu-correction" step in the computation of @@ -1193,45 +1195,46 @@ void KLContext::KLHelper::muCorrection(List& pol, const Generator& s, extremalize w.r.t. y, and subtract the appropriate term from P_{x,y}. */ -{ - const SchubertContext& p = schubert(); - const ExtrRow& e = extrList(y); - CoxNbr ys = p.rshift(y,s); - const MuRow& mu_row = muList(s,ys); +{ + const SchubertContext &p = schubert(); + const ExtrRow &e = extrList(y); + CoxNbr ys = p.rshift(y, s); + const MuRow &mu_row = muList(s, ys); for (Ulong j = 0; j < mu_row.size(); ++j) { - const MuPol& mu_pol = *mu_row[j].pol; + const MuPol &mu_pol = *mu_row[j].pol; if (mu_pol.isZero()) continue; CoxNbr z = mu_row[j].x; BitMap b(size()); - p.extractClosure(b,z); - maximize(p,b,p.descent(y)); - + p.extractClosure(b, z); + maximize(p, b, p.descent(y)); + Ulong i = 0; BitMap::Iterator b_end = b.end(); - + for (BitMap::Iterator k = b.begin(); k != b_end; ++k) { CoxNbr x = *k; while (e[i] < x) - ++i; - Ulong h = length(y)-length(z); - pol[i].subtract(klPol(x,z),mu_pol,h); + ++i; + Ulong h = length(y) - length(z); + pol[i].subtract(klPol(x, z), mu_pol, h); if (ERRNO) { - Error(ERRNO,this,x,y); - ERRNO = ERROR_WARNING; - return; + Error(ERRNO, this, x, y); + ERRNO = ERROR_WARNING; + return; } } } - return; + return; } -void KLContext::KLHelper::muCorrection(const CoxNbr& x, const Generator& s, - const CoxNbr& y, List& pol, const Ulong& a) +void KLContext::KLHelper::muCorrection(const CoxNbr &x, const Generator &s, + const CoxNbr &y, List &pol, + const Ulong &a) /* This function carries out the "mu-correction" step in the computation of @@ -1243,63 +1246,62 @@ void KLContext::KLHelper::muCorrection(const CoxNbr& x, const Generator& s, of Lusztig it is known that these are actually polynomials in q as well. */ -{ - const SchubertContext& p = schubert(); - CoxNbr ys = p.rshift(y,s); - if (!d_kl->isMuAllocated(s,ys)) { - allocMuRow(s,ys); +{ + const SchubertContext &p = schubert(); + CoxNbr ys = p.rshift(y, s); + if (!d_kl->isMuAllocated(s, ys)) { + allocMuRow(s, ys); if (ERRNO) goto abort; } { - const MuRow& mu_row = muList(s,ys); + const MuRow &mu_row = muList(s, ys); for (Ulong j = 0; j < mu_row.size(); ++j) { - + CoxNbr z = mu_row[j].x; - if (!p.inOrder(x,z)) - continue; - - const MuPol& mp = mu(s,z,ys); + if (!p.inOrder(x, z)) + continue; + + const MuPol &mp = mu(s, z, ys); if (mp.isZero()) - continue; - - Ulong h = length(y)-length(z); - const KLPol& kl_pol = klPol(x,z); + continue; + + Ulong h = length(y) - length(z); + const KLPol &kl_pol = klPol(x, z); if (ERRNO) - goto abort; - pol[a].subtract(kl_pol,mp,h); + goto abort; + pol[a].subtract(kl_pol, mp, h); if (ERRNO) - goto abort; + goto abort; } } - - return; + return; - abort: - Error(UEMU_FAIL,x,y); +abort: + Error(UEMU_FAIL, x, y); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::prepareRowComputation(const CoxNbr& y, - const Generator& s) +void KLContext::KLHelper::prepareRowComputation(const CoxNbr &y, + const Generator &s) /* - This function is an auxiliary to fillKLRow. It makes sure that the necessary - terms for the filling of the row of y in the k-l table are available. This - ensures that there will be no recursive calls to fillKLRow when the actual + This function is an auxiliary to fillKLRow. It makes sure that the necessary + terms for the filling of the row of y in the k-l table are available. This + ensures that there will be no recursive calls to fillKLRow when the actual computation starts. At this point it is assumed that y <= inverse(y). */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); - CoxNbr ys = p.rshift(y,s); + CoxNbr ys = p.rshift(y, s); /* get the row for ys */ @@ -1310,39 +1312,39 @@ void KLContext::KLHelper::prepareRowComputation(const CoxNbr& y, } { - if (!checkMuRow(s,ys)) { - fillMuRow(s,ys); + if (!checkMuRow(s, ys)) { + fillMuRow(s, ys); if (ERRNO) - goto abort; + goto abort; } - const MuRow& mu_row = muList(s,ys); - + const MuRow &mu_row = muList(s, ys); + for (Ulong j = 0; j < mu_row.size(); ++j) { if (mu_row[j].pol->isZero()) - continue; + continue; CoxNbr z = mu_row[j].x; if (!checkKLRow(z)) { - klsupport().allocRowComputation(z); - if (ERRNO) - goto abort; - fillKLRow(z); - if (ERRNO) - goto abort; + klsupport().allocRowComputation(z); + if (ERRNO) + goto abort; + fillKLRow(z); + if (ERRNO) + goto abort; } } } return; - abort: +abort: Error(ERRNO); ERRNO = ERROR_WARNING; return; } -void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol, - const Generator& s) +void KLContext::KLHelper::secondTerm(const CoxNbr &y, List &pol, + const Generator &s) /* This function adds the "second term", which is q^genL(s).P_{x,ys}, to the @@ -1354,25 +1356,25 @@ void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol, x in the extremal list of y which are <= ys. */ -{ - const SchubertContext& p = schubert(); +{ + const SchubertContext &p = schubert(); BitMap b(size()); - CoxNbr ys = p.rshift(y,s); + CoxNbr ys = p.rshift(y, s); - p.extractClosure(b,ys); - maximize(p,b,p.descent(y)); + p.extractClosure(b, ys); + maximize(p, b, p.descent(y)); Ulong i = 0; BitMap::Iterator b_end = b.end(); - const ExtrRow& e = extrList(y); + const ExtrRow &e = extrList(y); for (BitMap::Iterator j = b.begin(); j != b_end; ++j) { CoxNbr x = *j; - while(e[i] < x) + while (e[i] < x) ++i; - pol[i].add(klPol(x,ys),genL(s)); + pol[i].add(klPol(x, ys), genL(s)); if (ERRNO) { - Error(ERRNO,this,x,y); + Error(ERRNO, this, x, y); ERRNO = ERROR_WARNING; return; } @@ -1382,7 +1384,7 @@ void KLContext::KLHelper::secondTerm(const CoxNbr& y, List& pol, return; } -void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) +void KLContext::KLHelper::writeKLRow(const CoxNbr &y, List &pol) /* This function writes the polynomials from the list pol to klList(y); @@ -1397,12 +1399,12 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) */ { - KLRow& kl_row = klList(y); + KLRow &kl_row = klList(y); for (Ulong j = 0; j < kl_row.size(); ++j) { if (kl_row[j]) continue; - const KLPol* q = klTree().find(pol[j]); + const KLPol *q = klTree().find(pol[j]); if (q == 0) { /* an error occurred */ Error(ERRNO); ERRNO = ERROR_WARNING; @@ -1415,8 +1417,8 @@ void KLContext::KLHelper::writeKLRow(const CoxNbr& y, List& pol) return; } -void KLContext::KLHelper::writeMuRow(const MuRow& row, const Generator& s, - const CoxNbr& y) +void KLContext::KLHelper::writeMuRow(const MuRow &row, const Generator &s, + const CoxNbr &y) /* This function writes down row to the corresponding row in the mu-table @@ -1429,32 +1431,32 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const Generator& s, Ulong count = 0; for (Ulong j = 0; j < row.size(); ++j) { - const MuPol* pol = row[j].pol; + const MuPol *pol = row[j].pol; if (!pol->isZero()) count++; } /* copy non-zero terms to row in mu-table */ - MuTable& t = muTable(s); + MuTable &t = muTable(s); delete t[y]; t[y] = new MuRow(0); - MuRow& mu_row = *t[y]; + MuRow &mu_row = *t[y]; mu_row.setSize(count); count = 0; for (Ulong j = 0; j < row.size(); ++j) { - const MuPol* pol = row[j].pol; + const MuPol *pol = row[j].pol; if (!pol->isZero()) { /* append new element */ mu_row[count] = row[j]; count++; } } - + return; } -}; +}; // namespace uneqkl /***************************************************************************** @@ -1475,7 +1477,7 @@ void KLContext::KLHelper::writeMuRow(const MuRow& row, const Generator& s, namespace uneqkl { -KLPol& KLPol::add(const KLPol& p, const long& n) +KLPol &KLPol::add(const KLPol &p, const long &n) /* Increments the polynomial by p shifted by n, i.e. X^n.p, while checking @@ -1490,12 +1492,12 @@ KLPol& KLPol::add(const KLPol& p, const long& n) { /* set degree and valuation of the result */ - if (deg() < p.deg()+n) { - setDeg(p.deg()+n); + if (deg() < p.deg() + n) { + setDeg(p.deg() + n); } for (Degree j = 0; j <= p.deg(); ++j) { - safeAdd((*this)[j+n],p[j]); + safeAdd((*this)[j + n], p[j]); if (ERRNO) return *this; } @@ -1505,11 +1507,11 @@ KLPol& KLPol::add(const KLPol& p, const long& n) return *this; } -KLPol& KLPol::subtract(const KLPol& p, const MuPol& mp, const Ulong& n) +KLPol &KLPol::subtract(const KLPol &p, const MuPol &mp, const Ulong &n) /* This function subtracts from the current polynomial the polynomial p*mu - shifted by q^{n/2}. Here mp is a MuPol, i.e., a Laurent polynomial in + shifted by q^{n/2}. Here mp is a MuPol, i.e., a Laurent polynomial in q^{1/2}; it is assumed that n is such that mp*q^{n/2} is a polynomial in q. @@ -1520,13 +1522,13 @@ KLPol& KLPol::subtract(const KLPol& p, const MuPol& mp, const Ulong& n) { KLPol q(0); - q.setDeg((mp.deg()+n)/2); + q.setDeg((mp.deg() + n) / 2); for (long j = mp.val(); j <= mp.deg(); ++j) { if (mp[j] == 0) continue; /* if we get here, n + j is even */ - q[(n+j)/2] = mp[j]; + q[(n + j) / 2] = mp[j]; } /* compute the product and check for overflow */ @@ -1536,22 +1538,22 @@ KLPol& KLPol::subtract(const KLPol& p, const MuPol& mp, const Ulong& n) continue; for (Ulong j = 0; j <= p.deg(); ++j) { SKLCoeff a = p[j]; - safeMultiply(a,q[i]); + safeMultiply(a, q[i]); if (ERRNO) - return *this; - if (isZero() || (i+j) > deg()) - setDeg(i+j); - safeAdd(v[i+j],-a); + return *this; + if (isZero() || (i + j) > deg()) + setDeg(i + j); + safeAdd(v[i + j], -a); if (ERRNO) - return *this; + return *this; } } - reduceDeg(); - return *this; + reduceDeg(); + return *this; } -}; +}; // namespace uneqkl /**************************************************************************** @@ -1572,7 +1574,7 @@ KLPol& KLPol::subtract(const KLPol& p, const MuPol& mp, const Ulong& n) namespace uneqkl { -void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) +void cBasis(HeckeElt &h, const CoxNbr &y, KLContext &kl) /* This is what in the original Kazhdan-Lusztig paper is called the C'-basis, @@ -1581,24 +1583,24 @@ void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) */ { - const SchubertContext& p = kl.schubert(); + const SchubertContext &p = kl.schubert(); BitMap b(0); - p.extractClosure(b,y); + p.extractClosure(b, y); BitMap::Iterator b_end = b.end(); h.setSize(0); for (BitMap::Iterator x = b.begin(); x != b_end; ++x) { - const KLPol& pol = kl.klPol(*x,y); - HeckeMonomial m(*x,&pol); + const KLPol &pol = kl.klPol(*x, y); + HeckeMonomial m(*x, &pol); h.append(m); } return; } -}; +}; // namespace uneqkl /***************************************************************************** @@ -1616,35 +1618,35 @@ void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl) namespace uneqkl { -const MuPol& errorMuPol() +const MuPol &errorMuPol() { - static MuPol p(SKLCOEFF_MIN-1,MuPol::const_tag()); - /* cannot be a legal polynomial */ + static MuPol p(SKLCOEFF_MIN - 1, MuPol::const_tag()); + /* cannot be a legal polynomial */ return p; } -const KLPol& errorPol() +const KLPol &errorPol() { - static KLPol p(SKLCOEFF_MIN-1,KLPol::const_tag()); - /* cannot be a legal polynomial */ + static KLPol p(SKLCOEFF_MIN - 1, KLPol::const_tag()); + /* cannot be a legal polynomial */ return p; } -const KLPol& one() +const KLPol &one() { - static KLPol p(1,KLPol::const_tag()); + static KLPol p(1, KLPol::const_tag()); return p; } -}; +}; // namespace uneqkl namespace { -void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, - const Ulong& d, const long& m) +void muSubtraction(KLPol &p, const MuPol &mp, const KLPol &q, const Ulong &d, + const long &m) /* This function is an auxiliary to fillMu. It subtracts from p, which is @@ -1657,27 +1659,27 @@ void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, */ { - MuPol r(d*q.deg()+m,m); - r.setDegValue(d*q.deg()+m); + MuPol r(d * q.deg() + m, m); + r.setDegValue(d * q.deg() + m); for (long j = 0; j <= static_cast(q.deg()); ++j) { - r[d*j+m] = q[j]; + r[d * j + m] = q[j]; } for (long j = mp.val(); j <= mp.deg(); ++j) { if (!mp[j]) continue; for (long i = r.val(); i <= r.deg(); ++i) - if (i+j >= 0) { - SKLCoeff a = mp[j]; - safeMultiply(a,r[i]); - if (ERRNO) - return; - if (p.isZero() || (i+j) > static_cast(p.deg())) - p.setDeg(i+j); - safeAdd(p[i+j],-a); - if (ERRNO) - return; + if (i + j >= 0) { + SKLCoeff a = mp[j]; + safeMultiply(a, r[i]); + if (ERRNO) + return; + if (p.isZero() || (i + j) > static_cast(p.deg())) + p.setDeg(i + j); + safeAdd(p[i + j], -a); + if (ERRNO) + return; } } @@ -1685,7 +1687,7 @@ void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, return; } - void positivePart(KLPol& p, const KLPol& q, const Ulong& d, const long& m) +void positivePart(KLPol &p, const KLPol &q, const Ulong &d, const long &m) /* Puts in p the positive part (i.e. the part with positive degree) of the @@ -1698,15 +1700,15 @@ void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, /* compute degree of result */ - long h = q.deg()*d + m; + long h = q.deg() * d + m; if (h < 0) return; p.setDeg(h); - p.setZero(h+1); + p.setZero(h + 1); - for (Degree j = q.deg()+1; j;) { + for (Degree j = q.deg() + 1; j;) { --j; p[h] = q[j]; h -= d; @@ -1717,7 +1719,7 @@ void muSubtraction(KLPol& p, const MuPol& mp, const KLPol& q, return; } -const MuPol* writeMu(BinaryTree& t, const KLPol& p) +const MuPol *writeMu(BinaryTree &t, const KLPol &p) /* This function symmetrizes p and returns it address on the mutree. @@ -1729,7 +1731,7 @@ const MuPol* writeMu(BinaryTree& t, const KLPol& p) if (p.isZero()) mp.setZero(); else { - mp.setBounds(p.deg(),-p.deg()); + mp.setBounds(p.deg(), -p.deg()); mp[0] = p[0]; for (long j = 1; j <= static_cast(p.deg()); ++j) { @@ -1741,16 +1743,15 @@ const MuPol* writeMu(BinaryTree& t, const KLPol& p) return t.find(mp); } -}; +}; // namespace namespace uneqkl { -const MuPol& zero() +const MuPol &zero() { - static MuPol p(0,MuPol::const_tag()); + static MuPol p(0, MuPol::const_tag()); return p; } -}; - +}; // namespace uneqkl diff --git a/uneqkl.h b/uneqkl.h index a8e06b3..e9ce324 100644 --- a/uneqkl.h +++ b/uneqkl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef UNEQKL_H /* guard against multiple inclusions */ +#ifndef UNEQKL_H /* guard against multiple inclusions */ #define UNEQKL_H #include "globals.h" @@ -19,76 +19,78 @@ #include "search.h" namespace uneqkl { - using namespace coxeter; - using namespace coxtypes; - using namespace hecke; - using namespace klsupport; - using namespace list; - using namespace polynomials; - using namespace bits; - using namespace memory; - using namespace search; +using namespace coxeter; +using namespace coxtypes; +using namespace hecke; +using namespace klsupport; +using namespace list; +using namespace polynomials; +using namespace bits; +using namespace memory; +using namespace search; /******** type declarations **************************************************/ - class KLContext; - class KLPol; - class MuPol; - struct KLStatus; - struct MuData; +class KLContext; +class KLPol; +class MuPol; +struct KLStatus; +struct MuData; - typedef List KLRow; +typedef List KLRow; - typedef List MuRow; - typedef List MuTable; - typedef List > HeckeElt; +typedef List MuRow; +typedef List MuTable; +typedef List> HeckeElt; /******** function declarations **********************************************/ - void cBasis(HeckeElt& h, const CoxNbr& y, KLContext& kl); - const MuPol& errorMuPol(); - const KLPol& errorPol(); - const KLPol& one(); - const MuPol& zero(); +void cBasis(HeckeElt &h, const CoxNbr &y, KLContext &kl); +const MuPol &errorMuPol(); +const KLPol &errorPol(); +const KLPol &one(); +const MuPol &zero(); /******** type definitions ***************************************************/ -class KLPol:public Polynomial { +class KLPol : public Polynomial { static const SKLCoeff min_coeff = SKLCOEFF_MIN; static const SKLCoeff max_coeff = SKLCOEFF_MAX; + public: - static PolynomialType polType() {return UNEQ_KLPOL;} - KLPol() {}; - KLPol(const Ulong& n):Polynomial(n) {}; - KLPol(const SKLCoeff& c, const_tag):Polynomial(c,const_tag()) {}; - ~KLPol() {}; - KLPol& add(const KLPol& p, const long& n); - KLPol& subtract(const KLPol& p, const MuPol& mp, const Ulong& n); + static PolynomialType polType() { return UNEQ_KLPOL; } + KLPol(){}; + KLPol(const Ulong &n) : Polynomial(n){}; + KLPol(const SKLCoeff &c, const_tag) : Polynomial(c, const_tag()){}; + ~KLPol(){}; + KLPol &add(const KLPol &p, const long &n); + KLPol &subtract(const KLPol &p, const MuPol &mp, const Ulong &n); }; -class MuPol:public LaurentPolynomial { +class MuPol : public LaurentPolynomial { public: struct const_tag {}; - MuPol() {}; - MuPol(const SDegree& d, const SDegree& o = 0) - :LaurentPolynomial(d,o) {}; - MuPol(const SKLCoeff& c, const_tag):LaurentPolynomial(0,0) - {d_pol.setDegValue(0); d_pol[0] = c;} - ~MuPol() {}; + MuPol(){}; + MuPol(const SDegree &d, const SDegree &o = 0) + : LaurentPolynomial(d, o){}; + MuPol(const SKLCoeff &c, const_tag) : LaurentPolynomial(0, 0) { + d_pol.setDegValue(0); + d_pol[0] = c; + } + ~MuPol(){}; }; struct MuData { CoxNbr x; - const MuPol* pol; -/* constructors anc destructors*/ - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(MuData));} - MuData() {}; - MuData(const CoxNbr& x, const MuPol* pol):x(x),pol(pol) {}; -/* comparison */ - bool operator> (const MuData& m) const; /* inlined */ - bool operator< (const MuData& m) const; /* inlined */ - bool operator== (const MuData& m) const; /* inlined */ + const MuPol *pol; + /* constructors anc destructors*/ + void operator delete(void *ptr) { return arena().free(ptr, sizeof(MuData)); } + MuData(){}; + MuData(const CoxNbr &x, const MuPol *pol) : x(x), pol(pol){}; + /* comparison */ + bool operator>(const MuData &m) const; /* inlined */ + bool operator<(const MuData &m) const; /* inlined */ + bool operator==(const MuData &m) const; /* inlined */ }; struct KLStatus { @@ -99,93 +101,107 @@ struct KLStatus { Ulong munodes; Ulong mucomputed; Ulong muzero; -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLStatus));} - KLStatus() {}; - ~KLStatus() {}; + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLStatus)); + } + KLStatus(){}; + ~KLStatus(){}; }; class KLContext { - KLSupport* d_klsupport; - List d_klList; - List d_muTable; - List d_L; /* lengths of generators */ + KLSupport *d_klsupport; + List d_klList; + List d_muTable; + List d_L; /* lengths of generators */ List d_length; /* lengths of context elements */ BinaryTree d_klTree; BinaryTree d_muTree; - KLStatus* d_status; + KLStatus *d_status; struct KLHelper; /* provides helper functions */ - KLHelper* d_help; + KLHelper *d_help; friend struct KLHelper; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(KLContext));} - KLContext(KLSupport* kls, const CoxGraph& G, const Interface& I); + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(KLContext)); + } + KLContext(KLSupport *kls, const CoxGraph &G, const Interface &I); ~KLContext(); -/* accessors */ - const ExtrRow& extrList(const CoxNbr& y) const; /* inlined */ - Ulong genL(const Generator& s) const; /* inlined */ - CoxNbr inverse(const CoxNbr& x) const; /* inlined */ - bool isKLAllocated(const CoxNbr& y) const; /* inlined */ - bool isMuAllocated(const Generator& s, const CoxNbr& y) const; /* inlined */ - const KLRow& klList(const CoxNbr& y) const; /* inlined */ - const KLSupport& klsupport() const; /* inlined */ - Generator last(const CoxNbr& x) const; /* inlined */ - Ulong length(const CoxNbr& x) const; /* inlined */ - const MuRow& muList(const Generator& s, const CoxNbr& y) const;/* inlined */ - Rank rank() const; /* inlined */ - const SchubertContext& schubert() const; /* inlined */ - Ulong size() const; /* inlined */ -/* modifiers */ - void applyInverse(const CoxNbr& y); - void applyIPermutation(const CoxNbr& y, const Permutation& a); /* inlined */ + /* accessors */ + const ExtrRow &extrList(const CoxNbr &y) const; /* inlined */ + Ulong genL(const Generator &s) const; /* inlined */ + CoxNbr inverse(const CoxNbr &x) const; /* inlined */ + bool isKLAllocated(const CoxNbr &y) const; /* inlined */ + bool isMuAllocated(const Generator &s, const CoxNbr &y) const; /* inlined */ + const KLRow &klList(const CoxNbr &y) const; /* inlined */ + const KLSupport &klsupport() const; /* inlined */ + Generator last(const CoxNbr &x) const; /* inlined */ + Ulong length(const CoxNbr &x) const; /* inlined */ + const MuRow &muList(const Generator &s, const CoxNbr &y) const; /* inlined */ + Rank rank() const; /* inlined */ + const SchubertContext &schubert() const; /* inlined */ + Ulong size() const; /* inlined */ + /* modifiers */ + void applyInverse(const CoxNbr &y); + void applyIPermutation(const CoxNbr &y, const Permutation &a); /* inlined */ void fillKL(); void fillMu(); - void fillMu(const Generator& s); - const KLPol& klPol(const CoxNbr& x, const CoxNbr& y); - const MuPol& mu(const Generator& s, const CoxNbr& x, const CoxNbr& y); - void row(HeckeElt& h, const CoxNbr& y); - void permute(const Permutation& a); - void revertSize(const Ulong& n); - void setSize(const Ulong& n); + void fillMu(const Generator &s); + const KLPol &klPol(const CoxNbr &x, const CoxNbr &y); + const MuPol &mu(const Generator &s, const CoxNbr &x, const CoxNbr &y); + void row(HeckeElt &h, const CoxNbr &y); + void permute(const Permutation &a); + void revertSize(const Ulong &n); + void setSize(const Ulong &n); }; /******** inline definitions ************************************************/ -inline bool MuData::operator> (const MuData& m) const {return x > m.x;} -inline bool MuData::operator< (const MuData& m) const {return x < m.x;} -inline bool MuData::operator== (const MuData& m) const {return x == m.x;} - -inline const ExtrRow& KLContext::extrList(const CoxNbr& y) const - {return klsupport().extrList(y);} -inline Ulong KLContext::genL(const Generator& s) const {return d_L[s];} -inline CoxNbr KLContext::inverse(const CoxNbr& x) const - {return klsupport().inverse(x);} -inline bool KLContext::isKLAllocated(const CoxNbr& y) const - {return d_klList[y] != 0;} -inline bool KLContext::isMuAllocated(const Generator& s, const CoxNbr& y) const - {return (*d_muTable[s])[y] != 0;} -inline const KLRow& KLContext::klList(const CoxNbr& y) const - {return *d_klList[y];} -inline const KLSupport& KLContext::klsupport() const {return *d_klsupport;} -inline Generator KLContext::last(const CoxNbr& x) const - {return klsupport().last(x);} -inline Ulong KLContext::length(const CoxNbr& x) const {return d_length[x];} -inline const MuRow& KLContext::muList(const Generator& s, const CoxNbr& y) - const {return d_muTable[s][0][y][0];} -inline Rank KLContext::rank() const {return d_klsupport->rank();} -inline const SchubertContext& KLContext::schubert() const - {return klsupport().schubert();} -inline Ulong KLContext::size() const {return d_klList.size();} - -inline void KLContext::applyIPermutation(const CoxNbr& y, - const Permutation& a) - {return rightRangePermute(*d_klList[y],a);} +inline bool MuData::operator>(const MuData &m) const { return x > m.x; } +inline bool MuData::operator<(const MuData &m) const { return x < m.x; } +inline bool MuData::operator==(const MuData &m) const { return x == m.x; } +inline const ExtrRow &KLContext::extrList(const CoxNbr &y) const { + return klsupport().extrList(y); +} +inline Ulong KLContext::genL(const Generator &s) const { return d_L[s]; } +inline CoxNbr KLContext::inverse(const CoxNbr &x) const { + return klsupport().inverse(x); +} +inline bool KLContext::isKLAllocated(const CoxNbr &y) const { + return d_klList[y] != 0; +} +inline bool KLContext::isMuAllocated(const Generator &s, + const CoxNbr &y) const { + return (*d_muTable[s])[y] != 0; +} +inline const KLRow &KLContext::klList(const CoxNbr &y) const { + return *d_klList[y]; } +inline const KLSupport &KLContext::klsupport() const { return *d_klsupport; } +inline Generator KLContext::last(const CoxNbr &x) const { + return klsupport().last(x); +} +inline Ulong KLContext::length(const CoxNbr &x) const { return d_length[x]; } +inline const MuRow &KLContext::muList(const Generator &s, + const CoxNbr &y) const { + return d_muTable[s][0][y][0]; +} +inline Rank KLContext::rank() const { return d_klsupport->rank(); } +inline const SchubertContext &KLContext::schubert() const { + return klsupport().schubert(); +} +inline Ulong KLContext::size() const { return d_klList.size(); } + +inline void KLContext::applyIPermutation(const CoxNbr &y, + const Permutation &a) { + return rightRangePermute(*d_klList[y], a); +} + +} // namespace uneqkl #endif diff --git a/vector.h b/vector.h index 3aa2c23..538fe30 100644 --- a/vector.h +++ b/vector.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef VECTOR_H /* guarantee unique inclusion */ +#ifndef VECTOR_H /* guarantee unique inclusion */ #define VECTOR_H #include "globals.h" @@ -14,92 +14,105 @@ #include "memory.h" namespace vector { - using namespace coxeter; - using namespace io; - using namespace list; - using namespace memory; +using namespace coxeter; +using namespace io; +using namespace list; +using namespace memory; /* type declarations */ -template -class Vector; +template class Vector; /********* implementation **************************************************/ -template -class Vector -{ - private: - List d_list; - public: -/* constructors and destructors */ - Vector(){}; - Vector(Ulong n):d_list(n) {}; - Vector(const Vector& w):d_list(w.list()) {}; - Vector(T* const& ptr, const Ulong& n):d_list(ptr,n) {}; - Vector(T* const& ptr, const Ulong& n, bool b):d_list(ptr,n,b) {}; - ~Vector() {}; -/* manipulators */ - T& operator[] (const Ulong& j); /* inlined */ - const Vector& operator= (const Vector& w); /* inlined */ - Vector& operator+= (const Vector& w); - Vector& operator-= (const Vector& w); - Vector& operator*= (const T& a); - Ulong& dim(); /* inlined */ - T* ptr(); /* inlined */ - void reduceDim(); - void setDim(const Ulong& n); /* inlined */ - void setDimValue(const Ulong& n); /* inlined */ - void setVect(const T *source, const Ulong& first, const Ulong& r); - /* inlined */ - void setVect(const T *source, const Ulong& r); /* inlined */ - void setZero(const Ulong& first, const Ulong& r); /* inlined */ - void setZero(const Ulong& r); /* inlined */ - void setZero(); /* inlined */ -/* accessors */ - const T& operator[] (const Ulong& j) const; /* inlined */ - const Ulong& dim() const; /* inlined */ - const List& list() const; /* inlined */ - const T* ptr() const; /* inlined */ - }; +template class Vector { +private: + List d_list; -/* inline implementations */ +public: + /* constructors and destructors */ + Vector(){}; + Vector(Ulong n) : d_list(n){}; + Vector(const Vector &w) : d_list(w.list()){}; + Vector(T *const &ptr, const Ulong &n) : d_list(ptr, n){}; + Vector(T *const &ptr, const Ulong &n, bool b) : d_list(ptr, n, b){}; + ~Vector(){}; + /* manipulators */ + T &operator[](const Ulong &j); /* inlined */ + const Vector &operator=(const Vector &w); /* inlined */ + Vector &operator+=(const Vector &w); + Vector &operator-=(const Vector &w); + Vector &operator*=(const T &a); + Ulong &dim(); /* inlined */ + T *ptr(); /* inlined */ + void reduceDim(); + void setDim(const Ulong &n); /* inlined */ + void setDimValue(const Ulong &n); /* inlined */ + void setVect(const T *source, const Ulong &first, const Ulong &r); + /* inlined */ + void setVect(const T *source, const Ulong &r); /* inlined */ + void setZero(const Ulong &first, const Ulong &r); /* inlined */ + void setZero(const Ulong &r); /* inlined */ + void setZero(); /* inlined */ + /* accessors */ + const T &operator[](const Ulong &j) const; /* inlined */ + const Ulong &dim() const; /* inlined */ + const List &list() const; /* inlined */ + const T *ptr() const; /* inlined */ +}; -template inline T& Vector::operator[] (const Ulong& j) - {return d_list[j];} -template -inline const Vector& Vector::operator= (const Vector& w) - {d_list.assign(w.list()); return *this;} -template Ulong& Vector::dim() {return d_list.size();} -template inline T* Vector::ptr() {return d_list.ptr();} -template inline void Vector::setDim(const Ulong& n) - {Ulong d = dim(); d_list.setSize(n); if (n>d) setZero(d,n-d);} -template inline void Vector::setDimValue(const Ulong& n) - {d_list.setSizeValue(n);} -template -inline void Vector::setVect(const T *source, const Ulong& first, - const Ulong& r) - {d_list.setData(source,first,r);} -template inline void Vector::setVect(const T *source, - const Ulong& r) - {setVect(source,0,r);} -template inline void Vector::setZero(const Ulong& first, - const Ulong& r) - {d_list.setZero(first,r);} -template - inline void Vector::setZero(const Ulong& r) {d_list.setZero(0,r);} -template inline void Vector::setZero() {d_list.setZero();} -template - inline const T& Vector::operator[] (const Ulong& j) const - {return d_list[j];} -template - inline const Ulong& Vector::dim() const {return d_list.size();} -template - inline const List& Vector::list() const {return d_list;} -template - inline const T* Vector::ptr() const {return d_list.ptr();} +/* inline implementations */ +template inline T &Vector::operator[](const Ulong &j) { + return d_list[j]; +} +template +inline const Vector &Vector::operator=(const Vector &w) { + d_list.assign(w.list()); + return *this; +} +template Ulong &Vector::dim() { return d_list.size(); } +template inline T *Vector::ptr() { return d_list.ptr(); } +template inline void Vector::setDim(const Ulong &n) { + Ulong d = dim(); + d_list.setSize(n); + if (n > d) + setZero(d, n - d); +} +template inline void Vector::setDimValue(const Ulong &n) { + d_list.setSizeValue(n); +} +template +inline void Vector::setVect(const T *source, const Ulong &first, + const Ulong &r) { + d_list.setData(source, first, r); } +template +inline void Vector::setVect(const T *source, const Ulong &r) { + setVect(source, 0, r); +} +template +inline void Vector::setZero(const Ulong &first, const Ulong &r) { + d_list.setZero(first, r); +} +template inline void Vector::setZero(const Ulong &r) { + d_list.setZero(0, r); +} +template inline void Vector::setZero() { d_list.setZero(); } +template inline const T &Vector::operator[](const Ulong &j) const { + return d_list[j]; +} +template inline const Ulong &Vector::dim() const { + return d_list.size(); +} +template inline const List &Vector::list() const { + return d_list; +} +template inline const T *Vector::ptr() const { + return d_list.ptr(); +} + +} // namespace vector #include "vector.hpp" diff --git a/vector.hpp b/vector.hpp index 27d4b05..cd4ac57 100644 --- a/vector.hpp +++ b/vector.hpp @@ -1,13 +1,13 @@ /* This is vector.cpp - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux See file main.cpp for full copyright notice */ /**************************************************************************** - This module contains the implementation of the vector template. + This module contains the implementation of the vector template. Just as for lists, we define vectors only for types where copy-constructors are simply bitwise copy; i.e., vectors are really strings. Otheerwise, @@ -32,7 +32,8 @@ namespace vector { -template Vector& Vector::operator+= (const Vector& w) +template +Vector &Vector::operator+=(const Vector &w) /* Operator += for Vectors always makes sure that there is enough @@ -40,7 +41,7 @@ template Vector& Vector::operator+= (const Vector& w) */ { - if (w.dim() > dim()) /* enlarge v if necessary and extend by zero */ + if (w.dim() > dim()) /* enlarge v if necessary and extend by zero */ setDim(w.dim()); for (Ulong j = 0; j < w.dim(); j++) @@ -49,8 +50,8 @@ template Vector& Vector::operator+= (const Vector& w) return *this; } - -template Vector& Vector::operator-= (const Vector& w) +template +Vector &Vector::operator-=(const Vector &w) /* Operator -= for Vectors always makes sure that there is enough @@ -60,7 +61,7 @@ template Vector& Vector::operator-= (const Vector& w) { unsigned long j; - if (w.dim() > dim()) /* enlarge v if necessary and extend by zero */ + if (w.dim() > dim()) /* enlarge v if necessary and extend by zero */ setDim(w.dim()); for (Ulong j = 0; j < w.dim(); j++) @@ -69,8 +70,8 @@ template Vector& Vector::operator-= (const Vector& w) return *this; } - -template Vector& Vector::operator*= (const T& a) +template +Vector &Vector::operator*=(const T &a) /* Scalar multiplication operator. @@ -83,7 +84,8 @@ template Vector& Vector::operator*= (const T& a) return *this; } -template void Vector::reduceDim() +template +void Vector::reduceDim() /* This function reduces the dimension to the smallest value that will contain @@ -94,13 +96,13 @@ template void Vector::reduceDim() for (Ulong j = dim(); j;) { j--; if (d_list[j]) { - d_list.setSize(j+1); + d_list.setSize(j + 1); return; } } - + d_list.setSize(0); return; } -}; +}; // namespace vector diff --git a/version.h b/version.h index 03eaa2f..642009b 100644 --- a/version.h +++ b/version.h @@ -1,17 +1,17 @@ /* This is version.h - + Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux Coxeter version 3.1 Copyright (C) 2015 Travis Scrimshaw See file main.cpp for full copyright notice */ -#ifndef VERSION_H /* guard against multiple inclusions */ +#ifndef VERSION_H /* guard against multiple inclusions */ #define VERSION_H namespace version { - const char* const NAME = "Coxeter"; - const char* const VERSION = "3.1"; -}; +const char *const NAME = "Coxeter"; +const char *const VERSION = "3.1"; +}; // namespace version #endif diff --git a/wgraph.cpp b/wgraph.cpp index 176d134..8154062 100644 --- a/wgraph.cpp +++ b/wgraph.cpp @@ -31,15 +31,14 @@ ****************************************************************************/ -namespace -{ - using namespace wgraph; - using namespace stack; +namespace { +using namespace wgraph; +using namespace stack; - void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, - Partition &pi, OrientedGraph *P = 0); +void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, Partition &pi, + OrientedGraph *P = 0); -}; +}; // namespace /**************************************************************************** @@ -85,109 +84,106 @@ namespace ****************************************************************************/ -namespace wgraph -{ +namespace wgraph { - WGraph::WGraph(const Ulong &n) : d_coeff(n), d_descent(n) +WGraph::WGraph(const Ulong &n) + : d_coeff(n), d_descent(n) - /* - Constructor for the WGraph class. - */ +/* + Constructor for the WGraph class. +*/ - { - d_graph = new OrientedGraph(n); - } +{ + d_graph = new OrientedGraph(n); +} - WGraph::~WGraph() +WGraph::~WGraph() - /* - The only non-automatic part is the deletion of d_graph. - */ +/* + The only non-automatic part is the deletion of d_graph. +*/ - { - delete d_graph; - } +{ + delete d_graph; +} - void WGraph::reset() +void WGraph::reset() - /* - This function resets the structure to an empty graph of the same size. - */ +/* + This function resets the structure to an empty graph of the same size. +*/ - { - d_graph->reset(); - d_coeff.setZero(); - d_descent.setZero(); +{ + d_graph->reset(); + d_coeff.setZero(); + d_descent.setZero(); - return; - } + return; +} - void WGraph::setSize(const Ulong &n) +void WGraph::setSize(const Ulong &n) - /* - Sets the sizes of the data structures so that the graph can accomodate - n vertices. - */ +/* + Sets the sizes of the data structures so that the graph can accomodate + n vertices. +*/ - { - d_graph->setSize(n); - d_coeff.setSize(n); - d_descent.setSize(n); +{ + d_graph->setSize(n); + d_coeff.setSize(n); + d_descent.setSize(n); - return; - } + return; +} - void WGraph::print(FILE *file, const Interface &I) const +void WGraph::print(FILE *file, const Interface &I) const - /* - Prints the graph on a file in ascii format. - */ +/* + Prints the graph on a file in ascii format. +*/ - { - const OrientedGraph &Y = *d_graph; +{ + const OrientedGraph &Y = *d_graph; - int d = digits(size() - 1, 10); + int d = digits(size() - 1, 10); - /* count number of edges */ + /* count number of edges */ - Ulong count = 0; + Ulong count = 0; - for (Vertex x = 0; x < size(); ++x) - { - const EdgeList &e = Y.edge(x); - count += e.size(); - } + for (Vertex x = 0; x < size(); ++x) { + const EdgeList &e = Y.edge(x); + count += e.size(); + } - // find alignement - - String str(0); - LFlags f = leqmask[I.rank() - 1]; - interface::append(str, f, I); - Ulong descent_maxwidth = str.length(); - - fprintf(file, "%lu vertices, %lu edges\n\n", size(), count); - - for (Vertex x = 0; x < size(); ++x) - { - fprintf(file, "%*lu : ", d, x); - io::reset(str); - interface::append(str, descent(x), I); - pad(str, descent_maxwidth); - io::print(file, str); - fprintf(file, " "); - const EdgeList e = Y.edge(x); - const CoeffList c = coeffList(x); - for (Ulong j = 0; j < e.size(); ++j) - { - fprintf(file, "%lu(%lu)", e[j], static_cast(c[j])); - if (j + 1 < e.size()) /* there is more to come */ - fprintf(file, ","); - } - fprintf(file, "\n"); + // find alignement + + String str(0); + LFlags f = leqmask[I.rank() - 1]; + interface::append(str, f, I); + Ulong descent_maxwidth = str.length(); + + fprintf(file, "%lu vertices, %lu edges\n\n", size(), count); + + for (Vertex x = 0; x < size(); ++x) { + fprintf(file, "%*lu : ", d, x); + io::reset(str); + interface::append(str, descent(x), I); + pad(str, descent_maxwidth); + io::print(file, str); + fprintf(file, " "); + const EdgeList e = Y.edge(x); + const CoeffList c = coeffList(x); + for (Ulong j = 0; j < e.size(); ++j) { + fprintf(file, "%lu(%lu)", e[j], static_cast(c[j])); + if (j + 1 < e.size()) /* there is more to come */ + fprintf(file, ","); } + fprintf(file, "\n"); } +} -}; +}; // namespace wgraph /**************************************************************************** @@ -225,285 +221,266 @@ namespace wgraph ****************************************************************************/ -namespace wgraph -{ +namespace wgraph { - OrientedGraph::~OrientedGraph() +OrientedGraph::~OrientedGraph() - /* - Destruction is automatic. - */ +/* + Destruction is automatic. +*/ - { - } +{} - void OrientedGraph::cells(Partition &pi, OrientedGraph *P) const - - /* - Define a preorder relation on the vertices by setting x <= y iff there is an - oriented path from x to y. This function puts in pi the partition function - corresponding to the equivalence classes of this preorder. We use the - Tarjan algorithm, explained in one of the Knuth books, but which I learned - from Bill Casselman. - - The vertices for which the partition function is already defined will - be said to be dealt with. These are marked off in an auxiliary bitmap. - The algorithm goes as follows. Start with the first vertex that has not - been dealt with, say x0. We will have to deal (potentially) with the set - of all vertices visible from x0 (i.e >= x0). There will be a stack of - vertices, corresponding to a path originating from x0, such that at each - point in time, each vertex y >= x0 which is not dealt with will be - equivalent to an element of the stack; the least such (in the stack - ordering) will be called y_min, so that for instance x0_min = 0. We - record these values in an additional table, initialized to some value - undefined. - - Now let x be at the top of the stack. Look at the edges originating from - x. Ignore the ones that go to vertices which are dealt with. If there - are no edges left, x is minimal and is a class by itself; we can take - it off, mark it as dealt with, and continue. Otherwise, run through the - edges one by one. Let the edge be x->y. If y_min is defined, this means - that y has already been examined, and is not dealt with. But each such - element is equivalent to an element in the active stack, so y_min should - be one of the elements in the active stack, hence x is visible from y_min: - in other words, x and y are equivalent, and we set x_min = y_min if - y_min < x_min. Otherwise, y is seen for the first time; then we just put - it on the stack. When we are done with the edges of x, we have now the - value of x_min which is the inf over the edges originating from x of - the y_min. If this value is equal to the stack-position of x, we see that x - is minimal in its class, and we get a new class by taking all the successors - of x not already dealt with. We then move to the parent of x and continue - the process there. - */ - - { - static Permutation a(0); - static BitMap b(0); - static List v(1); - static List elist(1); - static List ecount(1); - static List min(0); - - pi.setSize(size()); - pi.setClassCount(0); - - b.setSize(size()); - b.reset(); - min.setSize(size()); - min.setZero(); - - for (Vertex x = 0; x < size(); ++x) - min[x] = size(); - - for (Vertex x = 0; x < size(); ++x) - { - - if (b.getBit(x)) /* x is dealt with */ - continue; +void OrientedGraph::cells(Partition &pi, OrientedGraph *P) const - v[0] = x; - v.setSize(1); - elist[0] = &edge(x); - elist.setSize(1); - ecount[0] = 0; - ecount.setSize(1); - min[x] = 0; - Ulong t = 1; - - while (t) - { - Vertex y = v[t - 1]; - Vertex z; - const EdgeList &e = *elist[t - 1]; - for (; ecount[t - 1] < e.size(); ++ecount[t - 1]) - { - z = e[ecount[t - 1]]; - if (b.getBit(z)) - continue; - if (min[z] == size()) /* z is new */ - goto add_path; - if (min[y] > min[z]) - min[y] = min[z]; - } - /* at this point we have exhausted the edges of y */ - if (min[y] == t - 1) - { /* take off class */ - getClass(*this, y, b, pi, P); - } - else if (min[y] < min[v[t - 2]]) /* if t=1, previous case holds */ - min[v[t - 2]] = min[y]; - t--; - continue; - add_path: - v.setSize(t + 1); - elist.setSize(t + 1); - ecount.setSize(t + 1); - v[t] = z; - elist[t] = &edge(z); - ecount[t] = 0; - min[z] = t; - t++; +/* + Define a preorder relation on the vertices by setting x <= y iff there is an + oriented path from x to y. This function puts in pi the partition function + corresponding to the equivalence classes of this preorder. We use the + Tarjan algorithm, explained in one of the Knuth books, but which I learned + from Bill Casselman. + + The vertices for which the partition function is already defined will + be said to be dealt with. These are marked off in an auxiliary bitmap. + The algorithm goes as follows. Start with the first vertex that has not + been dealt with, say x0. We will have to deal (potentially) with the set + of all vertices visible from x0 (i.e >= x0). There will be a stack of + vertices, corresponding to a path originating from x0, such that at each + point in time, each vertex y >= x0 which is not dealt with will be + equivalent to an element of the stack; the least such (in the stack + ordering) will be called y_min, so that for instance x0_min = 0. We + record these values in an additional table, initialized to some value + undefined. + + Now let x be at the top of the stack. Look at the edges originating from + x. Ignore the ones that go to vertices which are dealt with. If there + are no edges left, x is minimal and is a class by itself; we can take + it off, mark it as dealt with, and continue. Otherwise, run through the + edges one by one. Let the edge be x->y. If y_min is defined, this means + that y has already been examined, and is not dealt with. But each such + element is equivalent to an element in the active stack, so y_min should + be one of the elements in the active stack, hence x is visible from y_min: + in other words, x and y are equivalent, and we set x_min = y_min if + y_min < x_min. Otherwise, y is seen for the first time; then we just put + it on the stack. When we are done with the edges of x, we have now the + value of x_min which is the inf over the edges originating from x of + the y_min. If this value is equal to the stack-position of x, we see that x + is minimal in its class, and we get a new class by taking all the successors + of x not already dealt with. We then move to the parent of x and continue + the process there. +*/ + +{ + static Permutation a(0); + static BitMap b(0); + static List v(1); + static List elist(1); + static List ecount(1); + static List min(0); + + pi.setSize(size()); + pi.setClassCount(0); + + b.setSize(size()); + b.reset(); + min.setSize(size()); + min.setZero(); + + for (Vertex x = 0; x < size(); ++x) + min[x] = size(); + + for (Vertex x = 0; x < size(); ++x) { + + if (b.getBit(x)) /* x is dealt with */ + continue; + + v[0] = x; + v.setSize(1); + elist[0] = &edge(x); + elist.setSize(1); + ecount[0] = 0; + ecount.setSize(1); + min[x] = 0; + Ulong t = 1; + + while (t) { + Vertex y = v[t - 1]; + Vertex z; + const EdgeList &e = *elist[t - 1]; + for (; ecount[t - 1] < e.size(); ++ecount[t - 1]) { + z = e[ecount[t - 1]]; + if (b.getBit(z)) + continue; + if (min[z] == size()) /* z is new */ + goto add_path; + if (min[y] > min[z]) + min[y] = min[z]; } + /* at this point we have exhausted the edges of y */ + if (min[y] == t - 1) { /* take off class */ + getClass(*this, y, b, pi, P); + } else if (min[y] < min[v[t - 2]]) /* if t=1, previous case holds */ + min[v[t - 2]] = min[y]; + t--; + continue; + add_path: + v.setSize(t + 1); + elist.setSize(t + 1); + ecount.setSize(t + 1); + v[t] = z; + elist[t] = &edge(z); + ecount[t] = 0; + min[z] = t; + t++; } - - return; } - void OrientedGraph::levelPartition(Partition &pi) const - - /* - Assuming the graph has no oriented cycles, this function writes in pi the - partition of the vertices according to their level, where sinks have level - 0, then sinks in the remaining poset have level one, etc. - - NOTE : the implementation is simple-minded : we traverse the graph as many - times as there are levels. - */ - - { - static BitMap b(0); - static BitMap b1(0); - - b.setSize(size()); - b.reset(); - b1.setSize(size()); - b1.reset(); - pi.setSize(size()); - Ulong count = 0; - Ulong current_level = 0; - - while (count < size()) - { - for (SetElt x = 0; x < size(); ++x) - { - if (b.getBit(x)) - continue; - const EdgeList e = d_edge[x]; - for (Ulong j = 0; j < e.size(); ++j) - { - if (!b.getBit(e[j])) /* next x */ - goto nextx; - } - /* i we get here, x is the next element in the permutation */ - pi[x] = current_level; - b1.setBit(x); - ++count; - nextx: + return; +} + +void OrientedGraph::levelPartition(Partition &pi) const + +/* + Assuming the graph has no oriented cycles, this function writes in pi the + partition of the vertices according to their level, where sinks have level + 0, then sinks in the remaining poset have level one, etc. + + NOTE : the implementation is simple-minded : we traverse the graph as many + times as there are levels. +*/ + +{ + static BitMap b(0); + static BitMap b1(0); + + b.setSize(size()); + b.reset(); + b1.setSize(size()); + b1.reset(); + pi.setSize(size()); + Ulong count = 0; + Ulong current_level = 0; + + while (count < size()) { + for (SetElt x = 0; x < size(); ++x) { + if (b.getBit(x)) continue; + const EdgeList e = d_edge[x]; + for (Ulong j = 0; j < e.size(); ++j) { + if (!b.getBit(e[j])) /* next x */ + goto nextx; } - b.assign(b1); - current_level++; + /* i we get here, x is the next element in the permutation */ + pi[x] = current_level; + b1.setBit(x); + ++count; + nextx: + continue; } - - pi.setClassCount(current_level); - return; + b.assign(b1); + current_level++; } - void OrientedGraph::permute(const Permutation &a) + pi.setClassCount(current_level); + return; +} - /* - This function permutes the graph according to the permutation a, according - to the usual rule : the edges of a(x) should be the image under a of the - edge set of x. +void OrientedGraph::permute(const Permutation &a) - As usual, permuting values is easy : it is enough to apply a to the - elements in the various edgelists. Permuting ranges is trickier, because - it involves a^-1. +/* + This function permutes the graph according to the permutation a, according + to the usual rule : the edges of a(x) should be the image under a of the + edge set of x. - It is assumed of course that a holds a permutation of size size(). - */ + As usual, permuting values is easy : it is enough to apply a to the + elements in the various edgelists. Permuting ranges is trickier, because + it involves a^-1. - { - static BitMap b(0); - static EdgeList e_buf(0); + It is assumed of course that a holds a permutation of size size(). +*/ - /* permute values */ +{ + static BitMap b(0); + static EdgeList e_buf(0); - for (SetElt x = 0; x < size(); ++x) - { - EdgeList &e = d_edge[x]; - for (Ulong j = 0; j < e.size(); ++j) - { - e[j] = a[e[j]]; - } + /* permute values */ + + for (SetElt x = 0; x < size(); ++x) { + EdgeList &e = d_edge[x]; + for (Ulong j = 0; j < e.size(); ++j) { + e[j] = a[e[j]]; } + } - /* permute ranges */ + /* permute ranges */ - b.setSize(size()); - b.reset(); + b.setSize(size()); + b.reset(); - for (SetElt x = 0; x < size(); ++x) - { - if (b.getBit(x)) - continue; - if (a[x] == x) - { /* fixed point */ - b.setBit(x); - continue; - } - for (SetElt y = a[x]; y != x; y = a[y]) - { - /* back up values for y */ - e_buf.shallowCopy(d_edge[y]); - /* put values for x in y */ - d_edge[y].shallowCopy(d_edge[x]); - /* store backup values in x */ - d_edge[x].shallowCopy(e_buf); - /* set bit */ - b.setBit(y); - } + for (SetElt x = 0; x < size(); ++x) { + if (b.getBit(x)) + continue; + if (a[x] == x) { /* fixed point */ b.setBit(x); + continue; + } + for (SetElt y = a[x]; y != x; y = a[y]) { + /* back up values for y */ + e_buf.shallowCopy(d_edge[y]); + /* put values for x in y */ + d_edge[y].shallowCopy(d_edge[x]); + /* store backup values in x */ + d_edge[x].shallowCopy(e_buf); + /* set bit */ + b.setBit(y); } + b.setBit(x); } +} - void OrientedGraph::print(FILE *file) const +void OrientedGraph::print(FILE *file) const - /* - Does a printout of the graph on the file. - */ +/* + Does a printout of the graph on the file. +*/ - { - fprintf(file, "size : %lu\n\n", size()); +{ + fprintf(file, "size : %lu\n\n", size()); - int d = digits(size(), 10); + int d = digits(size(), 10); - for (Vertex x = 0; x < size(); ++x) - { - const EdgeList &e = edge(x); - fprintf(file, "%*lu : ", d, x); - for (Ulong j = 0; j < e.size(); ++j) - { - fprintf(file, "%*lu", d, e[j]); - if (j < e.size() - 1) - { /* there is more to come */ - fprintf(file, ","); - } + for (Vertex x = 0; x < size(); ++x) { + const EdgeList &e = edge(x); + fprintf(file, "%*lu : ", d, x); + for (Ulong j = 0; j < e.size(); ++j) { + fprintf(file, "%*lu", d, e[j]); + if (j < e.size() - 1) { /* there is more to come */ + fprintf(file, ","); } - fprintf(file, "\n"); } - fprintf(file, "\n"); - - return; } - void OrientedGraph::reset() + fprintf(file, "\n"); - /* - Resets the structure to hold a edge-less graph of the same size. - */ + return; +} - { - for (Ulong j = 0; j < size(); ++j) - { - d_edge[j].setSize(0); - } +void OrientedGraph::reset() - return; +/* + Resets the structure to hold a edge-less graph of the same size. +*/ + +{ + for (Ulong j = 0; j < size(); ++j) { + d_edge[j].setSize(0); } -}; + return; +} + +}; // namespace wgraph /**************************************************************************** @@ -516,60 +493,52 @@ namespace wgraph ****************************************************************************/ -namespace -{ +namespace { - void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, - Partition &pi, OrientedGraph *P) - - /* - After the element y has been identified as minimal among the elements not - already marked in b, this function marks off the equivalence class of y; - these are just the elements visible from y and not already marked in b. - The class is also written as a new class in pi. - */ - - { - static Fifo c; - - Ulong a = pi.classCount(); - c.push(y); - b.setBit(y); - pi[y] = a; - if (P) - P->setSize(a + 1); - - while (c.size()) - { - Vertex x = c.pop(); - const EdgeList &e = X.edge(x); - for (Ulong j = 0; j < e.size(); ++j) - { - Vertex z = e[j]; - if (b.getBit(z)) - { - if (P && (pi[z] < a)) - { /* add a new edge to P */ - EdgeList &f = P->edge(a); - if (find(f, pi[z]) == not_found) - { /* edge is new */ - insert(f, pi[z]); - } +void getClass(const OrientedGraph &X, const Vertex &y, BitMap &b, Partition &pi, + OrientedGraph *P) + +/* + After the element y has been identified as minimal among the elements not + already marked in b, this function marks off the equivalence class of y; + these are just the elements visible from y and not already marked in b. + The class is also written as a new class in pi. +*/ + +{ + static Fifo c; + + Ulong a = pi.classCount(); + c.push(y); + b.setBit(y); + pi[y] = a; + if (P) + P->setSize(a + 1); + + while (c.size()) { + Vertex x = c.pop(); + const EdgeList &e = X.edge(x); + for (Ulong j = 0; j < e.size(); ++j) { + Vertex z = e[j]; + if (b.getBit(z)) { + if (P && (pi[z] < a)) { /* add a new edge to P */ + EdgeList &f = P->edge(a); + if (find(f, pi[z]) == not_found) { /* edge is new */ + insert(f, pi[z]); } - continue; - } - else - { - c.push(z); - b.setBit(z); - pi[z] = a; } + continue; + } else { + c.push(z); + b.setBit(z); + pi[z] = a; } } + } - pi.setClassCount(a + 1); + pi.setClassCount(a + 1); - return; - } + return; +} -}; +}; // namespace diff --git a/wgraph.h b/wgraph.h index 64872e3..95ad944 100644 --- a/wgraph.h +++ b/wgraph.h @@ -5,29 +5,29 @@ See file main.cpp for full copyright notice */ -#ifndef WGRAPH_H /* guard against multiple inclusions */ +#ifndef WGRAPH_H /* guard against multiple inclusions */ #define WGRAPH_H #include "globals.h" #include "list.h" namespace wgraph { - using namespace coxeter; - using namespace list; -}; +using namespace coxeter; +using namespace list; +}; // namespace wgraph /******** type declarations *************************************************/ namespace wgraph { - class WGraph; - class OrientedGraph; - - typedef Ulong Vertex; - typedef unsigned short Coeff; - typedef List CoeffList; - typedef Vertex Edge; - typedef List EdgeList; -}; +class WGraph; +class OrientedGraph; + +typedef Ulong Vertex; +typedef unsigned short Coeff; +typedef List CoeffList; +typedef Vertex Edge; +typedef List EdgeList; +}; // namespace wgraph /******** type definitions **************************************************/ @@ -35,81 +35,87 @@ namespace wgraph { #include "interface.h" namespace wgraph { - using namespace bits; - using namespace interface; +using namespace bits; +using namespace interface; class OrientedGraph { - private: +private: List d_edge; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(OrientedGraph));} - OrientedGraph(const Ulong &n):d_edge(n) {}; + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { + return arena().free(ptr, sizeof(OrientedGraph)); + } + OrientedGraph(const Ulong &n) : d_edge(n){}; ~OrientedGraph(); -/* accessors */ - void cells(Partition& pi, OrientedGraph* P = 0) const; - const EdgeList& edge(const Vertex& x) const; /* inlined */ - Vertex firstMinimal(const BitMap& b) const; - void levelPartition(Partition& pi) const; - void print(FILE* file) const; - Ulong size() const; /* inlined */ -/* modifiers */ - EdgeList& edge(const Vertex& x); /* inlined */ - void permute(const Permutation& a); + /* accessors */ + void cells(Partition &pi, OrientedGraph *P = 0) const; + const EdgeList &edge(const Vertex &x) const; /* inlined */ + Vertex firstMinimal(const BitMap &b) const; + void levelPartition(Partition &pi) const; + void print(FILE *file) const; + Ulong size() const; /* inlined */ + /* modifiers */ + EdgeList &edge(const Vertex &x); /* inlined */ + void permute(const Permutation &a); void reset(); - void setSize(const Ulong& n); /* inlined */ + void setSize(const Ulong &n); /* inlined */ }; class WGraph { - private: - OrientedGraph* d_graph; +private: + OrientedGraph *d_graph; List d_coeff; List d_descent; - public: -/* constructors and destructors */ - void* operator new(size_t size) {return arena().alloc(size);} - void operator delete(void* ptr) - {return arena().free(ptr,sizeof(WGraph));} + +public: + /* constructors and destructors */ + void *operator new(size_t size) { return arena().alloc(size); } + void operator delete(void *ptr) { return arena().free(ptr, sizeof(WGraph)); } WGraph(const Ulong &n); ~WGraph(); -/* accessors */ - const CoeffList& coeffList(const Vertex& x) const; /* inlined */ - const LFlags& descent(const Vertex& x) const; /* inlined */ - const EdgeList& edge(const Vertex& x) const; /* inlined */ - const OrientedGraph& graph() const; /* inlined */ - Ulong size() const; /* inlined */ -/* modifiers */ - CoeffList& coeffList(const Vertex& x); /* inlined */ - LFlags& descent(const Vertex& x); /* inlined */ - EdgeList& edge(const Vertex& x); /* inlined */ - OrientedGraph& graph(); /* inlined */ + /* accessors */ + const CoeffList &coeffList(const Vertex &x) const; /* inlined */ + const LFlags &descent(const Vertex &x) const; /* inlined */ + const EdgeList &edge(const Vertex &x) const; /* inlined */ + const OrientedGraph &graph() const; /* inlined */ + Ulong size() const; /* inlined */ + /* modifiers */ + CoeffList &coeffList(const Vertex &x); /* inlined */ + LFlags &descent(const Vertex &x); /* inlined */ + EdgeList &edge(const Vertex &x); /* inlined */ + OrientedGraph &graph(); /* inlined */ void reset(); - void setSize(const Ulong& n); -/* input/output */ - void print(FILE* file, const Interface& I) const; + void setSize(const Ulong &n); + /* input/output */ + void print(FILE *file, const Interface &I) const; }; - inline const CoeffList& WGraph::coeffList(const Vertex& x) const - {return d_coeff[x];} - inline const LFlags& WGraph::descent(const Vertex& x) const - {return d_descent[x];} - inline const EdgeList& WGraph::edge(const Vertex& x) const - {return d_graph->edge(x);} - inline const OrientedGraph& WGraph::graph() const {return *d_graph;} - inline CoeffList& WGraph::coeffList(const Vertex& x) {return d_coeff[x];} - inline EdgeList& WGraph::edge(const Vertex& x) {return d_graph->edge(x);} - inline Ulong WGraph::size() const {return d_graph->size();} - inline OrientedGraph& WGraph::graph() {return *d_graph;} - - inline LFlags& WGraph::descent(const Vertex& x) {return d_descent[x];} - inline const EdgeList& OrientedGraph::edge(const Vertex& x) const - {return d_edge[x];} - inline Ulong OrientedGraph::size() const {return d_edge.size();} - inline EdgeList& OrientedGraph::edge(const Vertex& x) {return d_edge[x];} - inline void OrientedGraph::setSize(const Ulong& n) {d_edge.setSize(n);} - +inline const CoeffList &WGraph::coeffList(const Vertex &x) const { + return d_coeff[x]; +} +inline const LFlags &WGraph::descent(const Vertex &x) const { + return d_descent[x]; +} +inline const EdgeList &WGraph::edge(const Vertex &x) const { + return d_graph->edge(x); } +inline const OrientedGraph &WGraph::graph() const { return *d_graph; } +inline CoeffList &WGraph::coeffList(const Vertex &x) { return d_coeff[x]; } +inline EdgeList &WGraph::edge(const Vertex &x) { return d_graph->edge(x); } +inline Ulong WGraph::size() const { return d_graph->size(); } +inline OrientedGraph &WGraph::graph() { return *d_graph; } + +inline LFlags &WGraph::descent(const Vertex &x) { return d_descent[x]; } +inline const EdgeList &OrientedGraph::edge(const Vertex &x) const { + return d_edge[x]; +} +inline Ulong OrientedGraph::size() const { return d_edge.size(); } +inline EdgeList &OrientedGraph::edge(const Vertex &x) { return d_edge[x]; } +inline void OrientedGraph::setSize(const Ulong &n) { d_edge.setSize(n); } + +} // namespace wgraph #endif From e9be90180c96e1c2f40eb9def3d04094c7345988 Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Thu, 28 Dec 2023 11:14:20 -0800 Subject: [PATCH 5/6] changing ifdefs to pragmas --- affine.h | 2 +- automata.h | 2 +- bits.h | 2 +- cells.h | 2 +- commands.h | 2 +- constants.h | 2 +- coxgroup.h | 2 +- coxtypes.h | 2 +- dictionary.h | 2 +- directories.h | 2 +- dotval.h | 2 +- error.h | 2 +- fcoxgroup.h | 2 +- files.h | 2 +- general.h | 2 +- globals.h | 2 +- graph.h | 2 +- hecke.h | 2 +- help.h | 2 +- interactive.h | 2 +- interface.h | 2 +- invkl.h | 2 +- io.h | 2 +- iterator.h | 2 +- kl.h | 2 +- klsupport.h | 2 +- list.h | 2 +- memory.h | 2 +- minroots.h | 2 +- posets.h | 2 +- schubert.h | 2 +- search.h | 2 +- special.h | 2 +- stack.h | 2 +- transducer.h | 2 +- type.h | 2 +- typeA.h | 2 +- uneqkl.h | 2 +- vector.h | 2 +- version.h | 2 +- wgraph.h | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/affine.h b/affine.h index 43fc3e9..7fe7704 100644 --- a/affine.h +++ b/affine.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef AFFINE_H /* guarantee single inclusion */ +#ifndef AFFINE_H #define AFFINE_H #include "globals.h" diff --git a/automata.h b/automata.h index c12773f..a7145a4 100644 --- a/automata.h +++ b/automata.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef AUTOMATA_H /* guard against multiple inclusions */ +#ifndef AUTOMATA_H #define AUTOMATA_H #include "globals.h" diff --git a/bits.h b/bits.h index cdb3b89..f26a5b9 100644 --- a/bits.h +++ b/bits.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef BITS_H /* guarantee single inclusion */ +#ifndef BITS_H #define BITS_H #include diff --git a/cells.h b/cells.h index 0a48811..4f742eb 100644 --- a/cells.h +++ b/cells.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CELLS_H /* guard against multiple inclusions */ +#ifndef CELLS_H #define CELLS_H #include "globals.h" diff --git a/commands.h b/commands.h index e75e483..c8882b1 100644 --- a/commands.h +++ b/commands.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef COMMANDS_H /* guard against multiple inclusions */ +#ifndef COMMANDS_H #define COMMANDS_H #include "globals.h" diff --git a/constants.h b/constants.h index 5b62215..0472c66 100644 --- a/constants.h +++ b/constants.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CONSTANTS_H /* guard against multiple inclusions */ +#ifndef CONSTANTS_H #define CONSTANTS_H #include diff --git a/coxgroup.h b/coxgroup.h index d65f4a6..93f4953 100644 --- a/coxgroup.h +++ b/coxgroup.h @@ -51,7 +51,7 @@ */ -#ifndef COXGROUP_H /* guarantee single inclusion */ +#ifndef COXGROUP_H #define COXGROUP_H #include "globals.h" diff --git a/coxtypes.h b/coxtypes.h index 2d27203..54cc86a 100644 --- a/coxtypes.h +++ b/coxtypes.h @@ -11,7 +11,7 @@ ****************************************************************************/ -#ifndef COXTYPES_H /* guard against multiple inclusions */ +#ifndef COXTYPES_H #define COXTYPES_H #include diff --git a/dictionary.h b/dictionary.h index bce8b02..4464799 100644 --- a/dictionary.h +++ b/dictionary.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef DICTIONARY_H /* guard against multiple inclusions */ +#ifndef DICTIONARY_H #define DICTIONARY_H #include "globals.h" diff --git a/directories.h b/directories.h index d9da303..55b29f3 100644 --- a/directories.h +++ b/directories.h @@ -6,7 +6,7 @@ See file main.cpp for full copyright notice */ -#ifndef DIRECTORIES_H /* guard against multiple inclusions */ +#ifndef DIRECTORIES_H #define DIRECTORIES_H /* diff --git a/dotval.h b/dotval.h index 3db0369..a8fe75d 100644 --- a/dotval.h +++ b/dotval.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef DOTVAL_H /* guard against multiple inclusions */ +#ifndef DOTVAL_H #define DOTVAL_H namespace dotval { diff --git a/error.h b/error.h index d3d9de8..4c2b293 100644 --- a/error.h +++ b/error.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef ERROR_H /* guard against multiple inclusions */ +#ifndef ERROR_H #define ERROR_H #include "globals.h" diff --git a/fcoxgroup.h b/fcoxgroup.h index a0bdb09..726319d 100644 --- a/fcoxgroup.h +++ b/fcoxgroup.h @@ -16,7 +16,7 @@ ****************************************************************************/ -#ifndef FCOXGROUP_H /* guard against multiple inclusions */ +#ifndef FCOXGROUP_H #define FCOXGROUP_H #include "globals.h" diff --git a/files.h b/files.h index ca6ca1f..9359d75 100644 --- a/files.h +++ b/files.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef FILES_H /* guard against multiple inclusions */ +#ifndef FILES_H #define FILES_H #include "globals.h" diff --git a/general.h b/general.h index b77a274..7841f45 100644 --- a/general.h +++ b/general.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef GENERAL_H /* guard against multiple inclusions */ +#ifndef GENERAL_H #define GENERAL_H #include "globals.h" diff --git a/globals.h b/globals.h index 972331e..a3efad3 100644 --- a/globals.h +++ b/globals.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef GLOBALS_H /* guard against multiple inclusions */ +#ifndef GLOBALS_H #define GLOBALS_H // TODO: Check to make sure we need these diff --git a/graph.h b/graph.h index d666a52..6f36ca1 100644 --- a/graph.h +++ b/graph.h @@ -7,7 +7,7 @@ /* type definitions */ -#ifndef GRAPH_H /* guarantee single inclusion */ +#ifndef GRAPH_H #define GRAPH_H #include "globals.h" diff --git a/hecke.h b/hecke.h index e44b5d2..1c1c8f0 100644 --- a/hecke.h +++ b/hecke.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef HECKE_H /* guard against multiple inclusions */ +#ifndef HECKE_H #define HECKE_H #include "globals.h" diff --git a/help.h b/help.h index e51f4bc..89fa75e 100644 --- a/help.h +++ b/help.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef HELP_H /* guard against multiple inclusions */ +#ifndef HELP_H #define HELP_H #include "globals.h" diff --git a/interactive.h b/interactive.h index bb183b8..11dd2f6 100644 --- a/interactive.h +++ b/interactive.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERACTIVE_H /* guard against multiple inclusions */ +#ifndef INTERACTIVE_H #define INTERACTIVE_H #include "globals.h" diff --git a/interface.h b/interface.h index 8f6bee4..4e5edfe 100644 --- a/interface.h +++ b/interface.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERFACE_H /* guard against multiple inclusions */ +#ifndef INTERFACE_H #define INTERFACE_H #include "globals.h" diff --git a/invkl.h b/invkl.h index 28949fb..68af5d5 100644 --- a/invkl.h +++ b/invkl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INVKL_H /* guard against multiple inclusions */ +#ifndef INVKL_H #define INVKL_H #include "globals.h" diff --git a/io.h b/io.h index 8b41cca..e0452b6 100644 --- a/io.h +++ b/io.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef IO_H /* guarantee single inclusion */ +#ifndef IO_H #define IO_H #include "globals.h" diff --git a/iterator.h b/iterator.h index 5211318..76575f7 100644 --- a/iterator.h +++ b/iterator.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef ITERATOR_H /* guard against multiple inclusions */ +#ifndef ITERATOR_H #define ITERATOR_H #include "globals.h" diff --git a/kl.h b/kl.h index 84efd97..8884152 100644 --- a/kl.h +++ b/kl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KL_H /* guard against multiple inclusions */ +#ifndef KL_H #define KL_H #include diff --git a/klsupport.h b/klsupport.h index de832f0..72f2b56 100644 --- a/klsupport.h +++ b/klsupport.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KLSUPPORT_H /* guard against multiple inclusions */ +#ifndef KLSUPPORT_H #define KLSUPPORT_H #include "globals.h" diff --git a/list.h b/list.h index ecc2031..43fb10c 100644 --- a/list.h +++ b/list.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef LIST_H /* guarantee single inclusion */ +#ifndef LIST_H #define LIST_H #include diff --git a/memory.h b/memory.h index 63f7860..aec21bf 100644 --- a/memory.h +++ b/memory.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef MEMORY_H /* guard against multiple inclusions */ +#ifndef MEMORY_H #define MEMORY_H #include "globals.h" diff --git a/minroots.h b/minroots.h index 30073f2..fc7544f 100644 --- a/minroots.h +++ b/minroots.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef MINROOTS_H /* guarantee single inclusion */ +#ifndef MINROOTS_H #define MINROOTS_H #include diff --git a/posets.h b/posets.h index 906c0f1..1e0e89f 100644 --- a/posets.h +++ b/posets.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef POSETS_H /* guard against multiple inclusions */ +#ifndef POSETS_H #define POSETS_H #include "globals.h" diff --git a/schubert.h b/schubert.h index 33cca72..99368b0 100644 --- a/schubert.h +++ b/schubert.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef SCHUBERT_H /* guard against multiple inclusions */ +#ifndef SCHUBERT_H #define SCHUBERT_H #include "globals.h" diff --git a/search.h b/search.h index 012fe10..72ef276 100644 --- a/search.h +++ b/search.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef SEARCH_H /* guard against multiple inclusions */ +#ifndef SEARCH_H #define SEARCH_H #include "globals.h" diff --git a/special.h b/special.h index 5b80146..766de9f 100644 --- a/special.h +++ b/special.h @@ -6,7 +6,7 @@ */ -#ifndef SPECIAL_H /* guard against multiple inclusions */ +#ifndef SPECIAL_H #define SPECIAL_H #include "globals.h" diff --git a/stack.h b/stack.h index 25c65b1..6fed52a 100644 --- a/stack.h +++ b/stack.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef STACK_H /* guard against multiple inclusions */ +#ifndef STACK_H #define STACK_H #include "globals.h" diff --git a/transducer.h b/transducer.h index af36c72..9d758d8 100644 --- a/transducer.h +++ b/transducer.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef TRANSDUCER_H /* guarantee single inclusion */ +#ifndef TRANSDUCER_H #define TRANSDUCER_H #include "globals.h" diff --git a/type.h b/type.h index ee09f20..f1139ff 100644 --- a/type.h +++ b/type.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef TYPE_H /* guard against multiple inclusions */ +#ifndef TYPE_H #define TYPE_H #include "globals.h" diff --git a/typeA.h b/typeA.h index 36d22a0..51df5e5 100644 --- a/typeA.h +++ b/typeA.h @@ -9,7 +9,7 @@ as permutations. */ -#ifndef TYPEA_H /* guard against multiple inclusions */ +#ifndef TYPEA_H #define TYPEA_H #include "globals.h" diff --git a/uneqkl.h b/uneqkl.h index e9ce324..9f5abc1 100644 --- a/uneqkl.h +++ b/uneqkl.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef UNEQKL_H /* guard against multiple inclusions */ +#ifndef UNEQKL_H #define UNEQKL_H #include "globals.h" diff --git a/vector.h b/vector.h index 538fe30..01a2d4a 100644 --- a/vector.h +++ b/vector.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef VECTOR_H /* guarantee unique inclusion */ +#ifndef VECTOR_H #define VECTOR_H #include "globals.h" diff --git a/version.h b/version.h index 642009b..c155121 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ See file main.cpp for full copyright notice */ -#ifndef VERSION_H /* guard against multiple inclusions */ +#ifndef VERSION_H #define VERSION_H namespace version { diff --git a/wgraph.h b/wgraph.h index 95ad944..934592b 100644 --- a/wgraph.h +++ b/wgraph.h @@ -5,7 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef WGRAPH_H /* guard against multiple inclusions */ +#ifndef WGRAPH_H #define WGRAPH_H #include "globals.h" From bd0537fac6fd24d1727e79ffd9a19c88a5628137 Mon Sep 17 00:00:00 2001 From: Adam Nemecek Date: Thu, 28 Dec 2023 11:19:19 -0800 Subject: [PATCH 6/6] pragma once --- affine.h | 5 +---- automata.h | 5 +---- bits.cpp | 1 + bits.h | 5 +---- cells.h | 5 +---- commands.h | 5 +---- constants.h | 5 +---- coxgroup.h | 5 +---- coxtypes.h | 5 +---- dictionary.h | 5 +---- directories.h | 5 +---- dotval.h | 5 +---- error.h | 5 +---- fcoxgroup.h | 5 +---- files.h | 5 +---- general.h | 5 +---- globals.h | 5 +---- graph.h | 5 +---- hecke.h | 5 +---- help.h | 5 +---- interactive.h | 5 +---- interface.h | 5 +---- invkl.h | 5 +---- io.h | 5 +---- iterator.h | 5 +---- kl.h | 5 +---- klsupport.h | 5 +---- list.h | 5 +---- memory.h | 5 +---- minroots.h | 5 +---- posets.h | 5 +---- schubert.h | 5 +---- search.h | 5 +---- special.h | 5 +---- stack.h | 5 +---- transducer.h | 5 +---- type.h | 5 +---- typeA.h | 5 +---- uneqkl.h | 5 +---- vector.h | 5 +---- version.h | 5 +---- wgraph.h | 5 +---- 42 files changed, 42 insertions(+), 164 deletions(-) diff --git a/affine.h b/affine.h index 7fe7704..bcaa1da 100644 --- a/affine.h +++ b/affine.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef AFFINE_H -#define AFFINE_H +#pragma once #include "globals.h" #include "coxgroup.h" @@ -112,5 +111,3 @@ class GeneralASRCoxGroup : public AffineSmallRankCoxGroup { */ inline CoxSize AffineCoxGroup::order() const { return infinite_coxsize; } } // namespace affine - -#endif diff --git a/automata.h b/automata.h index a7145a4..83e919c 100644 --- a/automata.h +++ b/automata.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef AUTOMATA_H -#define AUTOMATA_H +#pragma once #include "globals.h" #include "bits.h" @@ -84,5 +83,3 @@ inline Ulong ExplicitAutomaton::rank() const { return d_rank; } inline Ulong ExplicitAutomaton::size() const { return d_size; } } // namespace automata - -#endif diff --git a/bits.cpp b/bits.cpp index 7b485cd..60bf8a4 100644 --- a/bits.cpp +++ b/bits.cpp @@ -138,6 +138,7 @@ Permutation &Permutation::compose(const Permutation &a) { for (SetElt x = 0; x < size(); ++x) + // this[x] = a[x]; operator[](x) = a[operator[](x)]; return *this; diff --git a/bits.h b/bits.h index f26a5b9..f395448 100644 --- a/bits.h +++ b/bits.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef BITS_H -#define BITS_H +#pragma once #include #include @@ -514,5 +513,3 @@ void sortI_f(const List &r, F &f, Permutation &a) { } } // namespace bits - -#endif diff --git a/cells.h b/cells.h index 4f742eb..d46d89b 100644 --- a/cells.h +++ b/cells.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CELLS_H -#define CELLS_H +#pragma once #include "globals.h" #include "bits.h" @@ -49,5 +48,3 @@ void lrWGraph(WGraph &X, kl::KLContext &kl); void lrWGraph(WGraph &X, const SubSet &q, kl::KLContext &kl); void printCellPartition(FILE *file, const kl::KLContext &kl); } // namespace cells - -#endif diff --git a/commands.h b/commands.h index c8882b1..addde81 100644 --- a/commands.h +++ b/commands.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef COMMANDS_H -#define COMMANDS_H +#pragma once #include "globals.h" #include "coxgroup.h" @@ -102,5 +101,3 @@ inline void CommandTree::exit() const { return d_exit(); } inline CommandTree *CommandTree::helpMode() const { return d_help; } } // namespace commands - -#endif diff --git a/constants.h b/constants.h index 0472c66..ba345dd 100644 --- a/constants.h +++ b/constants.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef CONSTANTS_H -#define CONSTANTS_H +#pragma once #include @@ -28,5 +27,3 @@ unsigned firstBit(Ulong f); void initConstants(); unsigned lastBit(Ulong f); } // namespace constants - -#endif diff --git a/coxgroup.h b/coxgroup.h index 93f4953..7ddd84e 100644 --- a/coxgroup.h +++ b/coxgroup.h @@ -51,8 +51,7 @@ */ -#ifndef COXGROUP_H -#define COXGROUP_H +#pragma once #include "globals.h" #include "coxtypes.h" @@ -450,5 +449,3 @@ template void CoxGroup::setOutputTraits(C) { } } // namespace coxeter - -#endif diff --git a/coxtypes.h b/coxtypes.h index 54cc86a..4f9a509 100644 --- a/coxtypes.h +++ b/coxtypes.h @@ -11,8 +11,7 @@ ****************************************************************************/ -#ifndef COXTYPES_H -#define COXTYPES_H +#pragma once #include @@ -119,5 +118,3 @@ inline CoxWord &CoxWord::operator=(const CoxWord &h) { inline CoxLetter &CoxWord::operator[](const Length &j) { return d_list[j]; } inline void CoxWord::setLength(Length n) { d_list.setSize(n + 1); } } // namespace coxtypes - -#endif diff --git a/dictionary.h b/dictionary.h index 4464799..a745a3a 100644 --- a/dictionary.h +++ b/dictionary.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef DICTIONARY_H -#define DICTIONARY_H +#pragma once #include "globals.h" #include "memory.h" @@ -70,5 +69,3 @@ template class Dictionary { } // namespace dictionary #include "dictionary.hpp" - -#endif diff --git a/directories.h b/directories.h index 55b29f3..360808e 100644 --- a/directories.h +++ b/directories.h @@ -6,8 +6,7 @@ See file main.cpp for full copyright notice */ -#ifndef DIRECTORIES_H -#define DIRECTORIES_H +#pragma once /* This file tells where the directories can be found which contain some @@ -29,5 +28,3 @@ const char *const COXMATRIX_DIR = "/usr/local/coxeter/coxeter_matrices"; const char *const HEADER_DIR = "/usr/local/coxeter/headers"; const char *const MESSAGE_DIR = "/usr/local/coxeter/messages"; }; // namespace directories - -#endif diff --git a/dotval.h b/dotval.h index a8fe75d..17fea67 100644 --- a/dotval.h +++ b/dotval.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef DOTVAL_H -#define DOTVAL_H +#pragma once namespace dotval { enum DotVal { @@ -26,5 +25,3 @@ enum DotVal { one = 6 }; }; - -#endif diff --git a/error.h b/error.h index 4c2b293..eec2126 100644 --- a/error.h +++ b/error.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef ERROR_H -#define ERROR_H +#pragma once #include "globals.h" @@ -77,5 +76,3 @@ extern int ERRNO; void Error(int number, ...); } // namespace error - -#endif diff --git a/fcoxgroup.h b/fcoxgroup.h index 726319d..b7134af 100644 --- a/fcoxgroup.h +++ b/fcoxgroup.h @@ -16,8 +16,7 @@ ****************************************************************************/ -#ifndef FCOXGROUP_H -#define FCOXGROUP_H +#pragma once #include "globals.h" #include "coxgroup.h" @@ -258,5 +257,3 @@ inline const FiltrationTerm *FiniteCoxGroup::transducer(const Rank &l) const { } } // namespace fcoxgroup - -#endif diff --git a/files.h b/files.h index 9359d75..41046a9 100644 --- a/files.h +++ b/files.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef FILES_H -#define FILES_H +#pragma once #include "globals.h" #include "hecke.h" @@ -448,5 +447,3 @@ struct OutputTraits { /******** inline definitions *************************************************/ #include "files.hpp" - -#endif diff --git a/general.h b/general.h index 7841f45..4659689 100644 --- a/general.h +++ b/general.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef GENERAL_H -#define GENERAL_H +#pragma once #include "globals.h" #include "coxgroup.h" @@ -111,5 +110,3 @@ class GeneralSRCoxGroup : public SmallRankCoxGroup { /* leaf class */ inline CoxSize GeneralCoxGroup::order() const { return undef_coxsize; } } // namespace general - -#endif diff --git a/globals.h b/globals.h index a3efad3..89d3f85 100644 --- a/globals.h +++ b/globals.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef GLOBALS_H -#define GLOBALS_H +#pragma once // TODO: Check to make sure we need these #include @@ -18,5 +17,3 @@ namespace coxeter { typedef unsigned long Ulong; /* shorthand */ }; - -#endif diff --git a/graph.h b/graph.h index 6f36ca1..62a4ed6 100644 --- a/graph.h +++ b/graph.h @@ -7,8 +7,7 @@ /* type definitions */ -#ifndef GRAPH_H -#define GRAPH_H +#pragma once #include "globals.h" #include "list.h" @@ -100,5 +99,3 @@ inline const List &CoxGraph::starOps() const { return d_starOps; } inline const Type &CoxGraph::type() const { return d_type; } }; // namespace graph - -#endif diff --git a/hecke.h b/hecke.h index 1c1c8f0..8b70326 100644 --- a/hecke.h +++ b/hecke.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef HECKE_H -#define HECKE_H +#pragma once #include "globals.h" #include "list.h" @@ -117,5 +116,3 @@ inline void HeckeMonomial

::setData(const CoxNbr &x, const P *pol) { }; // namespace hecke #include "hecke.hpp" - -#endif diff --git a/help.h b/help.h index 89fa75e..cfcc62b 100644 --- a/help.h +++ b/help.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef HELP_H -#define HELP_H +#pragma once #include "globals.h" @@ -119,5 +118,3 @@ void terse_h(); }; // namespace out } // namespace interface }; // namespace help - -#endif diff --git a/interactive.h b/interactive.h index 11dd2f6..203eaaf 100644 --- a/interactive.h +++ b/interactive.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERACTIVE_H -#define INTERACTIVE_H +#pragma once #include "globals.h" #include "bits.h" @@ -69,5 +68,3 @@ class OutputFile { }; }; // namespace interactive - -#endif diff --git a/interface.h b/interface.h index 4e5edfe..86abdbc 100644 --- a/interface.h +++ b/interface.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INTERFACE_H -#define INTERFACE_H +#pragma once #include "globals.h" #include "automata.h" @@ -355,5 +354,3 @@ inline void Interface::print(FILE *file, const CoxWord &g) const { } } // namespace interface - -#endif diff --git a/invkl.h b/invkl.h index 68af5d5..4ea3bce 100644 --- a/invkl.h +++ b/invkl.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef INVKL_H -#define INVKL_H +#pragma once #include "globals.h" #include "coxtypes.h" @@ -200,5 +199,3 @@ inline void KLContext::setFullKL() { d_status->flags |= KLStatus::kl_done; } inline void KLContext::setFullMu() { d_status->flags |= KLStatus::mu_done; } } // namespace invkl - -#endif diff --git a/io.h b/io.h index e0452b6..ae9e51d 100644 --- a/io.h +++ b/io.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef IO_H -#define IO_H +#pragma once #include "globals.h" #include "list.h" @@ -96,5 +95,3 @@ inline bool String::isDefined() const { return size(); } inline Ulong String::length() const { return size() - 1; } } // namespace io - -#endif diff --git a/iterator.h b/iterator.h index 76575f7..4cb949e 100644 --- a/iterator.h +++ b/iterator.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef ITERATOR_H -#define ITERATOR_H +#pragma once #include "globals.h" @@ -54,5 +53,3 @@ template class FilteredIterator { }; } // namespace iterator - -#endif diff --git a/kl.h b/kl.h index 8884152..cca4f54 100644 --- a/kl.h +++ b/kl.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KL_H -#define KL_H +#pragma once #include @@ -249,5 +248,3 @@ inline void KLContext::setFullKL() { d_status->flags |= KLStatus::kl_done; } inline void KLContext::setFullMu() { d_status->flags |= KLStatus::mu_done; } } // namespace kl - -#endif diff --git a/klsupport.h b/klsupport.h index 72f2b56..71e68f2 100644 --- a/klsupport.h +++ b/klsupport.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef KLSUPPORT_H -#define KLSUPPORT_H +#pragma once #include "globals.h" @@ -123,5 +122,3 @@ inline const SchubertContext &KLSupport::schubert() const { } } // namespace klsupport - -#endif diff --git a/list.h b/list.h index 43fb10c..cbd313c 100644 --- a/list.h +++ b/list.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef LIST_H -#define LIST_H +#pragma once #include @@ -145,5 +144,3 @@ template inline typename List::ConstIterator List::end() const { } // namespace list #include "list.hpp" - -#endif diff --git a/memory.h b/memory.h index aec21bf..475b97e 100644 --- a/memory.h +++ b/memory.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef MEMORY_H -#define MEMORY_H +#pragma once #include "globals.h" #include "constants.h" @@ -78,5 +77,3 @@ inline void *operator new(size_t size, memory::Arena &a) { inline void *operator new[](size_t size, memory::Arena &a) { return a.alloc(size); } - -#endif diff --git a/minroots.h b/minroots.h index fc7544f..5f89da2 100644 --- a/minroots.h +++ b/minroots.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef MINROOTS_H -#define MINROOTS_H +#pragma once #include #include "globals.h" @@ -121,5 +120,3 @@ inline Rank MinTable::rank() const { return d_rank; } inline MinNbr MinTable::size() const { return d_size; } }; // namespace minroots - -#endif diff --git a/posets.h b/posets.h index 1e0e89f..5ca1f38 100644 --- a/posets.h +++ b/posets.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef POSETS_H -#define POSETS_H +#pragma once #include "globals.h" @@ -66,5 +65,3 @@ namespace posets { inline Ulong Poset::size() const { return d_closure.size(); } }; // namespace posets - -#endif diff --git a/schubert.h b/schubert.h index 99368b0..f73974c 100644 --- a/schubert.h +++ b/schubert.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef SCHUBERT_H -#define SCHUBERT_H +#pragma once #include "globals.h" #include "coxtypes.h" @@ -361,5 +360,3 @@ inline ClosureIterator::operator bool() const { return d_valid; } inline const CoxNbr &ClosureIterator::current() const { return d_current; } } // namespace schubert - -#endif diff --git a/search.h b/search.h index 72ef276..2f6a1e4 100644 --- a/search.h +++ b/search.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef SEARCH_H -#define SEARCH_H +#pragma once #include "globals.h" #include "list.h" @@ -72,5 +71,3 @@ template inline TreeNode *BinaryTree::root() const { } // namespace search #include "search.hpp" - -#endif diff --git a/special.h b/special.h index 766de9f..176fadf 100644 --- a/special.h +++ b/special.h @@ -6,8 +6,7 @@ */ -#ifndef SPECIAL_H -#define SPECIAL_H +#pragma once #include "globals.h" #include "commands.h" @@ -20,5 +19,3 @@ using namespace coxeter; void addSpecialCommands(commands::CommandTree *tree); } // namespace special - -#endif diff --git a/stack.h b/stack.h index 6fed52a..d0b3de6 100644 --- a/stack.h +++ b/stack.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef STACK_H -#define STACK_H +#pragma once #include "globals.h" #include "list.h" @@ -73,5 +72,3 @@ template inline const T &Fifo::top() const { } // namespace stack #include "stack.hpp" - -#endif diff --git a/transducer.h b/transducer.h index 9d758d8..a376c75 100644 --- a/transducer.h +++ b/transducer.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef TRANSDUCER_H -#define TRANSDUCER_H +#pragma once #include "globals.h" @@ -174,5 +173,3 @@ inline const FiltrationTerm *Transducer::transducer(const Rank &l) const { } }; // namespace transducer - -#endif diff --git a/type.h b/type.h index f1139ff..f1a3475 100644 --- a/type.h +++ b/type.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef TYPE_H -#define TYPE_H +#pragma once #include "globals.h" #include "io.h" @@ -57,5 +56,3 @@ inline char &Type::operator[](const Ulong &j) { return d_name[j]; } inline String &Type::name() { return d_name; } }; // namespace coxeter - -#endif diff --git a/typeA.h b/typeA.h index 51df5e5..e7d8bad 100644 --- a/typeA.h +++ b/typeA.h @@ -9,8 +9,7 @@ as permutations. */ -#ifndef TYPEA_H -#define TYPEA_H +#pragma once #include "globals.h" #include "fcoxgroup.h" @@ -228,5 +227,3 @@ inline TypeAInterface &TypeACoxGroup::typeAInterface() { } } // namespace coxeter - -#endif diff --git a/uneqkl.h b/uneqkl.h index 9f5abc1..a1c1871 100644 --- a/uneqkl.h +++ b/uneqkl.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef UNEQKL_H -#define UNEQKL_H +#pragma once #include "globals.h" #include "coxtypes.h" @@ -203,5 +202,3 @@ inline void KLContext::applyIPermutation(const CoxNbr &y, } } // namespace uneqkl - -#endif diff --git a/vector.h b/vector.h index 01a2d4a..c29fd9d 100644 --- a/vector.h +++ b/vector.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef VECTOR_H -#define VECTOR_H +#pragma once #include "globals.h" #include "io.h" @@ -115,5 +114,3 @@ template inline const T *Vector::ptr() const { } // namespace vector #include "vector.hpp" - -#endif diff --git a/version.h b/version.h index c155121..2977185 100644 --- a/version.h +++ b/version.h @@ -6,12 +6,9 @@ See file main.cpp for full copyright notice */ -#ifndef VERSION_H -#define VERSION_H +#pragma once namespace version { const char *const NAME = "Coxeter"; const char *const VERSION = "3.1"; }; // namespace version - -#endif diff --git a/wgraph.h b/wgraph.h index 934592b..2865c5f 100644 --- a/wgraph.h +++ b/wgraph.h @@ -5,8 +5,7 @@ See file main.cpp for full copyright notice */ -#ifndef WGRAPH_H -#define WGRAPH_H +#pragma once #include "globals.h" #include "list.h" @@ -117,5 +116,3 @@ inline EdgeList &OrientedGraph::edge(const Vertex &x) { return d_edge[x]; } inline void OrientedGraph::setSize(const Ulong &n) { d_edge.setSize(n); } } // namespace wgraph - -#endif