CMS 3D CMS Logo

lat::BitOpsMagic< B > Struct Template Reference

Bit operation helpers using Binary Magic Numbers. More...

#include <Iguana/Utilities/classlib/utils/BitOps.h>


Classes

struct  Type


Detailed Description

template<unsigned int B>
struct lat::BitOpsMagic< B >

Bit operation helpers using Binary Magic Numbers.

Magic numbers have unusual or special properties in certain calculations. With binary magic numbers discussed by [Freed, Edwin E. 1983. "Binary Magic Numbers---Some Applications and Algorithms", Dr Dobb's Journal, 8(4: April), pp 24--37.] it is possible to write algorithms that are typically faster by a factor of $N/log_2(N)$ than the more obvious ones. They can be used to:

The binary magic numbers come in a sequence (hence this recursive template) where the Nth number is itself an infinite binary number from right to left of $2^N$ ones follwed by $2^N$ zeroes, followed by $2^N$ ones and so on. The first five numbers in the sequence are ...0101010101010101, ...0011001100110011, ...0000111100001111 and ...0000000011111111. Often one will use just these patterns, but occasionally also the inverse (= one's complement) reverse pattern.

The patterns have B (which must be a power of two, i.e. $2^N$ above) consequtive ones and or zeros. It is assumed that T, the unsigned integral type used as the "word" in the operations, has a size that is a power of two.

Definition at line 94 of file BitOps.h.


The documentation for this struct was generated from the following file:
Generated on Tue Jun 9 18:48:21 2009 for CMSSW by  doxygen 1.5.4