Go to the documentation of this file.
23 #ifndef COM_DAFER45_TBTK_BIT_REGISTER
24 #define COM_DAFER45_TBTK_BIT_REGISTER
44 BitRegister(
unsigned int numBits = 8*
sizeof(
unsigned int));
104 void setBit(
unsigned int position,
bool values);
107 bool getBit(
unsigned int position)
const;
160 std::ostream &stream,
171 static constexpr
unsigned int MOST_SIGNIFICANT_BIT_MASK
172 = (
unsigned int)0x1 << (8*
sizeof(
unsigned int)-1);
177 result.values = values | rhs.values;
183 result.values = values & rhs.values;
189 result.values = values^rhs.values;
195 result.values = values + rhs.values;
201 result.values = values - rhs.values;
206 return values < rhs.values;
210 return values > rhs.values;
214 return values == rhs.values;
218 values += rhs.values;
222 values -= rhs.values;
260 result.values = values << rhs;
266 result.values = values >> rhs;
271 for(
int n = 8*
sizeof(values)-1; n >= 0; n--)
277 values &= ~(1 << position);
278 values ^= (value << position);
282 return (0x1 & (values >> position));
286 this->values = values;
306 return 8*
sizeof(values);
310 unsigned int x = values;
311 x = x - ((x >> 1) & 0x55555555);
312 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
313 x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
316 return (x & 0x0000003F);
320 return values & MOST_SIGNIFICANT_BIT_MASK;
324 values |= MOST_SIGNIFICANT_BIT_MASK;
328 values &= !MOST_SIGNIFICANT_BIT_MASK;
336 std::stringstream stream;
337 for(
unsigned int n =
getNumBits(); n > 0; n--)
344 std::ostream &stream,
bool operator<(const BitRegister &rhs) const
Definition: BitRegister.h:205
const BitRegister & operator--()
Definition: BitRegister.h:237
Register of bits.
Definition: BitRegister.h:41
const BitRegister operator+(const BitRegister &rhs) const
Definition: BitRegister.h:193
bool getBit(unsigned int position) const
Definition: BitRegister.h:281
unsigned int getValues() const
Definition: BitRegister.h:289
bool operator>(const BitRegister &rhs) const
Definition: BitRegister.h:209
void operator+=(const BitRegister &rhs)
Definition: BitRegister.h:217
void print() const
Definition: BitRegister.h:270
void operator-=(const BitRegister &rhs)
Definition: BitRegister.h:221
void clearMostSignificantBit()
Definition: BitRegister.h:327
unsigned int getNumOneBits() const
Definition: BitRegister.h:309
const BitRegister operator^(const BitRegister &rhs) const
Definition: BitRegister.h:187
const BitRegister operator&(const BitRegister &rhs) const
Definition: BitRegister.h:181
BitRegister operator<<(unsigned int rhs) const
Definition: BitRegister.h:258
void clear()
Definition: BitRegister.h:301
BitRegister(unsigned int numBits=8 *sizeof(unsigned int))
void setValues(unsigned int values)
Definition: BitRegister.h:285
void setBit(unsigned int position, bool values)
Definition: BitRegister.h:276
BitRegister cloneStructure() const
Definition: BitRegister.h:331
const BitRegister operator|(const BitRegister &rhs) const
Definition: BitRegister.h:175
std::string toString() const
Definition: BitRegister.h:335
const BitRegister & operator++()
Definition: BitRegister.h:225
bool toBool() const
Definition: BitRegister.h:293
unsigned int toUnsignedInt() const
Definition: BitRegister.h:297
bool getMostSignificantBit() const
Definition: BitRegister.h:319
const BitRegister operator-(const BitRegister &rhs) const
Definition: BitRegister.h:199
void operator=(const BitRegister &rhs)
Definition: BitRegister.h:249
static std::ostream out
Definition: Streams.h:70
bool operator==(const BitRegister &rhs) const
Definition: BitRegister.h:213
std::ostream & operator<<(std::ostream &stream, const HoppingAmplitude &hoppingAmplitude)
Definition: HoppingAmplitude.h:315
unsigned int getNumBits() const
Definition: BitRegister.h:305
void setMostSignificantBit()
Definition: BitRegister.h:323
BitRegister operator>>(unsigned int rhs) const
Definition: BitRegister.h:264