19 #ifndef ATOMPROBE_SAMPLING_H 20 #define ATOMPROBE_SAMPLING_H 27 #include <gsl/gsl_randist.h> 28 #include <gsl/gsl_rng.h> 34 void sampleIons(
const std::vector<IonHit> &ions,
float sampleFactor,
35 std::vector<IonHit> &sampled,
bool strongRandom=
true);
41 const std::vector<T> &source,
size_t num,gsl_rng *rng)
44 if(source.size() <= num)
47 result.resize(source.size());
48 #pragma omp parallel for 49 for(
size_t ui=0; ui<num; ui++)
50 result[ui] = source[ui];
61 gsl_ran_choose (rng, &(result[0]), num, (
void*)&(source[0]), source.size(),
sizeof(
IonHit));
72 while(i < (source.size()<<1))
86 start =(size_t)((
double)rand()/RAND_MAX*i);
99 if(res< source.size())
101 result[ui] =source[res];
113 template<
class T>
void randomIndices(std::vector<T> &res,
size_t num,
size_t nMax, gsl_rng *rng)
115 num = std::min(num,nMax);
119 for(
auto i=0; i<num; i++)
122 for(
auto i=num; i<nMax;i++)
125 j = gsl_rng_uniform_int(rng,i);
This class implements a Linear Feedback Shift Register (in software)
void setState(size_t newState)
Set the internal lfsr state. Note 0 is the lock-up state.
void setMaskPeriod(unsigned int newMask)
Set the mask to use such that the period is 2^n-1. 3 is minimum 60 is maximum.
void sampleIons(const std::vector< IonHit > &ions, float sampleFactor, std::vector< IonHit > &sampled, bool strongRandom=true)
size_t randomSelect(std::vector< T > &result, const std::vector< T > &source, size_t num, gsl_rng *rng)
size_t clock()
Get a value from the shift register, and advance.
void randomIndices(std::vector< T > &res, size_t num, size_t nMax, gsl_rng *rng)
This is a data holding class for POS file ions, from.