atlas  0.6
partition_def.h
Go to the documentation of this file.
1 
10 /*
11  This is partition_def.h.
12 
13  Copyright (C) 2004,2005 Fokko du Cloux
14  part of the Atlas of Lie Groups and Representations
15 
16  For license information see the LICENSE file
17 */
18 
19 #include <queue>
20 
21 #include "bitmap.h"
22 #include "sl_list.h"
23 
24 /*****************************************************************************
25 
26  This file contains the definition of the template declared in partition.h:
27 
28  - Partition orbits(F a, unsigned long n, unsigned long limit) : constructs
29  the orbit partition defined by the "action function" a;
30 
31 ******************************************************************************/
32 
33 namespace atlas {
34 
35 namespace partition {
36 
37 /* Although the function |orbits| currently needs only one instantiation (from
38  cartanclass.cpp), it has to be defined as a template, and has to be
39  dynamically instantiated: explicit instantiation here is impossible because
40  the template argument |F| needs to be specialised to a class local to the
41  instantiating code (in the anonymous namespace of the file cartanclass.cpp)
42 */
43 
72 template<typename F> // class F serving as function object (ul,ul)->ul
73  Partition orbits(const F& a, size_t c, unsigned long n)
74 {
75  Partition result(n);
76 
77  bitmap::BitMap b(n); // as yet unclassified elements
78  b.fill(); // initially that means everyone
79 
80  for (bitmap::BitMap::iterator it=b.begin(); it(); ++it) // |b| will shrink
81  {
82  unsigned long root = *it; // starting element for a fresh orbit
83  unsigned long thisClass = result.new_class(root);
84  std::queue<unsigned long,containers::sl_list<unsigned long> > q;
85  q.push(root);
86  b.remove(root); // avoid looping back to |root| later
87 
88  do
89  {
90  unsigned long x = q.front(); q.pop();
91 
92  for (unsigned long i=0; i<c; ++i)
93  {
94  unsigned long y = a(i,x);
95  if (b.isMember(y)) // new element was found
96  {
97  b.remove(y);
98  result.addToClass(thisClass,y);
99  q.push(y);
100  }
101  }
102  }
103  while (not q.empty());
104  }
105  return result;
106 }
107 
108 } // |namespace partition|
109 
110 } // |namespace atlas|
mod_pointer root
Definition: common.c:127
Definition: partition.h:51
Definition: Poincare.cpp:13
Partition orbits(const F &, unsigned long, unsigned long)
iterator begin() const
Definition: bitmap.cpp:130
unsigned long new_class(unsigned long c)
Definition: partition.cpp:107
void fill()
Definition: bitmap.cpp:484
void addToClass(unsigned long c, unsigned long j)
Adds value j to class #c.
Definition: partition.h:116
Definitions and declarations for the BitMap class.
unsigned long n
Definition: axis.cpp:77
Definition: Atlas.h:38
Container of a large (more than twice the machine word size) set of bits.
Definition: bitmap.h:52
void remove(unsigned long n)
Definition: bitmap.h:207
bool isMember(unsigned long n) const
Definition: bitmap.h:138
Traverses the set bits of a BitMap.
Definition: bitmap.h:266