atlas  0.6
constants.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 CONSTANTS_H /* guard against multiple inclusions */
13 #define CONSTANTS_H
14 
15 // extra defs for windows compilation -spc
16 #ifdef WIN32
17 #define and &&
18 #define or ||
19 #define not !
20 #endif
21 
22 #include <cstddef>
23 #include <limits>
24 
25 /******** constants **********************************************************/
26 
27 namespace atlas {
28 
29  namespace aux {
30  template<unsigned long n> struct BaseShift // value gives 2log of n
31  { static const unsigned long value = 1 + BaseShift<n/2>::value; };
32  template<> struct BaseShift<1ul> { static const unsigned long value = 0; };
33  }
34 
35 struct constants
36 {
37 
38  static const unsigned charBits = std::numeric_limits<unsigned char>::digits;
39  static const unsigned char ucharMax = ~0; // all bits in byte set
40  static const unsigned longBits = std::numeric_limits<unsigned long>::digits;
41  static const unsigned sizeBits = std::numeric_limits<size_t>::digits;
42  static const unsigned long hiBit = 1ul << (longBits - 1);
43  static const unsigned long firstCharMask = (1ul << charBits) - 1;
44  static const unsigned long posBits = longBits - 1; // longBits is power of 2
45  static const unsigned long baseBits = ~posBits; // mask for non bit-position
46  static const unsigned long baseShift = aux::BaseShift<longBits>::value;
47 
48  static unsigned long bitMask[longBits];
49  static unsigned char firstbit[1ul << charBits];
50  static unsigned char lastbit[1ul << charBits]; // last bit PLUS ONE
51  static unsigned long leqMask[longBits];
52  static unsigned long lMask[longBits+1];
53 
57  static const size_t RANK_MAX = 32;
58 
59 private: // trickery to ensure initialization is performed exactly once
60  static constants init();
61  static const constants dummy; // a |static| variable can be of own class!
62 }; // |struct constants|
63 
64 } // |namespace atlas|
65 
66 #endif
unsigned long digits(unsigned long a, unsigned long b)
Definition: ioutils.cpp:33
Definition: constants.h:30
static const constants dummy
Definition: constants.h:61
Definition: constants.h:35
static const unsigned long value
Definition: constants.h:31
unsigned long n
Definition: axis.cpp:77
Definition: Atlas.h:38