atlas  0.6
size.h
Go to the documentation of this file.
1 
5 /*
6  Copyright (C) 2004,2005 Fokko du Cloux
7  part of the Atlas of Lie Groups and Representations
8 
9  For license information see the LICENSE file
10 */
11 
12 #ifndef SIZE_H /* guard against multiple inclusions */
13 #define SIZE_H
14 
15 #include "size_fwd.h"
16 
17 #include <cstring>
18 #include "constants.h"
19 
20 /******** type declarations **************************************************/
21 
22 namespace atlas {
23 
24 
25 
26 /******** constant declarations **********************************************/
27 
28 namespace size {
29 
39  template<unsigned long n> class PrimesMax
40  {
41  public:
42  static const unsigned long value; // no value supplied in generic case
43  };
44 
45 
46  // predefined values for likely instances of RANK_MAX
53  template<> class PrimesMax<8> {
54  public:
55  static const unsigned long value = 4ul;
56  };
57 
65  template<> class PrimesMax<16> {
66  public:
67  static const unsigned long value = 7ul;
68  };
69 
77  template<> class PrimesMax<32> {
78  public:
79  static const unsigned long value = 11ul;
80  };
81 
89  template<> class PrimesMax<64> {
90  public:
91  static const unsigned long value = 18ul;
92  };
93 
102 
103 } // |namespace size|
104 
105 /******** function declarations **********************************************/
106 
107 namespace size {
108 
109  unsigned long prime(size_t);
110 
111  Size factorial (unsigned long n);
112 
113 }
114 
115 /******** type definitions ***************************************************/
116 
117 namespace size {
118 
130 template<typename C> class SizeType
131 {
132  C d_exp[PRIMES_MAX];
133 
134  public:
135 // constructors and destructors
136  SizeType() { std::memset(d_exp,0,PRIMES_MAX*sizeof(C)); }
137 
138  explicit SizeType(unsigned long);
139 
140 // copy and assignment (defaults suffice)
141 
142 // accessors
143  C operator[] (size_t j) const { return d_exp[j]; }
144 
145  bool operator== (const SizeType& c) const
146  { return std::memcmp(d_exp,c.d_exp,PRIMES_MAX*sizeof(C))==0; }
147  bool operator!= (const SizeType& c) const
148  { return std::memcmp(d_exp,c.d_exp,PRIMES_MAX*sizeof(C))!=0; }
149 
150  unsigned long piece(size_t) const; // return $prime(i)^{d_exp[i]}$
151  unsigned long toUlong() const; // try to represent as unsigned long
152 
153 // manipulators
154  C& operator[] (size_t j) { return d_exp[j]; }
155 
156  SizeType& operator*= (const SizeType&);
157 
158  SizeType& operator*= (unsigned long n) { return operator*=(SizeType(n)); }
159 
160  SizeType& operator/= (const SizeType&);
161 
162  void reset() { std::memset(d_exp,0,PRIMES_MAX*sizeof(C)); }
163 
164  void twoShift(C n) // multiplication by 2^n; prime #0 is 2
165  { d_exp[0] += n; }
166 }; // |template<typename C> class SizeType|
167 
168 } // |namespace size|
169 
170 } // |namespace atlas|
171 
172 #endif
SizeType()
Definition: size.h:136
unsigned long size
Definition: testprint.cpp:46
Size factorial(unsigned long n)
Return the factorial of |n|.
Definition: size.cpp:156
bool operator!=(const type_expr &x, const type_expr &y)
Definition: axis-types.h:374
A template to indicate the (manually computed) ordinal (position on the list of primes) of the larges...
Definition: size.h:39
SizeType & operator*=(unsigned long n)
Definition: size.h:158
Vector< C > & operator/=(Vector< C > &v, C c)
Definition: matrix.cpp:99
unsigned long n
Definition: axis.cpp:77
bool operator==(const type_expr &x, const type_expr &y)
Definition: axis-types.cpp:257
void reset()
Definition: size.h:162
const size_t PRIMES_MAX
Position on the list of primes of the largest possible prime factor of a Weyl group of rank at most R...
Definition: size.h:101
Definition: Atlas.h:38
void twoShift(C n)
Definition: size.h:164
C d_exp[PRIMES_MAX]
Definition: size.h:132
unsigned long prime(size_t j)
Definition: size.cpp:149
Stores a positive integer as product of prime powers, using the first PRIMES_MAX primes.
Definition: Atlas.h:127
static const unsigned long value
Definition: size.h:42