/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcTrkRecon/MdcTrkRecon-00-03-45/MdcTrkRecon/countBits.h

Go to the documentation of this file.
00001 // Count the number of bits set in a word; return that number.
00002 // Use a small lookup table. Size of lookup table is tradeoff between 
00003 // # of iterations needed and cache space used. 
00004 
00005 inline int countbits(unsigned word) {
00006    const int nbit[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
00007    int nset=0;
00008    for (unsigned i=0;i<2*sizeof(unsigned);i++) { // assume char = 8 bits, i.e. two
00009        nset+=nbit[word&0xf];                // iterations per 'char' size object
00010        word>>=4;
00011    }
00012    return nset;
00013 }

Generated on Tue Nov 29 23:13:33 2016 for BOSS_7.0.2 by  doxygen 1.4.7