libatomprobe
Library for Atom Probe Tomography (APT) computation
|
This class implements a Linear Feedback Shift Register (in software) More...
#include <lfsr.h>
Public Member Functions | |
size_t | clock () |
Get a value from the shift register, and advance. More... | |
void | setState (size_t newState) |
Set the internal lfsr state. Note 0 is the lock-up state. More... | |
void | setMaskPeriod (unsigned int newMask) |
Set the mask to use such that the period is 2^n-1. 3 is minimum 60 is maximum. More... | |
bool | verifyTable (size_t maxLen=0) |
Check the validity of the table. More... | |
This class implements a Linear Feedback Shift Register (in software)
This is a mathematical construct based upon polynomials over closed natural numbers (N mod p). This will generate a weakly random digit string, but with guaranteed no duplicates, using O(1) memory and O(n) calls. The no duplicate guarantee is weak-ish, only guaranteeing no repetition in the shift register for 2^n-1 iterations. n can be set by setMaskPeriod. After this the sequence will repeat
size_t AtomProbe::LinearFeedbackShiftReg::clock | ( | ) |
Get a value from the shift register, and advance.
Definition at line 152 of file lfsr.cpp.
Referenced by AtomProbe::randomSelect(), and verifyTable().
void AtomProbe::LinearFeedbackShiftReg::setMaskPeriod | ( | unsigned int | newMask | ) |
Set the mask to use such that the period is 2^n-1. 3 is minimum 60 is maximum.
Definition at line 98 of file lfsr.cpp.
References ASSERT.
Referenced by AtomProbe::randomSelect(), setState(), and verifyTable().
|
inline |
Set the internal lfsr state. Note 0 is the lock-up state.
Definition at line 39 of file lfsr.h.
References setMaskPeriod(), and verifyTable().
Referenced by AtomProbe::randomSelect(), and verifyTable().
bool AtomProbe::LinearFeedbackShiftReg::verifyTable | ( | size_t | maxLen = 0 | ) |
Check the validity of the table.
Definition at line 113 of file lfsr.cpp.
References ASSERT, clock(), AtomProbe::maximumLinearTable, setMaskPeriod(), and setState().
Referenced by setState().