archrelease: copy trunk to community-x86_64
[ArchLinux/community.git] / coxeter / trunk / coxeter-sage.patch
blob4e6ce4cfc17901f5f99e0155f6cf3cc95b1d3c6d
1 See https://github.com/tscrim/coxeter/pull/14
3 commit 7b46d5ea88cfdcaa4af549f61c58c330fb513948
4 Author: Jeroen Demeyer <jdemeyer@cage.ugent.be>
5 Date: Mon Feb 26 14:43:08 2018 +0100
7 Add Sage interface
9 diff --git a/sage.cpp b/sage.cpp
10 new file mode 100644
11 index 0000000..74f86be
12 --- /dev/null
13 +++ b/sage.cpp
14 @@ -0,0 +1,56 @@
15 +/*
16 + Coxeter version 3.0 Copyright (C) 2009 Mike Hansen
17 + See file main.cpp for full copyright notice
18 +*/
20 +#include "sage.h"
22 +namespace sage {
24 + void interval(List<CoxWord>& list, CoxGroup& W, const CoxWord& g, const CoxWord& h)
26 + /*
27 + Returns a list of the elements in the Bruhat interval between g and h.
28 + Note that this assumes that g and h are in order.
29 + */
30 + {
31 + if (not W.inOrder(g,h)) {
32 + return;
33 + }
35 + W.extendContext(h);
37 + CoxNbr x = W.contextNumber(g);
38 + CoxNbr y = W.contextNumber(h);
40 + BitMap b(W.contextSize());
41 + W.extractClosure(b,y);
43 + BitMap::ReverseIterator b_rend = b.rend();
44 + List<CoxNbr> res(0);
46 + for (BitMap::ReverseIterator i = b.rbegin(); i != b_rend; ++i)
47 + if (not W.inOrder(x,*i)) {
48 + BitMap bi(W.contextSize());
49 + W.extractClosure(bi,*i);
50 + CoxNbr z = *i; // andnot will invalidate iterator
51 + b.andnot(bi);
52 + b.setBit(z); // otherwise the decrement will not be correct
53 + } else
54 + res.append(*i);
56 + schubert::NFCompare nfc(W.schubert(),W.ordering());
57 + Permutation a(res.size());
58 + sortI(res,nfc,a);
60 + list.setSize(0);
61 + for (size_t j = 0; j < res.size(); ++j) {
62 + CoxWord w(0);
63 + W.schubert().append(w, res[a[j]]);
64 + list.append(w);
65 + }
67 + return;
68 + }
71 diff --git a/sage.h b/sage.h
72 new file mode 100644
73 index 0000000..5b3df8a
74 --- /dev/null
75 +++ b/sage.h
76 @@ -0,0 +1,23 @@
77 +/*
78 + Coxeter version 3.0 Copyright (C) 2009 Mike Hansen
79 + See file main.cpp for full copyright notice
80 +*/
82 +#ifndef SAGE_H /* guard against multiple inclusions */
83 +#define SAGE_H
85 +#include "globals.h"
86 +#include "coxgroup.h"
87 +#include "coxtypes.h"
88 +#include "schubert.h"
89 +#include "list.h"
91 +namespace sage {
92 + using namespace coxeter;
93 + using namespace coxtypes;
94 + using namespace list;
96 + void interval(List<CoxWord>& result, CoxGroup& W, const CoxWord& g, const CoxWord& h);
99 +#endif