libatomprobe
Library for Atom Probe Tomography (APT) computation
Public Member Functions | List of all members
AtomProbe::LinearFeedbackShiftReg Class Reference

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...
 

Detailed Description

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

Definition at line 30 of file lfsr.h.

Member Function Documentation

◆ clock()

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().

◆ setMaskPeriod()

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().

◆ setState()

void AtomProbe::LinearFeedbackShiftReg::setState ( size_t  newState)
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().

Here is the call graph for this function:

◆ 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().

Here is the call graph for this function:

The documentation for this class was generated from the following files: